geojson-vt
Advanced tools
Comparing version 2.1.2 to 2.1.3
{ | ||
"name": "geojson-vt", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Slice GeoJSON data into vector tiles efficiently", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/mapbox/geojson-vt", |
@@ -60,2 +60,3 @@ ## geojson-vt — GeoJSON Vector Tiles | ||
indexMaxPoints: 100000, // max number of points per tile in the index | ||
solidChildren: false // whether to include solid tile children in the index | ||
}); | ||
@@ -74,2 +75,7 @@ ``` | ||
##### 2.1.3 (Aug 14, 2015) | ||
- Added `solidChildren` option that includes children of solid filled square tiles in the index (off by default). | ||
- Added back solid tile heuristics (not tiling solid filled square tiles further). | ||
##### 2.1.2 (Aug 13, 2015) | ||
@@ -76,0 +82,0 @@ |
@@ -51,2 +51,3 @@ 'use strict'; | ||
indexMaxPoints: 100000, // max number of points per tile in the tile index | ||
solidChildren: false, // whether to tile solid square tiles further | ||
tolerance: 3, // simplification tolerance (higher means simpler) | ||
@@ -64,3 +65,4 @@ extent: 4096, // tile extent | ||
extent = options.extent, | ||
buffer = options.buffer; | ||
buffer = options.buffer, | ||
solidChildren = options.solidChildren; | ||
@@ -99,2 +101,5 @@ // avoid recursion by using a processing queue | ||
// stop tiling if the tile is solid clipped square | ||
if (!solidChildren && isClippedSquare(tile, extent, buffer)) continue; | ||
// if it's the first-pass tiling | ||
@@ -180,2 +185,4 @@ if (!cz) { | ||
if (parent.source) { | ||
if (isClippedSquare(parent, extent, options.buffer)) return transformTile(parent, extent); | ||
if (debug > 1) console.time('drilling down'); | ||
@@ -239,1 +246,22 @@ this.splitTile(parent.source, z0, x0, y0, z, x, y); | ||
} | ||
// checks whether a tile is a whole-area fill after clipping; if it is, there's no sense slicing it further | ||
function isClippedSquare(tile, extent, buffer) { | ||
var features = tile.source; | ||
if (features.length !== 1) return false; | ||
var feature = features[0]; | ||
if (feature.type !== 3 || feature.geometry.length > 1) return false; | ||
var len = feature.geometry[0].length; | ||
if (len !== 5) return false; | ||
for (var i = 0; i < len; i++) { | ||
var p = transformPoint(feature.geometry[0][i], extent, tile.z2, tile.x, tile.y); | ||
if ((p[0] !== -buffer && p[0] !== extent + buffer) || | ||
(p[1] !== -buffer && p[1] !== extent + buffer)) return false; | ||
} | ||
return true; | ||
} |
1803962
8087
112