spatial.addLayer

过程

使用给定的 type(参见 spatial.layerTypes)和配置添加一个新层。返回该层的根节点。

签名

spatial.addLayer(name :: STRING, type :: STRING, encoderConfig :: STRING, indexConfig =  :: STRING) :: (node :: NODE)

输入参数

名称 类型 默认 描述

名称 (name)

STRING

null

层的名称

type

STRING

null

新层的类型。可以通过 spatial.layer 查询已有的层类型。

encoderConfig

STRING

null

该层用于对索引节点的几何形状进行编码/解码的编码器配置

indexConfig

STRING

""

新创建的索引的配置

输出参数

名称 类型 描述

节点

NODE

示例

将同一节点添加到多个层

创建一些节点
UNWIND range(1,100) as i
CREATE (n:Point {
    id: i,
    point1: point( { latitude: 56.0, longitude: 12.0 } ),
    point2: point( { latitude: 57.0, longitude: 13.0 } )
})

创建一个层 point1 来为节点 Point 的属性 point1 建立索引。将其包围盒保存到 Point 节点的属性 point1BB 中。通过关系类型 RTREE_P1_TYPE 将该节点与索引层关联。

CALL spatial.addLayer(
	'point1',
	'NativePoint',
	'point1:point1BB',
	'{"referenceRelationshipType": "RTREE_P1_TYPE"}'
)

创建一个层 point2 来为节点 Point 的属性 point2 建立索引。将其包围盒保存到 Point 节点的属性 point2BB 中。通过关系类型 RTREE_P2_TYPE 将该节点与索引层关联。

CALL spatial.addLayer(
	'point2',
	'NativePoint',
	'point2:point2BB',
	'{"referenceRelationshipType": "RTREE_P2_TYPE"}'
)

以每批 10 条的方式为层 point1 中的节点建立索引

MATCH (p:Point)
WITH (count(p) / 10) AS pages, collect(p) AS nodes
UNWIND range(0, pages) AS i CALL {
    WITH i, nodes
    CALL spatial.addNodes('point1', nodes[(i * 10)..((i + 1) * 10)]) YIELD count
    RETURN count AS count
} IN TRANSACTIONS OF 1 ROWS
RETURN sum(count) AS count
表 1. 结果
count
100

以每批 10 条的方式为层 point2 中的节点建立索引

MATCH (p:Point)
WITH (count(p) / 10) AS pages, collect(p) AS nodes
UNWIND range(0, pages) AS i CALL {
	WITH i, nodes
	CALL spatial.addNodes('point2', nodes[(i * 10)..((i + 1) * 10)]) YIELD count
	RETURN count AS count
} IN TRANSACTIONS OF 1 ROWS
RETURN sum(count) AS count
表 2. 结果
count
100
© . This site is unofficial and not affiliated with Neo4j, Inc.