0

How can I return a paginated GeoJSON payload from an API, including page information?

The pagination applies to the number of features in a feature collection. If the standards specify pagination, links to the details would be useful. As far as I know the pagination for JSON/GeoJSON is not specified in specs e.g.

For example, consider these two options. The first option is to add a "pages" data-structure to the GeoJSON, e.g.

{
    "type": "FeatureCollection",
    "features": [{
        "geometry": {
            "coordinates": [
                [
                    [-123.3948022, 41.254734],
                    [-123.3948022, 41.2537144],
                    [-123.3907336, 41.2537144],
                    [-123.3907336, 41.254734],
                    [-123.3948022, 41.254734]
                ]
            ],
            "type": "Polygon"
        },
        "properties": {
            "level": 0
        },
        "type": "Feature"
    }, {
        "geometry": {
            "coordinates": [
                [
                    [-123.3907336, 41.254734],
                    [-123.3907336, 41.2537144],
                    [-123.3893774, 41.2537144],
                    [-123.3893774, 41.254734],
                    [-123.3907336, 41.254734]
                ]
            ],
            "type": "Polygon"
        },
        "properties": {
            "level": 2
        },
        "type": "Feature"
    }],
    "pages": {
        "next": {
            "limit": 2,
            "offset": 2
        },
        "page": {
            "limit": 2,
            "offset": 0
        },
        "prev": null
    }
}

The second option creates a nested JSON payload with separate geojson and pages fields, i.e. the pseudo-JSON is like:

{
  "geojson": { ... },
  "pages": {
    "next": {
        "limit": 2,
        "offset": 2
    },
    "page": {
        "limit": 2,
        "offset": 0
    },
    "prev": null
  }
}

Or similarly, but without the extra "pages" nesting:

{
  "geojson": { ... },
  "next": {
        "limit": 2,
        "offset": 2
  },
  "page": {
        "limit": 2,
        "offset": 0
  },
  "prev": null
}

1 Answer 1

3

You probably want to look at the OGC Features API (aka WFS3) which covers this great detail.

Example 10 of the standard covers offsets which seems to be what you want.

If you need a working example of the standard GeoServer has an experimental extension you can add.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.