Skip to content
A collection of tools for fast and flexible Vector Tile encoding, decoding and merging.
Branch: master
Clone or download
Pull request Compare This branch is 2 commits behind marauder-io:master.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis
clipper
encoder
gradle/wrapper
models
projector
utils
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
build.gradle
gradlew
gradlew.bat
settings.gradle

README.md

Supercharger

Apache License, Version 2.0 Build Status

A marauder's supercharged collection of Vector Tile Tools

The Encoder is the main module to work with vector tiles. When talking about vector tiles, it refers to a standard developed by MapBox (https://github.com/mapbox/vector-tile-spec).

The collection consists of following supercharged components:

Encoder

A Encoder and Decoder for Mapbox Vector Tiles. We implement the specification version 2.1 (https://github.com/mapbox/vector-tile-spec/tree/master/2.1).

Features

  • Fast vector tile encoding from simple GeoJSON like Objects
  • Fast Vector tile decoding
  • Efficient & flexible vector tile merging
    • Directly from two BLOBs
    • By injecting one tile in another's encoding function call
  • Runs without JTS or GeoTools dependencies
    • Also JTS Geometry support is implemented
  • Allows to merge tiles without completely decoding them

Usage

Gradle

Artifacts are published on OSS Sonatype and Maven Central.

Gradle dependency:

compile group: 'io.marauder.supercharger', name: 'encoder', version: '0.0.3'
compile group: 'io.marauder.supercharger', name: 'models', version: '0.0.3'
compile group: 'io.marauder.supercharger', name: 'projector', version: '0.0.3'
compile group: 'io.marauder.supercharger', name: 'utils', version: '0.0.3'
compile group: 'io.marauder.supercharger', name: 'clipper', version: '0.0.3'

For snapshots use this repository:

maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }

Encoding Example

val f1 = Feature(
                type = GeoJsonType.Feature,
                geometry = Geometry.Polygon(
                        type = GeometryType.Polygon,
                        coordinates = listOf(
                                listOf(
                                        listOf(10.0, 10.0), listOf(10.0, 20.0), listOf(20.0, 20.0), listOf(20.0, 10.0), listOf(10.0, 10.0)
                                )
                        )
                ),
                properties = mapOf("A" to Value.StringValue("B"), "N" to Value.IntValue(3), "C" to Value.IntValue(2))
        )
val f1 = JSON.plain.parse<List<Feature>>(File("features.geojson").readText())
val encoder = Encoder()
val tile : vector_tile.VectorTile.Tile = encoder.encode(listOf(f1), "test1")
val tile : vector_tile.VectorTile.Tile = encoder.encode(listOf(f2), "test2")

Decoding Example

val bytes = File("file.pbf").readBytes()
val encoder = Encoder()
val features: List<Feature> = encoder.decode(bytes)

Current Limitations

  • Multiple layers are supported, but merging by injecting features into the encoding process does support only one layer.

Hints

  • As intended our Encoder/Decoder does no coordinate transformation and clipping

Geometry Clipping

Provides functionality to clip functions in x or y direction on given boundaries.

val clipper = Clipper()
clipper.clip(fc = featureCollection, ...)

Geometry Models

Available models

  • GeoJson - Feature collection
  • Feature - A features
  • Geometry - A geometry, sub classes used to instantiate
  • Value - Holds a feature's property value, sub classes used to instantiate

Geometry JTS/WKT support

val g1 = Geometry.fromJTS(jtsObject)
val g2 = Geometry.fromWKT(wktString)

val jts = g1.toJTS()
val wkt = g1.toWKT()

Geometry Projector

val projector = Projector(extend = 4096)
projector.transformGeometry(...)

Geometry Utils

Util functions for geometry intersection testing and geometry simplifications.

License

SuperCharger is licensed under the Apache License, Version 2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You can’t perform that action at this time.