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
| Parameter | Description |
|---|---|
wsname | The name of the workspace. The name must be unique. |
sql | The SQL statement used to build the topological network of the workspace in memory. |
Return values
| Return value | Description |
|---|---|
t | The workspace was created successfully. |
f | The workspace creation failed. |
Usage notes
SQL query requirements
The SQL query result must contain the following four fields:
| Field | Type | Description |
|---|---|---|
id | SMALLINT, INTEGER, or BIGINT | The unique identifier of the edge. |
source | SMALLINT, INTEGER, or BIGINT | The identifier of the source node of the edge. |
target | SMALLINT, INTEGER, or BIGINT | The identifier of the destination node of the edge. |
geometry | GEOMETRY | The 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_workspacetable.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)