pub struct FeatureTable {
pub name: String,
pub geometry_column: String,
pub srs_id: Option<i32>,
pub schema: Vec<FieldDefinition>,
pub features: Vec<FeatureRow>,
}Expand description
An in-memory representation of a GeoPackage feature table.
Holds the table schema and all feature rows that have been loaded.
Fields§
§name: StringName of the feature table (matches gpkg_contents.table_name).
geometry_column: StringName of the geometry column.
srs_id: Option<i32>Spatial reference system ID, or None when unknown.
schema: Vec<FieldDefinition>Column definitions (excludes the geometry column and FID).
features: Vec<FeatureRow>Loaded feature rows.
Implementations§
Source§impl FeatureTable
impl FeatureTable
Sourcepub fn new(name: impl Into<String>, geometry_column: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, geometry_column: impl Into<String>) -> Self
Create a new, empty feature table with the given name and geometry column.
Sourcepub fn feature_count(&self) -> usize
pub fn feature_count(&self) -> usize
Return the number of loaded feature rows.
Sourcepub fn add_feature(&mut self, row: FeatureRow)
pub fn add_feature(&mut self, row: FeatureRow)
Append a feature row to the table.
Sourcepub fn get_feature(&self, fid: i64) -> Option<&FeatureRow>
pub fn get_feature(&self, fid: i64) -> Option<&FeatureRow>
Find a feature by its FID, or return None.
Sourcepub fn bbox(&self) -> Option<(f64, f64, f64, f64)>
pub fn bbox(&self) -> Option<(f64, f64, f64, f64)>
Return the union bounding box of all feature geometries, or None when
there are no geometries.
Sourcepub fn features_in_bbox(
&self,
min_x: f64,
min_y: f64,
max_x: f64,
max_y: f64,
) -> Vec<&FeatureRow>
pub fn features_in_bbox( &self, min_x: f64, min_y: f64, max_x: f64, max_y: f64, ) -> Vec<&FeatureRow>
Return all features whose geometry bounding box intersects the query bbox.
Features with None geometry are excluded. The check is a simple AABB
intersection test (not precise polygon intersection).
Sourcepub fn distinct_values(&self, field_name: &str) -> Vec<FieldValue>
pub fn distinct_values(&self, field_name: &str) -> Vec<FieldValue>
Collect all distinct (non-Null) values for a named field across all features.
The returned vec is deduplicated by equality.
Sourcepub fn to_geojson(&self) -> String
pub fn to_geojson(&self) -> String
Serialise the feature table as a GeoJSON FeatureCollection string.
Geometry None is encoded as "geometry":null.
Trait Implementations§
Source§impl Clone for FeatureTable
impl Clone for FeatureTable
Source§fn clone(&self) -> FeatureTable
fn clone(&self) -> FeatureTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more