0

我正在测试orientdb 空间模块。我整理了一个简单的数据集,其中包含纳斯卡线 ( nazca_lines.csv) 中一些地理符号的坐标:

Name,Latitude,Longitude
Hummingbird,-14.692131,-75.148892
Monkey,-14.706940,-75.138532
Condor,-14.697444,-75.126208
Spider,-14.694145,-75.122381
Spiral,-14.688277,-75.122746
Hands,-14.694459,-75.113881
Tree,-14.693898,-75.114520
Astronaut,-14.745222,-75.079755
Dog,-14.706401,-75.130788
Wing,-14.680309,-75.100385
Parrot,-14.689463,-75.107498

我使用以下方法创建空间索引:

CREATE INDEX GeoGlyph.index.Location 
ON GeoGlyph(Latitude,Longitude) SPATIAL ENGINE LUCENE

我可以使用类似于我在此堆栈溢出问题中生成的查询来生成特定地理字形内(例如 2 公里)内的节点列表:

SELECT $temp.Name AS SourceName, Name AS TargetName, $distance.format("%.4f") AS Distance 
FROM GeoGlyph 
LET $temp = first((SELECT * FROM GeoGlyph WHERE Name = "Tree"))
WHERE [Latitude,Longitude,$spatial] 
NEAR [$temp.Latitude, $temp.Longitude,{"maxDistance":2}] 
ORDER BY Distance

这给了我这个结果:

+----+----------+----------+--------+
|#   |SourceName|TargetName|Distance|
+----+----------+----------+--------+
|0   |Tree      |Tree      |0.0000  |
|1   |Tree      |Hands     |0.0884  |
|2   |Tree      |Spider    |0.9831  |
|3   |Tree      |Spiral    |1.0883  |
|4   |Tree      |Condor    |1.5735  |
+----+----------+----------+--------+

这很好,但我只能找到相对于特定节点的节点。我想扩展它以询问彼此相距 2 公里以内的所有节点对。

我感兴趣的结果如下所示:

+----+-----------+-----------+--------+
|#   |SourceName |TargetName |Distance|
+----+-----------+-----------+--------+
|1   |Hummingbird|Monkey     |1.6314  |
|2   |Monkey     |Dog        |1.8035  |
|3   |Dog        |Condor     |0.9349  |  
|4   |Dog        |Spider     |1.5487  |
|5   |Condor     |Spider     |0.6772  |
|6   |Condor     |Spiral     |1.2685  |
|7   |Condor     |Tree       |1.5735  |
|8   |Condor     |Hands      |1.6150  |
|9   |Spider     |Spiral     |0.6797  |
 ...

有任何想法吗?

4

1 回答 1

0

您应该使用 OPoint 类型的新空间模块功能

并使用 ST_Distance_Sphere 函数

http://orientdb.com/docs/2.2/Spatial-Index.html#stdistancesphere-from-orientdb-224

于 2016-12-06T17:51:56.297 回答