Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var streets = normalize(tileLayers.streets.road);
streets.features = streets.features.concat(normalize(flatten(tileLayers.streets.bridge)).features);
streets.features = streets.features.concat(normalize(flatten(tileLayers.streets.tunnel)).features);
// clip features to tile
streets = clip(streets, tile);
tigerRoads = clip(tigerRoads, tile);
streets = normalize(flatten(streets));
tigerRoads = normalize(flatten(tigerRoads));
// buffer streets
var streetBuffers = turf.featurecollection([]);
streetBuffers.features = streets.features.map(function(road){
return turf.buffer(road, 5, 'meters').features[0];
});
streetBuffers = normalize(turf.merge(streetBuffers));
// erase street buffer from tiger lines
var tigerDeltas = turf.featurecollection([]);
tigerRoads.features.forEach(function(tigerRoad){
streetBuffers.features.forEach(function(streetsRoad){
var roadDiff = turf.erase(tigerRoad, streetsRoad);
if(roadDiff) tigerDeltas.features.push(roadDiff);
});
});
tigerDeltas = normalize(flatten(tigerDeltas));
done(null, {
diff: tigerDeltas,
tiger: tigerRoads,
streets: streets
});
]);
geojson = turf.extent(input);
} else {
displayHelp();
console.error('No geometry provided. Pipe geojson, or use --point or --extent');
return process.exit(1);
}
if (argv.buffer) {
var radius = parseFloat(argv.buffer);
var units = /mi$/.test(argv.buffer) ? 'miles' : 'kilometers';
geojson = turf.buffer(geojson, radius, units);
}
// tilecover doesn't like features
geojson = turf.merge(geojson);
if (geojson.type === 'Feature') {
geojson = geojson.geometry;
}
callback();
},
function performAction(callback) {
performbuffer(geom, bufferamt, function(err, finalgeom) {
if (err) return callback(err);
// tilecover doesn't like features
if (finalgeom.type !== 'Polygon') {
finalgeom = turf.merge(finalgeom);
}
if (finalgeom.type === 'FeatureCollection') {
if (finalgeom.features.length > 1) return callback(new Error('Too many features'));
finalgeom = finalgeom.features[0];
}
if (finalgeom.type === 'Feature') {
finalgeom = finalgeom.geometry;
}
var tiles = [];
if (metatile === 1) {
tiles = tilecover.tiles(finalgeom, {min_zoom: z, max_zoom: z});
} else {
var dz = {"2":1, "4":2, "8":3}[metatile];
var metatiles = tilecover.tiles(finalgeom, {min_zoom: z - dz, max_zoom: z - dz});
return point;
}
try {
var points;
var polygons = [];
for (var i = 0; i < groundSurfaces.length; i++) {
points = citygmlPoints(groundSurfaces[i]).map((point) => {
return proj4('EPSG:ORIGIN').inverse([point[0], point[1]]);
});
polygons.push(turf.polygon([points], properties));
}
var featureCollection = turf.featurecollection(polygons);
var polygon = turf.merge(featureCollection);
return polygon;
} catch(err) {
console.error(chalk.red(err));
return point;
}
};
merge: function(layers) {
var self = this
var updates = {}
for (var id in layers) {
var layer = layers[id]
var fc = gjutils.newFeatureCollection()
var newFeatures = []
if (layer.geojson.type === 'FeatureCollection') {
for (var i = 0; i < layer.geojson.features.length; i++) {
if (layer.geojson.features[i].selected) {
fc.features.push(layer.geojson.features[i])
} else {
newFeatures.push(layer.geojson.features[i])
}
}
newFeatures.push(turf.merge(fc))
var newGj = gjutils.newFeatureCollection()
newGj.features = newGj.features.concat(newFeatures)
layer.mapLayer.clearLayers()
layer.mapLayer = false
updates[id] = {
geojson: newGj
}
}
}
LayerActions.updateList(updates)
},
erase: function(layers) {