Skip to main content

GpkgBinaryParser

Struct GpkgBinaryParser 

Source
pub struct GpkgBinaryParser;
Expand description

Parser and encoder for the GeoPackageBinary (GPB) and WKB geometry formats.

The GeoPackageBinary layout is:

magic[2]     = 0x47 0x50  ("GP")
version[1]
flags[1]     bits 0-2: envelope indicator
             bit  3:   empty-geometry flag
             bit  5:   byte order (0=BE, 1=LE)
srs_id[4]    i32, same byte order as flags bit 5
envelope     0/32/48/64 bytes depending on flags bits 0-2
WKB          remainder of the blob

Implementations§

Source§

impl GpkgBinaryParser

Source

pub fn parse(data: &[u8]) -> Result<GpkgGeometry, GpkgError>

Parse a GeoPackageBinary blob into a GpkgGeometry.

§Errors
Source

pub fn parse_wkb(data: &[u8]) -> Result<GpkgGeometry, GpkgError>

Parse a WKB (Well-Known Binary) blob into a GpkgGeometry.

Both big-endian (byte_order = 0) and little-endian (byte_order = 1) WKB are supported.

Source

pub fn to_wkb(geom: &GpkgGeometry) -> Vec<u8>

Encode a GpkgGeometry as little-endian WKB.

Source

pub fn to_gpb(geom: &GpkgGeometry, srs_id: i32) -> Vec<u8>

Encode a GpkgGeometry as a GeoPackageBinary blob (no envelope, LE byte order).

The resulting bytes begin with the magic GP (0x47 0x50).

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.