2016-11-03 2 views
0

を使用して半径内のすべての点は、私はテーブルを持っている:一覧ハイブ

id_center|latitude_of_center|longitude_of_center|id_point|latitude_of_point|longitude_of_point 

テーブルは、私は、各id_centerのために表示されるでしょう出力を取得しようとしている行

の何百万でありますid_pointsは半径5マイル以内にあり、距離は降順でソートされます。各行には完全なデータが格納されているため、各id_centerは可能なすべてのid_pointを別々の行に格納します。ここでは、私がこれまで試したものだ、と私はちょうどヌル結果を取得しています:たST_LineStringのために

hive> add jar /home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar; 
Added [/home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar] to class path 
Added resources: [/home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar] 
hive> add jar /home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar; 
Added [/home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar] to class path 
Added resources: [/home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar] 
hive> create temporary function ST_GeodesicLengthWGS84 AS 'com.esri.hadoop.hive.ST_GeodesicLengthWGS84'; 
OK 
Time taken: 0.014 seconds 
hive> create temporary function ST_SetSRID AS 'com.esri.hadoop.hive.ST_SetSRID'; 
OK 
Time taken: 0.008 seconds 
hive> create temporary function ST_LineString AS 'com.esri.hadoop.hive.ST_LineString'; 

SELECT * FROM mytable WHERE ST_GeodesicLengthWGS84(ST_SetSRID(ST_LineString(latitude_of_center, longitude_of_center, latitude_of_point, longitude_of_point), 4326)) <= 8046.72 

答えて

0

、最初経度必要、その後、緯度 - (X、Y)の順序を。 (GIS-SE https://gis.stackexchange.com/questions/178950/hive-gis-st-geodesiclengthwgs84-not-returning-expected-distanceでも議論されているように)

+0

私は緯度/経度の値を反転していますが、クエリは機能しているようですが、距離をフィールドとして返さなかったとします。私はフィールドとしてそれを作成するために何かをHQLステートメントに追加する必要があると思います...何が起こる必要がありますか? – knobby

+0

'select *'の代わりに 'select ST_GeodesicLength ...' –