首页 / 浏览问题 / 移动GIS / 问题详情
imobile如何自动生成岛洞多边形
76EXP 2022年03月28日

各位大佬,请问iMobile有没有办法不手动选择面而自动生成岛洞多边形?文档上写的是需要手选。

1个回答

您好,如果需要自动生成先将两个几何对象查询出来,然后通过Geometrist.clip裁剪就可以了
9,127EXP 2022年03月28日

大佬,下面是我写的生成岛洞的代码,这个好像没有执行成功,按理来说生成成功的话,选中的记录会合并成一条记录,但是实际上并没有合并,麻烦你帮我看下哪里不对:

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方法我看了下文档有点类似于求交。

您好,第一个问题使用Action岛洞是否已经生成了呢?裁剪和相交在结果上是一样的,但是所保留的属性信息是不一样的,裁剪运算不对属性表做任何处理,而求交运算可以让用户选择需要保留的属性字段。
没有生成岛洞,idesktop上打开也没有生成,另外我这边用的是求交和裁剪的取反。
您那边加我一个联系呢,把你的代码发我一下。谢谢。联系方式私信您
已加,还麻烦您帮忙看看呢

实现思路:获取需要擦除的几何对象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();
...