Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow antimeridian bbox on OGC Features API #6951

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"features":[],"links":[{"href":"http://localhost/cgi-bin/mapserv/OGCAPI_TEST/ogcapi/collections/mn_counties/items?f=json&limit=1&offset=0&bbox=160.6,-55.95,-170,-25.89","rel":"self","title":"Items for this collection as GeoJSON","type":"application/geo+json"},{"href":"http://localhost/cgi-bin/mapserv/OGCAPI_TEST/ogcapi/collections/mn_counties/items?f=html&limit=1&offset=0&bbox=160.6,-55.95,-170,-25.89","rel":"alternate","title":"Items for this collection as HTML","type":"text/html"}],"numberMatched":0,"numberReturned":0,"type":"FeatureCollection"}
1 change: 1 addition & 0 deletions msautotest/api/ogcapi.map
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# RUN_PARMS: ogcapi_collections_mn_counties_items_bbox_crs_epsg_4326.json [MAPSERV] "PATH_INFO=/[MAPFILE]/ogcapi/collections/mn_counties/items" "QUERY_STRING=f=json&bbox=-90,-180,90,0&bbox-crs=http://www.opengis.net/def/crs/EPSG/0/4326&limit=1" > [RESULT_DEMIME]
# RUN_PARMS: ogcapi_collections_mn_counties_items_bad_bbox_crs.json [MAPSERV] "PATH_INFO=/[MAPFILE]/ogcapi/collections/mn_counties/items" "QUERY_STRING=f=json&bbox=-90,-180,90,0&bbox-crs=http://www.opengis.net/def/crs/EPSG/0/12345&limit=1" > [RESULT_DEMIME]
# RUN_PARMS: ogcapi_collections_mn_counties_items_empty_bbox_crs.json [MAPSERV] "PATH_INFO=/[MAPFILE]/ogcapi/collections/mn_counties/items" "QUERY_STRING=f=json&bbox=-90,-180,90,0&bbox-crs=&limit=1" > [RESULT_DEMIME]
# RUN_PARMS: ogcapi_collections_mn_counties_items_antimeridian_bbox.json [MAPSERV] "PATH_INFO=/[MAPFILE]/ogcapi/collections/mn_counties/items" "QUERY_STRING=f=json&bbox=160.6,-55.95,-170,-25.89&limit=1" > [RESULT_DEMIME]
# RUN_PARMS: ogcapi_collections_mn_counties_items_unknown_parameter.json.txt [MAPSERV] "PATH_INFO=/[MAPFILE]/ogcapi/collections/mn_counties/items" "QUERY_STRING=f=json&unknown=parameter" > [RESULT]
# RUN_PARMS: ogcapi_collections_mn_counties_items_limit_1.json [MAPSERV] "PATH_INFO=/[MAPFILE]/ogcapi/collections/mn_counties/items" "QUERY_STRING=f=json&limit=1" > [RESULT_DEMIME]
# RUN_PARMS: ogcapi_collections_mn_counties_items_limit_1_offset_2.json [MAPSERV] "PATH_INFO=/[MAPFILE]/ogcapi/collections/mn_counties/items" "QUERY_STRING=f=json&limit=1&offset=2" > [RESULT_DEMIME]
Expand Down
5 changes: 5 additions & 0 deletions src/mapogcapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ static bool getBbox(mapObj *map, layerObj *layer, cgiRequestObj *request,
bbox->maxx = values[2];
bbox->maxy = values[3];

if (bbox->minx > bbox->maxx) {
// the bbox can span the antimeridian and give the
// lower-value first - in this case swap the values
std::swap(bbox->minx, bbox->maxx);
Copy link
Contributor

@rouault rouault Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the fix would be much more complicated than just switching minx and maxx.

We should actually issue 2 queries:

  • one with [bbox->minx, 180] range
  • another one with [-180, bbox->maxx] range

and merge the results

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah of course, this is going to get the completely wrong results.. I presume this issue wasn't addressed in WFS queries? Will look now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume this issue wasn't addressed in WFS queries?

no, WFS hasn't any such special processing for antimeridian crossing

}
// validate bbox is well-formed (degenerate is ok)
if (MS_VALID_SEARCH_EXTENT(*bbox) != MS_TRUE) {
outputError(OGCAPI_PARAM_ERROR, "Bad value for bbox.");
Expand Down
Loading