26 lines
780 B
JavaScript
26 lines
780 B
JavaScript
|
function Tin(points=[]) {
|
||
|
let arr = []
|
||
|
points.forEach(p=>{
|
||
|
arr.push(turf.point( [parseFloat(p[0]), parseFloat(p[1])]))
|
||
|
})
|
||
|
var tin = turf.tin(turf.featureCollection(arr));
|
||
|
let polylines=[]
|
||
|
tin.features.forEach((feature, index) => {
|
||
|
feature.geometry.coordinates.forEach((coordinate,) => {
|
||
|
polylines.push([
|
||
|
coordinate[0],
|
||
|
coordinate[1],
|
||
|
coordinate[2],
|
||
|
])
|
||
|
})
|
||
|
})
|
||
|
return polylines
|
||
|
return JSON.stringify(polylines)
|
||
|
}
|
||
|
|
||
|
function BooleanPointInPolygon(point,polygon=[]) {
|
||
|
var pt = turf.point([point[0],point[1]]);
|
||
|
var poly = turf.polygon([polygon]);
|
||
|
var scaledPoly = turf.transformScale(poly, 2);
|
||
|
return turf.booleanPointInPolygon(pt, poly)
|
||
|
}
|