spatial.addPointLayer

过程

添加一个新的简单点图层,返回图层根节点

签名

spatial.addPointLayer(name :: STRING, indexType = rtree :: STRING, crsName =  :: STRING, indexConfig =  :: STRING) :: (node :: NODE)

输入参数

名称 类型 默认 描述

名称 (name)

STRING

null

层的名称

indexType

STRING

"rtree"

新图层的类型。可以使用 spatial.layer 查询已有的图层类型

crsName

STRING

""

要使用的坐标参考系统(CRS),有效值为:wgs84

indexConfig

STRING

""

新创建的索引的配置

输出参数

名称 类型 描述

节点

NODE

示例

创建一个用于索引节点的图层

CALL spatial.addPointLayer('my-simple-rtree-layer')
表 1. 结果
节点
(:SpatialLayer {
    geomencoder: "SimplePointEncoder",
    index_type: "rtree",
    layer: "my-simple-rtree-layer",
    layer_type: "SimplePointLayer"
})

创建要索引的节点

CREATE (n:Node {id: 42, latitude:60.1,longitude:15.2}) SET n.location=point(n) RETURN n

索引节点

MATCH (n:Node) WITH n CALL spatial.addNode('my-simple-rtree-layer',n) YIELD node RETURN node
表 2. 结果
节点
(:Node {
    bbox: [ 15.2, 60.1, 15.2, 60.1 ],
    gtype: 1,
    id: 42,
    latitude: 60.1,
    location: point({x: 15.2, y: 60.1, crs: 'wgs-84'}),
    longitude: 15.2
})

在指定距离内查找节点

CALL spatial.withinDistance('my-simple-rtree-layer',{lon:15.0,lat:60.0},100)
表 3. 结果
距离 节点
15.713441434310283
(:Node {
    bbox: [ 15.2, 60.1, 15.2, 60.1 ],
    gtype: 1,
    id: 42,
    latitude: 60.1,
    location: point({x: 15.2, y: 60.1, crs: 'wgs-84'}),
    longitude: 15.2
})
© . This site is unofficial and not affiliated with Neo4j, Inc.