OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_spatial.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
31
32#ifndef OPENSWMM_SPATIAL_H
33#define OPENSWMM_SPATIAL_H
34
35#include "openswmm_engine.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/* =========================================================================
42 * CRS (Coordinate Reference System)
43 * ========================================================================= */
44
56SWMM_ENGINE_API int swmm_spatial_set_crs(SWMM_Engine engine, const char* crs);
57
65SWMM_ENGINE_API int swmm_spatial_get_crs(SWMM_Engine engine, char* buf, int buflen);
66
67/* =========================================================================
68 * Node coordinates
69 * ========================================================================= */
70
79SWMM_ENGINE_API int swmm_spatial_set_node_coord(SWMM_Engine engine, int idx, double x, double y);
80
89SWMM_ENGINE_API int swmm_spatial_get_node_coord(SWMM_Engine engine, int idx, double* x, double* y);
90
99SWMM_ENGINE_API int swmm_spatial_get_node_coords_bulk(SWMM_Engine engine, double* x_buf, double* y_buf, int count);
100
109SWMM_ENGINE_API int swmm_spatial_set_node_coords_bulk(SWMM_Engine engine, const double* x_buf, const double* y_buf, int count);
110
111/* =========================================================================
112 * Link coordinates (centroid or midpoint)
113 * ========================================================================= */
114
123SWMM_ENGINE_API int swmm_spatial_set_link_coord(SWMM_Engine engine, int idx, double x, double y);
124
133SWMM_ENGINE_API int swmm_spatial_get_link_coord(SWMM_Engine engine, int idx, double* x, double* y);
134
135/* =========================================================================
136 * Link vertices (polyline)
137 * ========================================================================= */
138
152SWMM_ENGINE_API int swmm_spatial_set_link_vertices(SWMM_Engine engine, int idx, const double* x, const double* y, int count);
153
166SWMM_ENGINE_API int swmm_spatial_get_link_vertex_count(SWMM_Engine engine, int idx, int* count);
167
183SWMM_ENGINE_API int swmm_spatial_get_link_vertices(SWMM_Engine engine, int idx, double* x, double* y, int max_count);
184
185/* =========================================================================
186 * Subcatchment coordinates (centroid)
187 * ========================================================================= */
188
197SWMM_ENGINE_API int swmm_spatial_set_subcatch_coord(SWMM_Engine engine, int idx, double x, double y);
198
207SWMM_ENGINE_API int swmm_spatial_get_subcatch_coord(SWMM_Engine engine, int idx, double* x, double* y);
208
209/* =========================================================================
210 * Subcatchment polygon
211 * ========================================================================= */
212
222SWMM_ENGINE_API int swmm_spatial_set_subcatch_polygon(SWMM_Engine engine, int idx, const double* x, const double* y, int count);
223
232
242SWMM_ENGINE_API int swmm_spatial_get_subcatch_polygon(SWMM_Engine engine, int idx, double* x, double* y, int max_count);
243
244/* =========================================================================
245 * Gage coordinates
246 * ========================================================================= */
247
256SWMM_ENGINE_API int swmm_spatial_set_gage_coord(SWMM_Engine engine, int idx, double x, double y);
257
266SWMM_ENGINE_API int swmm_spatial_get_gage_coord(SWMM_Engine engine, int idx, double* x, double* y);
267
268#ifdef __cplusplus
269} /* extern "C" */
270#endif
271
272#endif /* OPENSWMM_SPATIAL_H */
double * y
Definition odesolve.c:28
#define SWMM_ENGINE_API
Definition openswmm_2d.h:53
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:51
OpenSWMM Engine — primary transparent C API (master header).
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.
Definition openswmm_spatial_impl.cpp:115
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.
Definition openswmm_spatial_impl.cpp:204
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.
Definition openswmm_spatial_impl.cpp:255
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.
Definition openswmm_spatial_impl.cpp:229
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.
Definition openswmm_spatial_impl.cpp:140
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.
Definition openswmm_spatial_impl.cpp:237
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.
Definition openswmm_spatial_impl.cpp:155
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.
Definition openswmm_spatial_impl.cpp:105
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.
Definition openswmm_spatial_impl.cpp:81
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.
Definition openswmm_spatial_impl.cpp:218
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.
Definition openswmm_spatial_impl.cpp:129
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.
Definition openswmm_spatial_impl.cpp:265
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.
Definition openswmm_spatial_impl.cpp:194
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.
Definition openswmm_spatial_impl.cpp:71
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.
Definition openswmm_spatial_impl.cpp:61
SWMM_ENGINE_API int swmm_spatial_get_crs(SWMM_Engine engine, char *buf, int buflen)
Get the coordinate reference system string.
Definition openswmm_spatial_impl.cpp:46
SWMM_ENGINE_API int swmm_spatial_set_crs(SWMM_Engine engine, const char *crs)
Set the coordinate reference system string for the model.
Definition openswmm_spatial_impl.cpp:38
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.
Definition openswmm_spatial_impl.cpp:91