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
61SWMM_ENGINE_API int swmm_spatial_set_crs(SWMM_Engine engine, const char* crs);
62
75SWMM_ENGINE_API int swmm_spatial_get_crs(SWMM_Engine engine, char* buf, int buflen);
76
77/* =========================================================================
78 * Node coordinates
79 * ========================================================================= */
80
95SWMM_ENGINE_API int swmm_spatial_set_node_coord(SWMM_Engine engine, int idx, double x, double y);
96
108SWMM_ENGINE_API int swmm_spatial_node_has_coord(SWMM_Engine engine, int idx, int* present);
109
123SWMM_ENGINE_API int swmm_spatial_get_node_coord(SWMM_Engine engine, int idx, double* x, double* y);
124
139 double* y_buf, int count);
140
156 const double* y_buf, int count);
157
158/* =========================================================================
159 * Link coordinates (centroid or midpoint)
160 * ========================================================================= */
161
175SWMM_ENGINE_API int swmm_spatial_set_link_coord(SWMM_Engine engine, int idx, double x, double y);
176
190SWMM_ENGINE_API int swmm_spatial_get_link_coord(SWMM_Engine engine, int idx, double* x, double* y);
191
192/* =========================================================================
193 * Link vertices (polyline)
194 * ========================================================================= */
195
217SWMM_ENGINE_API int swmm_spatial_set_link_vertices(SWMM_Engine engine, int idx, const double* x,
218 const double* y, int count);
219
238SWMM_ENGINE_API int swmm_spatial_get_link_vertex_count(SWMM_Engine engine, int idx, int* count);
239
262SWMM_ENGINE_API int swmm_spatial_get_link_vertices(SWMM_Engine engine, int idx, double* x,
263 double* y, int max_count);
264
265/* =========================================================================
266 * Subcatchment coordinates (centroid)
267 * ========================================================================= */
268
283 double y);
284
298SWMM_ENGINE_API int swmm_spatial_get_subcatch_coord(SWMM_Engine engine, int idx, double* x,
299 double* y);
300
301/* =========================================================================
302 * Subcatchment polygon
303 * ========================================================================= */
304
323SWMM_ENGINE_API int swmm_spatial_set_subcatch_polygon(SWMM_Engine engine, int idx, const double* x,
324 const double* y, int count);
325
338 int* count);
339
359 double* y, int max_count);
360
361/* =========================================================================
362 * Gage coordinates
363 * ========================================================================= */
364
378SWMM_ENGINE_API int swmm_spatial_set_gage_coord(SWMM_Engine engine, int idx, double x, double y);
379
393SWMM_ENGINE_API int swmm_spatial_get_gage_coord(SWMM_Engine engine, int idx, double* x, double* y);
394
395/* =========================================================================
396 * [MAP] extent and units, and GUI annotation sections
397 * (closed C-API gaps 2026-10-11)
398 * ========================================================================= */
399
411SWMM_ENGINE_API int swmm_spatial_get_map_dimensions(SWMM_Engine engine, double* x1, double* y1,
412 double* x2, double* y2);
413
429SWMM_ENGINE_API int swmm_spatial_set_map_dimensions(SWMM_Engine engine, double x1, double y1,
430 double x2, double y2);
431
442SWMM_ENGINE_API int swmm_spatial_get_map_units(SWMM_Engine engine, char* buf, int buflen);
443
455SWMM_ENGINE_API int swmm_spatial_set_map_units(SWMM_Engine engine, const char* units);
456
475SWMM_ENGINE_API int swmm_spatial_get_annotation(SWMM_Engine engine, const char* section, char* buf,
476 int buflen, int* required);
477
492SWMM_ENGINE_API int swmm_spatial_set_annotation(SWMM_Engine engine, const char* section,
493 const char* text);
494
495#ifdef __cplusplus
496} /* extern "C" */
497#endif
498
499#endif /* OPENSWMM_SPATIAL_H */
double * y
Definition odesolve.c:37
#define SWMM_ENGINE_API
Definition openswmm_2d.h:62
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:55
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:149
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:245
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:306
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:275
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.
Definition openswmm_spatial_impl.cpp:88
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:178
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.
Definition openswmm_spatial_impl.cpp:286
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:193
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:139
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:111
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:262
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.
Definition openswmm_spatial_impl.cpp:435
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.
Definition openswmm_spatial_impl.cpp:374
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:165
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:316
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.
Definition openswmm_spatial_impl.cpp:409
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:234
SWMM_ENGINE_API int swmm_spatial_set_map_units(SWMM_Engine engine, const char *units)
Copy and uppercase the map-unit label.
Definition openswmm_spatial_impl.cpp:398
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:99
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.
Definition openswmm_spatial_impl.cpp:359
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:75
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:59
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:43
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:123
SWMM_ENGINE_API int swmm_spatial_get_map_units(SWMM_Engine engine, char *buf, int buflen)
Copy the stored map-unit label.
Definition openswmm_spatial_impl.cpp:387