各位大佬,请问iMobile有没有办法不手动选择面而自动生成岛洞多边形?文档上写的是需要手选。
大佬,下面是我写的生成岛洞的代码,这个好像没有执行成功,按理来说生成成功的话,选中的记录会合并成一条记录,但是实际上并没有合并,麻烦你帮我看下哪里不对:
val parameter = QueryParameter() var simids = Stream.of(isWithinGeoIds).map { item -> item }.collect(Collectors.toList()) var simidstr = TextUtils.join(",", simids) parameter.attributeFilter = "houseType='${HouseType.courtyard}' and SmID in (${simidstr})" parameter.cursorType = CursorType.STATIC // 进行查询 val selection: Selection = mapActivity.geonetryLayer!!.selection if (mapActivity.geometryDataSet != null) { mapActivity.geonetryLayer!!.isEditable=true mMapControl!!.action = Action.COMPOSE_HOLLOW_REGION; // 进行查询 val recordset: Recordset = mapActivity.geometryDataSet!!.query(parameter) if (recordset != null && recordset.recordCount > 0) { selection.fromRecordset(recordset); } mMapControl!!.submit() selection.clear() //依次关闭所有对象 recordset.close() recordset.dispose() // mMapControl!!.submit() mapActivity.geonetryLayer!!.isEditable=false }
另外您说的clip方法我看了下文档有点类似于求交。
实现思路:获取需要擦除的几何对象Geometry,然后使用该几何对象擦除大对象,形成岛洞。参考代码如下:
Datasource datasource = m_Workspace.getDatasources().get(0); DatasetVector datasetVector =(DatasetVector)datasource.getDatasets().get(0); Recordset query = datasetVector.query("SmID=1", CursorType.DYNAMIC); Recordset clip = datasetVector.query("SmID=2", CursorType.DYNAMIC); GeoRegion geoRegionSource = (GeoRegion) query.getGeometry(); GeoRegion geoRegionClip = (GeoRegion) clip.getGeometry(); Geometry clip1 = Geometrist.erase(geoRegionSource, geoRegionClip); query.edit(); query.setGeometry(clip1); query.update(); clip.edit(); clip.delete(); clip.refresh(); m_Map.refresh();