OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_geopackage.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
77
78#ifndef OPENSWMM_GEOPACKAGE_H
79#define OPENSWMM_GEOPACKAGE_H
80
82
83#ifdef __cplusplus
84extern "C" {
85#endif
86
87/* =========================================================================
88 * Opaque handle
89 * ========================================================================= */
90
92typedef void* SWMM_Gpkg;
93
94/* =========================================================================
95 * Return codes
96 * ========================================================================= */
97
98#define SWMM_GPKG_OK 0
99#define SWMM_GPKG_ERR -1
100
101/* =========================================================================
102 * Lifecycle
103 * ========================================================================= */
104
118
129
141
142/* =========================================================================
143 * Transactions
144 * ========================================================================= */
145
158
171
181
182/* =========================================================================
183 * Registration
184 * ========================================================================= */
185
198SWMM_ENGINE_API int swmm_gpkg_register(const char* license_key, const char* organization,
199 const char* contact_email, const char* deployment_id);
200
206
207/* =========================================================================
208 * Read: Simulation metadata
209 * ========================================================================= */
210
219
233SWMM_ENGINE_API int swmm_gpkg_simulation_id(SWMM_Gpkg gpkg, int index, char* buf, int bufsz);
234
235/* =========================================================================
236 * Read: Model object counts
237 * ========================================================================= */
238
249SWMM_ENGINE_API int swmm_gpkg_node_count(SWMM_Gpkg gpkg, const char* simulation_id);
260SWMM_ENGINE_API int swmm_gpkg_link_count(SWMM_Gpkg gpkg, const char* simulation_id);
271SWMM_ENGINE_API int swmm_gpkg_subcatch_count(SWMM_Gpkg gpkg, const char* simulation_id);
282SWMM_ENGINE_API int swmm_gpkg_gage_count(SWMM_Gpkg gpkg, const char* simulation_id);
293SWMM_ENGINE_API int swmm_gpkg_topology_edge_count(SWMM_Gpkg gpkg, const char* simulation_id);
302
303/* =========================================================================
304 * Read: Simulation result timeseries
305 * ========================================================================= */
306
329SWMM_ENGINE_API int swmm_gpkg_read_result_ts(SWMM_Gpkg gpkg, const char* simulation_id,
330 const char* object_type, const char* object_id,
331 const char* variable_name, double* times,
332 double* values, int max_count);
333
352SWMM_ENGINE_API int swmm_gpkg_result_ts_count(SWMM_Gpkg gpkg, const char* simulation_id,
353 const char* object_type, const char* object_id,
354 const char* variable_name);
355
356/* =========================================================================
357 * Read: Summary statistics
358 * ========================================================================= */
359
377SWMM_ENGINE_API int swmm_gpkg_read_summary(SWMM_Gpkg gpkg, const char* simulation_id,
378 const char* object_type, const char* object_id,
379 const char* variable_name, double* value);
380
381/* =========================================================================
382 * Write: Observed / sensor timeseries
383 * ========================================================================= */
384
406 const char* variable_name,
407 const char* object_type, const char* object_id,
408 const char* source, const char* units);
409
427 const char* timestamp, double value,
428 const char* quality_flag);
429
451 const char** timestamps, const double* values,
452 const char** quality_flags, int count);
453
454/* =========================================================================
455 * Read: Observed / sensor timeseries
456 * ========================================================================= */
457
466
476
497SWMM_ENGINE_API int swmm_gpkg_read_observed_values(SWMM_Gpkg gpkg, int series_id, char* timestamps,
498 int ts_buf_len, double* values, int max_count);
499
500/* =========================================================================
501 * Read: Ad-hoc queries
502 * ========================================================================= */
503
517SWMM_ENGINE_API int swmm_gpkg_query_int(SWMM_Gpkg gpkg, const char* sql);
518
533SWMM_ENGINE_API int swmm_gpkg_query_double(SWMM_Gpkg gpkg, const char* sql, double* result);
534
535#ifdef __cplusplus
536}
537#endif
538
539#endif /* OPENSWMM_GEOPACKAGE_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:62
Build-generated visibility and deprecation macros for the engine API.
SWMM_ENGINE_API const char * swmm_gpkg_last_error(SWMM_Gpkg gpkg)
Borrow the last stored handle diagnostic.
Definition openswmm_geopackage_impl.cpp:141
SWMM_ENGINE_API void swmm_gpkg_close(SWMM_Gpkg gpkg)
Roll back an outstanding transaction and delete the database handle.
Definition openswmm_geopackage_impl.cpp:130
SWMM_ENGINE_API int swmm_gpkg_register(const char *license_key, const char *organization, const char *contact_email, const char *deployment_id)
Submit process-global GeoPackage plugin registration metadata.
Definition openswmm_geopackage_impl.cpp:203
SWMM_ENGINE_API int swmm_gpkg_link_count(SWMM_Gpkg gpkg, const char *simulation_id)
Count link rows for one simulation.
Definition openswmm_geopackage_impl.cpp:264
SWMM_ENGINE_API SWMM_Gpkg swmm_gpkg_open(const char *path)
Open or create a writable GeoPackage and ensure its OpenSWMM schema exists.
Definition openswmm_geopackage_impl.cpp:109
SWMM_ENGINE_API int swmm_gpkg_gage_count(SWMM_Gpkg gpkg, const char *simulation_id)
Count rain-gage rows for one simulation.
Definition openswmm_geopackage_impl.cpp:286
SWMM_ENGINE_API int swmm_gpkg_read_summary(SWMM_Gpkg gpkg, const char *simulation_id, const char *object_type, const char *object_id, const char *variable_name, double *value)
Read a stored summary value for one simulation/object/variable.
Definition openswmm_geopackage_impl.cpp:388
SWMM_ENGINE_API int swmm_gpkg_simulation_id(SWMM_Gpkg gpkg, int index, char *buf, int bufsz)
Copy one simulation-run ID in creation-time order.
Definition openswmm_geopackage_impl.cpp:229
SWMM_ENGINE_API int swmm_gpkg_observed_series_count(SWMM_Gpkg gpkg)
Count observed-series definitions.
Definition openswmm_geopackage_impl.cpp:547
SWMM_ENGINE_API int swmm_gpkg_observed_value_count(SWMM_Gpkg gpkg, int series_id)
Count rows stored for an observed series ID.
Definition openswmm_geopackage_impl.cpp:557
SWMM_ENGINE_API int swmm_gpkg_create_observed_series(SWMM_Gpkg gpkg, const char *name, const char *variable_name, const char *object_type, const char *object_id, const char *source, const char *units)
Create a uniquely named observed series and resolve/create its variable row.
Definition openswmm_geopackage_impl.cpp:421
SWMM_ENGINE_API int swmm_gpkg_query_double(SWMM_Gpkg gpkg, const char *sql, double *result)
Execute supplied SQL and copy the first row/column as double.
Definition openswmm_geopackage_impl.cpp:619
void * SWMM_Gpkg
Opaque handle to an open GeoPackage database.
Definition openswmm_geopackage.h:92
SWMM_ENGINE_API int swmm_gpkg_result_ts_count(SWMM_Gpkg gpkg, const char *simulation_id, const char *object_type, const char *object_id, const char *variable_name)
Count result rows for one simulation/object/variable key.
Definition openswmm_geopackage_impl.cpp:320
SWMM_ENGINE_API int swmm_gpkg_write_observed_values(SWMM_Gpkg gpkg, int series_id, const char **timestamps, const double *values, const char **quality_flags, int count)
Insert a vector of observed values using one prepared statement.
Definition openswmm_geopackage_impl.cpp:511
SWMM_ENGINE_API int swmm_gpkg_node_count(SWMM_Gpkg gpkg, const char *simulation_id)
Count node rows for one simulation.
Definition openswmm_geopackage_impl.cpp:253
SWMM_ENGINE_API int swmm_gpkg_simulation_count(SWMM_Gpkg gpkg)
Count stored simulation-run rows.
Definition openswmm_geopackage_impl.cpp:219
SWMM_ENGINE_API int swmm_gpkg_variable_count(SWMM_Gpkg gpkg)
Count catalogue variables, including added observed-data variables.
Definition openswmm_geopackage_impl.cpp:308
SWMM_ENGINE_API int swmm_gpkg_read_observed_values(SWMM_Gpkg gpkg, int series_id, char *timestamps, int ts_buf_len, double *values, int max_count)
Copy a timestamp-ordered prefix of observed values.
Definition openswmm_geopackage_impl.cpp:573
SWMM_ENGINE_API int swmm_gpkg_write_observed_value(SWMM_Gpkg gpkg, int series_id, const char *timestamp, double value, const char *quality_flag)
Insert one observed timestamp/value into a series.
Definition openswmm_geopackage_impl.cpp:483
SWMM_ENGINE_API int swmm_gpkg_begin(SWMM_Gpkg gpkg)
Begin an immediate SQLite transaction on this handle.
Definition openswmm_geopackage_impl.cpp:149
SWMM_ENGINE_API int swmm_gpkg_query_int(SWMM_Gpkg gpkg, const char *sql)
Execute supplied SQL and return the first column of its first result row as int.
Definition openswmm_geopackage_impl.cpp:604
SWMM_ENGINE_API int swmm_gpkg_topology_edge_count(SWMM_Gpkg gpkg, const char *simulation_id)
Count node-link topology edge rows for one simulation.
Definition openswmm_geopackage_impl.cpp:297
SWMM_ENGINE_API int swmm_gpkg_rollback(SWMM_Gpkg gpkg)
Roll back this handle active transaction if one exists.
Definition openswmm_geopackage_impl.cpp:185
SWMM_ENGINE_API int swmm_gpkg_commit(SWMM_Gpkg gpkg)
Commit this handle active transaction.
Definition openswmm_geopackage_impl.cpp:167
SWMM_ENGINE_API int swmm_gpkg_read_result_ts(SWMM_Gpkg gpkg, const char *simulation_id, const char *object_type, const char *object_id, const char *variable_name, double *times, double *values, int max_count)
Copy the first time-ordered result rows for one simulation/object/variable.
Definition openswmm_geopackage_impl.cpp:347
SWMM_ENGINE_API int swmm_gpkg_is_registered(void)
Read process-global GeoPackage plugin registration state.
Definition openswmm_geopackage_impl.cpp:213
SWMM_ENGINE_API int swmm_gpkg_subcatch_count(SWMM_Gpkg gpkg, const char *simulation_id)
Count subcatchment rows for one simulation.
Definition openswmm_geopackage_impl.cpp:275