GpkgLayer

Struct GpkgLayer 

Source
pub struct GpkgLayer {
    pub layer_name: String,
    pub geometry_column: String,
    pub primary_key_column: String,
    pub geometry_type: GeometryType,
    pub geometry_dimension: Dimension,
    pub srs_id: u32,
    pub property_columns: Vec<ColumnSpec>,
    /* private fields */
}
Expand description

A GeoPackage layer with geometry metadata and column specs.

Fields§

§layer_name: String§geometry_column: String§primary_key_column: String§geometry_type: GeometryType§geometry_dimension: Dimension§srs_id: u32§property_columns: Vec<ColumnSpec>

Implementations§

Source§

impl GpkgLayer

Source

pub fn features(&self) -> Result<Vec<GpkgFeature>>

Return all the features in the layer.

Example:

use rusqlite_gpkg::Gpkg;

let gpkg = Gpkg::open_read_only("data/example.gpkg")?;
let layer = gpkg.get_layer("points")?;
for feature in layer.features()? {
    let _id = feature.id();
    let _geom = feature.geometry()?;
}
§Why does this return a vector instead of an iterator?

I was hoping we could avoid allocation here, but it seems rusqlite’s API requires allocation.

Source

pub fn features_batch<'a>( &'a self, batch_size: u32, ) -> Result<GpkgFeatureBatchIterator<'a>>

Return an iterator that yields features in batches.

This is intended for large layers where allocating a single Vec<GpkgFeature> could be expensive. Each iterator item is a Vec<GpkgFeature> with up to batch_size features.

Example:

use rusqlite_gpkg::Gpkg;

let gpkg = Gpkg::open_read_only("data/example.gpkg")?;
let layer = gpkg.get_layer("points")?;
for batch in layer.features_batch(100)? {
    let features = batch?;
    for feature in features {
        let _id = feature.id();
        let _geom = feature.geometry()?;
    }
}
Source

pub fn truncate(&self) -> Result<usize>

Remove all rows from the layer.

Example:

use rusqlite_gpkg::Gpkg;

let gpkg = Gpkg::open("data/example.gpkg")?;
let layer = gpkg.get_layer("points")?;
layer.truncate()?;
Source

pub fn insert<'p, G, P>(&self, geometry: G, properties: P) -> Result<()>
where G: GeometryTrait<T = f64>, P: IntoIterator<Item = &'p Value>,

Insert a feature with geometry and ordered property values.

Example:

use geo_types::Point;
use rusqlite_gpkg::{Gpkg, params};

let gpkg = Gpkg::open("data/example.gpkg")?;
let layer = gpkg.get_layer("points")?;

layer.insert(Point::new(1.0, 2.0), params!["alpha", 1])?;
Source

pub fn update<'p, G, P>( &self, geometry: G, properties: P, id: i64, ) -> Result<()>
where G: GeometryTrait<T = f64>, P: IntoIterator<Item = &'p Value>,

Update the feature with geometry and ordered property values.

Example:

use geo_types::Point;
use rusqlite_gpkg::{Gpkg, params};

let gpkg = Gpkg::open("data/example.gpkg")?;
let layer = gpkg.get_layer("points")?;
layer.update(Point::new(3.0, 4.0), params!["beta", false], 1)?;

Trait Implementations§

Source§

impl Debug for GpkgLayer

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