Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function(tileLayers, tile, done){
var bbox = tilebelt.tileToBBOX(tile);
var minDistance = 50/5280; // 50 ft in miles
var disconnects = turf.featurecollection([]);
var caps = [];
// Types we are looking for disconnected ends for
var preserve_type = { "motorway" : true, "primary" : true, "secondary" : true, "tertiary" : true, "trunk": true, "residential": true };
// Classes that we don't want to suggest that they should connect to
var reject_class = { "major_rail" : true, "minor_rail" : true, "aerialway" : true };
// First pass: finding road ends that don't connect to anything
for (var layer in tileLayers.streets) {
var i, j, k, f, g;
for (var i = 0; i < tileLayers.streets[layer].features.length; i++) {
var flat = flatten(tileLayers.streets[layer].features[i]);
for (var f = 0; f < flat.length; f++) {
let isIntersect = Turf.intersect(d, e);
if(isIntersect) {
isIntersect = arealizeGeometryCollection(isIntersect);
isIntersect.properties = d.properties;
isIntersect.properties.parentArea = Turf.area(d);
resultFeatures.push(isIntersect);
}
});
// console.log(resultFeatures);
// console.log(resultFeatures[0].geometry + ', ' + resultFeatures[0].properties);
// console.log(Turf.point(resultFeatures[0].geometry[1]));
});
return Turf.featurecollection(resultFeatures);
}
function filterGeoJSON(geojson) {
var outputLine = turf.linestring([]),
outputGeoJSON = turf.featurecollection([]),
minTimeDiff = 5, // 12 sampels / minute
minDistance = 20;
var feature = geojson.features[0],
coords = feature.geometry.coordinates,
times = feature.properties && feature.properties.coordTimes || null,
prevCoord,
prevTime,
newCoords,
newTimes = [];
// added no times option
if (times && !times[0].match(/^\d+$/)) {
// check if for special fucked up date format.
if (times[0].match(/^\d\d\d\d-\d-\d\d/)) {
times = times.map(function (t) {
function normalize (grid) {
grid.features = grid.features.filter(function(cell){
var year = 1955;
while(year <= 2013){
if (cell.properties[year.toString()] > 0) return true;
year++;
}
});
var breaks = {};
var year = 1955;
while(year <= 2013){
var filtered = turf.featurecollection([]);
filtered.features = grid.features.filter(function(cell){
if (cell.properties[year.toString()] > 0) return true;
});
breaks[year.toString()] = turf.quantile(filtered, year.toString(), [20,40,60,70,80,90,95,99]);
year++;
}
year = 1955;
while(year <= 2013){
var translation = breaks[year.toString()];
var translations = [
[0, translation[0], 1],
[translation[1], translation[2], 2],
[translation[2], translation[3], 3],
[translation[3], translation[4], 4],
a.features.forEach((d, i) => {
Logger.info(`[binaryDasymetricMapping][intersect][${i}/${a.features.length}]`);
b.features.forEach(e => {
const isIntersect = Turf.intersect(d, e);
if(isIntersect) {
isIntersect.properties = d.properties;
isIntersect.properties.parentArea = Turf.area(d);
resultFeatures.push(isIntersect);
}
});
});
return Turf.featurecollection(resultFeatures);
}
getArrayBuffer(url, function done(err, data) {
if (err) return callback(err)
if (data === null) return callback(null, featurecollection([]))
data = new vt.VectorTile(new Protobuf(new Uint8Array(data)))
parseTile(tile, data, callback)
})
}
module.exports = function(tileLayers, tile, writeData, done) {
var layer = tileLayers.osm.osm;
layer.features.map(function(val) {
if (val.geometry.type === 'Point') {
nodes[val.properties._osm_node_id] = val.geometry.coordinates;
}
});
var result = turf.featurecollection([]);
var nodes_invert = _.invert(nodes);
if (_.size(nodes_invert) !== _.size(nodes)) {
_.each(nodes_invert, function(v, k) {
delete nodes[v];
});
_.each(nodes, function(v) {
result.features.push(turf.point(v));
});
}
if (result.length > 0) {
writeData(JSON.stringify(result) + '\n');
}
done(null, null);
};
function getTraces (buses) {
return turf.featurecollection(Object.keys(buses).map(function(bus){
return buses[bus].route
}).filter(function(route){
if(route.geometry.coordinates.length > 1) return true
}))
}
var result = layer.features.filter(function(val) {
if (val.properties.junction && val.properties.junction === 'roundabout' && val.geometry.type === 'LineString') {
var coordinates = val.geometry.coordinates;
var coordinatesLength = coordinates.length;
var start = turf.point(coordinates[0]);
var end = turf.point(coordinates[coordinatesLength - 1]);
var distance = turf.distance(start, end, 'kilometers');
if (distance >= 0.02) {
val.properties._osmlint = 'falseroundabouts';
return true;
}
}
});
if (result.length > 0) {
var fc = turf.featurecollection(result);
writeData(JSON.stringify(fc) + '\n');
}
done(null, null);
};
let isIntersect = null;
try {
isIntersect = Turf.intersect(d, e);
} catch(e) { return; }
if(isIntersect) {
isIntersect = arealizeGeometryCollection(isIntersect);
isIntersect.properties = d.properties;
isIntersect.properties.parentArea = Turf.area(d);
resultFeatures.push(isIntersect);
}
});
});
return Turf.featurecollection(resultFeatures);
}