Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//========
// this was being used...
// let mergedElevationPoly = turf.merge(
// turf.featureCollection(elevationPolys));
//========
// - turf.merge is deprecated, so...
// - https://github.com/turf-junkyard/turf-merge
// This module is now deprecated in favor of using
// the turf-union module repeatedly on an array.
// - https://gis.stackexchange.com/questions/243460/turf-js-union-with-array-of-features
// console.log('feat collection:', turf.featureCollection(elevationPolys));
let mergedElevationPoly = turf.union.apply(
this, turf.featureCollection(elevationPolys).features);
// trim to desired search area
mergedElevationPoly = turf.intersect(
polygon, mergedElevationPoly);
if (mergedElevationPoly) {
let contourArea = turf.area(mergedElevationPoly.geometry);
// FIXME: ???????? ???????? ???????? ????????
// L.mapbox.featureLayer().setGeoJSON(mergedElevationPoly).addTo(map);
contours.push({
'geometry': mergedElevationPoly,
'ele': currentElevation,
'area': contourArea,
});
}
} catch (error) { // on merge fail, insert the previous contour again and skip
console.log('merge failed at elevation '+currentElevation);
console.log(error.message);
results.push(final);
};
// Each filter
for (let filterFeature of filter.features) {
try {
let geometry = filterFeature.geometry;
let filter = geometry.type === "Point" ? turf.circle(geometry, geometry.properties.radius) : geometry;
// Each incident
for (let feature of incidents.features) {
let geometry = feature.geometry;
// filter results to overlapping regions
let result = turf.intersect(filter, geometry.type === "Point" ? turf.circle(geometry, radius) : geometry.geometries[1].geometries[0]);
// if match
if (result !== undefined) format(feature);
}
} catch(error) {
res.status(500).send({ ok: false, code: 500, error: "Internal Server Error" });
console.error(error);
break;
}
}
// Sort results by HIGH→LOW warning levels
// then sort by Distance from Home
results.sort((a, b) => {
let home = ["-33.746", "150.7123"];
});
} else {
geoJSON.push(parsePoly(geometry.slice(10, -2)));
}
return geoJSON;
}
const geometry = params.area.geofield[0].geom;
const geomJSON = geoJSONify(geometry);
// Now I'll check whether the point is inside the polygon (isInside)
// OR if the point is within [radius] km of the polygon border (isNear)
const circle = turf.circle(params.point, params.radius, { units: 'kilometers' });
const polygon = turf.polygon(geomJSON);
const isInside = turf.inside(params.point, polygon);
const isNear = turf.intersect(circle, polygon) !== null;
if (isInside || isNear) {
commit('addLocalArea', params.area);
}
},
},
}
for (const feature of filters.filter.features) {
try {
const geometry = feature.geometry;
const filter = geometry.type === 'Point'
? turf.circle(geometry, geometry.properties.radius)
: geometry;
// Each incident
for (const feature of incidents.features) {
const geometry = feature.geometry;
// Filter Results for Overlapping Regions
try {
const result = turf.intersect(filter, geometry.type === 'Point'
? turf.circle(geometry, radius)
: geometry.geometries[1].geometries[0]);
// Match
if (result !== undefined) {
const formatted = this.format(feature);
if (formatted) results.push(formatted); // eslint-disable-line max-depth
}
} catch(error) {
console.log(error.message);
++missing;
continue;
}
}
} catch(error) {
res.status(500).send({ ok: false, error: 'Internal Server Error' });
feature2.features.forEach(feature2 => {
let poly2 = turf.polygon(feature2.geometry.coordinates)
const kinks2 = turf.kinks(poly2)
poly2 = (typeof kinks2 !== 'undefined' && jsts_validate(poly2)) || poly2
if (turf.booleanOverlap(poly1, poly2)) {
let intersection
try {
intersection = turf.intersect(poly1, poly2)
} catch (e) {
if (
e &&
e.message &&
e.message.includes('found non-noded intersection between')
) {
console.log(`${feature1.properties.CACODE} ,self-intersection`)
}
} finally {
if (intersection && intersection.geometry.coordinates) {
const area = turf.area(intersection)
if (area > 0) {
result.push({
code: feature2.properties.CACODE,
area,
})
taskGrid.features.forEach(f => {
let poly = turf.polygon(f.geometry.coordinates[0]);
let contains = turf.intersect(geom, poly);
if (contains === null) {
newTaskGrid.push(f);
} else {
const splitGrid = makeGrid(f, f.properties.zoom + 1, {});
splitGrid.features.forEach(g => {
newTaskGrid.push(g);
});
}
});
multiPt.properties._fromWay = val.properties['@id'];
//save detection
output[val.properties['@id']] = val;
output[val.properties['@id'] + 'M'] = multiPt;
}
}
}
var buildingTraceTree = rbush(bboxes.length);
buildingTraceTree.load(bboxes);
for (var z = 0; z < bboxes.length; z++) {
var bbox = bboxes[z];
var overlaps = buildingTraceTree.search(bbox);
for (var k = 0; k < overlaps.length; k++) {
var overlap = overlaps[k];
if (overlap.id !== bbox.id) {
var intersect = turf.intersect(
buildings[overlap.id],
buildings[bbox.id]
);
if (
intersect &&
(intersect.geometry.type === 'Polygon' ||
intersect.geometry.type === 'MultiPolygon')
) {
var area = turf.area(intersect);
if (area > overlapArea) {
var buildingA = buildings[overlap.id];
buildingA.properties._osmlint = osmlint;
var buildingB = buildings[bbox.id];
buildingB.properties._osmlint = osmlint;
var points = turf.explode(intersect);
var multiPoint = turf.combine(points).features[0];
['forw', 'bakw'].map(function(dir) {
var result = turf.intersect(searchResult[0][dir], searchResult[1][dir]);
if (!result || result.geometry.type == 'Point' || result.geometry.type == 'LineString') return;
if (!prev[dir]) prev[dir] = {};
try {
var diff1 = turf.difference(searchResult[0][dir], result);
var diff2 = turf.difference(searchResult[1][dir], result);
if (!diff1 || !diff2) {
prev[dir][key] = 'Include case';
} else {
prev[dir][key] = 'Not include case';
}
} catch(e) {
prev[dir][key] = 'Not include case';
}
});
return prev;