- 开始使用
- MEASUREMENT
- COORDINATE MUTATION
- TRANSFORMATION
- FEATURE CONVERSION
- MISC
- HELPER
- RANDOM
- DATA
- INTERPOLATION
- JOINS
- GRIDS
- CLASSIFICATION
- AGGREGATION
- META
- ASSERTIONS
- BOOLEANS
- UNIT CONVERSION
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
segmentEach
Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach() (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
遍历任何GeoJSON对象中的2-vertex
线段,类似于Array.forEach()
(Multi)Point
几何图形不包含线段,因此在此操作期间将忽略它们。
> npm install @turf/meta
参数
参数 | 类型 | 描述 |
---|---|---|
geojson | (FeatureCollection|Feature|Geometry) | any GeoJSON |
callback | Function | 回调函数 (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) |
返回
undefined - undefined
示例
// 注意:polygon首尾坐标要一致
var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
// Iterate over GeoJSON by 2-vertex segments
turf.segmentEach(polygon, function (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
//=currentSegment
//=featureIndex
//=multiFeatureIndex
//=geometryIndex
//=segmentIndex
});
// Calculate the total number of segments
var total = 0;
turf.segmentEach(polygon, function () {
total++;
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论