![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
OpenSWMM Engine — Spatial Frame C API. More...
#include "openswmm_engine.h"Go to the source code of this file.
Functions | |
| SWMM_ENGINE_API int | swmm_spatial_set_crs (SWMM_Engine engine, const char *crs) |
| Set the coordinate reference system string for the model. | |
| SWMM_ENGINE_API int | swmm_spatial_get_crs (SWMM_Engine engine, char *buf, int buflen) |
| Get the coordinate reference system string. | |
| SWMM_ENGINE_API int | swmm_spatial_set_node_coord (SWMM_Engine engine, int idx, double x, double y) |
| Set the X/Y coordinates for a node. | |
| SWMM_ENGINE_API int | swmm_spatial_node_has_coord (SWMM_Engine engine, int idx, int *present) |
| Read coordinate provenance without confusing an authored origin with missing data. | |
| SWMM_ENGINE_API int | swmm_spatial_get_node_coord (SWMM_Engine engine, int idx, double *x, double *y) |
| Get the X/Y coordinates for a node. | |
| SWMM_ENGINE_API int | swmm_spatial_get_node_coords_bulk (SWMM_Engine engine, double *x_buf, double *y_buf, int count) |
| Get X/Y coordinates for all nodes in a single call. | |
| SWMM_ENGINE_API int | swmm_spatial_set_node_coords_bulk (SWMM_Engine engine, const double *x_buf, const double *y_buf, int count) |
| Set X/Y coordinates for all nodes in a single call. | |
| SWMM_ENGINE_API int | swmm_spatial_set_link_coord (SWMM_Engine engine, int idx, double x, double y) |
| Set the centroid/midpoint X/Y coordinate for a link. | |
| SWMM_ENGINE_API int | swmm_spatial_get_link_coord (SWMM_Engine engine, int idx, double *x, double *y) |
| Get the centroid/midpoint X/Y coordinate for a link. | |
| SWMM_ENGINE_API int | swmm_spatial_set_link_vertices (SWMM_Engine engine, int idx, const double *x, const double *y, int count) |
| Set the polyline vertices for a link. | |
| SWMM_ENGINE_API int | swmm_spatial_get_link_vertex_count (SWMM_Engine engine, int idx, int *count) |
| Get the number of polyline vertices for a link. | |
| SWMM_ENGINE_API int | swmm_spatial_get_link_vertices (SWMM_Engine engine, int idx, double *x, double *y, int max_count) |
| Get the polyline vertices for a link. | |
| SWMM_ENGINE_API int | swmm_spatial_set_subcatch_coord (SWMM_Engine engine, int idx, double x, double y) |
| Set the centroid X/Y coordinate for a subcatchment. | |
| SWMM_ENGINE_API int | swmm_spatial_get_subcatch_coord (SWMM_Engine engine, int idx, double *x, double *y) |
| Get the centroid X/Y coordinate for a subcatchment. | |
| SWMM_ENGINE_API int | swmm_spatial_set_subcatch_polygon (SWMM_Engine engine, int idx, const double *x, const double *y, int count) |
| Set the polygon boundary vertices for a subcatchment. | |
| SWMM_ENGINE_API int | swmm_spatial_get_subcatch_polygon_count (SWMM_Engine engine, int idx, int *count) |
| Get the number of polygon vertices for a subcatchment. | |
| SWMM_ENGINE_API int | swmm_spatial_get_subcatch_polygon (SWMM_Engine engine, int idx, double *x, double *y, int max_count) |
| Get all polygon boundary rings for a subcatchment. | |
| SWMM_ENGINE_API int | swmm_spatial_set_gage_coord (SWMM_Engine engine, int idx, double x, double y) |
| Set the X/Y coordinate for a rain gage. | |
| SWMM_ENGINE_API int | swmm_spatial_get_gage_coord (SWMM_Engine engine, int idx, double *x, double *y) |
| Get the X/Y coordinate for a rain gage. | |
| SWMM_ENGINE_API int | swmm_spatial_get_map_dimensions (SWMM_Engine engine, double *x1, double *y1, double *x2, double *y2) |
| Read the stored map display extent. | |
| SWMM_ENGINE_API int | swmm_spatial_set_map_dimensions (SWMM_Engine engine, double x1, double y1, double x2, double y2) |
| Replace the stored map display extent. | |
| SWMM_ENGINE_API int | swmm_spatial_get_map_units (SWMM_Engine engine, char *buf, int buflen) |
| Copy the stored map-unit label. | |
| SWMM_ENGINE_API int | swmm_spatial_set_map_units (SWMM_Engine engine, const char *units) |
| Copy and uppercase the map-unit label. | |
| SWMM_ENGINE_API int | swmm_spatial_get_annotation (SWMM_Engine engine, const char *section, char *buf, int buflen, int *required) |
| Join stored annotation-section lines into text without a section header. | |
| SWMM_ENGINE_API int | swmm_spatial_set_annotation (SWMM_Engine engine, const char *section, const char *text) |
| Replace the passthrough lines of a supported annotation section. | |
OpenSWMM Engine — Spatial Frame C API.
CRS management, node/link/subcatchment/gage coordinates, link polyline vertices, and subcatchment polygon vertices.
| SWMM_ENGINE_API int swmm_spatial_get_annotation | ( | SWMM_Engine | engine, |
| const char * | section, | ||
| char * | buf, | ||
| int | buflen, | ||
| int * | required ) |
Join stored annotation-section lines into text without a section header.
Does not interpret annotation content; stored lines are joined with LF. Both buf and required may be NULL for a valid section.
| [in] | engine | Non-null live engine; caller provides exclusive access. No spatial-edit lifecycle guard is imposed. |
| [in] | section | Non-null case-insensitive LABELS, BACKDROP, PROFILE or PROFILES token. |
| [out] | buf | Optional caller-owned text destination. NULL queries required size regardless of buflen; non-null output is NUL-terminated and silently truncated. |
| [in] | buflen | Destination capacity in bytes including NUL; must be positive when buf is non-null. |
| [out] | required | Optional full byte count INCLUDING NUL, written before short/nonpositive buffer handling. Empty/absent section requires 1 byte. |
| SWMM_ENGINE_API int swmm_spatial_get_crs | ( | SWMM_Engine | engine, |
| char * | buf, | ||
| int | buflen ) |
Get the coordinate reference system string.
| [in] | engine | Engine handle. |
| [out] | buf | Caller-allocated buffer to receive the CRS string. |
| [in] | buflen | Size of buf in bytes. |
| SWMM_ENGINE_API int swmm_spatial_get_gage_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double * | x, | ||
| double * | y ) |
Get the X/Y coordinate for a rain gage.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based gage index. |
| [out] | x | Receives the X coordinate. |
| [out] | y | Receives the Y coordinate. |
| SWMM_ENGINE_API int swmm_spatial_get_link_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double * | x, | ||
| double * | y ) |
Get the centroid/midpoint X/Y coordinate for a link.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based link index. |
| [out] | x | Receives the X coordinate. |
| [out] | y | Receives the Y coordinate. |
| SWMM_ENGINE_API int swmm_spatial_get_link_vertex_count | ( | SWMM_Engine | engine, |
| int | idx, | ||
| int * | count ) |
Get the number of polyline vertices for a link.
Count includes the upstream node coordinate at index 0, followed by stored interior vertices (if any), and the downstream node coordinate as the final index.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based link index. |
| [out] | count | Receives the vertex count. |
| SWMM_ENGINE_API int swmm_spatial_get_link_vertices | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double * | x, | ||
| double * | y, | ||
| int | max_count ) |
Get the polyline vertices for a link.
Returned vertices are ordered as: 1) upstream node coordinate at index 0, 2) interior vertices in stored order, 3) downstream node coordinate as the final vertex.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based link index. |
| [out] | x | Caller-allocated buffer for X coordinates. |
| [out] | y | Caller-allocated buffer for Y coordinates. |
| [in] | max_count | Maximum number of vertices to write to the buffers. |
| SWMM_ENGINE_API int swmm_spatial_get_map_dimensions | ( | SWMM_Engine | engine, |
| double * | x1, | ||
| double * | y1, | ||
| double * | x2, | ||
| double * | y2 ) |
Read the stored map display extent.
| [in] | engine | Non-null live engine; caller provides exclusive access. No spatial-edit lifecycle guard is imposed. |
| [out] | x1 | Optional destination for the first X coordinate in map/CRS units. |
| [out] | y1 | Optional destination for the first Y coordinate in map/CRS units. |
| [out] | x2 | Optional destination for the second X coordinate in map/CRS units. |
| [out] | y2 | Optional destination for the second Y coordinate in map/CRS units. |
| SWMM_ENGINE_API int swmm_spatial_get_map_units | ( | SWMM_Engine | engine, |
| char * | buf, | ||
| int | buflen ) |
Copy the stored map-unit label.
| [in] | engine | Non-null live engine; caller provides exclusive access. No spatial-edit lifecycle guard is imposed. |
| [out] | buf | Non-null caller-owned text destination, empty when unspecified; NUL-terminated and silently truncated to buflen-1 bytes. |
| [in] | buflen | Positive capacity including NUL, in bytes. |
| SWMM_ENGINE_API int swmm_spatial_get_node_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double * | x, | ||
| double * | y ) |
Get the X/Y coordinates for a node.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based node index. |
| [out] | x | Receives the X coordinate. |
| [out] | y | Receives the Y coordinate. |
| SWMM_ENGINE_API int swmm_spatial_get_node_coords_bulk | ( | SWMM_Engine | engine, |
| double * | x_buf, | ||
| double * | y_buf, | ||
| int | count ) |
Get X/Y coordinates for all nodes in a single call.
| [in] | engine | Engine handle. |
| [out] | x_buf | Caller-allocated buffer for X coordinates (count elements). |
| [out] | y_buf | Caller-allocated buffer for Y coordinates (count elements). |
| [in] | count | Number of nodes (should equal swmm_node_count()). |
| SWMM_ENGINE_API int swmm_spatial_get_subcatch_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double * | x, | ||
| double * | y ) |
Get the centroid X/Y coordinate for a subcatchment.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based subcatchment index. |
| [out] | x | Receives the X coordinate. |
| [out] | y | Receives the Y coordinate. |
| SWMM_ENGINE_API int swmm_spatial_get_subcatch_polygon | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double * | x, | ||
| double * | y, | ||
| int | max_count ) |
Get all polygon boundary rings for a subcatchment.
Multiple rings are concatenated with explicit closing XY vertices; the last ring may be open. Counts include repeated closing vertices.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based subcatchment index. |
| [out] | x | Caller-allocated buffer for X coordinates. |
| [out] | y | Caller-allocated buffer for Y coordinates. |
| [in] | max_count | Maximum number of vertices to write to the buffers. |
| SWMM_ENGINE_API int swmm_spatial_get_subcatch_polygon_count | ( | SWMM_Engine | engine, |
| int | idx, | ||
| int * | count ) |
Get the number of polygon vertices for a subcatchment.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based subcatchment index. |
| [out] | count | Receives the polygon vertex count. |
| SWMM_ENGINE_API int swmm_spatial_node_has_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| int * | present ) |
Read coordinate provenance without confusing an authored origin with missing data.
| [in] | engine | Non-null live engine; caller provides exclusive access. No spatial-edit lifecycle guard is imposed. |
| [in] | idx | Zero-based existing node index. |
| [out] | present | Non-null destination: 1 when coordinate provenance is present, otherwise 0. An authored (0,0) may be present. |
| SWMM_ENGINE_API int swmm_spatial_set_annotation | ( | SWMM_Engine | engine, |
| const char * | section, | ||
| const char * | text ) |
Replace the passthrough lines of a supported annotation section.
Internal blank lines are retained; a trailing LF does not create a final additional empty line. Stores text for later serialization without interpreting drawing/profile syntax.
| [in] | engine | Non-null live engine; caller provides exclusive access. No spatial-edit lifecycle guard is imposed. |
| [in] | section | Non-null case-insensitive LABELS, BACKDROP, PROFILE or PROFILES token. |
| [in] | text | Borrowed NUL-terminated content to copy; NULL/empty removes the section. LF separates lines; CR bytes are discarded. |
| SWMM_ENGINE_API int swmm_spatial_set_crs | ( | SWMM_Engine | engine, |
| const char * | crs ) |
Set the coordinate reference system string for the model.
The CRS string is stored as metadata (e.g., an EPSG code or WKT string). It is not used for coordinate transformations but is preserved in hot start files for consistency checking.
| [in] | engine | Engine handle. |
| [in] | crs | Null-terminated CRS string (e.g., "EPSG:4326"). |
| SWMM_ENGINE_API int swmm_spatial_set_gage_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double | x, | ||
| double | y ) |
Set the X/Y coordinate for a rain gage.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based gage index. |
| [in] | x | X coordinate in CRS units. |
| [in] | y | Y coordinate in CRS units. |
| SWMM_ENGINE_API int swmm_spatial_set_link_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double | x, | ||
| double | y ) |
Set the centroid/midpoint X/Y coordinate for a link.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based link index. |
| [in] | x | X coordinate in CRS units. |
| [in] | y | Y coordinate in CRS units. |
| SWMM_ENGINE_API int swmm_spatial_set_link_vertices | ( | SWMM_Engine | engine, |
| int | idx, | ||
| const double * | x, | ||
| const double * | y, | ||
| int | count ) |
Set the polyline vertices for a link.
Vertices define the intermediate points of a link's path between its upstream and downstream nodes.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based link index. |
| [in] | x | Array of vertex X coordinates. |
| [in] | y | Array of vertex Y coordinates. |
| [in] | count | Number of vertices. |
| SWMM_ENGINE_API int swmm_spatial_set_map_dimensions | ( | SWMM_Engine | engine, |
| double | x1, | ||
| double | y1, | ||
| double | x2, | ||
| double | y2 ) |
Replace the stored map display extent.
Does not require minimum/maximum ordering, change object coordinates or compute a new bounding box.
| [in] | engine | Non-null live engine; caller provides exclusive access. No spatial-edit lifecycle guard is imposed. |
| [in] | x1 | Finite first X coordinate in map/CRS units. |
| [in] | y1 | Finite first Y coordinate in map/CRS units. |
| [in] | x2 | Finite second X coordinate in map/CRS units. |
| [in] | y2 | Finite second Y coordinate in map/CRS units. |
| SWMM_ENGINE_API int swmm_spatial_set_map_units | ( | SWMM_Engine | engine, |
| const char * | units ) |
Copy and uppercase the map-unit label.
Does not restrict the label vocabulary, rescale geometry or reproject coordinates.
| [in] | engine | Non-null live engine; caller provides exclusive access. No spatial-edit lifecycle guard is imposed. |
| [in] | units | Non-null NUL-terminated label (such as FEET, METERS, DEGREES or NONE); empty is allowed. |
| SWMM_ENGINE_API int swmm_spatial_set_node_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double | x, | ||
| double | y ) |
Set the X/Y coordinates for a node.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based node index. |
| [in] | x | X coordinate in CRS units. |
| [in] | y | Y coordinate in CRS units. |
| SWMM_ENGINE_API int swmm_spatial_set_node_coords_bulk | ( | SWMM_Engine | engine, |
| const double * | x_buf, | ||
| const double * | y_buf, | ||
| int | count ) |
Set X/Y coordinates for all nodes in a single call.
| [in] | engine | Engine handle. |
| [in] | x_buf | Array of X coordinates (count elements). |
| [in] | y_buf | Array of Y coordinates (count elements). |
| [in] | count | Number of nodes. |
| SWMM_ENGINE_API int swmm_spatial_set_subcatch_coord | ( | SWMM_Engine | engine, |
| int | idx, | ||
| double | x, | ||
| double | y ) |
Set the centroid X/Y coordinate for a subcatchment.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based subcatchment index. |
| [in] | x | X coordinate in CRS units. |
| [in] | y | Y coordinate in CRS units. |
| SWMM_ENGINE_API int swmm_spatial_set_subcatch_polygon | ( | SWMM_Engine | engine, |
| int | idx, | ||
| const double * | x, | ||
| const double * | y, | ||
| int | count ) |
Set the polygon boundary vertices for a subcatchment.
Multiple rings are concatenated, each closed by repeating its first XY vertex. The final ring may be open. Even/odd containment defines holes.
| [in] | engine | Engine handle. |
| [in] | idx | Zero-based subcatchment index. |
| [in] | x | Array of polygon vertex X coordinates. |
| [in] | y | Array of polygon vertex Y coordinates. |
| [in] | count | Number of polygon vertices. |