assuming I use the following query to match the locations to a poi within 10km distance:
SELECT
poi.poi_id,
h.loc_id,
(ST_Distance(poi.geom,h.geom)*111.111) as distanceinkm
FROM iut_poi_transl AS poi, hrs_loc as h
WHERE poi.poigr_id != 30 AND ST_DWithin(poi.geom,h.geom,0.09)
Data is SRID 4326.
Does it use the geometry or the geography type?
If uses geometry how do I have to change the query to get use geography type?
Answer
as said before it uses the type it gets. so what you have to do is to feed it with geography. If your data is stored as geometry you can cast to geography on the fly
poi.geom::geography
SELECT
poi.poi_id,h.loc_id,
(ST_Distance(poi.geom::geography,h.geom::geography)/1000) as distanceinkm
FROM iut_poi_transl AS poi, hrs_loc as h
WHERE poi.poigr_id != 30 AND ST_DWithin(poi.geom::geography,h.geom::geography,10000)
No comments:
Post a Comment