One open, writable OGR table inside a GeoPackage.
More...
#include <featurestore.h>
|
| | FeatureStore () |
| |
| | ~FeatureStore () |
| |
| | FeatureStore (const FeatureStore &)=delete |
| |
| FeatureStore & | operator= (const FeatureStore &)=delete |
| |
| bool | open (const QString &gpkgPath, const QString &table, QString *error=nullptr) |
| | Open table in gpkgPath for update. The store owns the dataset and closes it in close.
|
| |
| void | attach (GDALDataset *ds, OGRLayer *layer, const QString &gpkgPath, const QString &table) |
| | Adopt a dataset and layer someone else owns.
|
| |
| void | close () |
| |
| bool | isOpen () const |
| |
| QString | gpkgPath () const |
| |
| QString | tableName () const |
| |
| Schema | schema () const |
| | The schema read back from the open table. Reflects any field added or removed since open.
|
| |
| GeometryType | geometryType () const |
| |
| bool | hasZ () const |
| |
| QString | srsWkt () const |
| | CRS WKT of the geometry column; empty when the table declares none (the layer then assumes canvas CRS, as GISVectorLayer already does — see its crsAssumed signal).
|
| |
| int | count () const |
| |
| QVector< FeatureId > | featureIds () const |
| |
| bool | feature (FeatureId id, Feature &out) const |
| |
| QVector< Feature > | allFeatures () const |
| |
| FeatureId | addFeature (const Feature &f, QString *error=nullptr) |
| | Insert f.
|
| |
| bool | setGeometry (FeatureId id, const FeatureGeometry &g, QString *error=nullptr) |
| |
| bool | setAttributes (FeatureId id, const QVariantMap &attrs, QString *error=nullptr) |
| |
| bool | setFeature (FeatureId id, const Feature &f, QString *error=nullptr) |
| |
| bool | removeFeature (FeatureId id, QString *error=nullptr) |
| |
| bool | addField (const FieldDef &f, QString *error=nullptr) |
| |
| bool | removeField (const QString &name, QString *error=nullptr) |
| | Drop the column name.
|
| |
| bool | flush () |
| | Flush pending writes to disk. Called after every command so a crash cannot lose an edit and so a concurrent read-only opener (a mesh worker) sees current data.
|
| |
|
| static bool | ensureGeoPackage (const QString &gpkgPath, QString *error=nullptr) |
| | Create an empty GeoPackage at gpkgPath if it does not exist.
|
| |
| static QStringList | tables (const QString &gpkgPath) |
| | Table names inside gpkgPath; empty when it cannot be read.
|
| |
| static bool | tableExists (const QString &gpkgPath, const QString &table) |
| |
| static QString | uniqueTableName (const QString &gpkgPath, const QString &desired) |
| | Derive a table name from desired that is not yet used in gpkgPath, appending _1, _2, … as needed.
|
| |
| static bool | createTable (const QString &gpkgPath, const QString &table, GeometryType type, bool hasZ, const Schema &schema, const QString &srsWkt, QString *error=nullptr) |
| | Create a new table.
|
| |
| static bool | dropTable (const QString &gpkgPath, const QString &table, QString *error=nullptr) |
| | Permanently drop table from gpkgPath.
|
| |
One open, writable OGR table inside a GeoPackage.
Non-copyable: it owns a GDALDataset.
◆ FeatureStore() [1/2]
| openswmmvis::feature::FeatureStore::FeatureStore |
( |
| ) |
|
◆ ~FeatureStore()
| openswmmvis::feature::FeatureStore::~FeatureStore |
( |
| ) |
|
◆ FeatureStore() [2/2]
| openswmmvis::feature::FeatureStore::FeatureStore |
( |
const FeatureStore & |
| ) |
|
|
delete |
◆ addFeature()
| FeatureId openswmmvis::feature::FeatureStore::addFeature |
( |
const Feature & |
f, |
|
|
QString * |
error = nullptr |
|
) |
| |
Insert f.
When f.id is a valid id the store attempts to reuse it, so a redo of AddFeatureCommand restores the SAME id an undo removed — the stable-id contract AddAnnotationCommand documents at mapundostack.h:964-970. If the id is taken, OGR assigns a fresh one and that is what is returned.
- Returns
- The stored id, or kInvalidFeatureId on failure.
◆ addField()
| bool openswmmvis::feature::FeatureStore::addField |
( |
const FieldDef & |
f, |
|
|
QString * |
error = nullptr |
|
) |
| |
◆ allFeatures()
| QVector< Feature > openswmmvis::feature::FeatureStore::allFeatures |
( |
| ) |
const |
◆ attach()
| void openswmmvis::feature::FeatureStore::attach |
( |
GDALDataset * |
ds, |
|
|
OGRLayer * |
layer, |
|
|
const QString & |
gpkgPath, |
|
|
const QString & |
table |
|
) |
| |
Adopt a dataset and layer someone else owns.
FeatureLayer opens its GeoPackage through GISVectorLayer's own handle (so the paint loop and the write path share one connection rather than two on the same SQLite file) and then attaches this store to it. The store performs every write but never closes the dataset — close only detaches.
ds must have been opened with GDAL_OF_UPDATE or every write fails with GDAL's read-only error, which is reported normally.
◆ close()
| void openswmmvis::feature::FeatureStore::close |
( |
| ) |
|
◆ count()
| int openswmmvis::feature::FeatureStore::count |
( |
| ) |
const |
◆ createTable()
| bool openswmmvis::feature::FeatureStore::createTable |
( |
const QString & |
gpkgPath, |
|
|
const QString & |
table, |
|
|
GeometryType |
type, |
|
|
bool |
hasZ, |
|
|
const Schema & |
schema, |
|
|
const QString & |
srsWkt, |
|
|
QString * |
error = nullptr |
|
) |
| |
|
static |
Create a new table.
- Parameters
-
| gpkgPath | Container; created via ensureGeoPackage first. |
| table | Sanitised name (see sanitizeTableName). |
| type | Geometry type; decides the table's OGR geometry type. |
| hasZ | When true the table is created 2.5D (wkbSetZ). |
| schema | Attribute columns; may be empty. |
| srsWkt | CRS WKT for the geometry column; may be empty. |
Fails when the table already exists — the caller is expected to have resolved the name with uniqueTableName.
◆ dropTable()
| bool openswmmvis::feature::FeatureStore::dropTable |
( |
const QString & |
gpkgPath, |
|
|
const QString & |
table, |
|
|
QString * |
error = nullptr |
|
) |
| |
|
static |
Permanently drop table from gpkgPath.
◆ ensureGeoPackage()
| bool openswmmvis::feature::FeatureStore::ensureGeoPackage |
( |
const QString & |
gpkgPath, |
|
|
QString * |
error = nullptr |
|
) |
| |
|
static |
Create an empty GeoPackage at gpkgPath if it does not exist.
Succeeds silently when the file is already a readable GeoPackage, so callers may treat it as "ensure".
◆ feature()
| bool openswmmvis::feature::FeatureStore::feature |
( |
FeatureId |
id, |
|
|
Feature & |
out |
|
) |
| const |
◆ featureIds()
| QVector< FeatureId > openswmmvis::feature::FeatureStore::featureIds |
( |
| ) |
const |
◆ flush()
| bool openswmmvis::feature::FeatureStore::flush |
( |
| ) |
|
Flush pending writes to disk. Called after every command so a crash cannot lose an edit and so a concurrent read-only opener (a mesh worker) sees current data.
◆ geometryType()
| GeometryType openswmmvis::feature::FeatureStore::geometryType |
( |
| ) |
const |
◆ gpkgPath()
| QString openswmmvis::feature::FeatureStore::gpkgPath |
( |
| ) |
const |
|
inline |
◆ hasZ()
| bool openswmmvis::feature::FeatureStore::hasZ |
( |
| ) |
const |
◆ isOpen()
| bool openswmmvis::feature::FeatureStore::isOpen |
( |
| ) |
const |
|
inline |
◆ open()
| bool openswmmvis::feature::FeatureStore::open |
( |
const QString & |
gpkgPath, |
|
|
const QString & |
table, |
|
|
QString * |
error = nullptr |
|
) |
| |
Open table in gpkgPath for update. The store owns the dataset and closes it in close.
◆ operator=()
◆ removeFeature()
| bool openswmmvis::feature::FeatureStore::removeFeature |
( |
FeatureId |
id, |
|
|
QString * |
error = nullptr |
|
) |
| |
◆ removeField()
| bool openswmmvis::feature::FeatureStore::removeField |
( |
const QString & |
name, |
|
|
QString * |
error = nullptr |
|
) |
| |
Drop the column name.
GeoPackage column deletion depends on the GDAL build; when the driver reports no OLCDeleteField capability this fails with an explanatory message rather than silently leaving the column.
◆ schema()
| Schema openswmmvis::feature::FeatureStore::schema |
( |
| ) |
const |
The schema read back from the open table. Reflects any field added or removed since open.
◆ setAttributes()
| bool openswmmvis::feature::FeatureStore::setAttributes |
( |
FeatureId |
id, |
|
|
const QVariantMap & |
attrs, |
|
|
QString * |
error = nullptr |
|
) |
| |
◆ setFeature()
| bool openswmmvis::feature::FeatureStore::setFeature |
( |
FeatureId |
id, |
|
|
const Feature & |
f, |
|
|
QString * |
error = nullptr |
|
) |
| |
◆ setGeometry()
| bool openswmmvis::feature::FeatureStore::setGeometry |
( |
FeatureId |
id, |
|
|
const FeatureGeometry & |
g, |
|
|
QString * |
error = nullptr |
|
) |
| |
◆ srsWkt()
| QString openswmmvis::feature::FeatureStore::srsWkt |
( |
| ) |
const |
CRS WKT of the geometry column; empty when the table declares none (the layer then assumes canvas CRS, as GISVectorLayer already does — see its crsAssumed signal).
◆ tableExists()
| bool openswmmvis::feature::FeatureStore::tableExists |
( |
const QString & |
gpkgPath, |
|
|
const QString & |
table |
|
) |
| |
|
static |
◆ tableName()
| QString openswmmvis::feature::FeatureStore::tableName |
( |
| ) |
const |
|
inline |
◆ tables()
| QStringList openswmmvis::feature::FeatureStore::tables |
( |
const QString & |
gpkgPath | ) |
|
|
static |
Table names inside gpkgPath; empty when it cannot be read.
◆ uniqueTableName()
| QString openswmmvis::feature::FeatureStore::uniqueTableName |
( |
const QString & |
gpkgPath, |
|
|
const QString & |
desired |
|
) |
| |
|
static |
Derive a table name from desired that is not yet used in gpkgPath, appending _1, _2, … as needed.
The documentation for this class was generated from the following files: