shp文件  平行线两端衔接构面

1、首先使用ArcToolBox中的near提取所有多段线的端点,保存成点文件

2、新建一个线文件,遍历上一步的点文件并生成“线段”插入到线文件中

3、代码如下(ArcEngine):

             //  定义变量
            ILine pLine null;
            ISegmentCollection pSegColl null;
            IPoint pStartPt null ;
            IPoint pEndPt null;
            ITransform2D pTransform;
            double dLength;
            double dAngle;
            double PI Math.PI;
            long ptCount; // 点图层要素总数

            // 获取点层
            IFeatureLayer ptLyr axMapControl1.Map.get_Layer(1) as IFeatureLayer;
            IFeatureClass ptFeatClass ptLyr.FeatureClass;
            ptCount ptFeatClass.FeatureCount(null);

            // 编辑线层
            IFeatureLayer axMapControl1.Map.get_Layer(0) as IFeatureLayer;
            IFeatureClass fc l.FeatureClass;
            IWorkspaceEdit (fc as IDataset).Workspace as IWorkspaceEdit;
            w.StartEditing(true);
            w.StartEditOperation();
            IPoint p;
            IFeatureBuffer featBuffer fc.CreateFeatureBuffer();
            IFeatureCursor cur fc.Insert(true);
  

            // 遍历点层
            IFeatureCursor ptFeatClassCursor ptFeatClass.Search(null,false);
            IFeature ptFeature ptFeatClassCursor.NextFeature();
            object ep System.Reflection.Missing.Value;
            while(ptFeature != null)
            {
                // 获取相应字段值
                dLength Convert.ToDouble(ptFeature.get_Value(6).ToString());
                dAngle Convert.ToDouble(ptFeature.get_Value(7).ToString());

                pStartPt (IPoint)ptFeature.ShapeCopy;
                pEndPt new PointClass();
                pEndPt.PutCoords(pStartPt.X dLength,pStartPt.Y);
                pLine new LineClass();
                pLine.PutCoords(pStartPt,pEndPt);
                ISegment pSegment pLine as ISegment;

                dAngle 1.0 dAngle PI 180;
                pSegColl new PolylineClass();
                pSegColl.AddSegment(pSegment,ref ep,ref ep);
                pTransform pSegColl as ITransform2D;
                pTransform.Rotate(pStartPt,dAngle);

                featBuffer.Shape pSegColl as IGeometry;
                cur.InsertFeature(featBuffer);

                ptFeature ptFeatClassCursor.NextFeature();
            }
            ptFeatClassCursor null;

            w.StopEditOperation();
            w.StopEditing(true);
        }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值