New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mapnik-omnivore

Package Overview
Dependencies
Maintainers
26
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapnik-omnivore - npm Package Compare versions

Comparing version 2.2.4 to 3.0.0

54

lib/datasource-processor.js

@@ -348,40 +348,20 @@ var fs = require('fs'),

*/
function getMinMaxZoomGDAL(pixelSize, center, proj, callback){
var refFrom = new gdal.SpatialReference.fromProj4(proj);
var refTo = new gdal.SpatialReference.fromEPSG(3857);
var transform = new gdal.CoordinateTransformation(refFrom, refTo);
function getMinMaxZoomGDAL(pixelSize, center, proj, callback) {
var circumference = 40075000;
// Grab half of pixelsize and add/subtract to center longitude to create a horizontal line
var halfPixelsPerUnit = pixelSize[0]/2;
var line = new gdal.LineString();
line.points.add(center[0], (center[1] - halfPixelsPerUnit));
line.points.add(center[0], (center[1] + halfPixelsPerUnit));
// Transform native res pixel distance to google mercator pixel distance in meters
try {
line.transform(transform);
} catch (e) {
return callback(e);
}
var mercatorPixelSize = line.getLength();
// After transforming pixelsize, earth circumference will always be in meters...?
var circ = 40075000;
var lat = center[1];
var res;
var maxzoom;
//iterate through zoom levels to find threshold and set maxzoom
for(var zoom = 19; zoom >=0; zoom--){
// calculate resolution (meters/pixel) for each zoom level
// S=C*cos(y)/2^(z+8)...from http://wiki.openstreetmap.org/wiki/Zoom_levels
// calculates for lat north AND south of equator
res = circ * Math.cos(lat*Math.PI/180) / Math.pow(2,(zoom+8));
//use the source's resolution as the threshold
if(res >= mercatorPixelSize){
maxzoom = zoom+1;
return callback(null, Math.max(0, maxzoom-6), maxzoom);
}
if (zoom <= 0) return callback(invalid('Failed to set min/max zoom'));
}
};
// Create lookup table to determine max zoom level for given spatial resolution
var zoomLevels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
var spatialResolutions = zoomLevels.map(function(z) {
return circumference * Math.cos(0) / Math.pow(2, (z + 8));
});
var validSpatialResolutions = spatialResolutions.filter(function(res) {
return res > pixelSize[0]
});
var maxzoom = validSpatialResolutions.length;
var minzoom = Math.max(0, maxzoom - 6);
return callback(null, minzoom, maxzoom);
}
/**

@@ -388,0 +368,0 @@ * Detects unit type of the gdal source, using the srs/projection

{
"name": "mapnik-omnivore",
"version": "2.2.4",
"version": "3.0.0",
"description": "Node module that returns metadata of spatial files.",

@@ -5,0 +5,0 @@ "main": "index.js",

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