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

@carto/cartonik

Package Overview
Dependencies
Maintainers
15
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.6.1 to 0.7.0

6

CHANGELOG.md
# Cartonik ChangeLog
## v0.7.0 (2019-07-30)
- Preview: add option `concurrency` to avoid map-pool exhaustion in renderer
## v0.6.1 (2019-07-10)

@@ -9,3 +13,3 @@

- Implements `preview` method to to create static maps from tiles based on center (lng, lat) coordinates or bounding box area.
- 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

@@ -12,0 +16,0 @@ - Now bouding box is an object ({ west, south, east, north })

@@ -6,4 +6,4 @@ 'use strict'

module.exports = async function blend ({ coordinates, offsets, dimensions, format, quality, getTile }) {
const tiles = await Promise.all(getTiles({ coordinates, getTile }))
module.exports = async function blend ({ coordinates, offsets, dimensions, format, quality, getTile, concurrency }) {
const tiles = await getTilesInBatches({ coordinates, getTile, concurrency })

@@ -20,2 +20,31 @@ if (!tiles || !tiles.length) {

async function getTilesInBatches ({ coordinates, getTile, concurrency }) {
const batches = getCoordinateBatches({ coordinates, concurrency })
const tiles = []
for (const coords of batches) {
tiles.push(...await Promise.all(getTiles({ coordinates: coords, getTile })))
}
return tiles
}
function getCoordinateBatches ({ coordinates, concurrency }) {
const batches = []
for (let from = 0; from < coordinates.length; from += concurrency) {
let to = from + concurrency
if (to > coordinates.length) {
to = coordinates.length
}
const batch = coordinates.slice(from, to)
batches.push(batch)
}
return batches
}
function getTiles ({ coordinates, getTile }) {

@@ -22,0 +51,0 @@ const getTilePromisified = promisify(getTile)

@@ -23,2 +23,3 @@ 'use strict'

const tileSize = options.tileSize || 256
const concurrency = options.concurrency || 32
let zoom = options.zoom

@@ -30,3 +31,15 @@

return { getTile, bbox, center, dimensions, zoom, scale, format, quality, limit, tileSize }
return {
getTile,
bbox,
center,
dimensions,
zoom,
scale,
format,
quality,
limit,
tileSize,
concurrency
}
}

6

lib/preview/index.js

@@ -17,3 +17,4 @@ 'use strict'

zoom,
limit
limit,
concurrency
} = defaults(options)

@@ -33,3 +34,4 @@

quality,
getTile
getTile,
concurrency
})

@@ -36,0 +38,0 @@

{
"name": "@carto/cartonik",
"version": "0.6.1",
"version": "0.7.0",
"description": "Render maps with @carto/mapnik",

@@ -5,0 +5,0 @@ "publishConfig": {

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

- `tileSize`: `number` default `256`. Size of tiles used in `getTile` function.
- `concurrency`: `number` default `32`. Number of concurrent calls to getTile. Useful to avoid map-pool exhaustion. Ideally, should match with `poolSize` (`os.cpus().length`) + `poolMaxWaitingClients` (`32`).

@@ -124,0 +125,0 @@ ## :1234: Versioning

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