gbif / geocode

Geocode webservice and client
Apache License 2.0
4 stars 4 forks source link

Consider renaming field distance #11

Open timrobertson100 opened 3 years ago

timrobertson100 commented 3 years ago

The geocode API [example call] returns a distance field, such as:

{
  "id": "CL",
  "type": "Political",
  "source": "http://www.naturalearthdata.com/", 
  "title": "Chile",
  "isoCountryCode2Digit": "CL",
  "distance": 0.022322887300003803
},

To improve the intuitiveness I suggest we rename the field to include the unit. I presume this is in kilometers so perhaps something along the lines of distanceInKM would be better?

MattBlissett commented 3 years ago

It is in degrees, i.e. not 22 metres from the coast of Chile but very roughly 2½ km.

Did someone ask for this?

The distance field is meant to show whether the point is inside or outside the feature, and to order the features the point is outside. I would need to check again how accurate it is, especially nearer the poles, as it is using PostGIS's fast Cartesian geometry functions rather than the version with full topological accuracy: https://postgis.net/docs/ST_Distance.html

timrobertson100 commented 3 years ago

Thanks for the explanation @MattBlissett

Did someone ask for this?

Not specifically - I was asked by someone using it what the unit was. Since I didn't know I made the suggestion since others will likely ask too.

distanceInDegrees might be appropriate or if we don't want people to use it other than for ranking results perhaps sortOrder or similar would avoid possible misuse (e.g. an inaccurate result at poles).

tucotuco commented 3 years ago

Thanks for the explanation. Renaming it would be good, to avoid further questions if nothing else. Calculating actual distance would probably be way too slow for an API and the results would be even more likely to raise questions of accuracy due to shape (im)precision.