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
76
77#ifndef OPENSWMM_GEOPACKAGE_H
78#define OPENSWMM_GEOPACKAGE_H
79
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
86/* =========================================================================
87 * Opaque handle
88 * ========================================================================= */
89
91typedef void* SWMM_Gpkg;
92
93/* =========================================================================
94 * Return codes
95 * ========================================================================= */
96
97#define SWMM_GPKG_OK 0
98#define SWMM_GPKG_ERR -1
99
100/* =========================================================================
101 * Lifecycle
102 * ========================================================================= */
103
115
124
131
132/* =========================================================================
133 * Transactions
134 * ========================================================================= */
135
147
154
161
162/* =========================================================================
163 * Registration
164 * ========================================================================= */
165
175SWMM_ENGINE_API int swmm_gpkg_register(const char* license_key,
176 const char* organization,
177 const char* contact_email,
178 const char* deployment_id);
179
185
186/* =========================================================================
187 * Read: Simulation metadata
188 * ========================================================================= */
189
196
207 char* buf, int bufsz);
208
209/* =========================================================================
210 * Read: Model object counts
211 * ========================================================================= */
212
213SWMM_ENGINE_API int swmm_gpkg_node_count(SWMM_Gpkg gpkg, const char* simulation_id);
214SWMM_ENGINE_API int swmm_gpkg_link_count(SWMM_Gpkg gpkg, const char* simulation_id);
215SWMM_ENGINE_API int swmm_gpkg_subcatch_count(SWMM_Gpkg gpkg, const char* simulation_id);
216SWMM_ENGINE_API int swmm_gpkg_gage_count(SWMM_Gpkg gpkg, const char* simulation_id);
217SWMM_ENGINE_API int swmm_gpkg_topology_edge_count(SWMM_Gpkg gpkg, const char* simulation_id);
219
220/* =========================================================================
221 * Read: Simulation result timeseries
222 * ========================================================================= */
223
242 const char* simulation_id,
243 const char* object_type,
244 const char* object_id,
245 const char* variable_name,
246 double* times,
247 double* values,
248 int max_count);
249
263 const char* simulation_id,
264 const char* object_type,
265 const char* object_id,
266 const char* variable_name);
267
268/* =========================================================================
269 * Read: Summary statistics
270 * ========================================================================= */
271
284 const char* simulation_id,
285 const char* object_type,
286 const char* object_id,
287 const char* variable_name,
288 double* value);
289
290/* =========================================================================
291 * Write: Observed / sensor timeseries
292 * ========================================================================= */
293
311 const char* name,
312 const char* variable_name,
313 const char* object_type,
314 const char* object_id,
315 const char* source,
316 const char* units);
317
329 int series_id,
330 const char* timestamp,
331 double value,
332 const char* quality_flag);
333
355 int series_id,
356 const char** timestamps,
357 const double* values,
358 const char** quality_flags,
359 int count);
360
361/* =========================================================================
362 * Read: Observed / sensor timeseries
363 * ========================================================================= */
364
371
379
393 int series_id,
394 char* timestamps,
395 int ts_buf_len,
396 double* values,
397 int max_count);
398
399/* =========================================================================
400 * Read: Ad-hoc queries
401 * ========================================================================= */
402
409SWMM_ENGINE_API int swmm_gpkg_query_int(SWMM_Gpkg gpkg, const char* sql);
410
418SWMM_ENGINE_API int swmm_gpkg_query_double(SWMM_Gpkg gpkg, const char* sql,
419 double* result);
420
421#ifdef __cplusplus
422}
423#endif
424
425#endif /* OPENSWMM_GEOPACKAGE_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:53
SWMM_ENGINE_API const char * swmm_gpkg_last_error(SWMM_Gpkg gpkg)
Get the last error message.
Definition openswmm_geopackage_impl.cpp:96
SWMM_ENGINE_API void swmm_gpkg_close(SWMM_Gpkg gpkg)
Close the GeoPackage and free all resources.
Definition openswmm_geopackage_impl.cpp:86
SWMM_ENGINE_API int swmm_gpkg_register(const char *license_key, const char *organization, const char *contact_email, const char *deployment_id)
Register the GeoPackage plugin.
Definition openswmm_geopackage_impl.cpp:138
SWMM_ENGINE_API int swmm_gpkg_link_count(SWMM_Gpkg gpkg, const char *simulation_id)
Definition openswmm_geopackage_impl.cpp:189
SWMM_ENGINE_API SWMM_Gpkg swmm_gpkg_open(const char *path)
Open an existing GeoPackage file.
Definition openswmm_geopackage_impl.cpp:66
SWMM_ENGINE_API int swmm_gpkg_gage_count(SWMM_Gpkg gpkg, const char *simulation_id)
Definition openswmm_geopackage_impl.cpp:203
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 single summary statistic value.
Definition openswmm_geopackage_impl.cpp:287
SWMM_ENGINE_API int swmm_gpkg_simulation_id(SWMM_Gpkg gpkg, int index, char *buf, int bufsz)
Get the simulation_id at the given index.
Definition openswmm_geopackage_impl.cpp:162
SWMM_ENGINE_API int swmm_gpkg_observed_series_count(SWMM_Gpkg gpkg)
Get the number of observed series in the GeoPackage.
Definition openswmm_geopackage_impl.cpp:429
SWMM_ENGINE_API int swmm_gpkg_observed_value_count(SWMM_Gpkg gpkg, int series_id)
Get the number of values in an observed series.
Definition openswmm_geopackage_impl.cpp:435
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 an observed data series.
Definition openswmm_geopackage_impl.cpp:318
SWMM_ENGINE_API int swmm_gpkg_query_double(SWMM_Gpkg gpkg, const char *sql, double *result)
Execute a read-only SQL query and get the first double result.
Definition openswmm_geopackage_impl.cpp:491
void * SWMM_Gpkg
Opaque handle to an open GeoPackage database.
Definition openswmm_geopackage.h:91
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)
Get the number of result timeseries records for a query.
Definition openswmm_geopackage_impl.cpp:225
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)
Bulk-write a vector of observed data points to a series.
Definition openswmm_geopackage_impl.cpp:394
SWMM_ENGINE_API int swmm_gpkg_node_count(SWMM_Gpkg gpkg, const char *simulation_id)
Definition openswmm_geopackage_impl.cpp:182
SWMM_ENGINE_API int swmm_gpkg_simulation_count(SWMM_Gpkg gpkg)
Get the number of simulation runs in the GeoPackage.
Definition openswmm_geopackage_impl.cpp:156
SWMM_ENGINE_API int swmm_gpkg_variable_count(SWMM_Gpkg gpkg)
Definition openswmm_geopackage_impl.cpp:217
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)
Read observed timeseries values into caller-supplied arrays.
Definition openswmm_geopackage_impl.cpp:448
SWMM_ENGINE_API int swmm_gpkg_write_observed_value(SWMM_Gpkg gpkg, int series_id, const char *timestamp, double value, const char *quality_flag)
Write a single observed data point.
Definition openswmm_geopackage_impl.cpp:370
SWMM_ENGINE_API int swmm_gpkg_begin(SWMM_Gpkg gpkg)
Begin a transaction for bulk operations.
Definition openswmm_geopackage_impl.cpp:103
SWMM_ENGINE_API int swmm_gpkg_query_int(SWMM_Gpkg gpkg, const char *sql)
Execute a read-only SQL query and get the first integer result.
Definition openswmm_geopackage_impl.cpp:480
SWMM_ENGINE_API int swmm_gpkg_topology_edge_count(SWMM_Gpkg gpkg, const char *simulation_id)
Definition openswmm_geopackage_impl.cpp:210
SWMM_ENGINE_API int swmm_gpkg_rollback(SWMM_Gpkg gpkg)
Roll back the current transaction.
Definition openswmm_geopackage_impl.cpp:125
SWMM_ENGINE_API int swmm_gpkg_commit(SWMM_Gpkg gpkg)
Commit the current transaction.
Definition openswmm_geopackage_impl.cpp:114
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)
Read a result timeseries for one object and variable.
Definition openswmm_geopackage_impl.cpp:249
SWMM_ENGINE_API int swmm_gpkg_is_registered(void)
Check whether the GeoPackage plugin is registered.
Definition openswmm_geopackage_impl.cpp:150
SWMM_ENGINE_API int swmm_gpkg_subcatch_count(SWMM_Gpkg gpkg, const char *simulation_id)
Definition openswmm_geopackage_impl.cpp:196