Creates a model for a OGC GeoPackage file.
The GeoPackage decoder allows decoding files following the OGC GeoPackage specification.
One way conflicts can happen is if features which already have an id are added to the model; for performance reasons the uniqueness of the id is only checked against the in-memory features, not against those in the GeoPackage file. Until the conflict is resolved by persisting the changes, the shadowed features in the GeoPackage file are not visible (i.e. they don't appear in query results).
const std::string source = "test/resources/Data/GeoPackage/states10.gpkg";
if (!tablesExpected.has_value()) {
std::cout << "Failed to load GeoPackage file " << source << ": " << tablesExpected.error().getMessage() << std::endl;
return;
}
const std::vector<GeoPackageTableMetadata>& tables = tablesExpected.value();
std::cout << "The GeoPackage file contains " << tables.size() << " table(s):" << std::endl;
std::cout << " * Table '" << table.getName() << "' ";
if (modelExpected.has_value()) {
auto model = std::dynamic_pointer_cast<IFeatureModel>(*modelExpected);
if (model != nullptr) {
uint32_t count = 0;
count++;
return true;
});
std::cout << "contains " << count << " features.";
}
} else {
ErrorInfo errorInfo = modelExpected.error();
std::cout << "could not be decoded: " << errorInfo.getMessage();
}
} else {
std::cout << "contains raster data.";
}
std::cout << std::endl;
}
This class exposes details for a failed method call.
Definition: ErrorInfo.h:38
A Feature is a (partial) copy of a domain object.
Definition: Feature.h:34
static FeatureQuery all()
This method is a convenience factory method that creates a query to retrieve all features.
std::shared_ptr< GeoPackageDataSource > build()
Build the GeoPackage data source .
Builder & tableName(std::string tableName)
Sets the name of the table that needs to be decoded.
Builder & source(std::string source)
Sets the absolute path to the GeoPackage file.
static Builder newBuilder()
Returns the builder class for creation of the GeoPackage data source.
static luciad::expected< std::vector< GeoPackageTableMetadata >, ErrorInfo > discoverTables(const std::string &source, bool includeUnsupportedDataTypes)
Discovers the available tables in the given source file.
static luciad::expected< std::shared_ptr< Model >, ErrorInfo > decode(const std::shared_ptr< GeoPackageDataSource > &dataSource, const GeoPackageModelDecoderOptions &options)
Creates a model for a OGC GeoPackage file.
static std::shared_ptr< IFeatureQueryCallback > create(std::function< bool(Feature)> function)
Creates a default IFeatureQueryCallback instance that delegates the IFeatureQueryCallback::handleFeat...