arcgis java 修复几何图形

我们在做图形面积计算或者导出地块时,总会遇到个别的地块坐标顺序不对,从而在计算面积时会出现面积为负数,这实在是太烦了,于是再我的不谢寻找下终于找到了解决这个的方法,这个方法就是拓扑

话不多说上代码,用以下代码就可以修复arcgis坐标面积为负的这个问题 主要用到的接口

ITopologicalOperator 可以自己去百度看看 
public static IGeometry repairGeometry(IGeometry geometry) {
        try {
            ITopologicalOperator2 topo2 = (ITopologicalOperator2) geometry;
            if (topo2 != null && !topo2.isKnownSimple()) {
                topo2.simplify();
            }
            ITopologicalOperator3 topo3 = (ITopologicalOperator3) geometry;
            if (topo3 != null) {
                topo3.setIsKnownSimple(false);
                int[] arg0 = new int[1];
                arg0[0] = esriNonSimpleReasonEnum.esriNonSimpleOK;
                boolean simpleEx = topo3.isSimpleEx(arg0);
                if (!simpleEx) {
                    topo3.simplify();
                }
            }
            return geometry;
        } catch (Exception ex) {
            LogUtil.error(ex.getMessage(),ex.getCause());
            return geometry;
        }
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值