Creates an in-memory map matching workspace from road network topology data returned by a SQL query.
Syntax
boolean ST_CreateWorkspace(text wsname, text sql);Parameters
| Parameter | Description |
|---|---|
wsname | The name of the workspace. Must be unique across all workspaces. |
sql | The SQL statement that constructs the topological network of the workspace in memory. The query result must contain the four fields described in the Description section. |
Return values
| Return value | Description |
|---|---|
t | The workspace was created successfully. |
f | The workspace creation failed. |
Description
A map matching workspace holds an in-memory representation of road network topology. Create or load a workspace before calling any road matching functions.
The workspace name must be unique. To view existing workspaces, query the mapmatching_workspace table.
The SQL query result used to build a workspace must return exactly four fields:
id: The unique identifier of the edge. Accepted types: SMALLINT, INTEGER, BIGINT.source: The identifier of the source node of the edge. Accepted types: SMALLINT, INTEGER, BIGINT.target: The identifier of the target node of the edge. Accepted types: SMALLINT, INTEGER, BIGINT.geometry: The geometry of the edge. Accepted type: GEOMETRY. Only LineString and MultiLineString geometries are supported. For MultiLineString, only the first child LineString is used.
The topological network is built in map units. For coordinate conversion, use the ST_Transform function.
Examples
Prerequisites
Prepare road network data and build a road network topology. For details, see .
Create a workspace from all road segments
SELECT ST_CreateWorkspace('mm_ws_test1', 'select fid, source, target, geom from network');Create a workspace from filtered road segments
SELECT ST_CreateWorkspace('mm_ws_test2', $$ select fid, source, target, geom from network where fid > 10 $$);View created workspaces
SELECT * from mapmatching_workspace;Sample output:
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)