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

geojson-vt

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-vt - npm Package Compare versions

Comparing version 2.1.8 to 2.2.0

approx.js

20

package.json
{
"name": "geojson-vt",
"version": "2.1.8",
"version": "2.2.0",
"description": "Slice GeoJSON data into vector tiles efficiently",

@@ -19,12 +19,12 @@ "homepage": "https://github.com/mapbox/geojson-vt",

"devDependencies": {
"benchmark": "^1.0.0",
"browserify": "^12.0.1",
"coveralls": "^2.11.4",
"eslint": "^1.9.0",
"eslint-config-mourner": "^1.0.1",
"benchmark": "^2.1.0",
"browserify": "^13.0.1",
"coveralls": "^2.11.9",
"eslint": "^2.10.2",
"eslint-config-mourner": "^2.0.1",
"faucet": "0.0.1",
"istanbul": "^0.4.0",
"tape": "^4.2.2",
"uglify-js": "^2.5.0",
"watchify": "^3.6.0"
"istanbul": "^0.4.3",
"tape": "^4.5.1",
"uglify-js": "^2.6.2",
"watchify": "^3.7.0"
},

@@ -31,0 +31,0 @@ "license": "ISC",

@@ -79,2 +79,7 @@ ## geojson-vt — GeoJSON Vector Tiles

##### 2.2.0 (Jun 9, 2015)
- Fixed ring winding order for polygons and multipolygons in accordance with vector tile specification 2.0.
- Fixed handling of features with null geometry (now ignored instead of throwing an error).
##### 2.1.8 (Nov 9, 2015)

@@ -81,0 +86,0 @@

@@ -81,2 +81,3 @@ 'use strict';

dist = points.dist,
outer = points.outer,
len = points.length,

@@ -97,3 +98,3 @@ a, j, last;

slice.push(intersect(a, b, k1), intersect(a, b, k2));
if (!closed) slice = newSlice(slices, slice, area, dist);
if (!closed) slice = newSlice(slices, slice, area, dist, outer);

@@ -106,3 +107,3 @@ } else if (bk >= k1) slice.push(intersect(a, b, k1)); // ---|--> |

slice.push(intersect(a, b, k2), intersect(a, b, k1));
if (!closed) slice = newSlice(slices, slice, area, dist);
if (!closed) slice = newSlice(slices, slice, area, dist, outer);

@@ -117,7 +118,7 @@ } else if (bk <= k2) slice.push(intersect(a, b, k2)); // | <--|---

slice.push(intersect(a, b, k1));
if (!closed) slice = newSlice(slices, slice, area, dist);
if (!closed) slice = newSlice(slices, slice, area, dist, outer);
} else if (bk > k2) { // | ---|-->
slice.push(intersect(a, b, k2));
if (!closed) slice = newSlice(slices, slice, area, dist);
if (!closed) slice = newSlice(slices, slice, area, dist, outer);
}

@@ -139,3 +140,3 @@ // | --> |

// add the final slice
newSlice(slices, slice, area, dist);
newSlice(slices, slice, area, dist, outer);
}

@@ -146,3 +147,3 @@

function newSlice(slices, slice, area, dist) {
function newSlice(slices, slice, area, dist, outer) {
if (slice.length) {

@@ -153,2 +154,3 @@ // we don't recalculate the area/length of the unclipped geometry because the case where it goes

slice.dist = dist;
if (outer !== undefined) slice.outer = outer;

@@ -155,0 +157,0 @@ slices.push(slice);

@@ -27,2 +27,7 @@ 'use strict';

function convertFeature(features, feature, tolerance) {
if (feature.geometry === null) {
// ignore features with null geometry
return;
}
var geom = feature.geometry,

@@ -32,3 +37,3 @@ type = geom.type,

tags = feature.properties,
i, j, rings;
i, j, rings, projectedRing;

@@ -47,3 +52,5 @@ if (type === 'Point') {

for (i = 0; i < coords.length; i++) {
rings.push(project(coords[i], tolerance));
projectedRing = project(coords[i], tolerance);
if (type === 'Polygon') projectedRing.outer = (i === 0);
rings.push(projectedRing);
}

@@ -56,3 +63,5 @@ features.push(create(tags, type === 'Polygon' ? 3 : 2, rings));

for (j = 0; j < coords[i].length; j++) {
rings.push(project(coords[i][j], tolerance));
projectedRing = project(coords[i][j], tolerance);
projectedRing.outer = (j === 0);
rings.push(projectedRing);
}

@@ -104,3 +113,3 @@ }

y = y < -1 ? -1 :
y = y < 0 ? 0 :
y > 1 ? 1 : y;

@@ -107,0 +116,0 @@

@@ -74,2 +74,4 @@ 'use strict';

if (type === 3) rewind(simplifiedRing, ring.outer);
simplified.push(simplifiedRing);

@@ -87,1 +89,16 @@ }

}
function rewind(ring, clockwise) {
var area = signedArea(ring);
if (area < 0 === clockwise) ring.reverse();
}
function signedArea(ring) {
var sum = 0;
for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {
p1 = ring[i];
p2 = ring[j];
sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
}
return sum;
}

@@ -1,1 +0,1 @@

{"z0-0-0":[{"geometry":[[3186,4096],[3197,-4096]],"type":1,"tags":null},{"geometry":[[[3197,2048],[3209,2037]]],"type":2,"tags":null}]}
{"z0-0-0":[{"geometry":[[3186,4096],[3197,0]],"type":1,"tags":null},{"geometry":[[[3197,2048],[3209,2037]]],"type":2,"tags":null}]}

@@ -1,1 +0,1 @@

{"z0-0-0":[{"geometry":[[[3186,2048],[3197,2048],[3197,2037],[3186,2037],[3186,2048]]],"type":3,"tags":{"prop0":"value0","prop1":{"this":"that"}}}]}
{"z0-0-0":[{"geometry":[[[3186,2048],[3186,2037],[3197,2037],[3197,2048],[3186,2048]]],"type":3,"tags":{"prop0":"value0","prop1":{"this":"that"}}}]}
'use strict';
var fs = require('fs');
var geojsonvt = require('../src/index');

@@ -7,9 +8,4 @@

if (require.main === module) { // if called directly
var fs = require('fs');
var result = genTiles(JSON.parse(fs.readFileSync(process.argv[2])), process.argv[3], process.argv[4]);
console.log(JSON.stringify(result));

@@ -16,0 +12,0 @@ }

@@ -12,2 +12,3 @@ 'use strict';

testTiles('collection.json', 'collection-tiles.json');
testTiles('single-geom.json', 'single-geom-tiles.json');

@@ -23,3 +24,4 @@ test('throws on invalid GeoJSON', function (t) {

test('full tiling test: ' + inputFile, function (t) {
t.same(genTiles(getJSON(inputFile), maxZoom, maxPoints), getJSON(expectedFile));
var tiles = genTiles(getJSON(inputFile), maxZoom, maxPoints);
t.same(getJSON(expectedFile), tiles);
t.end();

@@ -30,8 +32,14 @@ });

test('empty geojson', function (t) {
t.same(genTiles(getJSON('empty.json')), {});
t.same({}, genTiles(getJSON('empty.json')));
t.end();
});
test('null geometry', function (t) {
// should ignore features with null geometry
t.same({}, genTiles(getJSON('feature-null-geometry.json')));
t.end();
});
function getJSON(name) {
return JSON.parse(fs.readFileSync(path.join(__dirname, '/fixtures/' + name)));
}

Sorry, the diff of this file is not supported yet

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