Socket
Socket
Sign inDemoInstall

tile-cover

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tile-cover - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

test/fixtures/russia_out.geojson

53

index.js

@@ -85,43 +85,20 @@ var tilebelt = require('tilebelt'),

function splitSeek(tile, geom, locked, limits) {
if (!tileGeomEquals(tile, geom)) {
var tileCovers = true;
var doIntersect = needsIntersect(tilebelt.tileToGeoJSON(tile), geom);
var intersects;
if (doIntersect) {
intersects = intersect(fc(tilebelt.tileToGeoJSON(tile)), fc(feature(geom)));
}
if (!intersects || intersects.features[0].type === 'GeometryCollection') {
tileCovers = false;
}
if (tile[2] === 0 || (tileCovers && tile[2] < limits.max_zoom)) {
var children = tilebelt.getChildren(tile);
children.forEach(function(t) {
splitSeek(t, intersects.features[0], locked, limits);
});
} else if (tileCovers) {
locked.push(tile);
}
} else {
locked.push(tile);
var tileCovers = true;
var doIntersect = needsIntersect(tilebelt.tileToGeoJSON(tile), geom);
var intersects;
if (doIntersect) {
intersects = intersect(fc(tilebelt.tileToGeoJSON(tile)), fc(feature(geom)));
}
}
if (!intersects || intersects.features[0].type === 'GeometryCollection') {
tileCovers = false;
}
function tileGeomEquals(tile, geom) {
tile = tilebelt.getParent(tile);
var tileGeojson = tilebelt.tileToGeoJSON(tile).geometry;
if (tileGeojson.coordinates[0].length === 5 && geom.coordinates[0].length === 5) {
var numShared = 0;
geom.coordinates[0].forEach(function(coord1) {
tileGeojson.coordinates[0].forEach(function(coord2) {
if (coord1[0] === coord2[0] && coord1[1] === coord2[1]) {
numShared++;
}
});
if (tile[2] === 0 || (tileCovers && tile[2] < limits.max_zoom)) {
var children = tilebelt.getChildren(tile);
children.forEach(function(t) {
splitSeek(t, intersects.features[0], locked, limits);
});
if (numShared === 7) {
return true;
}
} else {
return false;
} else if (tileCovers) {
//console.log(tile[2])
locked.push(tile);
}

@@ -128,0 +105,0 @@ }

{
"name": "tile-cover",
"version": "0.3.1",
"version": "0.4.0",
"description": "generate the minimum number of tiles to cover a geojson geometry",

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

@@ -57,1 +57,25 @@ var cover = require('../'),

});
test('russia', function(t){
var russia = JSON.parse(fs.readFileSync(__dirname+'/fixtures/russia.geojson'));
var limits = {
min_zoom: 6,
max_zoom: 6
};
t.ok(cover.geojson(russia, limits), 'russia geojson');
t.ok(cover.tiles(russia, limits).length, 'russia tiles');
t.ok(cover.indexes(russia, limits).length, 'russia indexes');
t.equal(cover.indexes(russia, limits).length, 457)
fs.writeFileSync(__dirname+'/fixtures/russia_out.geojson', JSON.stringify(cover.geojson(russia, limits), 'russia tiles'));
//console.log(cover.tiles(russia, limits))
t.end();
});
function f(g, name){
return {
type:'Feature',
properties: {name: name},
geometry: g
}
}
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