A Java library for efficient reading of Mapbox Vector Tiles.
This libraries is modeled after these high-performance Javascript libraries:
This library has no external dependencies.
Use it as follows:
// Where `buf` is a `byte[]` representing an uncompressed Mapbox Vector Tile
Pbf pbf = new Pbf(buf);
VectorTile vectorTile = new VectorTile(pbf, pbf.length);
for (VectorTileLayer layer : vectorTile.layers.values()) {
System.out.println("Layer: " + layer.name);
for (int i = 0; i < layer.length; i++) {
VectorTileFeature feature = layer.feature(i);
System.out.println("Feature: " + feature.id);
System.out.println("Properties: " + feature.properties);
System.out.println("Type: " + VectorTileFeature.types[feature.type]);
System.out.println("Geometry: " + feature.loadGeometry());
}
}
Run the tests as follows:
gradle test
The tests currently only ensure that input MVT files can be parsed without errors.
No assertions on content are currently done.
If you'd like to check to see if your MVT file can be parsed, drop it in the ./fixtures
directory and it will be automatically parsed in the tests.