gost / server

GOST - Go implementation of OGC SensorThings API
MIT License
61 stars 19 forks source link

geo.distance #177

Closed derkod closed 4 years ago

derkod commented 4 years ago

I think this is not an issue, but a lack of knowlegde from my part. I have some 2000 sensors in the GOST-DB. All with a Location. When I do:

~/v1.0/Locations?$filter=geo.distance(location,geography'POINT(5.134 52.070)') lt 1

two Locations are returned. Which are not the two closest to 5.134 52.070 When I change the lt into gt two other Locations are returned. How is that possible? If the distance is not less than 1 it should be greater or equal than 1. And another, maybe related question: what is the unit of this 1? Where am I going wrong?

Thanks in advance, Derko

bertt commented 4 years ago

Hi, this is in decimal degrees, 1 degree is roughly 111 km...

derkod commented 4 years ago

OK. Thank you. I can now see that lessen the distance gives sensors that are closer to the defined location. But I always get max 2 results. Even if I increase the distance. And even when I change the lt into gt. Always two and not necessarily the same two when varying the distance. Am I misunderstanding the behaviour?

bertt commented 4 years ago

Hi I tried to reproduce this but couldn't

1] distance = 0.001

https://gost.geodan.nl/v1.0/Locations?$filter=geo.distance(location,geography'POINT(4.941135 52.314020)') lt 0.001

gives 9 results

2] distance = 0.0001

https://gost.geodan.nl/v1.0/Locations?$filter=geo.distance(location,geography'POINT(4.941135 52.314020)') lt 0.0001

gives 2 results

derkod commented 4 years ago

Hi,

We investigated a bit further and have seen that the query that is sent to the database always has a LIMIT 2 .

SELECT A_location.location_id AS A_location_id, A_location.location_name AS A_location_name, A_location.location_description AS A_location_description, A_location.location_encodingtype AS A_location_encodingtype, A_location.location_geojson AS A_location_geojson FROM (SELECT location.id AS location_id, location.name AS location_name, location.description AS location_description, location.encodingtype AS location_encodingtype, location.geojson::text AS location_geojson FROM v1_1.location WHERE ST_DISTANCE(ST_GeomFromGeoJSON(public.ST_AsGeoJSON(location.location)), ST_GeomFromText('POINT(4.941135 52.314020)')) < 1 ORDER BY location_id DESC LIMIT 2 OFFSET 0) AS A_location

Any idea where this LIMIT 2 comes from?

bertt commented 4 years ago

we think this is resolved in an update, can you try using latest version of server?

bertt commented 4 years ago

Hi, whats the status of this issue?

derkod commented 4 years ago

It's pretty sure we installed the API-version having this problem. As I am not allowed to do installations myself I have to wait for our central IT dept to do that.

derkod commented 4 years ago

Problem solved with newest version. Thanks!