npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mapbox/vtshaver

v0.3.3

Published

Creates style-optimized vector tiles

Downloads

81

Readme

Vector Tile Shaver

Style-optimized vector tiles. The shaver takes a Mapbox Vector Tile and a Mapbox GL Style and removes layers, features, and properties in the tile that are not used by the style to reduce the size of the tile. Read the feature release blog post and the api-documentation for more info.

Build Status codecov badge

shaved-bearded tile and unshaved-bearded tile

Installation

npm install @mapbox/vtshaver

If you want to install locally you can also do:

git clone https://github.com/mapbox/vtshaver
cd vtshaver
npm install

API Usage

CLI

Shaver provides 2 command line tools:

vtshave

vtshave [args]

  --tile:    required: path to the input vector tile
  --style:   required: path to a gl style to use to shave
  --zoom:    required: the zoom level
  --maxzoom: optional: the maxzoom of a tileset relevant to the tile buffer being shaved
  --out:     optional: pass a path if you want the shaved tile to be saved

Will output a size comparison of how many bytes were shaved off the tile.

Example:

  vtshave --tile tile.mvt --zoom 0 --maxzoom 16 --style style.json

vtshaver-filters

vtshaver-filters [args]

  --style:   required: path to a gl style to parse
  --sources: optional: list of one or more sources (comma separated) to display in the output (default is all sources)
  --pretty:  optional: whether to pretty print the output (default false). Pass '--pretty' to indent the JSON.

Will output a json object describing each of the source-layers and their parsed metadata to be used for shaving.

Example:

  vtshaver-filters --style style.json > meta.json

Develop

Build binaries

make

For Mac M1 users, there are a couple of extra steps before building

  • Comment out linking instructions in your local binding.gyp as follows
#  'make_global_settings': [
#    ['CXX', '<(module_root_dir)/mason_packages/.link/bin/clang++'],
#    ['CC', '<(module_root_dir)/mason_packages/.link/bin/clang'],
#    ['LINK', '<(module_root_dir)/mason_packages/.link/bin/clang++'],
#    ['AR', '<(module_root_dir)/mason_packages/.link/bin/llvm-ar'],
#    ['NM', '<(module_root_dir)/mason_packages/.link/bin/llvm-nm']
#  ],
  • Switch to x86_64 processor since arm64 has unresolved issues with the latest mbgl-core library
$ arch --x86_64 zsh

Test

make test

Run bench test

node bench/bench-batch.js --iterations 50 --concurrency 10

Optionally combine with the time command

Docs

Documentation is generated using Documentation.js --polyglot mode. Generate docs in API.md by running:

make docs

NOTE: we are pinned to [email protected] because 5.x removed C++ support: https://github.com/documentationjs/documentation/blob/master/CHANGELOG.md#500-2017-07-27