Beispiel #1
0
        /// <summary>
        /// 获取缓冲多边形
        /// </summary>
        /// <param name="distance">缓冲半径</param>
        /// <returns>缓冲多边形</returns>
        private IPolygon GetBufferPolygon(double distance)
        {
            IPolyline startLine = renderPolyline.GetFdeGeometry() as IPolyline;

            if (startLine == null)
            {
                return(null);
            }

            IPolyline drawSource = startLine.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPolyline;

            //如果是球面需投影到平面再做缓冲区计算
            if (currentCRS.CrsType == gviCoordinateReferenceSystemType.gviCrsGeographic)
            {
                drawSource.Project(projectCRS);
            }
            ITopologicalOperator2D drawBufferLine = drawSource as ITopologicalOperator2D;
            IPolygon bufferPolygon = drawBufferLine.Buffer2D(distance, gviBufferStyle.gviBufferCapbutt) as IPolygon;

            bufferPolygon.SpatialCRS = drawSource.SpatialCRS;
            if (currentCRS.CrsType == gviCoordinateReferenceSystemType.gviCrsGeographic)
            {
                bufferPolygon.Project(currentCRS);
            }

            polygon = bufferPolygon;
            IPolygon ppolygon = bufferPolygon.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPolygon;  //设置三维坐标

            //不被地面遮挡
            for (int j = 0; j < ppolygon.ExteriorRing.PointCount; j++)
            {
                IPoint p = ppolygon.ExteriorRing.GetPoint(j);
                p.Z = 1;
                ppolygon.ExteriorRing.UpdatePoint(j, p);
            }
            return(ppolygon);
        }
Beispiel #2
0
        private void OnFinishedDraw()
        {
            if (this._drawTool != null)
            {
                if (this.radioGroup1.SelectedIndex == 0)
                {
                    if (this._drawTool.GetSelectFeatureLayerPickResult() != null && this._drawTool.GetSelectPoint() != null)
                    {
                        IFeatureLayerPickResult pr = this._drawTool.GetSelectFeatureLayerPickResult();
                        string g       = pr.FeatureLayer.FeatureClassId.ToString();
                        string facName = Dictionary3DTable.Instance.GetFacilityClassNameByDFFeatureClassID(g);
                        if (facName != "PipeLine")
                        {
                            XtraMessageBox.Show("您选择的不是管线设施。", "提示");
                            return;
                        }
                        DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(g);
                        if (dffc == null)
                        {
                            return;
                        }
                        int        fid = pr.FeatureId;
                        MajorClass mc  = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(g);
                        if (mc == null)
                        {
                            return;
                        }
                        _num++;

                        IPoint             interPoint = this._drawTool.GetSelectPoint();
                        ISimplePointSymbol sps        = new SimplePointSymbol();
                        sps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                        sps.Size      = SystemInfo.Instance.SymbolSize;
                        IRenderPoint rp = d3.ObjectManager.CreateRenderPoint(interPoint, sps, d3.ProjectTree.RootID);
                        this._dict[_num] = rp.Guid;

                        ILabel label = d3.ObjectManager.CreateLabel(d3.ProjectTree.RootID);
                        IPoint pt    = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                        pt.SetCoords(interPoint.X, interPoint.Y, interPoint.Z + 1, 0, 0);
                        label.Position = pt;
                        label.Text     = _num.ToString();
                        TextSymbol    ts = new TextSymbol();
                        TextAttribute ta = new TextAttribute();
                        ta.TextColor          = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16);
                        ta.TextSize           = SystemInfo.Instance.TextSize;
                        ts.TextAttribute      = ta;
                        label.TextSymbol      = ts;
                        this._dictLabel[_num] = label.Guid;

                        DataRow dr = this._dt.NewRow();
                        dr["Num"]          = _num;
                        dr["PipeType"]     = mc;
                        dr["Fid"]          = fid;
                        dr["FeatureClass"] = dffc.GetFeatureClass();
                        dr["InterPoint"]   = interPoint;
                        this._dt.Rows.Add(dr);
                    }
                }
                if (this.radioGroup1.SelectedIndex == 1)
                {
                    if (this._drawTool.GetGeo() != null)
                    {
                        WaitForm.Start("正在进行相交查询...", "请稍后");
                        IPolyline line = this._drawTool.GetGeo() as IPolyline;
                        IPolyline l    = line.Clone2(gviVertexAttribute.gviVertexAttributeNone) as IPolyline;
                        List <DF3DFeatureClass> listdffc = DF3DFeatureClassManager.Instance.GetFeatureClassByFacilityClassName("PipeLine");
                        if (listdffc == null)
                        {
                            return;
                        }
                        foreach (DF3DFeatureClass dffc in listdffc)
                        {
                            IFeatureClass fc = dffc.GetFeatureClass();
                            if (fc == null)
                            {
                                continue;
                            }
                            MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fc.GuidString);
                            if (mc == null)
                            {
                                continue;
                            }
                            if (this._dt.Rows.Count > 0)
                            {
                                if (this._dt.Rows[0]["PipeType"] != null && this._dt.Rows[0]["PipeType"] is MajorClass)
                                {
                                    if (mc.Name != (this._dt.Rows[0]["PipeType"] as MajorClass).Name)
                                    {
                                        continue;
                                    }
                                }
                            }
                            ISpatialFilter filter = new SpatialFilter();
                            filter.Geometry      = l;
                            filter.GeometryField = "FootPrint";
                            filter.SpatialRel    = gviSpatialRel.gviSpatialRelIntersects;
                            int counttemp = fc.GetCount(filter);
                            if (counttemp == 0)
                            {
                                continue;
                            }
                            IFdeCursor cursor = null;
                            IRowBuffer row    = null;
                            try
                            {
                                IFieldInfoCollection fields = fc.GetFields();
                                cursor = fc.Search(filter, true);
                                while ((row = cursor.NextRow()) != null)
                                {
                                    IPolyline geo      = row.GetValue(fields.IndexOf("FootPrint")) as IPolyline;
                                    IPolyline geoShape = row.GetValue(fields.IndexOf("Shape")) as IPolyline;
                                    if (geo == null || geoShape == null || geo.GeometryType != gviGeometryType.gviGeometryPolyline || geoShape.GeometryType != gviGeometryType.gviGeometryPolyline)
                                    {
                                        continue;
                                    }
                                    if ((l as IRelationalOperator2D).Intersects2D(geo))
                                    {
                                        IPoint intersectPointTemp = (l as ITopologicalOperator2D).Intersection2D(geo) as IPoint;
                                        double height             = geoShape.StartPoint.Z + (geoShape.EndPoint.Z - geoShape.StartPoint.Z)
                                                                    * Math.Sqrt((geo.StartPoint.X - intersectPointTemp.X) * (geo.StartPoint.X - intersectPointTemp.X) + (geo.StartPoint.Y - intersectPointTemp.Y) * (geo.StartPoint.Y - intersectPointTemp.Y)) / geo.Length;
                                        IPoint intersectPoint = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                        intersectPoint.Z = height;
                                        intersectPoint.X = intersectPointTemp.X;
                                        intersectPoint.Y = intersectPointTemp.Y;
                                        int fid = int.Parse(row.GetValue(0).ToString());
                                        _num++;

                                        ISimplePointSymbol sps = new SimplePointSymbol();
                                        sps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                                        sps.Size      = SystemInfo.Instance.SymbolSize;
                                        IRenderPoint rp = d3.ObjectManager.CreateRenderPoint(intersectPoint, sps, d3.ProjectTree.RootID);
                                        this._dict[_num] = rp.Guid;

                                        ILabel label = d3.ObjectManager.CreateLabel(d3.ProjectTree.RootID);
                                        IPoint pt    = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                        pt.SetCoords(intersectPoint.X, intersectPoint.Y, intersectPoint.Z + 1, 0, 0);
                                        label.Position = pt;
                                        label.Text     = _num.ToString();
                                        TextSymbol    ts = new TextSymbol();
                                        TextAttribute ta = new TextAttribute();
                                        ta.TextColor          = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16);
                                        ta.TextSize           = SystemInfo.Instance.TextSize;
                                        ts.TextAttribute      = ta;
                                        label.TextSymbol      = ts;
                                        this._dictLabel[_num] = label.Guid;

                                        DataRow dr = this._dt.NewRow();
                                        dr["Num"]          = _num;
                                        dr["PipeType"]     = mc;
                                        dr["Fid"]          = fid;
                                        dr["FeatureClass"] = fc;
                                        dr["InterPoint"]   = intersectPoint;
                                        this._dt.Rows.Add(dr);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            finally
                            {
                                if (cursor != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                    cursor = null;
                                }
                                if (row != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                                    row = null;
                                }
                            }
                        }
                        WaitForm.Stop();
                    }
                }
            }
        }
Beispiel #3
0
 // Shap数据中含各顶点高程数据
 private bool GetPipeLineVertexs(IGeometry geo, double sHeight, double eHeight, out IPolyline route)
 {
     route = null;
     try
     {
         IPolyline polyline = null;
         if ((geo == null) || ((polyline = geo as IPolyline) == null))
         {
             return(false);
         }
         IPoint pointValue = null;
         route = DrawGeometry.geoFactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
         if (polyline.PointCount == 2)
         {
             pointValue   = polyline.StartPoint.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint;
             pointValue.Z = sHeight;
             route.AppendPoint(pointValue);
             pointValue   = polyline.EndPoint.Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint;
             pointValue.Z = eHeight;
             route.AppendPoint(pointValue);
         }
         else
         {
             IPoint      point;
             Stack <int> stack = new Stack <int>();
             double      num4  = eHeight - sHeight;
             if (Math.Abs(num4) < 0.0015)
             {
                 point = null;
                 for (int i = 0; i < polyline.PointCount; i++)
                 {
                     pointValue = polyline.GetPoint(i).Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                     if (i < 1)
                     {
                         pointValue.Z = sHeight;
                         route.AppendPoint(pointValue);
                         point = pointValue;
                     }
                     else if (Math.Sqrt(((pointValue.X - point.X) * (pointValue.X - point.X)) + ((pointValue.Y - point.Y) * (pointValue.Y - point.Y))) < (this._dia1 * 1.5))
                     {
                         stack.Push(i);
                     }
                     else
                     {
                         pointValue.Z = sHeight;
                         route.AppendPoint(pointValue);
                         point = pointValue;
                     }
                 }
             }
             else
             {
                 double    num3   = sHeight;
                 IPolyline o      = polyline.Clone2(gviVertexAttribute.gviVertexAttributeNone) as IPolyline;
                 double    length = o.Length;
                 Marshal.ReleaseComObject(o);
                 point = null;
                 for (int j = 0; j < polyline.PointCount; j++)
                 {
                     pointValue = polyline.GetPoint(j).Clone2(gviVertexAttribute.gviVertexAttributeZ) as IPoint;
                     if (j < 1)
                     {
                         pointValue.Z = sHeight;
                         route.AppendPoint(pointValue);
                         point = pointValue;
                     }
                     else
                     {
                         double num2;
                         if ((num2 = Math.Sqrt(((pointValue.X - point.X) * (pointValue.X - point.X)) + ((pointValue.Y - point.Y) * (pointValue.Y - point.Y)))) < (this._dia1 * 1.5))
                         {
                             stack.Push(j);
                         }
                         else
                         {
                             num3        += (num2 / length) * num4;
                             pointValue.Z = num3;
                             route.AppendPoint(pointValue);
                             point = pointValue;
                         }
                     }
                 }
             }
             while (stack.Count > 0)
             {
                 polyline.RemovePoints(stack.Pop(), 1);
             }
         }
         return(true);
     }
     catch (Exception exception)
     {
         return(false);
     }
 }
Beispiel #4
0
        private void AddRecord()
        {
            try
            {
                this.beforeRowBufferMap.Clear();
                SelectCollection.Instance().Clear();
                if (reg == null || tc == null)
                {
                    return;
                }
                FacStyleClass style = this.cmbStyle.EditValue as FacStyleClass;
                if (style == null)
                {
                    return;
                }
                SubClass sc = this.cmbClassify.EditValue as SubClass;

                DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer;
                if (featureClassInfo == null)
                {
                    return;
                }
                IFeatureClass fc = featureClassInfo.GetFeatureClass();
                if (fc == null)
                {
                    return;
                }
                IResourceManager manager = fc.FeatureDataSet as IResourceManager;
                if (manager == null)
                {
                    return;
                }
                IFeatureLayer fl = featureClassInfo.GetFeatureLayer();
                if (fl == null)
                {
                    return;
                }
                IFieldInfoCollection fields = fc.GetFields();
                int indexOid = fields.IndexOf(fc.FidFieldName);
                if (indexOid == -1)
                {
                    return;
                }
                int mpindex = fields.IndexOf(fl.GeometryFieldName);
                if (mpindex == -1)
                {
                    return;
                }
                int indexShape = fields.IndexOf("Shape");
                if (indexShape == -1)
                {
                    return;
                }
                int indexFootPrint = fields.IndexOf("FootPrint");
                if (indexFootPrint == -1)
                {
                    return;
                }
                int indexStyleId = fields.IndexOf("StyleId");
                if (indexStyleId == -1)
                {
                    return;
                }
                int indexFacilityId = fields.IndexOf("FacilityId");
                if (indexFacilityId == -1)
                {
                    return;
                }

                IFieldInfo fiShape = fields.Get(indexShape);
                if (fiShape == null || fiShape.GeometryDef == null)
                {
                    return;
                }

                IGeometry geo = this._drawTool.GetGeo();
                if (geo.GeometryType != gviGeometryType.gviGeometryPolyline)
                {
                    return;
                }
                IPolyline line   = geo as IPolyline;
                IPolyline geoOut = this._geoFact.CreateGeometry(gviGeometryType.gviGeometryPolyline, fiShape.GeometryDef.VertexAttribute) as IPolyline;
                for (int i = 0; i < line.PointCount; i++)
                {
                    IPoint ptGet  = line.GetPoint(i);
                    IPoint pttemp = ptGet.Clone2(fiShape.GeometryDef.VertexAttribute) as IPoint;
                    if (fiShape.GeometryDef.HasZ)
                    {
                        pttemp.SetCoords(ptGet.X, ptGet.Y, ptGet.Z, 0, 0);
                    }
                    else
                    {
                        pttemp.SetCoords(ptGet.X, ptGet.Y, 0, 0, 0);
                    }
                    geoOut.AppendPoint(pttemp);
                }

                IQueryFilter filter = new QueryFilter();
                filter.WhereClause      = "1=1";
                filter.ResultBeginIndex = 0;
                filter.ResultLimit      = 1;
                filter.PostfixClause    = "ORDER BY " + fc.FidFieldName + " desc";
                IFdeCursor cursor = null;
                cursor = fc.Search(filter, false);
                IRowBuffer rowtemp = cursor.NextRow();
                int        oid     = 0;
                if (rowtemp != null)
                {
                    oid = int.Parse(rowtemp.GetValue(indexOid).ToString());
                }
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }

                IRowBufferFactory fac = new RowBufferFactory();
                IRowBuffer        row = fac.CreateRowBuffer(fields);
                row.SetValue(indexOid, oid + 1);
                row.SetValue(indexShape, geoOut);
                row.SetValue(indexFootPrint, geoOut.Clone2(gviVertexAttribute.gviVertexAttributeNone));
                row.SetValue(indexStyleId, style.ObjectId);
                row.SetValue(indexFacilityId, BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant());
                if (sc != null)
                {
                    int indexClassify = fields.IndexOf(this._classifyName);
                    int indexGroupId  = fields.IndexOf("GroupId");
                    if (indexClassify != -1 && indexGroupId != -1)
                    {
                        row.SetValue(indexClassify, sc.Name);
                        row.SetValue(indexGroupId, sc.GroupId);
                    }
                }
                foreach (DataRow dr in this._dt.Rows)
                {
                    IFieldInfo fi = dr["F"] as IFieldInfo;
                    if (fi == null)
                    {
                        continue;
                    }
                    string fn    = fi.Name;
                    int    index = fields.IndexOf(fn);
                    if (index != -1)
                    {
                        if (dr["FV"] == null)
                        {
                            row.SetNull(index);
                        }
                        else
                        {
                            string strobj = dr["FV"].ToString();
                            bool   bRes   = false;
                            switch (fi.FieldType)
                            {
                            case gviFieldType.gviFieldBlob:
                            case gviFieldType.gviFieldGeometry:
                            case gviFieldType.gviFieldUnknown:
                                break;

                            case gviFieldType.gviFieldFloat:
                                float f;
                                bRes = float.TryParse(strobj, out f);
                                if (bRes)
                                {
                                    row.SetValue(index, f);
                                }
                                else
                                {
                                    row.SetNull(index);
                                }
                                break;

                            case gviFieldType.gviFieldDouble:
                                double d;
                                bRes = double.TryParse(strobj, out d);
                                if (bRes)
                                {
                                    row.SetValue(index, d);
                                }
                                else
                                {
                                    row.SetNull(index);
                                }
                                break;

                            case gviFieldType.gviFieldFID:
                            case gviFieldType.gviFieldUUID:
                            case gviFieldType.gviFieldInt16:
                                Int16 i16;
                                bRes = Int16.TryParse(strobj, out i16);
                                if (bRes)
                                {
                                    row.SetValue(index, i16);
                                }
                                else
                                {
                                    row.SetNull(index);
                                }
                                break;

                            case gviFieldType.gviFieldInt32:
                                Int32 i32;
                                bRes = Int32.TryParse(strobj, out i32);
                                if (bRes)
                                {
                                    row.SetValue(index, i32);
                                }
                                else
                                {
                                    row.SetNull(index);
                                }
                                break;

                            case gviFieldType.gviFieldInt64:
                                Int64 i64;
                                bRes = Int64.TryParse(strobj, out i64);
                                if (bRes)
                                {
                                    row.SetValue(index, i64);
                                }
                                else
                                {
                                    row.SetNull(index);
                                }
                                break;

                            case gviFieldType.gviFieldString:
                                row.SetValue(index, strobj);
                                break;

                            case gviFieldType.gviFieldDate:
                                DateTime dt;
                                bRes = DateTime.TryParse(strobj, out dt);
                                if (bRes)
                                {
                                    row.SetValue(index, dt);
                                }
                                else
                                {
                                    row.SetNull(index);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }

                Fac plf = new PipeLineFac(reg, style, row, tc, false, false);

                IModelPoint mp          = null;
                IModel      finemodel   = null;
                IModel      simplemodel = null;
                string      name        = "";
                if (UCAuto3DCreate.RebuildModel(plf, style, out mp, out finemodel, out simplemodel, out name))
                {
                    if (finemodel == null || mp == null)
                    {
                        return;
                    }
                    mp.ModelEnvelope = finemodel.Envelope;
                    row.SetValue(mpindex, mp);
                    //if (mc != null)
                    //{
                    //    if (indexClassify != -1 && indexGroupid != -1)
                    //    {

                    //    }
                    //}
                    bool bRes = false;
                    if (!string.IsNullOrEmpty(mp.ModelName))
                    {
                        if (!manager.ModelExist(mp.ModelName))
                        {
                            if (manager.AddModel(mp.ModelName, finemodel, simplemodel))
                            {
                                bRes = true;
                            }
                        }
                        else
                        {
                            if (manager.UpdateModel(mp.ModelName, finemodel) && manager.UpdateSimplifiedModel(mp.ModelName, simplemodel))
                            {
                                bRes = true;
                            }
                        }
                    }
                    if (!bRes)
                    {
                        return;
                    }
                    IRowBufferCollection rowCol = new RowBufferCollection();
                    rowCol.Add(row);
                    beforeRowBufferMap[featureClassInfo] = rowCol;
                    UpdateDatabase();
                    app.Current3DMapControl.FeatureManager.RefreshFeatureClass(fc);
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #5
0
        private void LineQuery()
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IGeometry geo = this._drawTool.GetGeo();
                if (geo == null || geo.GeometryType != gviGeometryType.gviGeometryPolyline)
                {
                    return;
                }
                IPolyline line = geo as IPolyline;
                IPolyline l    = line.Clone2(gviVertexAttribute.gviVertexAttributeNone) as IPolyline;
                if (l.Length > 500)
                {
                    XtraMessageBox.Show("横断面线超过500米,分析效率很低,请重新绘制", "提示");
                    return;
                }
                WaitForm.Start("正在进行横断面分析...", "请稍后");
                DF3DApplication app = DF3DApplication.Application;
                if (app == null || app.Current3DMapControl == null)
                {
                    return;
                }

                List <MajorClass> list = LogicDataStructureManage3D.Instance.GetAllMajorClass();
                if (list == null)
                {
                    return;
                }
                string        road1   = "";
                string        road2   = "";
                bool          bAlert  = false;
                double        hmax    = double.MinValue;
                double        hmin    = double.MaxValue;
                List <PPLine> pplines = new List <PPLine>();
                foreach (MajorClass mc in list)
                {
                    foreach (SubClass sc in mc.SubClasses)
                    {
                        if (!sc.Visible3D)
                        {
                            continue;
                        }
                        string[] arrFc3DId = mc.Fc3D.Split(';');
                        if (arrFc3DId == null)
                        {
                            continue;
                        }
                        foreach (string fc3DId in arrFc3DId)
                        {
                            DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            IFeatureClass fc  = dffc.GetFeatureClass();
                            FacilityClass fac = dffc.GetFacilityClass();
                            if (fc == null || fac == null || fac.Name != "PipeLine")
                            {
                                continue;
                            }

                            IFieldInfoCollection fields = fc.GetFields();
                            int indexShape = fields.IndexOf("Shape");
                            if (indexShape == -1)
                            {
                                continue;
                            }
                            int indexFootPrint = fields.IndexOf("FootPrint");
                            if (indexFootPrint == -1)
                            {
                                continue;
                            }
                            DFDataConfig.Class.FieldInfo fiDiameter = fac.GetFieldInfoBySystemName("Diameter");
                            if (fiDiameter == null)
                            {
                                continue;
                            }
                            int indexDiameter = fields.IndexOf(fiDiameter.Name);
                            if (indexDiameter == -1)
                            {
                                continue;
                            }
                            DFDataConfig.Class.FieldInfo fiRoad = fac.GetFieldInfoBySystemName("Road");
                            int indexRoad = -1;
                            if (fiRoad != null)
                            {
                                indexRoad = fields.IndexOf(fiRoad.Name);
                            }
                            DFDataConfig.Class.FieldInfo fiHLB = fac.GetFieldInfoBySystemName("HLB");
                            int indexHLB = -1;
                            if (fiHLB != null)
                            {
                                indexHLB = fields.IndexOf(fiHLB.Name);
                            }
                            int indexClassify = fields.IndexOf(mc.ClassifyField);

                            ISpatialFilter pSpatialFilter = new SpatialFilter();
                            pSpatialFilter.Geometry      = l;
                            pSpatialFilter.GeometryField = "FootPrint";
                            pSpatialFilter.SpatialRel    = gviSpatialRel.gviSpatialRelIntersects;
                            pSpatialFilter.WhereClause   = mc.ClassifyField + " = '" + sc.Name + "'";

                            cursor = fc.Search(pSpatialFilter, false);
                            while ((row = cursor.NextRow()) != null)
                            {
                                if (indexRoad != -1 && !row.IsNull(indexRoad))
                                {
                                    if (road2 == "")
                                    {
                                        road1 = row.GetValue(indexRoad).ToString();
                                        road2 = row.GetValue(indexRoad).ToString();
                                    }
                                    else
                                    {
                                        road1 = row.GetValue(indexRoad).ToString();
                                        if (road1 != road2)
                                        {
                                            if (!bAlert)
                                            {
                                                XtraMessageBox.Show("横断面线跨越多条道路,当前只绘制在【" + road2 + "】上的管线横断面图。", "提示");
                                                bAlert = true;
                                            }
                                            continue;
                                        }
                                    }
                                }


                                double startSurfHeight = double.MaxValue;
                                double endSurfHeight   = double.MaxValue;
                                if (!app.Current3DMapControl.Terrain.IsRegistered)
                                {
                                    DFDataConfig.Class.FieldInfo fiStartSurfHeight = fac.GetFieldInfoBySystemName("StartSurfHeight");
                                    if (fiStartSurfHeight == null)
                                    {
                                        continue;
                                    }
                                    int indexStartSurfHeight = fields.IndexOf(fiStartSurfHeight.Name);
                                    if (indexStartSurfHeight == -1)
                                    {
                                        continue;
                                    }
                                    DFDataConfig.Class.FieldInfo fiEndSurfHeight = fac.GetFieldInfoBySystemName("EndSurfHeight");
                                    if (fiEndSurfHeight == null)
                                    {
                                        continue;
                                    }
                                    int indexEndSurfHeight = fields.IndexOf(fiEndSurfHeight.Name);
                                    if (indexEndSurfHeight == -1)
                                    {
                                        continue;
                                    }
                                    if (!row.IsNull(indexStartSurfHeight))
                                    {
                                        startSurfHeight = double.Parse(row.GetValue(indexStartSurfHeight).ToString());
                                    }
                                    if (!row.IsNull(indexEndSurfHeight))
                                    {
                                        endSurfHeight = double.Parse(row.GetValue(indexEndSurfHeight).ToString());
                                    }
                                }
                                if (!row.IsNull(indexShape) && !row.IsNull(indexFootPrint))
                                {
                                    object objFootPrint = row.GetValue(indexFootPrint);
                                    object objShape     = row.GetValue(indexShape);
                                    if (objFootPrint is IPolyline && objShape is IPolyline)
                                    {
                                        IPolyline polylineFootPrint = objFootPrint as IPolyline;
                                        IPolyline polylineShape     = objShape as IPolyline;
                                        IGeometry geoIntersect      = (geo as ITopologicalOperator2D).Intersection2D(polylineFootPrint);
                                        if (geoIntersect == null)
                                        {
                                            continue;
                                        }
                                        PPLine ppline = new PPLine();
                                        if (indexClassify == -1 || row.IsNull(indexClassify))
                                        {
                                            ppline.facType = mc.Name;
                                        }
                                        else
                                        {
                                            ppline.facType = row.GetValue(indexClassify).ToString();
                                        }
                                        if (!row.IsNull(indexDiameter))
                                        {
                                            string diameter = row.GetValue(indexDiameter).ToString();
                                            if (diameter.Trim() == "")
                                            {
                                                continue;
                                            }
                                            ppline.dia = diameter;
                                            int indexDia = diameter.IndexOf('*');
                                            if (indexDia != -1)
                                            {
                                                ppline.isrect = true;
                                                int  iDia1;
                                                bool bDia1 = int.TryParse(diameter.Substring(0, indexDia), out iDia1);
                                                if (!bDia1)
                                                {
                                                    continue;
                                                }
                                                int  iDia2;
                                                bool bDia2 = int.TryParse(diameter.Substring(indexDia + 1, diameter.Length - indexDia - 1), out iDia2);
                                                if (!bDia2)
                                                {
                                                    continue;
                                                }
                                                ppline.gj.Add(iDia1);
                                                ppline.gj.Add(iDia2);
                                            }
                                            else
                                            {
                                                ppline.isrect = false;
                                                int  iDia;
                                                bool bDia = int.TryParse(diameter, out iDia);
                                                if (!bDia)
                                                {
                                                    continue;
                                                }
                                                ppline.gj.Add(iDia);
                                                ppline.gj.Add(iDia);
                                            }
                                        }
                                        int hlb = 0;
                                        if (indexHLB != -1 && !row.IsNull(indexHLB))
                                        {
                                            string strhlb = row.GetValue(indexHLB).ToString();
                                            if (strhlb.Contains("内"))
                                            {
                                                hlb = 1;
                                            }
                                            else if (strhlb.Contains("外"))
                                            {
                                                hlb = -1;
                                            }
                                            else
                                            {
                                                hlb = 0;
                                            }
                                            ppline.hlb = hlb;
                                        }
                                        #region  交点为一个
                                        if (geoIntersect.GeometryType == gviGeometryType.gviGeometryPoint) //交点为1个
                                        {
                                            IPoint ptIntersect = geoIntersect as IPoint;
                                            ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y, ptIntersect.Z);
                                            ppline.clh        = GetInterPointHeight(ptIntersect, polylineShape, polylineFootPrint);
                                            if (ppline.clh > hmax)
                                            {
                                                hmax = ppline.clh;
                                            }
                                            if (ppline.clh < hmin)
                                            {
                                                hmin = ppline.clh;
                                            }

                                            if (app.Current3DMapControl.Terrain.IsRegistered)
                                            {
                                                ppline.cgh = app.Current3DMapControl.Terrain.GetElevation(ptIntersect.X, ptIntersect.Y, Gvitech.CityMaker.RenderControl.gviGetElevationType.gviGetElevationFromDatabase);
                                            }
                                            else
                                            {
                                                ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight)
                                                             * Math.Sqrt((polylineFootPrint.StartPoint.X - ptIntersect.X) * (polylineFootPrint.StartPoint.X - ptIntersect.X)
                                                                         + (polylineFootPrint.StartPoint.Y - ptIntersect.Y) * (polylineFootPrint.StartPoint.Y - ptIntersect.Y)) / polylineFootPrint.Length;
                                            }
                                            if (ppline.cgh > hmax)
                                            {
                                                hmax = ppline.cgh;
                                            }
                                            if (ppline.cgh < hmin)
                                            {
                                                hmin = ppline.cgh;
                                            }
                                            // 辅助画图
                                            ppline.startPt = new PPPoint(l.StartPoint.X, l.StartPoint.Y, l.StartPoint.Z);
                                            pplines.Add(ppline);
                                        }
                                        #endregion

                                        #region 交点为多个
                                        else if (geoIntersect.GeometryType == gviGeometryType.gviGeometryMultiPoint) //交点为多个
                                        {
                                            IMultiPoint multiPts = geoIntersect as IMultiPoint;
                                            for (int m = 0; m < multiPts.GeometryCount; m++)
                                            {
                                                IPoint ptIntersect = multiPts.GetPoint(m);
                                                ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y, ptIntersect.Z);
                                                ppline.clh        = GetInterPointHeight(ptIntersect, polylineShape, polylineFootPrint);
                                                if (ppline.clh > hmax)
                                                {
                                                    hmax = ppline.clh;
                                                }
                                                if (ppline.clh < hmin)
                                                {
                                                    hmin = ppline.clh;
                                                }

                                                if (app.Current3DMapControl.Terrain.IsRegistered)
                                                {
                                                    ppline.cgh = app.Current3DMapControl.Terrain.GetElevation(ptIntersect.X, ptIntersect.Y, Gvitech.CityMaker.RenderControl.gviGetElevationType.gviGetElevationFromDatabase);
                                                }
                                                else
                                                {
                                                    ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight)
                                                                 * Math.Sqrt((polylineFootPrint.StartPoint.X - ptIntersect.X) * (polylineFootPrint.StartPoint.X - ptIntersect.X)
                                                                             + (polylineFootPrint.StartPoint.Y - ptIntersect.Y) * (polylineFootPrint.StartPoint.Y - ptIntersect.Y)) / polylineFootPrint.Length;
                                                }
                                                if (ppline.cgh > hmax)
                                                {
                                                    hmax = ppline.cgh;
                                                }
                                                if (ppline.cgh < hmin)
                                                {
                                                    hmin = ppline.cgh;
                                                }

                                                // 辅助画图
                                                ppline.startPt = new PPPoint(l.StartPoint.X, l.StartPoint.Y, l.StartPoint.Z);
                                                pplines.Add(ppline);
                                            }
                                        }
                                        #endregion

                                        else
                                        {
                                            continue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                WaitForm.Stop();
                if (pplines.Count < 2)
                {
                    XtraMessageBox.Show("相交管线少于2个", "提示");
                    return;
                }
                pplines.Sort(new PPLineCompare());
                double spacesum = 0.0;
                for (int i = 1; i < pplines.Count; i++)
                {
                    PPLine line1 = pplines[i - 1];
                    PPLine line2 = pplines[i];
                    line2.space = Math.Sqrt((line1.interPoint.X - line2.interPoint.X) * (line1.interPoint.X - line2.interPoint.X)
                                            + (line1.interPoint.Y - line2.interPoint.Y) * (line1.interPoint.Y - line2.interPoint.Y));
                    spacesum += line2.space;
                }
                ;
                var                str1    = (pplines[0].interPoint.X / 1000).ToString("0.00");
                var                str2    = (pplines[0].interPoint.Y / 1000).ToString("0.00");
                string             mapNum  = str2 + "-" + str1;
                string             mapName = SystemInfo.Instance.SystemFullName + "横断面图";
                FrmSectionAnalysis dialog  = new FrmSectionAnalysis("横断面分析结果", 0);
                dialog.SetInfo(mapName, mapNum, pplines, hmax, hmin, spacesum, road2);
                dialog.Show();
            }
            catch (Exception ex)
            {
                WaitForm.Stop();
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }