Skip to content

Commit

Permalink
don't include useless tiles; stop tiling on <=100 points
Browse files Browse the repository at this point in the history
closes #7
  • Loading branch information
mourner committed Dec 4, 2014
1 parent 46001ba commit e645cdf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/tilegeojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function tileGeoJSON(geojson, maxZoom) {
});

} else {
throw new Error('Unsupported GeoJSON type');
console.log('Unsupported GeoJSON type: ' + geom.type);
}
}
console.timeEnd('preprocess features');
Expand All @@ -56,12 +56,15 @@ function tileGeoJSON(geojson, maxZoom) {

function splitTile(stats, tiles, features, z, tx, ty, x1, y1, x2, y2, maxZoom) {

stats[z] = (stats[z] || 0) + 1;

var id = toID(z, tx, ty),
tile = tiles[id] = transformFeatures(features, Math.pow(2, z), tx, ty);
tile = transformFeatures(features, Math.pow(2, z), tx, ty);

if (isClippedSquare(tile)) return; // useless tile

tiles[id] = tile;
stats[z] = (stats[z] || 0) + 1;

if (z === maxZoom || isClippedSquare(tile)) return;
if (z === maxZoom || coordsNumWithin(features, 100)) return;

var x = (x1 + x2) / 2,
y = (y1 + y2) / 2,
Expand Down

0 comments on commit e645cdf

Please sign in to comment.