Neo4j Spatial-使用withinDistance获取起始节点和匹配节点之间的距离

时间:2013-06-07 10:08:41

标签: neo4j

是否可以在此查询中获取起始坐标与匹配节点之间的距离:

START n=node:stadiumsLocation('withinDistance:[53.489271,-2.246704, 5.0]') RETURN n

对于每一个返回的n,我也想知道从n到[53.489271,-2.246704]的距离

我知道结果按距离排序,但我可以得到实际值吗?

2 个答案:

答案 0 :(得分:0)

https://github.com/neo4j-contrib/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/IndexProviderTest.java#L281

@Test
public void testDistance() throws ParseException {
WKTReader wktRdr = new WKTReader();
Geometry A = wktRdr.read("POINT(40.00 30.00 )");
Geometry B = wktRdr.read("POINT(40.00 40.00 )");
DistanceOp distOp = new DistanceOp(A, B);
assertEquals(10.0, distOp.distance(), 0);
}

答案 1 :(得分:0)

您可以使用HAVERSINE函数计算匹配节点的距离,如下所示:

array(
    0 => array(
        "gi|1786181|",
        "gi|1786192|"
    ),
    1 => array(
        "1786181",
        "1786192"
    )
)

空间插件似乎没有任何此功能的方法。