Skip to main content

FeatureTable

Struct FeatureTable 

Source
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: String

Name of the feature table (matches gpkg_contents.table_name).

§geometry_column: String

Name 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

Source

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.

Source

pub fn feature_count(&self) -> usize

Return the number of loaded feature rows.

Source

pub fn add_feature(&mut self, row: FeatureRow)

Append a feature row to the table.

Source

pub fn get_feature(&self, fid: i64) -> Option<&FeatureRow>

Find a feature by its FID, or return None.

Source

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.

Source

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).

Source

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.

Source

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

Source§

fn clone(&self) -> FeatureTable

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FeatureTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.