spatial.addLayer

Procedure

Adds a new layer with the given type (see spatial.layerTypes) and configuration. Returns the layers root node.

Signature

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

Input parameters

Name Type Default Description

name

STRING

null

The name of the layer

type

STRING

null

The type of the new layer. Existing layer types can be queried by spatial.layer

encoderConfig

STRING

null

The configuration of the encoder that is used by layer to en-/decode the geometry of indexed nodes

indexConfig

STRING

""

The configuration of the newly created index

Output parameters

Name Type Description

node

NODE

Examples

Add the same node to multiple layers

Create some nodes
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 } )
})

Create a layer point1 to index property point1 of node Point. Save the bounding box in the property point1BB of the Point node. Associate the node with the index layer via relationship type RTREE_P1_TYPE.

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

Create a layer point2 to index property point2 of node Point. Save the bounding box in the property point2BB of the Point node. Associate the node with the index layer via relationship type RTREE_P2_TYPE.

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

Index the nodes in layer point1 in chunks of 10

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
Table 1. Result
count
100

Index the nodes in layer point2 in chunks of 10

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
Table 2. Result
count
100