生成的Polyline这样示例拓扑

            //生成的Polyline要这样加点,ITopologicalOperator拓扑操作才正常,如果使用IPointCollection很有可能是COM错误
            IPoint pt1 = new PointClass();
            pt1.PutCoords(0, 100);
            IPoint pt2 = new PointClass();
            pt2.PutCoords(100, 100);
            IPoint pt3 = new PointClass();
            pt3.PutCoords(200, 100);
            IPoint pt4 = new PointClass();
            pt4.PutCoords(300, 100);
            IPoint pt5 = new PointClass();
            pt5.PutCoords(400, 100);
            IPoint pt6 = new PointClass();
            pt6.PutCoords(500, 100);
            IPoint pt7 = new PointClass();
            pt7.PutCoords(600, 100);

            object missing = Type.Missing;
            IGeometryCollection line1 = new PolylineClass();
            ISegmentCollection path1 = new PathClass();
            var L1 = new LineClass(); L1.PutCoords(pt1, pt2); path1.AddSegment(L1);
            var L2 = new LineClass(); L2.PutCoords(pt2, pt3); path1.AddSegment(L2);
            var L3 = new LineClass(); L3.PutCoords(pt3, pt4); path1.AddSegment(L3);
            var L4 = new LineClass(); L4.PutCoords(pt4, pt5); path1.AddSegment(L4);
            var L5 = new LineClass(); L5.PutCoords(pt5, pt6); path1.AddSegment(L5);
            var L6 = new LineClass(); L6.PutCoords(pt6, pt7); path1.AddSegment(L6);
            line1.AddGeometry(path1 as IGeometry, ref missing, ref missing);
            ((ITopologicalOperator)line1).Simplify();

            IPoint pt6a = new PointClass();
            pt6.PutCoords(500, 100);
            IPoint pt7a = new PointClass();
            pt7.PutCoords(600, 100);
            IGeometryCollection line2 = new PolylineClass();
            ISegmentCollection path2 = new PathClass();
            var L6a = new LineClass(); L6a.PutCoords(pt6a, pt7a); path2.AddSegment(L6a);
            line2.AddGeometry(path2 as IGeometry, ref missing, ref missing);
            ((ITopologicalOperator)line2).Simplify();

            var topo = line1 as ITopologicalOperator;
            IGeometry geo1 = null;
            IGeometry geo2 = null;
            //var topo2 = line as IRelationalOperator;
            //bool contain = topo2.Contains(intersectline);
            geo1 = topo.Difference(line2 as IGeometry);
            var diffGeo = (geo1 as IGeometryCollection).get_Geometry(0) as ISegmentCollection;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

赵之章

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值