只是想知道是否有一种方法可以轻松地将 turf.lineChunk 的输出转换为 turf.points?
testLineString = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
155.9668,
-2.9402
],
[
162.959225,
-2.94504
],
]
}
};
var chunk = turf.lineChunk(testLineString, 25, { units: "kilometers" });
var points = turf.points([ [], [], [], ]);
希望有这样简单的事情(但这行不通)
var points = turf.points(chunk.features);
我希望这些点能够在 turf.pointsWithinPolygon() 中使用
var inside = turf.pointsWithinPolygon(points ,turfpolygon);
谢谢你。
除了像下面这样的循环之外,似乎不是一个简单的方法:
for (var x = 0; x < chunkedLine.features.length; x++) {
if (foundWithinPolygon == false) {
points = turf.points([
[chunkedLine.features[x].geometry.coordinates[0][0], chunkedLine.features[x].geometry.coordinates[0][1]],
[chunkedLine.features[x].geometry.coordinates[1][0], chunkedLine.features[x].geometry.coordinates[1][1]],
]);
var ptsWithin = turf.pointsWithinPolygon(points, turfpolygon);
if (ptsWithin.features.length > 0) {
foundWithinPolygon = true;
break;
}
}
}