spatial.withinDistance

过程

返回图层中所有几何节点及其相对于给定坐标的有序距离

签名

spatial.withinDistance(layerName :: STRING, coordinate :: ANY, distanceInKm :: FLOAT) :: (node :: NODE, distance :: FLOAT)

输入参数

名称 类型 默认 描述

图层名称

STRING

null

层的名称

坐标

ANY

null

坐标的有效取值是

  • JTS 坐标

  • Neo4j 坐标

  • Neo4j 点 (Point)

  • 包含 'latitude' 和 'longitude' 键的 Map

  • 包含 'lat' 和 'lon' 键的 Map

  • 具有 'latitude' 和 'longitude' 属性的节点或关系

  • 具有 'lat' 和 'lon' 属性的节点或关系

distanceInKm

FLOAT

null

用于搜索几何对象的距离(单位:公里)

输出参数

名称 类型 描述

节点

NODE

距离

FLOAT

示例

创建本地点层

CALL spatial.addNativePointLayerXY('geom','x','y')
表 1. 结果
节点
(:SpatialLayer {
    geomencoder: "SimplePointEncoder",
    geomencoder_config: "x:y",
    index_type: "rtree",
    layer: "geom",
    layer_type: "SimplePointLayer"
})

创建节点并将其添加到索引中

CREATE (n:Node {id: 42, x: 5.0, y: 4.0}) WITH n CALL spatial.addNode('geom',n) YIELD node RETURN node

在指定距离内查找节点

CALL spatial.withinDistance('geom',point({latitude:4.1,longitude:5.1}),100)
表 2. 结果
距离 节点
15.705713907526011
(:Node {
    bbox: [ 5.0, 4.0, 5.0, 4.0 ],
    gtype: 1,
    id: 42,
    x: 5.0,
    y: 4.0
})
© . This site is unofficial and not affiliated with Neo4j, Inc.