#tile #vector #open #gis #low-cost-code

no-std open-vector-tile

This library reads/writes The Open Vector Tiles 1.0 Specification

1 unstable release

0.1.0 May 17, 2024

#22 in #tile

Download history 110/week @ 2024-05-12 36/week @ 2024-05-19

146 downloads per month

MIT license

43KB
305 lines

open-vector-tile npm downloads bundlephobia docs-ts docs-rust

About

A Modified TypeScript implementation of the Mapbox Vector Tile library. It is backwards compatible but offers a lot of new features and improvements including (but not limited to):

  • Proper module treeshake.
  • Pre-Tessellated & Indexed geometries to quickly ship data to the renderer.
  • Support for 3D geometries.
  • Support for M-Values for each geometry point (used by lines and polygons).
    • M-Values are stored as "Shapes" which reuses objects only needing to do lookups on values.
  • Column encoding of data to make it more compact. Better gzip and brotli compression.
  • Support nested objects in properties.

Inspiration

A very talented Markus Tremmel came up with the idea of migrating away from a row based approach to a column based approach with his COVTiles. I wanted to test the idea of simplifying his approach and see if it was worth the effort. Once I saw I got better results post compression I decided to finish this project.

Install

#bun
bun add open-vector-tile
# pnpm
pnpm add open-vector-tile
# yarn
yarn add open-vector-tile
# npm
npm install open-vector-tile

# cargo
cargo install ovtile

Example use

const fs = from 'fs'
import { VectorTile } from 'open-vector-tile'

// assume you can read (.pbf | .mvt | .ovt)
const fixture = fs.readFileSync('./x-y-z.vector.pbf')
// load the protobuf parsing it directly
const tile = new VectorTile(fixture)

console.log(tile)

// example layer
const { landuse } = tile.layers

// grab the first feature
console.log(landuse.feature(0))
console.log(landuse.feature(0).loadGeometry())

Development

Requirements

You need the tool tarpaulin to generate the coverage report. Install it using the following command:

cargo install cargo-tarpaulin

The bacon coverage tool is used to generate the coverage report. To utilize the pycobertura package for a prettier coverage report, install it using the following command:

pip install pycobertura

Running Tests

To run the tests, use the following command:

# TYPESCRIPT
## basic test
bun run test
## live testing
bun run test:dev

# RUST
## basic test
cargo test
# bacon
bacon test

Generating Coverage Report

To generate the coverage report, use the following command:

cargo tarpaulin
# bacon
bacon coverage # or type `l` inside the tool

Dependencies