Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// top_right = { "lat": positionAndBearing[0].lat + tr_lat_displacement, "lng": positionAndBearing[0].lng + tr_lng_displacement };
// bottom_right = { "lat": positionAndBearing[0].lat + br_lat_displacement, "lng": positionAndBearing[0].lng + br_lng_displacement };
// bottom_left = { "lat": positionAndBearing[0].lat + bl_lat_displacement, "lng": positionAndBearing[0].lng + bl_lng_displacement };
// top_left = { "lat": positionAndBearing[0].lat + tl_lat_displacement, "lng": positionAndBearing[0].lng + tl_lng_displacement };
top_right = [ positionAndBearing[0].lng + (this.defaultFootprint[category].lng_dst/2), positionAndBearing[0].lat + (this.defaultFootprint[category].lat_dst/2) ];
bottom_right = [ positionAndBearing[0].lng + (this.defaultFootprint[category].lng_dst/2), positionAndBearing[0].lat - (this.defaultFootprint[category].lat_dst/2) ];
bottom_left = [ positionAndBearing[0].lng - (this.defaultFootprint[category].lng_dst/2), positionAndBearing[0].lat - (this.defaultFootprint[category].lat_dst/2) ];
top_left = [ positionAndBearing[0].lng - (this.defaultFootprint[category].lng_dst/2), positionAndBearing[0].lat + (this.defaultFootprint[category].lat_dst/2) ];
var poly = turfPolygon(
[
[
top_right,
bottom_right,
bottom_left,
top_left,
top_right
]
]
);
// console.log(positionAndBearing[1]);
var rotatedPoly = turfTransformRotate(poly, positionAndBearing[1]);
if (DEMO_MODE) {
getPolygonFromRegion(region) {
const coords = [];
for (let p = 0; p < region.length; p++) {
let point = region.points[p];
const points = [point.y, point.x];
coords.push(points);
}
try {
return turf.polygon([coords]);
} catch (error) {
log.error(error);
return null;
}
}
export function getRhumbLineArea(polygon, projection) {
let transformedPoly = polygon;
if (projection !== referenceProjection) {
transformedPoly = polygon.clone().transform(projection, referenceProjection);
}
const coords = polygon.getCoordinates()[0];
if (coords.length < 4) {
return 0;
}
const poly = TurfPolygon(transformedPoly.getCoordinates());
return TurfArea(poly);
}
var cwCheck = isClockwise(coordinates);
if (cwCheck) coordinates = ['a', 'c', 'b', 'a'].map(function(key) {
return tri.properties[key].geom;
});
var geoms = tri.geometry.coordinates[0];
var props = tri.properties;
var properties = !cwCheck ? {
a: {geom: geoms[0], index: props['a'].index},
b: {geom: geoms[1], index: props['b'].index},
c: {geom: geoms[2], index: props['c'].index}
} : {
a: {geom: geoms[0], index: props['a'].index},
b: {geom: geoms[2], index: props['c'].index},
c: {geom: geoms[1], index: props['b'].index}
};
return turf.polygon([coordinates], properties);
}
.map(coordinates => turf.polygon(coordinates))
.forEach(polygon => {
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);
});
}
});
enlargePolygonFromRegion(region) {
const coords = [];
for (let p = 0; p < region.length; p++) {
let point = region.points[p];
const points = [point.y, point.x];
coords.push(points);
}
try {
const poly = turf.polygon([coords]);
const buffer = turf.transformScale(poly, 1.5);
return this.regionFromGeoJSON(buffer);
} catch (error) {
log.error(error);
return null;
}
}