Geographic Information Systems Asked by Darren Weber on December 12, 2020
To return a paginated GeoJSON payload from an API, what is the best practice or most common convention for 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 appreciated; AFAIK 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
}
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.
Answered by Ian Turton on December 12, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP