初始
This commit is contained in:
26
api/v1/common/tool/turf/turf.js
Normal file
26
api/v1/common/tool/turf/turf.js
Normal file
@ -0,0 +1,26 @@
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user