Home

Awesome

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: {} })

.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