An open API service indexing awesome lists of open source software.

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

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.