问题描述
我使用以下方法从我的蜂巢数据库中获取距中心200m以内的所有点。
SELECT * FROM mytable
WHERE ST_GeodesicLengthwgs84(ST_SetSRID(ST_Linestring(array(ST_Point(longitude_of_center,latitude_of_center),ST_Point(longitude_of_point,latitude_of_point))),4326)) <= 200;
请,我还需要获取选择的点与中心之间的距离作为新的列disT作为查询结果的一部分。
解决方法
您可以从与中心配对的每个选定点制作一个LineString,然后在每个这样的LineString上调用GeodesicLengthWGS84。它与您在where
子句中使用的Length调用相同,但也添加到了列投影中(所以类似select *,ST_GeodesicLengthWGS834(...) from ...
。
(披露:Esri Spatial Framework for Hadoop上的合作者)