0.0.8 • Published 1 year ago
cloudtiles v0.0.8
Cloudtiles
A client library for OpenCloudTiles
Install
npm i -s cloudtiles
Usage Example
const cloudtiles = require("cloudtiles");
const fs = require("fs");
const c = cloudtiles("https://example.org/planet.cloudtiles").getTile(z,x,y, function(err, buffer){
fs.writeFile("tile."+c.header.tile_format, buffer, function(){});
});
API
cloudtiles(src, { tms: true })
src
: can be a file path or url pointing to a cloudtiles container.tms
: settrue
if cloudtiles container uses tms scheme with inverted Y index
.getTile(z, x, y, function(err, tile))
Get a tile as buffer from a cloudtiles container
.getHeader(function(err, header))
Get the header of a cloudtiles container
.getMeta(function(err, metadata))
Get the metadata of a cloudtiles container
.getZoomLevels(function(err, zoom))
Get the available zoom levels of a cloudtiles container as an array of strings
[ '0', '1', '2', ... ];
.getBoundingBox(function(err, bbox))
Get the approximate bounding box of the highest available zoom level 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()
cloudtiles("./some.cloudtiles").server(8080, "localhost", function(){
console.log("Listening on http://localhost:8080/");
});
Routes
/{z}/{x}/{y}
get tile/tile.json
get TileJSON/style.json
get Style/
Display map in Browser with maplibre-gl-js and maplibre-gl-inspect
Standalone Server
When called directly, cloudtiles can act as a standalone server:
- Global Install:
cloudtiles <file|url> [--tms] [--port <port>] [--host <hostname|ip>]
- Local Install:
node node_modules/cloudtiles/cloudtiles.js <file|url> [--tms] [--port <port>] [--host <hostname|ip>]