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

Problem with geo.distance #184

Open
derkod opened this issue Jul 17, 2023 · 1 comment
Open

Problem with geo.distance #184

derkod opened this issue Jul 17, 2023 · 1 comment

Comments

@derkod
Copy link

derkod commented Jul 17, 2023

It seems the geo.distance functions does not work anymore.
This can only be the case because of a change in Postgis-functionality because we did not change the GOST-implementation.
The query that is executed is

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(5.0 52.0)')) < 0.05 ORDER BY location_id DESC LIMIT 201 OFFSET 0) AS A_location

This yields an error:
ERROR: ST_Distance: Operation on mixed SRID geometries (Point, 4326) != (Point, 0)

When I add SRID 4326 to ST_GeomFromText I get expected output

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(5.0 52.0)'**,4326**)) < 0.05 ORDER BY location_id DESC LIMIT 201 OFFSET 0) AS A_location

Is there a way to add this SRID in the API call?

@derkod
Copy link
Author

derkod commented Aug 10, 2023

Looks like our new Postgis-version has no default SRID anymore. When explicitly added to the API-call like this

https://api-samenmeten.rivm.nl/v1.0/Locations?$filter=geo.distance(location,%20geography%27SRID=4326;POINT(4.716%2052.01)%27)%20lt%200.05

it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant