OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_spatial_impl.cpp File Reference

C API implementation — spatial frame: CRS, coordinates, vertices, polygons. More...

Include dependency graph for openswmm_spatial_impl.cpp:

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_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 the polygon boundary vertices 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.
 

Detailed Description

C API implementation — spatial frame: CRS, coordinates, vertices, polygons.

See also
include/openswmm/engine/openswmm_spatial.h
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License

Function Documentation

◆ swmm_spatial_get_crs()

SWMM_ENGINE_API int swmm_spatial_get_crs ( SWMM_Engine  engine,
char *  buf,
int  buflen 
)

Get the coordinate reference system string.

Parameters
engineEngine handle.
bufCaller-allocated buffer to receive the CRS string.
buflenSize of buf in bytes.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_gage_coord()

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.

Parameters
engineEngine handle.
idxZero-based gage index.
[out]xReceives the X coordinate.
[out]yReceives the Y coordinate.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_link_coord()

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.

Parameters
engineEngine handle.
idxZero-based link index.
[out]xReceives the X coordinate.
[out]yReceives the Y coordinate.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_link_vertex_count()

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.

Parameters
engineEngine handle.
idxZero-based link index.
[out]countReceives the vertex count.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_link_vertices()

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.

Parameters
engineEngine handle.
idxZero-based link index.
[out]xCaller-allocated buffer for X coordinates.
[out]yCaller-allocated buffer for Y coordinates.
max_countMaximum number of vertices to write to the buffers.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_node_coord()

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.

Parameters
engineEngine handle.
idxZero-based node index.
[out]xReceives the X coordinate.
[out]yReceives the Y coordinate.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_node_coords_bulk()

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.

Parameters
engineEngine handle.
[out]x_bufCaller-allocated buffer for X coordinates (count elements).
[out]y_bufCaller-allocated buffer for Y coordinates (count elements).
countNumber of nodes (should equal swmm_node_count()).
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_subcatch_coord()

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.

Parameters
engineEngine handle.
idxZero-based subcatchment index.
[out]xReceives the X coordinate.
[out]yReceives the Y coordinate.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_subcatch_polygon()

SWMM_ENGINE_API int swmm_spatial_get_subcatch_polygon ( SWMM_Engine  engine,
int  idx,
double *  x,
double *  y,
int  max_count 
)

Get the polygon boundary vertices for a subcatchment.

Parameters
engineEngine handle.
idxZero-based subcatchment index.
[out]xCaller-allocated buffer for X coordinates.
[out]yCaller-allocated buffer for Y coordinates.
max_countMaximum number of vertices to write to the buffers.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_get_subcatch_polygon_count()

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.

Parameters
engineEngine handle.
idxZero-based subcatchment index.
[out]countReceives the polygon vertex count.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_set_crs()

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.

Parameters
engineEngine handle.
crsNull-terminated CRS string (e.g., "EPSG:4326").
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_set_gage_coord()

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.

Parameters
engineEngine handle.
idxZero-based gage index.
xX coordinate in CRS units.
yY coordinate in CRS units.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_set_link_coord()

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.

Parameters
engineEngine handle.
idxZero-based link index.
xX coordinate in CRS units.
yY coordinate in CRS units.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_set_link_vertices()

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.

Parameters
engineEngine handle.
idxZero-based link index.
xArray of vertex X coordinates.
yArray of vertex Y coordinates.
countNumber of vertices.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_set_node_coord()

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.

Parameters
engineEngine handle.
idxZero-based node index.
xX coordinate in CRS units.
yY coordinate in CRS units.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_set_node_coords_bulk()

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.

Parameters
engineEngine handle.
x_bufArray of X coordinates (count elements).
y_bufArray of Y coordinates (count elements).
countNumber of nodes.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_set_subcatch_coord()

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.

Parameters
engineEngine handle.
idxZero-based subcatchment index.
xX coordinate in CRS units.
yY coordinate in CRS units.
Returns
SWMM_OK on success, or an error code.

◆ swmm_spatial_set_subcatch_polygon()

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.

Parameters
engineEngine handle.
idxZero-based subcatchment index.
xArray of polygon vertex X coordinates.
yArray of polygon vertex Y coordinates.
countNumber of polygon vertices.
Returns
SWMM_OK on success, or an error code.