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

versatiles

v0.3.1

Published

A client library for VersaTiles

Downloads

28

Readme

VersaTiles

A client library for VersaTiles containers.

Install

npm i -s versatiles

Usage Example


const versatiles = require("versatiles");
const fs = require("fs");

const c = versatiles("https://example.org/planet.versatiles").getTile(z,x,y, function(err, buffer){

	fs.writeFile("tile."+c.header.tile_format, buffer, function(){});

});

API

versatiles(src, { tms: true, headers: {} })

  • src: can be a file path or url pointing to a versatiles container.
  • tms: set true if versatiles container uses tms scheme with inverted Y index
  • headers: additional request headers sent to the server when src is http
  • base: base url for relative urls in style.json / tile.json when the builtin webserver is started

.getTile(z, x, y, function(err, tile))

Get a tile as buffer from a versatiles container

.decompress(type, buffer, function(err, buffer))

Decompress a buffer, with type bein gzip, br or null, obtainable from header.tile_precompression

.getHeader(function(err, header))

Get the header of a versatiles container

.getMeta(function(err, metadata))

Get the metadata of a versatiles container

.getZoomLevels(function(err, zoom))

Get the available zoom levels of a versatiles container as an array of integers

[ 0, 1, 2, ... ];

.getBoundingBox(function(err, bbox))

Get the bounding box as an array of floats in the order WestLon, SouthLat, EastLon, NorthLat.

[
	13.07373046875,
	52.32191088594773,
	13.77685546875,
	52.68304276227742
]

.server(...)

Start a rudimentary webserver delivering tiles and metadata. Arguments are passed on to http.server.listen()

versatiles("./some.versatiles").server(8080, "localhost", function(){
	console.log("Listening on http://localhost:8080/");
});

Routes

Standalone Server

When called directly, versatiles can act as a standalone server.

This is for testing purposes, please feel discouraged from using this in a production environment.

Global Install

npm i -g versatiles
versatiles-server <file|url> [--tms] [--port <port>] [--host <hostname|ip>] [--base https://example.org] [--header-<header-key> <header-value>]

Local Install

npm i versatiles
node node_modules/versatiles/versatiles.js <file|url> [--tms] [--port <port>] [--host <hostname|ip>] [--base https://example.org] [--header-<header-key> <header-value>]

License

Unlicense