Struct VectorTile

Source
pub struct VectorTile {
    pub layers: BTreeMap<String, VectorLayer>,
    pub grids: BTreeMap<String, GridData>,
    pub images: BTreeMap<String, ImageData>,
    /* private fields */
}
Expand description

§Open Vector Tile

§Description

A Vector Tile may parse either Mapbox or OpenVector Tile Layers The input is an unsigned byte array that has encoded protobuffer messages.

Types of layers include:

  • Vector data - vector points, lines, and polygons with 3D coordinates, properties, and/or m-values
  • Image data - raster data that is RGB(A) encoded
  • Grid data: data that has a max-min range, works much like an image but has floating/double precision point values for each point on the grid

§Usage

use ovtile::{VectorTile, VectorLayerMethods};

let data: Vec<u8> = vec![];
let mut tile = VectorTile::new(data, None);

// VECTOR API

let landuse = tile.layer("landuse").unwrap();

// grab the first feature
let firstFeature = landuse.feature(0).unwrap();
// grab the geometry
let geometry = firstFeature.load_geometry();

// OR specifically ask for a geometry type
let points = firstFeature.load_points();
let lines = firstFeature.load_lines();

// If you want to take advantage of the pre-tessellated and indexed geometries
// and you're loading the data for a renderer, you can grab the pre-tessellated geometry
let (geometry_flat, indices) = firstFeature.load_geometry_flat();

// IMAGE API

let satellite = tile.images.get("satellite").unwrap();
// grab the image data
let data = &satellite.image;

// GRID API

let elevation = tile.grids.get("elevation").unwrap();
// grab the grid data
let data = &elevation.data;

Fields§

§layers: BTreeMap<String, VectorLayer>

the layers in the vector tile

§grids: BTreeMap<String, GridData>

Gridded data

§images: BTreeMap<String, ImageData>

Image data

Implementations§

Source§

impl VectorTile

Source

pub fn new(data: Vec<u8>, end: Option<usize>) -> Self

Create a new vector tile

Source

pub fn read_layers(&mut self) -> Option<()>

Read the layers

Source

pub fn layer(&mut self, name: &str) -> Option<&mut VectorLayer>

Get a layer given the name

Trait Implementations§

Source§

impl Debug for VectorTile

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<&mut VectorTile> for BaseVectorTile

Source§

fn from(vector_tile: &mut VectorTile) -> Self

Convert from Mapbox vector tile

Source§

impl ProtoRead for VectorTile

Source§

fn read(&mut self, tag: u64, pb: &mut Protobuf)

The read method is used to read a field from a protobuf message. The tag parameter is used to determine which field to read into the struct. The pbf parameter is used to read the data in the appropriate format. 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.