https://github.com/springmeyer/vector-tile-java
Java library for efficient reading of Mapbox Vector Tiles
https://github.com/springmeyer/vector-tile-java
Last synced: 5 months ago
JSON representation
Java library for efficient reading of Mapbox Vector Tiles
- Host: GitHub
- URL: https://github.com/springmeyer/vector-tile-java
- Owner: springmeyer
- License: other
- Created: 2024-06-26T17:24:11.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-05T17:04:59.000Z (almost 2 years ago)
- Last Synced: 2025-09-22T09:18:05.518Z (9 months ago)
- Language: Java
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vector-tile-java
A Java library for efficient reading of Mapbox Vector Tiles.
This libraries is modeled after these high-performance Javascript libraries:
- https://github.com/mapbox/vector-tile-js
- https://github.com/mapbox/pbf
## Usage
This library has no external dependencies.
Use it as follows:
```java
// 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());
}
}
```
## Developing
Run the tests as follows:
```bash
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.