Skip to content

Commit

Permalink
minor simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Mar 26, 2020
1 parent 7040949 commit 2cd11c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
9 changes: 2 additions & 7 deletions src/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ export default function createFeature(id, type, geom, tags) {
maxX: -Infinity,
maxY: -Infinity
};
calcBBox(feature);
return feature;
}

function calcBBox(feature) {
const geom = feature.geometry;
const type = feature.type;

if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {
calcLineBBox(feature, geom);
Expand All @@ -36,6 +29,8 @@ function calcBBox(feature) {
calcLineBBox(feature, polygon[0]);
}
}

return feature;
}

function calcLineBBox(feature, geom) {
Expand Down
16 changes: 5 additions & 11 deletions src/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,20 @@ export default function createTile(features, z, tx, ty, options) {
};
for (const feature of features) {
addFeature(tile, feature, tolerance, options);

const minX = feature.minX;
const minY = feature.minY;
const maxX = feature.maxX;
const maxY = feature.maxY;

if (minX < tile.minX) tile.minX = minX;
if (minY < tile.minY) tile.minY = minY;
if (maxX > tile.maxX) tile.maxX = maxX;
if (maxY > tile.maxY) tile.maxY = maxY;
}
return tile;
}

function addFeature(tile, feature, tolerance, options) {

const geom = feature.geometry;
const type = feature.type;
const simplified = [];

tile.minX = Math.min(tile.minX, feature.minX);
tile.minY = Math.min(tile.minY, feature.minY);
tile.maxX = Math.max(tile.maxX, feature.maxX);
tile.maxY = Math.max(tile.maxY, feature.maxY);

if (type === 'Point' || type === 'MultiPoint') {
for (let i = 0; i < geom.length; i += 3) {
simplified.push(geom[i], geom[i + 1]);
Expand Down

0 comments on commit 2cd11c2

Please sign in to comment.