All Products
Search
Document Center

:ST_3DGridPath

Last Updated:Apr 11, 2024

This topic describes the ST_3DGridPath function. This function calculates paths by using a 3D grid system.

Syntax

geomgrid[] ST_3DGridPath(geometry start, geometry end, box3d range, gridcost[] barriers, params text default '');

Parameters

Parameter

Description

start

The start point.

end

The end point.

range

The scope of path planning.

barriers

The cost of all grids with barriers.

params

The parameters used for calculation.

The following list describes the fields of the params parameter:

  • algorithm: the pathfinding algorithm

    • dij: the Dijkstra's algorithm

    • astar (default): the A* algorithm

    • nb_astar: the bidirectional A* algorithm

  • movement: the movement mode

    • cross (default): moves only to adjacent grids

    • octothorpe: moves to adjacent and diagonal grids

    • strict_octothorpe: moves to diagonal grids when adjacent grids are passable

  • distance: the distance estimation method

    • euclidean: the Euclidean distance

    • manhattan (default): the Manhattan distance

    • chebyshev: the Chebyshev distance

Example: {"algorithm":"astar","movement":"strict_octothorpe"}.

Note

If the params parameter is left empty or some fields of the parameter are not configured, the system uses the default values.

Description

This function calculates the grid path based on the specified data.

  • The start point and end point are 3D points, in which the values on the z-axis can be inaccurate. The algorithm automatically finds appropriate values on the z-axis for the 3D points and plans the path.

  • The range parameter specifies the range of path planning, which is configured based on digital surface model (DSM) data.

  • The barriers parameter combines the costs of all grids with barriers. You can call the ST_CostUnion operation to query the value of this parameter.

  • If the params parameter is left empty, the system uses aster, cross, and manhattan by default. The calculation result is an array of geometry grids arranged in sequence.

Examples

select st_astext(ST_3DGridPath(st_geomfromewkt('srid=4490;POINT Z (1 1 1)'), st_geomfromewkt('srid=4490;POINT Z (5 6 3)'),
'BOX3D(0 0 0,10 10 10)'::box3d, st_costunion(array[st_setcost(array[st_gridfromtext('GZ0000000001')],1), st_setcost(array[st_gridfromtext('GZ0000000000')],5)])));

--------------------------------------------------------------------------------
 {GZ0000000006,GZ0000000042,GZ0000000046,GZ0000000064,GZ0000000420,GZ0000000422,
GZ0000000426,GZ0000000604,GZ0000000640,GZ0000000644,GZ0000004200,GZ0000004240,
GZ0000004244,GZ0000004600,GZ0000004602,GZ0000004620,GZ0000004622,GZ0000006400,
GZ0000006420}

select ST_3DGridPath(st_geomfromewkt('srid=4490;POINT Z (1 1 1)'), st_geomfromewkt('srid=4490;POINT Z (5 6 3)'),
'BOX3D(0 0 0,10 10 10)'::box3d, st_costunion(array[st_setcost(array[st_gridfromtext('GZ0000000001')],1), st_setcost(array[st_gridfromtext('GZ0000000000')],5)]), '{"algorithm":"astar","movement":"strict_octothorpe","distance":"euclidean"}');

--------------------------------------------------------------------------------
 {GZ0000000006,GZ0000000060,GZ0000000066,GZ0000000600,GZ0000000606,GZ0000000660,
GZ0000000666,GZ0000006000,GZ0000006040,GZ0000006044,GZ0000006420}

3D grid system

image