Page MenuHomePhabricator

Clarify API documentation of `gsbbox` value formatting
Open, MediumPublic

Description

There is an inconsistency between the values given with the gsbbox parameter and the results of the geosearch query.
The de-fact bounding box seems to be significantly different than the xmin and xmax values used in the gsbbox parameter.

For example, the output of [a query using gsbbox=37.8|-122.3|37.7|-122.4](https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsbbox=37.8|-122.3|37.7|-122.4&format=json) includes includes a result with "lon": 57.63055555555555

{
  "pageid": 35718195,
  "ns": 0,
  "title": "Qaleh-ye Ali Mohammad",
  "lat": 37.75055555555556,
  "lon": 57.63055555555555,
  "dist": 1710.7,
  "primary": ""
},

Similarly, the output of [a query using gsbbox=30.41|145.05|30.33|145.03](https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsbbox=30.41|145.05|30.33|145.03&format=json) includes a result with "lon": -9.69:

{
  "pageid": 9464907,
  "ns": 0,
  "title": "1960 Agadir earthquake",
  "lat": 30.35,
  "lon": -9.69,
  "dist": 2419479.9,
  "primary": ""
},

The shift in the first example seems to be about +180 and the shift in the second example is about -155.

This may or may not be related to the unconventional coordinate order of gsbbox - ymax|xmax|ymin|xmin.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Aklapper renamed this task from Inconsistecy between the requested `gsbbox` values and the `geosearch` query results to Inconsistency between requested `gsbbox` values and `geosearch` query results.Oct 7 2019, 7:08 AM
EBernhardson subscribed.

This looks to be a problem with coordinate ordering, geodata needs to ensure when setting the top left and bottom right coordinates of the bounding box that it's actually using the left and right. It looks like geodata is intending for the input to be (lat_1,lon_1), (lat_2,lon_2). but then passes that directly as the bounding box edges without ensuring appropriate ordering.

Indeed, the geosearch by bounding box works fine by using ymax|xmin|ymin|xmax or top|left|bottom|right.

For example, the output of [a query using gsbbox=48.8531|2.349|48.85|2.3499](https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsbbox=48.8531|2.349|48.85|2.3499&format=json) includes a result with "lon": 2.3498

{
  "pageid": 62233,
  "ns": 0,
  "title": "Notre-Dame de Paris",
  "lat": 48.853,
  "lon": 2.3498,
  "dist": 163.3,
  "primary": ""
},

I have updated https://www.mediawiki.org/wiki/Extension:GeoData#list%3Dgeosearch accordingly.

The auto-generated documentation at https://en.wikipedia.org/w/api.php?action=help&modules=query+geosearch can also be made more clear, but I was unable to find its source.

TheDJ renamed this task from Inconsistency between requested `gsbbox` values and `geosearch` query results to Clarify API documentation of `gsbbox` value formatting.Mar 12 2020, 12:52 PM