提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
@如何使用openlayers实现Arcgis中自动填充空隙
前言
使用openlayers+jsts+turf开源空间拓扑库,可以实现多面中空隙自动填充
一、为什么使用ol+jsts+turf?
主要因为开源,功能开发能够随心所欲,更重要的是能够提高自己的框架能力
二、使用步骤
代码如下(示例):
var geomCut
if (cut.geometry.type == ‘MultiPolygon’) {
geomCut = turf.multiPolygon(cut.geometry.coordinates)
} else {
geomCut = turf.polygon(cut.geometry.coordinates)
}
for (const cuted of cutsed) {
var geomCuted
if (cuted.geometry.type == ‘MultiPolygon’) {
geomCuted = turf.multiPolygon(cuted.geometry.coordinates)
} else {
geomCuted = turf.polygon(cuted.geometry.coordinates)
}
var difference = turf.difference(geomCut, geomCuted)
geomCut = difference
}
var geomType = geomCut.geometry.type
let outGeom = geomType == 'Polygon' ? new Polygon(geomCut.geometry.coordinates || [])
: new MultiPolygon(geomCut.geometry.coordinates || [])