Socket
Socket
Sign inDemoInstall

@mapbox/abaculus

Package Overview
Dependencies
63
Maintainers
14
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mapbox/abaculus

stitches map tiles together for high-res exporting from tm2


Version published
Weekly downloads
4
decreased by-20%
Maintainers
14
Install size
119 MB
Created
Weekly downloads
 

Changelog

Source

v3.1.0

  • Update mocha to 6.x
  • Update mapnik to 4.2.1
  • Update d3-queue to 3.0.7
  • Add travis builds for node 6,8,10 latest lte releases

Readme

Source

abaculus

a small block of stone, tile, glass, or other material used in the construction of a mosaic

or,

a library for creating static maps from tiles based on center or corner lng,lat coordinates. Uses node-mapnik to stitch tiles together.

Build Status

Looking to create high res images of maps? Abaculus was written for use in Mapbox Studio and you can use Mapbox Studio to create and export high resolution images -- see https://www.mapbox.com/guides/print/ for more information. You can even use that utility from the command line.

usage

Usage and example formatting below, or see the tests for a more robust example with a getTile function.

input:

scale: integer between 1-4 and sets resolution (scale: 1 is 72dpi, scale: 4, is 288dpi)

zoom: zoom level

[w, s, e, n]: the bounding box for the west (lat val), south (lng val), east (lat val), north (lng val) for the desired area

x: longitude coordinate

y: latitude coordinate

width and height: desired pixel bounds for a map with a center coordinate. Will be multiplied by scale to maintain resolution.

format (optional): png or jpeg, default is png.

quality (optional): when used with jpeg format, accepts 1-100 and defaults to 80. when used with png format, accepts 2-256 (# of colors to reduce the image to) and defaults to none.

tileSize (optional, defaults to 256): Specifies input size of tiles used in getTile function.

getTile: a function that returns a tile buffer (png or otherwise) and headers given z, x, y, and a callback, such as from tilelive-vector or this test function.

limit (optional): max width or height of generated image in pixels. Default is 19008.

// Calculate image bounds from W,S,E,N bounding box.
var params = {
	zoom: {zoom},
	scale: {scale}
    bbox: [{w}, {s}, {e}, {n}],
    format: {format},
    quality: {quality},
	tileSize: {tileSize},
    getTile: function(z, x, y, callback){
		// do something
		return callback(null, buffer, headers);
	},
	limit: {limit}
};

or

// Calculate image bounds from center lng,lat coordinates and
// pixel dimensions of final image (will be multipled by scale).
var params = {
	zoom: {zoom},
	scale: {scale}
    center: {
    	x: {x},
    	y: {y},
    	w: {width},
    	h: {height}
    },
    format: {format},
    quality: {quality},
	tileSize: {tileSize},
    getTile: function(z,x,y, callback){
		// do something
		return callback(null, buffer, headers);
	},
	limit: {limit}
};
usage:
abaculus(params, function(err, image, headers){
	if (err) return err;
	// do something with image
});
output:

an image of desired resolution for the selected area.

FAQs

Last updated on 28 Jun 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc