Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const featuresSorted = this.sortDorParcelFeatures(features);
let feature;
if (!multipleAllowed) {
feature = features[0];
// dor
} else {
feature = featuresSorted[0];
}
// use turf to get area and perimeter of all parcels returned
for (let featureSorted of featuresSorted) {
// const turfPolygon = polygon(featureSorted.geometry.coordinates);
const turfPolygon = polygon(featureSorted.geometry.coordinates);
let turfCoordinates = []
for (let coordinate of featureSorted.geometry.coordinates[0]) {
// console.log('coordinate:', coordinate);
turfCoordinates.push(point(coordinate));
}
let distances = []
for (let i=0; i
var pt2 = point(100, 101)
// MultiLineString
var l1 = lineString([
[102.0,
-10.0],
[130.0,
4.0]])
var l2 = lineString([
[40.0,
-20.0],
[150.0,
18.0]])
// MultiPolygon
var p1 = polygon( [
[
[20.0,0.0],
[101.0,0.0],
[101.0,1.0],
[100.0,1.0],
[100.0,0.0]
]
])
var p2 = polygon([
[
[30.0,0.0],
[102.0,0.0],
[103.0,1.0]
]
])
function groupNestedRings(orderedLinearRings) {
// create a list of the (coordinates of) LinearRings
var lrList = orderedLinearRings.map(function (lr) {
return {lrCoordinates: lr, grouped: false};
});
var groupedLinearRingsCoords = [];
while (!allGrouped(lrList)) {
for (var i = 0; i < lrList.length; i++) {
if (!lrList[i].grouped) {
// create new group starting with the larger not already grouped ring
var group = [];
group.push(lrList[i].lrCoordinates);
lrList[i].grouped = true;
var outerMostPoly = polygon([lrList[i].lrCoordinates]);
// group all the rings contained by the outermost ring
for (var j = i + 1; j < lrList.length; j++) {
if (!lrList[j].grouped) {
var lrPoly = polygon([lrList[j].lrCoordinates]);
if (isInside(lrPoly, outerMostPoly)) {
group.push(lrList[j].lrCoordinates);
lrList[j].grouped = true;
}
}
}
// insert the new group
groupedLinearRingsCoords.push(group);
}
}
}
return groupedLinearRingsCoords;
function hexagon(center:number[], rx:number, ry:number, properties:any, cosines:number[], sines:number[]): any {
const vertices = [];
for (let i = 0; i < 6; i++) {
const x = round(center[0] + rx * cosines[i],6);
const y = round(center[1] + ry * sines[i],6);
vertices.push([x, y]);
}
//first and last vertex must be the same
vertices.push(vertices[0].slice());
let feature = turf.polygon([vertices], properties);
feature.properties.centroid = center;
return feature;
}
import { polygon } from '@turf/helpers';
import union from './';
const poly1 = polygon([[[0, 0], [10, 10], [20, 20], [0, 0]]]);
const poly2 = polygon([[[20, 30], [10, 10], [20, 20], [20, 30]]]);
union(poly1, poly2);
export function wayToLineString(
geom: OsmGeometry,
nodeCoords: number[][]
): Feature
toPolygon() {
if (this.polygon)
return this.polygon;
const coordinates = this.edges.map(edge => edge.from.coordinates);
coordinates.push(this.edges[0].from.coordinates);
return (this.polygon = polygon([coordinates]));
}
import {polygon} from '@turf/helpers';
import mask from './';
const poly1 = polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
const poly2 = polygon([[[30, 5], [-40, -10], [-50, -10], [-40, 5], [30, 5]]]);
mask(poly1)
mask(poly1, poly2)
private mapChange = (forceSetState: boolean = false) => {
const { map } = this.props;
const { superC, clusterPoints } = this.state;
const zoom = map.getZoom();
const canvas = map.getCanvas();
const w = canvas.width;
const h = canvas.height;
const upLeft = map.unproject([0, 0]).toArray();
const upRight = map.unproject([w, 0]).toArray();
const downRight = map.unproject([w, h]).toArray();
const downLeft = map.unproject([0, h]).toArray();
const newPoints = superC.getClusters(
bbox(polygon([[upLeft, upRight, downRight, downLeft, upLeft]])),
Math.round(zoom)
);
if (newPoints.length !== clusterPoints.length || forceSetState) {
this.setState({ clusterPoints: newPoints });
}
};