All Products
Search
Document Center

PolarDB:ST_CreateWorkspace

Last Updated:Mar 28, 2026

Creates an in-memory map matching workspace from topological road network data stored in relational tables.

Syntax

boolean ST_CreateWorkspace(text wsname, text sql);

Parameters

ParameterDescription
wsnameThe name of the workspace. The name must be unique.
sqlThe SQL statement used to build the topological network of the workspace in memory.

Return values

Return valueDescription
tThe workspace was created successfully.
fThe workspace creation failed.

Usage notes

SQL query requirements

The SQL query result must contain the following four fields:

FieldTypeDescription
idSMALLINT, INTEGER, or BIGINTThe unique identifier of the edge.
sourceSMALLINT, INTEGER, or BIGINTThe identifier of the source node of the edge.
targetSMALLINT, INTEGER, or BIGINTThe identifier of the destination node of the edge.
geometryGEOMETRYThe geometry of the edge. Only LineString and MultiLineString types are supported. If the type is MultiLineString, only the first child LineString object is used.

Workspace behavior

  • The workspace holds map topological network data in memory. Create or load this data before running road matching.

  • Workspace names must be unique. To list existing workspaces, query the mapmatching_workspace table.

  • The topological network uses map units. For coordinate conversion, use ST_Transform.

Examples

Before running the examples, prepare road network data and build a road network topology. For details, see .

Create a workspace using all objects

SELECT ST_CreateWorkspace('mm_ws_test1', 'select fid, source, target, geom from network');

Create a workspace using filtered objects

SELECT ST_CreateWorkspace('mm_ws_test2', $$ select fid, source, target, geom from network where fid > 10 $$);

View created workspaces

SELECT * from mapmatching_workspace;

Sample result:

 ws_id |   ws_name   |                             ws_sql                             | ws_options
-------+-------------+----------------------------------------------------------------+------------
     1 | mm_ws_test1 | select fid, source, target, geom from network                  |
     2 | mm_ws_test2 | select fid, source, target, geom from network where fid > 10  |
(2 rows)