Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@carto/cartonik

Package Overview
Dependencies
Maintainers
17
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@carto/cartonik - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

coverage/lcov-report/base.css

7

CHANGELOG.md
# Cartonik ChangeLog
## v0.6.0 (2019-06-17)
- Implements `preview` method to to create static maps from tiles based on center (lng, lat) coordinates or bounding box area.
- Calculate zoom based on bounding box parameter as default value
- Now bouding box is an object ({ west, south, east, north })
- Now center uses a lng, lat nomeclature
## v0.5.1 (2019-05-21)

@@ -4,0 +11,0 @@

5

package.json
{
"name": "@carto/cartonik",
"version": "0.5.1",
"version": "0.6.0",
"description": "Render maps with @carto/mapnik",

@@ -8,3 +8,3 @@ "publishConfig": {

},
"main": "lib/renderer-factory.js",
"main": "lib/cartonik.js",
"author": "CARTO (https://carto.com/)",

@@ -34,2 +34,3 @@ "contributors": [

"@carto/mapnik": "^3.6.2-carto.15",
"@mapbox/sphericalmercator": "^1.1.0",
"generic-pool": "^3.6.1",

@@ -36,0 +37,0 @@ "mime": "^2.4.0"

73

README.md

@@ -12,2 +12,3 @@ # Cartonik :earth_africa:

- Support traditional mapnik datasources: `shape`, `postgis`, `gdal`, `ogr`, etc..
- Render static images from tiles based on center (long, lat) or bounding box (east, south, west, north) coordinates.
- Optimized for high-performance services

@@ -23,8 +24,8 @@

## :wave: Hello Cartonik
## :globe_with_meridians: Render tiles
```js
const cartonik = require('cartonik')
const { rendererFactory } = require('cartonik')
const renderer = cartonik({ xml: '<Map>...</Map>' })
const renderer = rendererFactory({ xml: '<Map>...</Map>' })
const [ format, z, x, y ] = [ 'png', 0, 0, 0 ]

@@ -35,13 +36,11 @@

## :computer: Usage: cartonik(options)
## :computer: Usage: `rendererFactory(options)`
```js
const options = { ... }
const renderer = cartonik(options)
const renderer = rendererFactory(options)
```
## :triangular_ruler: Options
## :triangular_ruler: Renderer options
### Generic options
- `type`: `string` (either `raster` or `vector`, default `raster`). Whether the renderer aims to render Mapnik Vector Tiles or traditional raster formats (`png`, `utf`).

@@ -60,3 +59,3 @@ - `xml`: `string` (*required*). The [Mapnik XML](https://github.com/mapnik/mapnik/wiki/XMLConfigReference) configuration.

### Raster options (`type` = `raster`)
### Raster renderer options (`type` = `raster`)

@@ -70,6 +69,60 @@ - `metatile`: `number` (default `2`). The number of tiles included in a metatile. One metatile generates a group of images at once in batches before separating them into the final tiles - this improves efficiency in various ways.

### Vector options (`type` = `vector`)
### Vector renderer options (`type` = `vector`)
- `gzip`: `boolean` (default `true`). Compression method used to encoding a vector tile.
## :fireworks: Static images (previews)
```js
const { preview, rendererFactory } = require('cartonik')
const renderer = rendererFactory({ xml: '<Map>...</Map>' })
const { image } = await preview({
center: {
lng: -3.68529754,
lat: 40.40197212
},
dimensions: {
width: 200,
height: 200
},
getTile: function (x, y, z, callback) {
renderer.getTile('png', z, x, y)
.then(({ tile }) => callback(null, tile))
.catch((err) => callback(err))
}
})
```
**Note**: Preview implementes old getTile interface: `renderer.getTile(z, x, y, callback)`; this is going to change soon. The new interface is: `const tile = await renderer.getTile(format, z, x, y)`
## :computer: Usage: `preview(options)`
```js
const options = { ... }
const renderer = preview(options)
```
## :triangular_ruler: Preview options
- `getTile`: `function` (*required*). Function to retrive the required tiles to build the preview image.
- `bbox`: `object`. The bounding box for the west, south, east, and north coordinates of the requested area.
- `west`: `number`. Longitude coordinate.
- `south`: `number`. Latitude coordinate.
- `east`: `number`. Longitude coordinate.
- `north`: `number`. Latitude coordinate.
- `center`: `object`. Point where the preview is centered. This option must be used along `dimensions` option.
- `lng`: `number`. Long coordinate.
- `lat`: `number`. Latitude coordinate.
- `dimensions`: `object`. Preview's size in pixels. This options must be defined along `center` option and will be multiplied by scale to keep the resolution.
- `width`: `number`.
- `heigth`: `number`.
- `zoom`: `number` default 0. The `z` cordinate, `x` and `y` will be calculated based on either `bbox` or `center` coordinates.
- `scale`: `number` [`1-4`], default `1`. Resolution (scale: `1` is `72dpi`, scale: `4`, is `288dpi`).
- `format`: `string` either `png` or `jpg`, default `png`.
- `quality`: `number`. When used with `jpg` 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 `null`.
- `limit`: `number` default `19008`. Max width or height of requested image in pixels. Default is 19008.
- `tileSize`: `number` default `256`. Size of tiles used in `getTile` function.
## :1234: Versioning

@@ -76,0 +129,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc