Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var features = [];
for (let bFeature of data.buildings.bingbuildings.features) {
var bingOsmIntersect = osmCover.search(bFeature);
if (bingOsmIntersect.features.length == 0) {
// No intersection in the rbush means we should just write out the building
features.push(bFeature);
continue;
} else if (bingOsmIntersect.features.length > 0) {
var bCentroid = turf.centroid(bFeature);
var matchFound = false;
for (let oFeature of bingOsmIntersect.features) {
var oCentroid = turf.centroid(oFeature);
var dist = turf.distance(bCentroid, oCentroid);
if (dist < 0.05) {
matchFound = true;
break;
}
}
if (!matchFound) {
features.push(bFeature);
}
}
}
var fc = turf.featureCollection(features);
writeData(JSON.stringify(fc) + '\n');
done(null, null);
function isOval(highway) {
var centroidPt = turf.centroid(highway);
var points = turf.explode(highway);
var range = 1.2;
var flag = true;
var totalDistace = 0;
var distances = [];
for (var i = 0; i < points.features.length; i++) {
var distance = turf.distance(centroidPt, points.features[i], {
units: 'kilometers'
});
distances.push(distance);
totalDistace += distance;
}
var averageDistance = totalDistace / points.features.length;
for (var f = 0; f < distances.length; f++) {
if (distances[f] > averageDistance * range) {
flag = false;
}
}
return flag;
}
export function confidenceScore(bbox: BBox): number {
if (!bbox) { return 0 }
let result = 0
const poly = turf.bboxPolygon(bbox)
const sw = turf.point(poly.geometry.coordinates[0][0])
const ne = turf.point(poly.geometry.coordinates[0][2])
const distance = turf.distance(sw, ne, 'kilometers')
scoreMatrix.map(step => {
const [score, maximum] = step
if (distance < maximum) { result = score }
if (distance >= 25) { result = 1 }
})
return result
}