72 QString *error =
nullptr);
78 const QString &table);
85 const QString &desired);
104 QString *error =
nullptr);
108 const QString &table,
109 QString *error =
nullptr);
115 [[nodiscard]]
bool open(
const QString &
gpkgPath,
const QString &table,
116 QString *error =
nullptr);
130 void attach(GDALDataset *
ds, OGRLayer *layer,
131 const QString &
gpkgPath,
const QString &table);
134 [[nodiscard]]
bool isOpen()
const {
return m_layer !=
nullptr; }
136 [[nodiscard]] QString
gpkgPath()
const {
return m_gpkgPath; }
137 [[nodiscard]] QString
tableName()
const {
return m_table; }
145 [[nodiscard]]
bool hasZ()
const;
149 [[nodiscard]] QString
srsWkt()
const;
150 [[nodiscard]]
int count()
const;
154 [[nodiscard]] QVector<FeatureId>
featureIds()
const;
156 [[nodiscard]] QVector<Feature>
allFeatures()
const;
172 QString *error =
nullptr);
174 QString *error =
nullptr);
176 QString *error =
nullptr);
188 [[nodiscard]]
bool removeField(
const QString &
name, QString *error =
nullptr);
197 [[nodiscard]] OGRFeature *fetch(
FeatureId id)
const;
199 void applyAttributes(OGRFeature *feat,
const QVariantMap &attrs)
const;
201 [[nodiscard]] QVariantMap readAttributes(
const OGRFeature *feat)
const;
203 GDALDataset *m_dataset =
nullptr;
204 OGRLayer *m_layer =
nullptr;
207 bool m_ownsDataset =
true;
A complete feature geometry: a type plus zero or more parts.
Definition featuregeometry.h:205
One open, writable OGR table inside a GeoPackage.
Definition featurestore.h:56
void close()
Definition featurestore.cpp:308
~FeatureStore()
Definition featurestore.cpp:88
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,...
Definition featurestore.cpp:169
static bool ensureGeoPackage(const QString &gpkgPath, QString *error=nullptr)
Create an empty GeoPackage at gpkgPath if it does not exist.
Definition featurestore.cpp:97
FeatureStore & operator=(const FeatureStore &)=delete
FeatureStore(const FeatureStore &)=delete
bool hasZ() const
Definition featurestore.cpp:367
FeatureStore()
Definition featurestore.cpp:83
void attach(GDALDataset *ds, OGRLayer *layer, const QString &gpkgPath, const QString &table)
Adopt a dataset and layer someone else owns.
Definition featurestore.cpp:297
bool removeField(const QString &name, QString *error=nullptr)
Drop the column name.
Definition featurestore.cpp:691
QString gpkgPath() const
Definition featurestore.h:136
FeatureId addFeature(const Feature &f, QString *error=nullptr)
Insert f.
Definition featurestore.cpp:522
static bool dropTable(const QString &gpkgPath, const QString &table, QString *error=nullptr)
Permanently drop table from gpkgPath.
Definition featurestore.cpp:241
bool setAttributes(FeatureId id, const QVariantMap &attrs, QString *error=nullptr)
Definition featurestore.cpp:593
bool flush()
Flush pending writes to disk. Called after every command so a crash cannot lose an edit and so a conc...
Definition featurestore.cpp:715
bool addField(const FieldDef &f, QString *error=nullptr)
Definition featurestore.cpp:664
Schema schema() const
The schema read back from the open table. Reflects any field added or removed since open.
Definition featurestore.cpp:323
bool isOpen() const
Definition featurestore.h:134
QVector< Feature > allFeatures() const
Definition featurestore.cpp:465
bool removeFeature(FeatureId id, QString *error=nullptr)
Definition featurestore.cpp:645
GeometryType geometryType() const
Definition featurestore.cpp:353
bool setGeometry(FeatureId id, const FeatureGeometry &g, QString *error=nullptr)
Definition featurestore.cpp:566
QVector< FeatureId > featureIds() const
Definition featurestore.cpp:395
static bool tableExists(const QString &gpkgPath, const QString &table)
Definition featurestore.cpp:161
QString tableName() const
Definition featurestore.h:137
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.
Definition featurestore.cpp:275
bool setFeature(FeatureId id, const Feature &f, QString *error=nullptr)
Definition featurestore.cpp:617
int count() const
Definition featurestore.cpp:385
QString srsWkt() const
CRS WKT of the geometry column; empty when the table declares none (the layer then assumes canvas CRS...
Definition featurestore.cpp:373
static QStringList tables(const QString &gpkgPath)
Table names inside gpkgPath; empty when it cannot be read.
Definition featurestore.cpp:147
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.
Definition featurestore.cpp:181
An ordered list of FieldDef, with name lookup.
Definition featuretypes.h:104
enum OpenSWMM::Render::@788::Value::Type type
GDALDataset * ds
Definition meshattributeassigndialog.cpp:86
Definition featuregeometry.h:40
qint64 FeatureId
Definition featuretypes.h:33
GeometryType
Geometry kinds an editable feature layer can hold.
Definition featuregeometry.h:52
QString name
Definition sectionmodelbuilders.cpp:474
One editable feature: identity, geometry, attributes.
Definition featuretypes.h:150
One user-defined attribute column.
Definition featuretypes.h:67