pub struct Reader { /* private fields */ }
Expand description
Reader for decoding and accessing vector tile data.
Implementations§
Source§impl Reader
impl Reader
Sourcepub fn new(data: Vec<u8>) -> Result<Self, ParserError>
pub fn new(data: Vec<u8>) -> Result<Self, ParserError>
Creates a new Reader
instance with the provided vector tile data.
§Arguments
data
- The vector tile data as a byte vector.
§Returns
A result containing the Reader
instance if successful, or a DecodeError
if decoding the vector tile data fails.
§Examples
use mvt_reader::Reader;
let data = vec![/* Vector tile data */];
let reader = Reader::new(data);
Sourcepub fn get_layer_names(&self) -> Result<Vec<String>, ParserError>
pub fn get_layer_names(&self) -> Result<Vec<String>, ParserError>
Retrieves the names of the layers in the vector tile.
§Returns
A result containing a vector of layer names if successful, or a ParserError
if there is an error parsing the tile.
§Examples
use mvt_reader::Reader;
let data = vec![/* Vector tile data */];
let reader = Reader::new(data).unwrap();
match reader.get_layer_names() {
Ok(layer_names) => {
for name in layer_names {
println!("Layer: {}", name);
}
}
Err(error) => {
todo!();
}
}
Sourcepub fn get_layer_metadata(&self) -> Result<Vec<Layer>, ParserError>
pub fn get_layer_metadata(&self) -> Result<Vec<Layer>, ParserError>
Retrieves metadata about the layers in the vector tile.
§Returns
A result containing a vector of Layer
structs if successful, or a ParserError
if there is an error parsing the tile.
§Examples
use mvt_reader::Reader;
let data = vec![/* Vector tile data */];
let reader = Reader::new(data).unwrap();
match reader.get_layer_metadata() {
Ok(layers) => {
for layer in layers {
println!("Layer: {}", layer.name);
println!("Extent: {}", layer.extent);
}
}
Err(error) => {
todo!();
}
}
Sourcepub fn get_features(
&self,
layer_index: usize,
) -> Result<Vec<Feature>, ParserError>
pub fn get_features( &self, layer_index: usize, ) -> Result<Vec<Feature>, ParserError>
Retrieves the features of a specific layer in the vector tile.
§Arguments
layer_index
- The index of the layer.
§Returns
A result containing a vector of features if successful, or a ParserError
if there is an error parsing the tile or accessing the layer.
§Examples
use mvt_reader::Reader;
let data = vec![/* Vector tile data */];
let reader = Reader::new(data).unwrap();
match reader.get_features(0) {
Ok(features) => {
for feature in features {
todo!();
}
}
Err(error) => {
todo!();
}
}