计算半径 HIVE 内点与中心之间的距离

calculate distance between points and a center within a radius HIVE

我使用以下方法从我的蜂巢数据库中获取中心 200 米以内的所有点。

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 的合作者)