Crates.io | mvt-reader |
lib.rs | mvt-reader |
version | 1.5.0 |
source | src |
created_at | 2023-05-27 12:34:57.898479 |
updated_at | 2024-07-21 12:26:55.647906 |
description | A library for decoding and reading mapbox vector tiles in Rust and WebAssembly |
homepage | |
repository | https://github.com/codeart1st/mvt-reader |
max_upload_size | |
id | 875934 |
size | 58,630 |
wasm
feature)cargo build --release
cargo test
wasm-pack build --release --target nodejs -d pkg/node -- --features wasm && npm test
To use the mvt-reader
library in your Rust project, add the following to your Cargo.toml
file:
[dependencies]
mvt-reader = "1.5.0"
Then, you can import and use the library in your code:
use mvt_reader::{Reader, ParserError};
fn main() -> Result<(), ParserError> {
// Read a vector tile from file or data
let data = vec![/* Vector tile data */];
let reader = Reader::new(data)?;
// Get layer names
let layer_names = reader.get_layer_names()?;
for name in layer_names {
println!("Layer: {}", name);
}
// Get features for a specific layer
let layer_index = 0;
let features = reader.get_features(layer_index)?;
for feature in features {
todo!()
}
Ok(())
}
To use the mvt-reader library as a WebAssembly module in JavaScript, you can install it with npm and use it in your JavaScript code:
const { Reader } = require('mvt-reader')
const fs = require('fs')
// Example usage
const reader = new Reader(fs.readFileSync('path/to/tile.mvt'))
const layerNames = reader.getLayerNames()
console.log(layerNames)
// More code...
This project is licensed under the MIT License.