Exemplo n.º 1
0
        private void DoAnalysis()
        {
            IFeature             pFeature;
            IGeometry            pGeo;
            IGeometry            pPipeLineGeo;
            IFeatureClass        pFeatureClass;
            IFeatureCursor       pFeaCur;
            ITopologicalOperator pTopo;
            string scName = "";
            int    i      = 0;

            foreach (MajorClass mc in LogicDataStructureManage.Instance.GetAllMajorClass())
            {
                string[] arrFc2DId = mc.Fc2D.Split(';');//将二级大类所对应的要素类ID转换为数组
                if (arrFc2DId == null)
                {
                    continue;
                }

                foreach (SubClass sc in mc.SubClasses)
                {
                    if (!sc.Visible2D)
                    {
                        continue;
                    }
                    foreach (string fc2DId in arrFc2DId)                                                      //遍历二级子类所对应的要素类ID
                    {
                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC
                        if (dffc == null)
                        {
                            continue;
                        }
                        FacilityClass fcc = dffc.GetFacilityClass();
                        if (fcc.Name != "PipeLine")
                        {
                            continue;
                        }
                        IFeatureLayer fl = dffc.GetFeatureLayer();

                        ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                        pSpatialFilter.Geometry    = m_pGeoTrack;
                        pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                        pSpatialFilter.WhereClause = "SMSCODE =  '" + sc.Name + "'";
                        IFeatureClass fc = dffc.GetFeatureClass();
                        pFeaCur = fc.Search(pSpatialFilter, false);

                        while ((pFeature = pFeaCur.NextFeature()) != null)
                        {
                            DrawPipeInfo(fl, pFeature, i);
                            ++i;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void ReadFieldInfo()
        {
            List <DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode");

            if (list == null)
            {
                return;
            }
            dfcc = list[0];
            IFeatureClass fc = dfcc.GetFeatureClass();

            if (fc == null)
            {
                return;
            }
            FacilityClass fcc = dfcc.GetFacilityClass();
            List <DFDataConfig.Class.FieldInfo> m_list = fcc.FieldInfoCollection;

            foreach (DFDataConfig.Class.FieldInfo Field in m_list)
            {
                if (Field.NeedCheck)
                {
                    FieldName = Field.Name + "," + Field.Alias;
                    m_arrPntField.Add(FieldName);
                }
                else
                {
                    continue;
                }
            }
            List <DF2DFeatureClass> nist = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine");

            if (nist == null)
            {
                return;
            }

            dfcc = nist[0];
            fcc  = dfcc.GetFacilityClass();

            List <DFDataConfig.Class.FieldInfo> n_list = fcc.FieldInfoCollection;

            foreach (DFDataConfig.Class.FieldInfo Field in n_list)
            {
                if (Field.NeedCheck)
                {
                    FieldName = Field.Name + "," + Field.Alias;
                    m_arrArcField.Add(FieldName);
                }
                else
                {
                    continue;
                }
            }
        }
Exemplo n.º 3
0
        public Dictionary <string, string> GetAllPipeLines()
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            try
            {
                foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass()) //对所有二级大类进行遍历
                {
                    string[] arrFc2DId = mc.Fc2D.Split(';');                                      //将二级大类所对应的要素类ID转换为数组
                    if (arrFc2DId == null)
                    {
                        continue;
                    }
                    List <IFeature> lines = new List <IFeature>();
                    bool            bHave = false;
                    foreach (SubClass sc in mc.SubClasses)//对当前二级大类的子类进行遍历
                    {
                        if (!sc.Visible2D)
                        {
                            continue;
                        }
                        foreach (string fc2DId in arrFc2DId)                                                      //遍历二级子类所对应的要素类ID
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC
                            if (dffc == null)
                            {
                                continue;
                            }
                            FacilityClass facc = dffc.GetFacilityClass(); //得到设施类
                            IFeatureClass fc   = dffc.GetFeatureClass();  //得到要素类
                            if (fc == null || facc == null || facc.Name != "PipeLine")
                            {
                                continue;
                            }
                            IQueryFilter filter = new QueryFilter();
                            //filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc).Substring(0, UpOrDown.DecorateWhereClasuse(fc).Length - 4);
                            int count = fc.FeatureCount(filter);
                            bHave          = true;
                            dict[mc.Alias] = count.ToString();
                            break;
                        }
                        if (bHave)
                        {
                            break;
                        }
                    }
                }
                return(dict);
            }
            catch (System.Exception ex)
            {
                return(null);
            }
        }
        private IFeatureClass GetGCD()
        {
            //string path = Config.GetConfigValue("2DMdbPipe");
            //IWorkspaceFactory pWsF = new AccessWorkspaceFactory();
            //IFeatureWorkspace pFWs = pWsF.OpenFromFile(path, 0) as IFeatureWorkspace;
            //IFeatureClass pFc = pFWs.OpenFeatureClass("GCD");
            //return pFc;
            FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("GCD");

            string[] arrayFc2D = fac.Fc2D.Split(';');
            foreach (string fcID in arrayFc2D)
            {
                DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fcID);
                if (dffc == null)
                {
                    continue;
                }
                IFeatureClass fc = dffc.GetFeatureClass();
                return(fc);
            }
            return(null);
        }
 private IFeatureClass GetOnlyFcByFacilityClass(FacilityClass fac)
 {
     string[] arrayFc2D = fac.Fc2D.Split(';');
     if (arrayFc2D == null)
     {
         return(null);
     }
     foreach (string fc2d in arrayFc2D)
     {
         DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2d);
         if (dffc == null)
         {
             continue;
         }
         IFeatureClass fc = dffc.GetFeatureClass();
         if (fc == null)
         {
             return(null);
         }
         return(fc);
     }
     return(null);
 }
        private void treeLayer_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
        {
            this.cbProperty.Properties.Items.Clear();
            this.selectFeatureClass.Clear();
            try
            {
                List <string>       list          = new List <string>();
                List <TreeListNode> treeListNodes = this.treeLayer.GetAllCheckedNodes();
                foreach (TreeListNode node in treeListNodes)
                {
                    object obj = node.GetValue("NodeObject");
                    if (obj is DF2DFeatureClass)
                    {
                        DF2DFeatureClass dffc = obj as DF2DFeatureClass;
                        IFeatureClass    fc   = dffc.GetFeatureClass();

                        selectFeatureClass.Add(dffc);
                        FacilityClass fac = dffc.GetFacilityClass();

                        if (fc == null || dffc == null)
                        {
                            continue;
                        }
                        IFields fiCol = fc.Fields;
                        if (aliaNameAndName.Count > 0)
                        {
                            for (int i = 0; i < fiCol.FieldCount; i++)
                            {
                                string str  = fiCol.get_Field(i).AliasName;
                                string str2 = fiCol.get_Field(i).Name;
                                //aliaNameAndName.Add(str, str2);
                                FieldInfo fi = fac.GetFieldInfoByName(str2);
                                if (fi == null)
                                {
                                    continue;
                                }
                                else if (fi.CanQuery)
                                {
                                    list.Add(str);
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < fiCol.FieldCount; i++)
                            {
                                string str  = fiCol.get_Field(i).AliasName;
                                string str2 = fiCol.get_Field(i).Name;
                                aliaNameAndName.Add(str, str2);
                                FieldInfo fi = fac.GetFieldInfoByName(str2);
                                if (fi == null)
                                {
                                    continue;
                                }
                                else if (fi.CanQuery)
                                {
                                    list.Add(str);
                                }
                            }
                        }
                    }
                }
                if (list.Count > 0)
                {
                    foreach (string str2 in from v in list.Distinct <string>() orderby v select v)
                    {
                        if (!string.IsNullOrEmpty(str2))
                        {
                            this.cbProperty.Properties.Items.Add(str2);
                        }
                    }
                }
            }


            catch (System.Exception ex)
            {
            }
            //try
            //{
            //    List<string> list = new List<string>();
            //    foreach (TreeListNode node in this.treeLayer.GetAllCheckedNodes())
            //    {
            //        object obj = node.GetValue("NodeObject");
            //        if (obj is DF2DFeatureClass)
            //        {
            //            DF2DFeatureClass dffc = obj as DF2DFeatureClass;
            //            IFeatureClass fc = dffc.GetFeatureClass();
            //            FacilityClass fac = dffc.GetFacilityClass();
            //            if (fc == null || fac == null) continue;
            //            DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName();

            //            IFields fiCol = fc.Fields;
            //            int index = fiCol.FindField(fi.Name);
            //            if (index < 0) continue;
            //            IField pField = fiCol.get_Field(index);
            //            IQueryFilter filter = new QueryFilterClass();
            //            filter.SubFields = pField.Name;

            //            IFeatureCursor ftCursor = fc.Search(filter, true);
            //            IFeature pfeature = ftCursor.NextFeature();

            //            while (pfeature != null)
            //            {
            //                string temp = pfeature.get_Value(index).ToString();
            //                if (temp != null) list.Add(temp);
            //                pfeature = ftCursor.NextFeature();
            //            }


            //        }

            //    }


            //}
            //catch (System.Exception ex)
            //{

            //}
        }
Exemplo n.º 7
0
        /*private DataTable DoCrossAnalysis(Dictionary<string, List<IFeature>> dict,int crossType)
         * {
         *  if (dict.Count <= 0) return null;
         *  //dicCross = new Dictionary<string,string>();
         *  hsCross = new HashSet<string>();
         *  DataTable dt = new DataTable();
         *  dt.Columns.Add(new DataColumn("图层"));
         *  foreach (string s in dict.Keys)
         *  {
         *      dt.Columns.Add(new DataColumn(s));
         *  }
         *  try
         *  {
         *      foreach (MajorClass mca in LogicDataStructureManage2D.Instance.GetAllMajorClass())
         *      {
         *          if (!dict.ContainsKey(mca.Alias)) continue;
         *          List<IFeature> linesA = dict[mca.Alias];
         *          DataRow dr = dt.NewRow();
         *          dr["图层"] = mca.Alias;
         *          foreach (MajorClass mcb in LogicDataStructureManage2D.Instance.GetAllMajorClass())
         *          {
         *              if (!dict.ContainsKey(mcb.Alias)) continue;
         *              List<IFeature> linesB = dict[mcb.Alias];
         *              int count = 0;
         *
         *              //if (linesB == linesA) continue;
         *
         *              int n = 0;
         *              foreach (IFeature la in linesA)
         *              {
         *                  count++;
         *                  WaitForm.SetCaption("正在分析【" + mca.Alias + "】与【" + mcb.Alias + "】," + count + "/" + linesA.Count);
         *                  int dA = GetDiameter(la, this._diameter);
         *                  IPolyline lineA = la.Shape as IPolyline;
         *                  foreach (IFeature lb in linesB)
         *                  {
         *                      if (la == lb) continue;
         *                      int dB = GetDiameter(lb, this._diameter);
         *                      IPolyline lineB = lb.Shape as IPolyline;
         *                      //ITopologicalOperator topo = lineA as ITopologicalOperator;
         *                      ITopologicalOperator topo = lineA as ITopologicalOperator;
         *                      topo.Simplify();
         *                      IGeometry geo = topo.Intersect(lineB, esriGeometryDimension.esriGeometry0Dimension);
         *                      if (geo.IsEmpty) continue;
         *                      IPointCollection pc = geo as IPointCollection;
         *                      IPoint point = pc.get_Point(0);
         *                      //if (point == lineA.FromPoint || point == lineA.ToPoint || point == lineB.FromPoint || point == lineB.ToPoint)
         *                      if(IsPointSame(point,lineA.FromPoint)||IsPointSame(point,lineA.ToPoint)||IsPointSame(point,lineB.FromPoint)||IsPointSame(point,lineB.ToPoint))
         *                          continue;
         *                      double disA = double.MaxValue;
         *                      double zA = double.MaxValue;
         *                      GetDistanceAndZ(lineA, point, out disA, out zA);
         *                      double disB = double.MaxValue;
         *                      double zB = double.MaxValue;
         *                      GetDistanceAndZ(lineB, point, out disB, out zB);
         *                      double l = Double.MaxValue;
         *                      if (crossType == 0)
         *                      {
         *                          l = Convert.ToDouble((dA + dB) / 2000);
         *                      }
         *                      else
         *                      {
         *                          if (dictVertical.ContainsKey(mca.Name + "_" + mcb.Name))
         *
         *
         *                              l = (((double)dA +(double) dB) / 2000) + dictVertical[mca.Name + "_" + mcb.Name];
         *                      }
         *                      if (l == Double.MaxValue) continue;
         *                      if (System.Math.Abs(zA - zB) > l) continue;
         *                      else
         *                      {
         *                          string idA = mca.Name + "_" + la.OID;
         *                          string idB = mcb.Name + "_" + lb.OID;
         *                          hsCross.Add(idA + "," + idB);
         *                          n++;
         *                          //if (dicCross.ContainsValue(idA) && dicCross.ContainsKey(idB))
         *                          //{
         *                          //    if (dicCross[idB] == idA) continue;
         *
         *                          //}
         *                          //else
         *                          //{
         *                          //    if (dicCross.ContainsKey(idA)) continue;
         *                          //    dicCross[idA] = idB;
         *                          //    n++;
         *
         *                          //}
         *                          //cross.Add(idA + "," + idB);
         *                          //n++;
         *                      }
         *                  }
         *              }
         *              dr[mcb.Alias] = n;
         *
         *          }
         *          dt.Rows.Add(dr);
         *      }
         *      return dt;
         *  }
         *  catch (System.Exception ex)
         *  {
         *      return null;
         *  }
         *
         * }
         *
         * private bool IsPointSame(IPoint p1, IPoint p2)
         * {
         *  if (p1.X == p2.X && p1.Y == p2.Y && p1.Z == p2.Z) return true;
         *  else return false;
         * }
         * private void GetDistanceAndZ(IPolyline line, IPoint point, out double dis, out double z)
         * {
         *  if (line == null || point == null)
         *  {
         *      dis = double.MaxValue;
         *      z = double.MaxValue;
         *      return;
         *  }
         *  else
         *  {
         *      dis = System.Math.Sqrt((point.X - line.FromPoint.X) * (point.X - line.FromPoint.X) + (point.Y - line.FromPoint.Y) * (point.Y - line.FromPoint.Y));
         *      z = dis * (line.ToPoint.Z - line.FromPoint.Z) / line.Length + line.FromPoint.Z;
         *  }
         *
         * }
         *
         * private int GetDiameter(IFeature feature, string fieldName)
         * {
         *  IFields fields = feature.Fields;
         *  int index = fields.FindField(this._diameter);
         *  string d = feature.get_Value(index).ToString();
         *  int h;
         *  if (d.Contains("*"))
         *  {
         *      int n = d.IndexOf("*");
         *      string strd = d.Substring(n + 1);
         *      System.Int32.TryParse(strd, out h);
         *  }
         *  else
         *  {
         *      System.Int32.TryParse(d, out h);
         *  }
         *  return h;
         * }*/

        private void lbx_CrossPipe_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                app.Current2DMapControl.ActiveView.FocusMap.ClearSelection();
                string temp  = this.lbx_CrossPipe.SelectedItem.ToString();
                string lineA = temp.Substring(0, (temp.IndexOf(",")));
                string lineB = temp.Substring(temp.IndexOf(",") + 1);
                if (lineA == null || lineB == null)
                {
                    return;
                }
                string mcNameA = lineA.Substring(0, lineA.IndexOf("_"));
                string fOidA   = lineA.Substring(lineA.IndexOf("_") + 1);
                string mcNameB = lineB.Substring(0, lineB.IndexOf("_"));
                string fOidB   = lineB.Substring(lineB.IndexOf("_") + 1);
                int    OIDA;
                int    OIDB;
                Int32.TryParse(fOidA, out OIDA);
                Int32.TryParse(fOidB, out OIDB);

                foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())
                {
                    if (mc.Name == mcNameA)
                    {
                        bool     have      = false;
                        string[] arrFc2DId = mc.Fc2D.Split(';');
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        foreach (SubClass sc in mc.SubClasses)
                        {
                            if (!sc.Visible2D)
                            {
                                continue;
                            }
                            foreach (string fc2DId in arrFc2DId)
                            {
                                DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);//根据要素类ID得到DF2DFC
                                if (dffc == null)
                                {
                                    continue;
                                }
                                FacilityClass facc = dffc.GetFacilityClass(); //得到设施类
                                IFeatureClass fc   = dffc.GetFeatureClass();  //得到要素类
                                IFeatureLayer fl   = dffc.GetFeatureLayer();
                                if (fc == null || facc == null || facc.Name != "PipeLine")
                                {
                                    continue;
                                }
                                if (fl == null)
                                {
                                    return;
                                }
                                IFeature feature1 = fc.GetFeature(OIDA);
                                if (feature1 == null)
                                {
                                    return;
                                }
                                app.Current2DMapControl.ActiveView.FocusMap.SelectFeature(fl, feature1);
                                //app.Current2DMapControl.ActiveView.FocusMap.SelectFeature(fl, feature2);
                                IPolyline polyline = feature1.Shape as IPolyline;
                                IPoint    point    = polyline.ToPoint;
                                app.Current2DMapControl.MapScale = 500;
                                app.Current2DMapControl.CenterAt(point);
                                have = true;
                            }
                            if (have)
                            {
                                break;
                            }
                        }
                    }
                    if (mc.Name == mcNameB)
                    {
                        bool     have      = false;
                        string[] arrFc2DId = mc.Fc2D.Split(';');
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        foreach (SubClass sc in mc.SubClasses)
                        {
                            if (!sc.Visible2D)
                            {
                                continue;
                            }
                            foreach (string fc2DId in arrFc2DId)
                            {
                                DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);//根据要素类ID得到DF2DFC
                                if (dffc == null)
                                {
                                    continue;
                                }
                                FacilityClass facc = dffc.GetFacilityClass(); //得到设施类
                                IFeatureClass fc   = dffc.GetFeatureClass();  //得到要素类
                                IFeatureLayer fl   = dffc.GetFeatureLayer();
                                if (fc == null || facc == null || facc.Name != "PipeLine")
                                {
                                    continue;
                                }
                                if (fl == null)
                                {
                                    return;
                                }
                                IFeature feature = fc.GetFeature(OIDB);
                                app.Current2DMapControl.ActiveView.FocusMap.SelectFeature(fl, feature);
                                IPolyline polyline = feature.Shape as IPolyline;
                                IPoint    point    = polyline.FromPoint;
                                app.Current2DMapControl.MapScale = 500;
                                app.Current2DMapControl.CenterAt(point);

                                have = true;
                            }
                            if (have)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 8
0
        private bool HaveOne(FacilityClass facc, IGeometry pGeo)
        {
            bool haveone = false;

            string[] fc2D = facc.Fc2D.Split(';');
            if (fc2D.Length == 0)
            {
                return(false);
            }
            string           facID  = fc2D[0];
            DF2DFeatureClass dffacc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(facID);
            //如果图层不显示,则不查询
            TreeNodeComLayer treeLayer = dffacc.GetTreeLayer();

            if (treeLayer == null || !treeLayer.Visible)
            {
                return(false);
            }

            IFeatureClass  fc     = dffacc.GetFeatureClass();
            ISpatialFilter filter = new SpatialFilter();

            filter            = new SpatialFilter();
            filter.Geometry   = pGeo;
            filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureCursor cursor  = fc.Search(filter, false);
            IFeature       feature = cursor.NextFeature();

            if (feature != null)
            {
                haveone = true;
                DataTable dt = new DataTable();
                dt.TableName = facc.Name;
                DataColumn oidcol = new DataColumn();
                oidcol.ColumnName = "oid";
                oidcol.Caption    = "ID";
                dt.Columns.Add(oidcol);
                foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection)
                {
                    if (!fitemp.CanQuery)
                    {
                        continue;
                    }
                    DataColumn col = new DataColumn();
                    col.ColumnName = fitemp.Name;
                    col.Caption    = fitemp.Alias;
                    dt.Columns.Add(col);
                }

                DataRow dtRow = dt.NewRow();
                dtRow["oid"] = feature.get_Value(feature.Fields.FindField("OBJECTID"));
                foreach (DataColumn col in dt.Columns)
                {
                    int index1 = feature.Fields.FindField(col.ColumnName);
                    if (index1 < 0)
                    {
                        continue;
                    }
                    object obj1 = GetFieldValueByIndex(feature, index1);
                    string str  = "";
                    if (obj1 != null)
                    {
                        IField field = feature.Fields.get_Field(index1);
                        switch (field.Type)
                        {
                        case esriFieldType.esriFieldTypeBlob:
                        case esriFieldType.esriFieldTypeGeometry:
                        case esriFieldType.esriFieldTypeRaster:
                            continue;

                        case esriFieldType.esriFieldTypeDouble:

                            double d;
                            if (double.TryParse(obj1.ToString(), out d))
                            {
                                str = d.ToString("0.00");
                            }
                            break;

                        default:
                            str = obj1.ToString();
                            break;
                        }
                    }
                    dtRow[col.ColumnName] = str;
                }
                dt.Rows.Add(dtRow);
                if (dt.Rows.Count > 0)
                {
                    this._dict[facc.Alias] = dt;
                }
            }
            return(haveone);
        }
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication    app = DF2DApplication.Application;
            IGraphicsContainer gc  = app.Current2DMapControl.Map as IGraphicsContainer;

            gc.DeleteAllElements();
            bool ready = true;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_ActiveView = app.Current2DMapControl.ActiveView;
            IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay;

            try
            {
                if (button == 1)
                {
                    ISimpleLineSymbol pLineSym = new SimpleLineSymbol();
                    IRgbColor         pColor   = new RgbColorClass();
                    pColor.Red     = 255;
                    pColor.Green   = 255;
                    pColor.Blue    = 0;
                    pLineSym.Color = pColor;
                    pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
                    pLineSym.Width = 2;

                    ISimpleFillSymbol pFillSym = new SimpleFillSymbol();

                    pFillSym.Color   = pColor;
                    pFillSym.Style   = esriSimpleFillStyle.esriSFSDiagonalCross;
                    pFillSym.Outline = pLineSym;

                    object      symbol = pFillSym as object;
                    IRubberBand band   = new RubberRectangularPolygonClass();
                    IGeometry   geo    = band.TrackNew(m_Display, null);
                    app.Current2DMapControl.DrawShape(geo, ref symbol);
                    WaitForm.Start("正在查询...", "请稍后");

                    if (geo.IsEmpty)
                    {
                        IPoint searchPoint = new PointClass();
                        searchPoint.PutCoords(mapX, mapY);
                        geo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                        //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
                    }
                    if (ready)
                    {
                        foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())
                        {
                            if (mc.Alias == "电力" || mc.Alias == "通信" || mc.Alias == "架空")
                            {
                                continue;
                            }
                            string[] arrFc2DId = mc.Fc2D.Split(';');
                            if (arrFc2DId == null)
                            {
                                continue;
                            }
                            foreach (SubClass sc in mc.SubClasses)
                            {
                                if (!sc.Visible2D)
                                {
                                    continue;
                                }
                                foreach (string fc2DId in arrFc2DId)
                                {
                                    DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                    if (dffc == null)
                                    {
                                        continue;
                                    }
                                    FacilityClass facc = dffc.GetFacilityClass();
                                    IFeatureClass fc   = dffc.GetFeatureClass();
                                    if (fc == null || facc == null || facc.Name != "PipeLine")
                                    {
                                        continue;
                                    }
                                    DFDataConfig.Class.FieldInfo fiDirection = facc.GetFieldInfoBySystemName("FlowDirection");
                                    if (fiDirection == null)
                                    {
                                        continue;
                                    }

                                    IFields pFields = fc.Fields;
                                    //string[] name = new string[pFields.FieldCount];
                                    //for (int i = 0; i < pFields.FieldCount; i++)
                                    //{
                                    //    name[i] = pFields.get_Field(i).Name;
                                    //}
                                    int indexDirection = pFields.FindField(fiDirection.Name);
                                    if (indexDirection < 0)
                                    {
                                        continue;
                                    }
                                    IField         pField = pFields.get_Field(indexDirection);
                                    ISpatialFilter filter = new SpatialFilter();
                                    filter.Geometry    = geo;
                                    filter.SubFields   = pField.Name;
                                    filter.WhereClause = mc.ClassifyField + " =  '" + sc.Name + "'";
                                    filter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                    if (fc == null || geo == null)
                                    {
                                        return;
                                    }

                                    IFeatureCursor pFeatureCursor = null;
                                    IFeature       pFeature       = null;


                                    try
                                    {
                                        pFeatureCursor = fc.Search(filter, false);
                                        esriFlowDirection flowDirection = new esriFlowDirection();
                                        while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                        {
                                            object tempobj = pFeature.get_Value(indexDirection);
                                            int    dtemp;
                                            if (tempobj != null && Int32.TryParse(tempobj.ToString(), out dtemp))
                                            {
                                                switch (dtemp)
                                                {
                                                case 0:
                                                    flowDirection = esriFlowDirection.esriFDWithFlow;
                                                    break;

                                                case 1:
                                                    flowDirection = esriFlowDirection.esriFDAgainstFlow;
                                                    break;
                                                }
                                            }
                                            else
                                            {
                                                flowDirection = esriFlowDirection.esriFDIndeterminate;
                                            }
                                            IPolyline polyline    = pFeature.Shape as IPolyline;
                                            IPoint    middlePoint = new PointClass();
                                            polyline.QueryPoint(esriSegmentExtension.esriNoExtension, polyline.Length / 2, false, middlePoint);

                                            IArrowMarkerSymbol  arrowMarkerSymbol  = new ArrowMarkerSymbolClass();
                                            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                                            IElement            element            = null;
                                            if (flowDirection == esriFlowDirection.esriFDWithFlow)
                                            {
                                                arrowMarkerSymbol.Angle = GetLineAngleFrom2Points(polyline.FromPoint, polyline.ToPoint);
                                                arrowMarkerSymbol.Color = GetColorByRGBValue(0, 0, 0);
                                                arrowMarkerSymbol.Size  = 12;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = arrowMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else if (flowDirection == esriFlowDirection.esriFDAgainstFlow)
                                            {
                                                simpleMarkerSymbol.Angle = GetLineAngleFrom2Points(polyline.ToPoint, polyline.FromPoint);
                                                arrowMarkerSymbol.Color  = GetColorByRGBValue(0, 0, 0);
                                                arrowMarkerSymbol.Size   = 12;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = arrowMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else if (flowDirection == esriFlowDirection.esriFDIndeterminate)
                                            {
                                                simpleMarkerSymbol.Color = GetColorByRGBValue(0, 0, 0);
                                                simpleMarkerSymbol.Size  = 8;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = simpleMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else
                                            {
                                                simpleMarkerSymbol.Color = GetColorByRGBValue(255, 0, 0);
                                                simpleMarkerSymbol.Size  = 8;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = simpleMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            gc.AddElement(element, 0);
                                        }
                                    }
                                    catch (System.Exception ex)
                                    {
                                    }
                                }
                            }
                        }
                        WaitForm.Stop();
                        app.Current2DMapControl.ActiveView.Refresh();
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 10
0
        //public void ShowProperty()
        //{
        //    try
        //    {
        //        _dtShow.Rows.Clear();

        //        if (_dt == null || _dt.Rows.Count < _num) return;
        //        this.bsiInfo.Caption = "浏览 " + _num + "/" + _dt.Rows.Count;
        //        DataRow dr = _dt.Rows[_num - 1];
        //        for (int i = 0; i < _dt.Columns.Count; i++)
        //        {
        //            String columnName = _dt.Columns[i].ColumnName;
        //            if (columnName == null) continue;

        //            if (dr[columnName] == null || dr[columnName].ToString() == "") continue;
        //            string value = dr[columnName].ToString();
        //            double dTemp = 0.0;
        //            string dStrTemp = "";
        //            bool bDouble = double.TryParse(value, out dTemp);
        //            if (bDouble) dStrTemp = dTemp.ToString("0.00");
        //            else dStrTemp = value;
        //            DataRow drnew = _dtShow.NewRow();
        //            drnew["Property"] = columnName;
        //            drnew["Value"] = dStrTemp;
        //            _dtShow.Rows.Add(drnew);
        //        }
        //    }
        //    catch (System.Exception ex)
        //    {

        //    }
        //}
        private void ShowProperty()
        {
            try
            {
                if (_currentClass == null)
                {
                    return;
                }
                _dtShow.Rows.Clear();
                DataTable dt = _dict[_currentClass];
                if (dt == null || dt.Rows.Count < _num)
                {
                    return;
                }
                if (dt.Rows.Count == 0 || dt.Rows.Count == 1)
                {
                    this.bbiFirst.Enabled       = false;
                    this.bbiPreviousOne.Enabled = false;
                    this.bbiNextOne.Enabled     = false;
                    this.bbiLastOne.Enabled     = false;
                }
                else
                {
                    if (_num == 1)
                    {
                        this.bbiFirst.Enabled       = false;
                        this.bbiPreviousOne.Enabled = false;
                        this.bbiNextOne.Enabled     = true;
                        this.bbiLastOne.Enabled     = true;
                    }
                    else if (_num == dt.Rows.Count)
                    {
                        this.bbiFirst.Enabled       = true;
                        this.bbiPreviousOne.Enabled = true;
                        this.bbiNextOne.Enabled     = false;
                        this.bbiLastOne.Enabled     = false;
                    }
                    else
                    {
                        this.bbiFirst.Enabled       = true;
                        this.bbiPreviousOne.Enabled = true;
                        this.bbiNextOne.Enabled     = true;
                        this.bbiLastOne.Enabled     = true;
                    }
                }
                this.bsiInfo.Caption = "浏览 " + _num + "/" + dt.Rows.Count;
                DataRow dr = dt.Rows[_num - 1];
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    DataRow drnew = _dtShow.NewRow();
                    drnew["Property"] = dt.Columns[i].Caption;
                    drnew["Value"]    = dr[dt.Columns[i].ColumnName];
                    _dtShow.Rows.Add(drnew);
                }
                #region 定位
                DF2DApplication app = DF2DApplication.Application;
                if (app == null || app.Current2DMapControl == null)
                {
                    return;
                }
                if (_currentClass == "建筑物" || _currentClass == "构筑物")
                {
                    FacilityClass fac;
                    if (_currentClass == "建筑物")
                    {
                        fac = FacilityClassManager.Instance.GetFacilityClassByName("Building");
                    }
                    else
                    {
                        fac = FacilityClassManager.Instance.GetFacilityClassByName("Structure");
                    }
                    if (fac != null)
                    {
                        string[]         fc2D = fac.Fc2D.Split(';');
                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2D[0]);
                        if (dffc == null)
                        {
                            return;
                        }
                        IFeatureClass fc = dffc.GetFeatureClass();
                        IFeatureLayer fl = dffc.GetFeatureLayer();
                        if (fc == null)
                        {
                            return;
                        }
                        int      oid     = int.Parse(dr["oid"].ToString());
                        IFeature feature = fc.GetFeature(oid);
                        app.Current2DMapControl.ActiveView.FocusMap.ClearSelection();
                        app.Current2DMapControl.ActiveView.FocusMap.SelectFeature(fl as ILayer, feature);
                        app.Current2DMapControl.ActiveView.Refresh();
                        IGeometry geo    = feature.Shape;
                        IEnvelope pEnv   = geo.Envelope;
                        IPoint    pPoint = new PointClass();
                        pPoint.PutCoords((pEnv.XMax + pEnv.XMin) / 2, (pEnv.YMax + pEnv.YMin) / 2);
                        app.Current2DMapControl.MapScale = 500;
                        app.Current2DMapControl.CenterAt(pPoint);
                    }
                }
                else
                {
                    MajorClass mc = LogicDataStructureManage2D.Instance.GetMajorClassBySubClassName(_currentClass);
                    if (mc != null && !string.IsNullOrEmpty(mc.Fc2D))
                    {
                        string[] arrFc2DId = mc.Fc2D.Split(';');
                        if (arrFc2DId == null)
                        {
                            return;
                        }
                        foreach (string fc2DId in arrFc2DId)
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            FacilityClass fac = dffc.GetFacilityClass();
                            if (fac == null || fac.Name != dt.TableName)
                            {
                                continue;
                            }
                            IFeatureClass fc = dffc.GetFeatureClass();
                            IFeatureLayer fl = dffc.GetFeatureLayer();
                            if (fc == null)
                            {
                                continue;
                            }
                            int      oid     = int.Parse(dr["oid"].ToString());
                            IFeature feature = fc.GetFeature(oid);
                            app.Current2DMapControl.ActiveView.FocusMap.ClearSelection();
                            app.Current2DMapControl.ActiveView.FocusMap.SelectFeature(fl as ILayer, feature);
                            app.Current2DMapControl.ActiveView.Refresh();
                            IGeometry geo    = feature.Shape;
                            IEnvelope pEnv   = geo.Envelope;
                            IPoint    pPoint = new PointClass();
                            pPoint.PutCoords((pEnv.XMax + pEnv.XMin) / 2, (pEnv.YMax + pEnv.YMin) / 2);
                            app.Current2DMapControl.MapScale = 500;
                            app.Current2DMapControl.CenterAt(pPoint);
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 11
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            interPoints = new List <IntersectPoint>();
            DF2DApplication app   = DF2DApplication.Application;
            bool            ready = true;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_ActiveView = app.Current2DMapControl.ActiveView;
            IScreenDisplay   m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay;
            IGeometry        pGeo      = null;
            IPointCollection pIntersectPC;
            IPointCollection pLandSufPC;
            double           length = 0.0;

            try
            {
                if (button == 1)
                {
                    ISimpleLineSymbol pLineSym = new SimpleLineSymbol();
                    IRgbColor         pColor   = new RgbColorClass();
                    pColor.Red     = 255;
                    pColor.Green   = 255;
                    pColor.Blue    = 0;
                    pLineSym.Color = pColor;
                    pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
                    pLineSym.Width = 2;

                    IRubberBand pRubberBand;
                    pRubberBand = new RubberLineClass();
                    IGeometry pLine;
                    pLine = pRubberBand.TrackNew(m_Display, null);

                    object symbol = pLineSym as object;
                    app.Current2DMapControl.DrawShape(pLine, ref symbol);

                    WaitForm.Start("正在查询...", "请稍后");
                    //pGeo = PublicFunction.DoBuffer(pLine,PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    pGeo = pLine;
                    if (pGeo == null)
                    {
                        return;
                    }
                    length = (pGeo as IPolyline).Length;

                    if (ready)
                    {
                        double distemp   = 0.0;
                        IPoint tempPoint = null;
                        foreach (LogicGroup lg in LogicDataStructureManage.Instance.RootLogicGroups)
                        {
                            foreach (MajorClass mc in lg.MajorClasses)
                            {
                                foreach (SubClass sc in mc.SubClasses)
                                {
                                    if (!sc.Visible2D)
                                    {
                                        continue;
                                    }
                                    string[] arrFc2DId = mc.Fc2D.Split(';');
                                    if (arrFc2DId == null)
                                    {
                                        continue;
                                    }
                                    IFeatureCursor pFeatureCursor = null;
                                    IFeature       pFeature       = null;
                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        if (facc.Name != "PipeLine")
                                        {
                                            continue;
                                        }
                                        if (fc == null || pGeo == null)
                                        {
                                            continue;
                                        }
                                        ISpatialFilter pSpatialFilter = new SpatialFilter();
                                        pSpatialFilter.Geometry    = pGeo;
                                        pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                        pSpatialFilter.WhereClause = "SMSCODE =  '" + sc.Name + "'";
                                        int count = fc.FeatureCount(pSpatialFilter);
                                        if (count == 0)
                                        {
                                            continue;
                                        }
                                        pFeatureCursor = fc.Search(pSpatialFilter, false);
                                        string fcName = mc.Name;
                                        if (pFeatureCursor == null)
                                        {
                                            continue;
                                        }
                                        double distance;

                                        while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                        {
                                            IGeometry            pPipeLineGeo = pFeature.Shape;
                                            ITopologicalOperator pTopo        = pPipeLineGeo as ITopologicalOperator;
                                            IGeometry            geo          = pTopo.Intersect(pGeo, esriGeometryDimension.esriGeometry0Dimension);
                                            IPoint intersect;
                                            if (geo is IPoint)
                                            {
                                                double distanceF = double.MaxValue;
                                                intersect = geo as IPoint;
                                                if (pGeo is IPolyline)
                                                {
                                                    IPolyline line      = pGeo as IPolyline;
                                                    IPoint    fromPoint = line.FromPoint;
                                                    distanceF = GetDistanceOfTwoPoints(intersect, fromPoint);
                                                }
                                                if (distemp == 0.0)
                                                {
                                                    distance = distanceF;
                                                    distemp  = distanceF;
                                                }
                                                else
                                                {
                                                    distance = Math.Abs(distanceF - distemp);
                                                }
                                                IntersectPoint interPoint = new IntersectPoint(pFeature, intersect, fcName, distance, distanceF);
                                                interPoints.Add(interPoint);
                                            }
                                            if (geo is IPointCollection)
                                            {
                                                IPointCollection geoCol = geo as IPointCollection;
                                                for (int i = 0; i < geoCol.PointCount; i++)
                                                {
                                                    intersect = geoCol.get_Point(i) as IPoint;
                                                    double distanceF = double.MaxValue;

                                                    if (pGeo is IPolyline)
                                                    {
                                                        IPolyline line = pGeo as IPolyline;

                                                        IPoint fromPoint = line.FromPoint;
                                                        IPoint toPoint   = line.ToPoint;
                                                        if (distemp == 0.0)
                                                        {
                                                            double distance1 = GetDistanceOfTwoPoints(intersect, fromPoint);
                                                            double distance2 = GetDistanceOfTwoPoints(intersect, toPoint);
                                                            distanceF = distance1 < distance2 ? distance1 : distance2;
                                                            tempPoint = distance1 < distance2 ? fromPoint:toPoint;
                                                        }
                                                        else
                                                        {
                                                            if (tempPoint == null)
                                                            {
                                                                return;
                                                            }
                                                            distanceF = GetDistanceOfTwoPoints(intersect, tempPoint);
                                                        }
                                                    }
                                                    if (distemp == 0.0)
                                                    {
                                                        distance = distanceF;
                                                        distemp  = distanceF;
                                                    }
                                                    else
                                                    {
                                                        distance = Math.Abs(distanceF - distemp);
                                                    }
                                                    IntersectPoint interPoint = new IntersectPoint(pFeature, intersect, fcName, distance, distanceF);
                                                    interPoints.Add(interPoint);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                DrawPipeTransection(interPoints, length);
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 12
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication    app = DF2DApplication.Application;
            IGraphicsContainer gc  = app.Current2DMapControl.Map as IGraphicsContainer;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pActiveView = app.Current2DMapControl.ActiveView;
            m_Display     = app.Current2DMapControl.ActiveView.ScreenDisplay;
            IFeatureCursor pFeaCur;
            IFeature       pFeature;
            string         classify   = "";
            string         startNo    = "";
            string         endNo      = "";
            string         material   = "";
            string         coverstyle = "";
            string         diameter   = "";
            string         road       = "";
            bool           have       = false;

            try
            {
                if (button == 1)
                {
                    IRubberBand band = new RubberRectangularPolygonClass();
                    m_pGeoTrack = band.TrackNew(m_Display, null);

                    if (m_pGeoTrack.IsEmpty)
                    {
                        IPoint searchPoint = new PointClass();
                        searchPoint.PutCoords(mapX, mapY);
                        m_pGeoTrack = DF2DPipe.Class.PublicFunction.DoBuffer(searchPoint, DF2DPipe.Class.PublicFunction.ConvertPixelsToMapUnits(m_pActiveView, GlobalValue.System_Selection_Option().Tolerate));
                        //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
                    }
                    WaitForm.Start("正在查询...", "请稍后");
                    foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())
                    {
                        if (have)
                        {
                            break;
                        }
                        string[] arrFc2DId = mc.Fc2D.Split(';');//将二级大类所对应的要素类ID转换为数组
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        foreach (SubClass sc in mc.SubClasses)
                        {
                            if (have)
                            {
                                break;
                            }
                            if (!sc.Visible2D)
                            {
                                continue;
                            }
                            foreach (string fc2DId in arrFc2DId)                                                      //遍历二级子类所对应的要素类ID
                            {
                                DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC
                                if (dffc == null)
                                {
                                    continue;
                                }
                                FacilityClass fcc = dffc.GetFacilityClass();
                                if (fcc.Name != "PipeLine")
                                {
                                    continue;
                                }
                                IFeatureLayer  fl             = dffc.GetFeatureLayer();
                                IFeatureClass  fc             = dffc.GetFeatureClass();
                                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                                pSpatialFilter.Geometry    = m_pGeoTrack;
                                pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                pSpatialFilter.WhereClause = "SMSCODE =  '" + sc.Name + "'";
                                pFeaCur  = fc.Search(pSpatialFilter, false);
                                pFeature = pFeaCur.NextFeature();
                                if (pFeature == null)
                                {
                                    continue;
                                }
                                foreach (string field in sysFields)
                                {
                                    DFDataConfig.Class.FieldInfo fi = fcc.GetFieldInfoBySystemName(field);
                                    if (fi == null)
                                    {
                                        continue;
                                    }
                                    int    index = fc.Fields.FindField(fi.Name);
                                    object obj   = pFeature.get_Value(index);
                                    switch (field)
                                    {
                                    case "Classify":
                                        classify = obj.ToString();
                                        break;

                                    case "StartNo":
                                        startNo = obj.ToString();
                                        break;

                                    case "EndNo":
                                        endNo = obj.ToString();
                                        break;

                                    case "Material":
                                        material = obj.ToString();
                                        break;

                                    case "CoverStyle":
                                        coverstyle = obj.ToString();
                                        break;

                                    case "Diameter":
                                        diameter = obj.ToString();
                                        break;

                                    case "Road":
                                        road = obj.ToString();
                                        break;
                                    }
                                }
                                m_IntersectPipe = new IntersectPipe(pFeature, fl, 0, classify, startNo, endNo, material, coverstyle, diameter, road);
                                have            = true;
                            }
                        }
                    }
                }
                if (m_IntersectPipe == null)
                {
                    XtraMessageBox.Show("请重新获取单个管线");
                    WaitForm.Stop();
                }
                WaitForm.SetCaption("正在输出属性,请稍后...");
                DrawNodeLabels(m_IntersectPipe.Feature, m_IntersectPipe);
                WaitForm.Stop();
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 13
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            try
            {
                IMap2DView mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
                if (mapView == null)
                {
                    return;
                }
                if (app == null || app.Current2DMapControl == null || app.Workbench == null)
                {
                    return;
                }
                pGraphicsContainer.DeleteAllElements();
                app.Current2DMapControl.ActiveView.Refresh();

                IGeometry geo = app.Current2DMapControl.TrackCircle();
                if (geo != null)
                {
                    AddCircleElement(geo, this.m_ActiveView);
                    this.m_ActiveView.Refresh();
                }
                WaitForm.Start("正在查询...", "请稍后");
                FacilityClass facc = FacilityClassManager.Instance.GetFacilityClassByName("PipeNode");
                if (facc == null)
                {
                    return;
                }
                DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName("Additional");
                if (fi == null)
                {
                    return;
                }

                string[] fc2d = facc.Fc2D.Split(';');
                foreach (string fcID in fc2d)
                {
                    DF2DFeatureClass dffc   = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fcID);
                    IFeatureClass    fctemp = dffc.GetFeatureClass();
                    if (fctemp.AliasName.Contains("上水"))
                    {
                        fc = fctemp;
                        break;
                    }
                }
                if (fc == null)
                {
                    return;
                }
                int index = fc.Fields.FindField(fi.Name);
                if (index == -1)
                {
                    return;
                }
                ISpatialFilter filter = new SpatialFilter();
                filter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                filter.Geometry    = geo;
                filter.WhereClause = fi.Name + "='" + "消火栓' OR " + fi.Name + "='" + "消防栓'";
                IFeatureCursor cursor = fc.Search(filter, false);
                int            count  = fc.FeatureCount(filter);
                if (count == 0)
                {
                    XtraMessageBox.Show("所选区域内无消防栓!"); WaitForm.Stop(); return;
                }
                while ((feature = cursor.NextFeature()) != null)
                {
                    string Filename = Application.StartupPath + @"\..\Resource\Images\Icon\fireHydrant.png";
                    double xfea, yfea;
                    xfea = (feature.Extent.XMax + feature.Extent.XMin) / 2;
                    yfea = (feature.Extent.YMax + feature.Extent.YMin) / 2;
                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(xfea, yfea);
                    IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbolClass();
                    pPictureMarkerSymbol.Size = 50;
                    pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, Filename);
                    IMarkerElement pMarkerElement = new MarkerElementClass();
                    pMarkerElement.Symbol = pPictureMarkerSymbol as IMarkerSymbol;
                    IElement pElement = (IElement)pMarkerElement;
                    pElement.Geometry = pPoint;
                    pGraphicsContainer.AddElement(pElement, 0);
                }
                this.m_ActiveView.Refresh();
                WaitForm.Stop();
            }
            catch (System.Exception ex)
            {
                WaitForm.Stop();
                return;
            }
        }
Exemplo n.º 14
0
        private void DoQuery()
        {
            if (string.IsNullOrEmpty(this._sysFieldName))
            {
                return;
            }
            string value = this.teValue.Text.Trim();

            if (value.Length > 1)
            {
                int lastindex = value.LastIndexOf(';');
                if (lastindex == (value.Length - 1))
                {
                    value = value.Substring(0, value.Length - 1);
                }
            }
            string[] arr1 = value.Split(';');
            if (arr1 == null || arr1.Length == 0)
            {
                return;
            }
            string temp1 = "";

            foreach (string str1 in arr1)
            {
                temp1 += str1;
            }
            if (this.treeLayer.GetAllCheckedNodes() != null)
            {
                DF2DPipe.Class.Query query = new DF2DPipe.Class.Query();

                foreach (TreeListNode node in this.treeLayer.GetAllCheckedNodes())
                {
                    object obj = node.GetValue("NodeObject");
                    if (obj != null && obj is SubClass)
                    {
                        SubClass sc = obj as SubClass;
                        if (sc.Parent == null)
                        {
                            continue;
                        }
                        string   classifyField = sc.Parent.ClassifyField;
                        string[] arrFc2DId     = sc.Parent.Fc2D.Split(';');
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        foreach (string fc2DId in arrFc2DId)
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            IFeatureClass fc   = dffc.GetFeatureClass();
                            FacilityClass facc = dffc.GetFacilityClass();
                            if (this._sysFieldName == "Additional")
                            {
                                if (fc == null || facc == null || facc.Name != "PipeNode")
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                if (fc == null || facc == null || facc.Name != "PipeLine")
                                {
                                    continue;
                                }
                            }

                            DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName(this._sysFieldName);
                            if (fc == null || facc == null || fi == null)
                            {
                                continue;
                            }
                            int index = fc.FindField(fi.Name);
                            if (index == -1)
                            {
                                continue;
                            }
                            IFields pFields = fc.Fields;
                            IField  pField  = pFields.get_Field(index);


                            string whereClause = UpOrDown.DecorateWhereClasuse(fc) + classifyField + "='" + sc.Name + "'" + " AND ";

                            foreach (string str1 in arr1)
                            {
                                whereClause += pField.Name + "=" + str1 + " OR ";
                            }
                            whereClause = whereClause.Substring(0, whereClause.Length - 3);
                            IFeature       pFeature      = null;
                            IFeatureCursor pFeatureCusor = null;
                            try
                            {
                                IQueryFilter pQueryFilter = new QueryFilterClass();
                                pQueryFilter.WhereClause = whereClause;
                                pFeatureCusor            = fc.Search(pQueryFilter, true);
                                DataTable dt = new DataTable();
                                dt.TableName = facc.Name;
                                DataColumn oidcol = new DataColumn();
                                oidcol.ColumnName = "oid";
                                oidcol.Caption    = "ID";
                                dt.Columns.Add(oidcol);
                                foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection)
                                {
                                    if (!fitemp.CanQuery)
                                    {
                                        continue;
                                    }
                                    DataColumn col = new DataColumn();
                                    col.ColumnName = fitemp.Name;
                                    col.Caption    = fitemp.Alias;
                                    dt.Columns.Add(col);
                                }

                                while ((pFeature = pFeatureCusor.NextFeature()) != null)
                                {
                                    DataRow dtRow = dt.NewRow();
                                    dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID"));
                                    foreach (DataColumn col in dt.Columns)
                                    {
                                        int index1 = pFeature.Fields.FindField(col.ColumnName);
                                        if (index1 < 0)
                                        {
                                            continue;
                                        }
                                        object obj1 = pFeature.get_Value(index1);
                                        string str  = "";
                                        if (obj1 != null)
                                        {
                                            IField field = pFeature.Fields.get_Field(index1);
                                            switch (field.Type)
                                            {
                                            case esriFieldType.esriFieldTypeBlob:
                                            case esriFieldType.esriFieldTypeGeometry:
                                            case esriFieldType.esriFieldTypeRaster:
                                                continue;

                                            case esriFieldType.esriFieldTypeDouble:

                                                double d;
                                                if (double.TryParse(obj1.ToString(), out d))
                                                {
                                                    str = d.ToString("0.00");
                                                }
                                                break;

                                            default:
                                                str = obj1.ToString();
                                                break;
                                            }
                                        }
                                        dtRow[col.ColumnName] = str;
                                    }
                                    dt.Rows.Add(dtRow);
                                }
                                if (dt.Rows.Count > 0)
                                {
                                    this._dict[sc.Name] = dt;
                                }
                            }
                            catch
                            {
                            }
                            finally
                            {
                                if (pFeatureCusor != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCusor);
                                    pFeatureCusor = null;
                                }
                                if (pFeature != null)
                                {
                                    pFeature = null;
                                }
                            }
                        }
                    }
                }
            }
        }
        private DataTable RegionAnalysis(IGeometry geo)
        {
            DataTable dtResult = new DataTable();

            dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"),
                                                         new DataColumn("NUMBER", typeof(long)), new DataColumn("TOTALNUMBER", typeof(long)) });

            dtstats = new DataTable();
            dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"),
                                                        new DataColumn("NUMBER", typeof(int)) });
            List <MajorClass> list = LogicDataStructureManage2D.Instance.GetAllMajorClass();

            foreach (MajorClass mc in list)
            {
                string[] arrFc2DId = mc.Fc2D.Split(';');
                if (arrFc2DId == null)
                {
                    continue;
                }
                long majorclasscount = 0;
                int  indexStart      = dtResult.Rows.Count;
                foreach (SubClass sc in mc.SubClasses)
                {
                    long sccount = 0;
                    bool bHave   = false;
                    foreach (string fc2DId in arrFc2DId)
                    {
                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                        if (dffc == null)
                        {
                            continue;
                        }
                        FacilityClass facc = dffc.GetFacilityClass();
                        IFeatureClass fc   = dffc.GetFeatureClass();
                        if (fc == null || facc == null || facc.Name != "PipeNode")
                        {
                            continue;
                        }
                        ISpatialFilter filter = new SpatialFilter();
                        filter.Geometry    = geo;
                        filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";
                        filter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelContains;
                        int count = fc.FeatureCount(filter);
                        if (count == 0)
                        {
                            continue;
                        }
                        bHave    = true;
                        sccount += count;
                    }
                    if (bHave)
                    {
                        DataRow dr = dtResult.NewRow();
                        dr["PIPENODETYPE"] = mc;
                        dr["FIELDNAME"]    = "";
                        dr["PVALUE"]       = sc;
                        dr["NUMBER"]       = sccount;
                        majorclasscount   += sccount;
                        dtResult.Rows.Add(dr);

                        DataRow dr1 = dtstats.NewRow();
                        dr1["PIPENODETYPE"] = mc;
                        dr1["FIELDNAME"]    = sc;
                        dr1["NUMBER"]       = sccount;
                        dtstats.Rows.Add(dr1);
                    }
                }
                int indexEnd = dtResult.Rows.Count;
                for (int i = indexStart; i < indexEnd; i++)
                {
                    DataRow dr = dtResult.Rows[i];
                    dr["TOTALNUMBER"] = majorclasscount;
                }
            }
            return(dtResult);
        }
Exemplo n.º 16
0
        private void DoStats()
        {
            if (string.IsNullOrEmpty(this._sysFieldName))
            {
                return;
            }
            //string value = this.cbProperty.Text.Trim();
            //if (value.Length > 1)
            //{
            //    int lastindex = value.LastIndexOf(';');
            //    if (lastindex == (value.Length - 1))
            //        value = value.Substring(0, value.Length - 1);
            //}
            dttemp = new DataTable();
            dttemp.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"),
                                                       new DataColumn("FIELDNAME"), new DataColumn("PVALUE"),
                                                       new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) });
            dtstats = new DataTable();
            dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"),
                                                        new DataColumn("LENGTH", typeof(double)) });

            if (this.treelist.GetAllCheckedNodes() != null)
            {
                foreach (TreeListNode node in this.treelist.GetAllCheckedNodes())
                {
                    object obj = node.GetValue("NodeObject");
                    if (obj != null && obj is SubClass)
                    {
                        SubClass sc = obj as SubClass;
                        if (sc.Parent == null)
                        {
                            continue;
                        }
                        string[] arrFc2DId = sc.Parent.Fc2D.Split(';');
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        double subclasslength = 0.0;
                        int    indexStart     = dttemp.Rows.Count;
                        foreach (string fc2DId in arrFc2DId)
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            FacilityClass facc = dffc.GetFacilityClass();
                            IFeatureClass fc   = dffc.GetFeatureClass();
                            if (fc == null || facc == null || facc.Name != "PipeLine")
                            {
                                continue;
                            }
                            DFDataConfig.Class.FieldInfo fi           = facc.GetFieldInfoBySystemName(this._sysFieldName);
                            DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength2D");
                            if (fi == null || fiPipeLength == null)
                            {
                                continue;
                            }
                            int index = fc.Fields.FindField(fi.Name);
                            if (index == -1)
                            {
                                continue;
                            }
                            int indexPipeLength = fc.Fields.FindField(fiPipeLength.Name);
                            if (indexPipeLength == -1)
                            {
                                continue;
                            }
                            IField       fcfi   = fc.Fields.get_Field(index);
                            IQueryFilter filter = new QueryFilter();
                            filter.SubFields = fiPipeLength.Name;

                            //string[] arrvalue = value.Split(';');
                            if (list.Count <= 0)
                            {
                                return;
                            }
                            foreach (string strValue in list)
                            {
                                if (string.IsNullOrEmpty(strValue))
                                {
                                    continue;
                                }
                                switch (fcfi.Type)
                                {
                                case esriFieldType.esriFieldTypeBlob:
                                case esriFieldType.esriFieldTypeGeometry:
                                case esriFieldType.esriFieldTypeRaster:
                                    continue;
                                }
                                filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + sc.Parent.ClassifyField + " =  '" + sc.Name + "' and " + fi.Name + " = " + strValue;


                                IFeatureCursor pFeatureCursor = null;
                                IFeature       pFeature       = null;
                                double         subfieldlength = 0.0;
                                bool           bHave          = false;
                                #region
                                try
                                {
                                    pFeatureCursor = fc.Search(filter, true);
                                    while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                    {
                                        object tempobj = pFeature.get_Value(indexPipeLength);
                                        double dtemp   = 0.0;
                                        if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp))
                                        {
                                            bHave           = true;
                                            subfieldlength += dtemp;
                                        }
                                    }
                                }


                                catch { }
                                finally
                                {
                                    if (pFeatureCursor != null)
                                    {
                                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                                        pFeatureCursor = null;
                                    }
                                    if (pFeature != null)
                                    {
                                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature);
                                        pFeature = null;
                                    }
                                }
                                #endregion
                                if (bHave)
                                {
                                    DataRow dr = dttemp.NewRow();
                                    dr["PIPELINETYPE"] = sc;
                                    dr["FIELDNAME"]    = fi;
                                    dr["PVALUE"]       = strValue;
                                    subclasslength    += subfieldlength;
                                    dr["LENGTH"]       = subfieldlength.ToString("0.00");
                                    dttemp.Rows.Add(dr);

                                    DataRow dr1 = dtstats.NewRow();
                                    dr1["PIPELINETYPE"] = sc;
                                    dr1["FIELDNAME"]    = strValue;
                                    dr1["LENGTH"]       = subfieldlength.ToString("0.00");
                                    dtstats.Rows.Add(dr1);
                                }
                            }
                        }
                        int indexEnd = dttemp.Rows.Count;
                        for (int i = indexStart; i < indexEnd; i++)
                        {
                            DataRow dr = dttemp.Rows[i];
                            dr["TOTALLENGTH"] = subclasslength.ToString("0.00");
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        private void treelist_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
        {
            IFeatureCursor pFeatureCursor = null;
            IFeature       pFeature       = null;

            if (string.IsNullOrEmpty(this._sysFieldName))
            {
                return;
            }
            try
            {
                WaitForm.Start("正在加载列表...", "请稍后");

                foreach (TreeListNode node in this.treelist.GetAllCheckedNodes())
                {
                    object obj = node.GetValue("NodeObject");
                    if (obj != null && obj is SubClass)
                    {
                        SubClass sc = obj as SubClass;
                        if (sc.Parent == null)
                        {
                            continue;
                        }
                        string[] arrFc2DId = sc.Parent.Fc2D.Split(';');
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        foreach (string fc2DId in arrFc2DId)
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            FacilityClass facClass = dffc.GetFacilityClass();
                            IFeatureClass fc       = dffc.GetFeatureClass();
                            if (fc == null || facClass == null || facClass.Name != "PipeLine")
                            {
                                continue;
                            }
                            DFDataConfig.Class.FieldInfo fi = facClass.GetFieldInfoBySystemName(this._sysFieldName);
                            if (fi == null)
                            {
                                continue;
                            }

                            IFields pFields = fc.Fields;
                            int     index   = pFields.FindField(fi.Name);
                            if (index < 0)
                            {
                                continue;
                            }
                            IField pField = pFields.get_Field(index);


                            IQueryFilter pQueryFilter = new QueryFilterClass();
                            pQueryFilter.SubFields   = pField.Name;
                            pQueryFilter.WhereClause = sc.Parent.ClassifyField + " = " + "'" + sc.Name + "'";

                            pFeatureCursor = fc.Search(pQueryFilter, false);
                            pFeature       = pFeatureCursor.NextFeature();

                            while (pFeature != null)
                            {
                                object temp = pFeature.get_Value(index);
                                if (temp == null)
                                {
                                    continue;
                                }
                                string strtemp = "";
                                switch (pField.Type)
                                {
                                case esriFieldType.esriFieldTypeDouble:
                                case esriFieldType.esriFieldTypeInteger:
                                case esriFieldType.esriFieldTypeOID:
                                case esriFieldType.esriFieldTypeSingle:
                                case esriFieldType.esriFieldTypeSmallInteger:
                                    strtemp = temp.ToString();
                                    break;

                                case esriFieldType.esriFieldTypeDate:
                                case esriFieldType.esriFieldTypeString:
                                case esriFieldType.esriFieldTypeGUID:
                                    strtemp = "'" + temp.ToString() + "'";
                                    break;

                                case esriFieldType.esriFieldTypeBlob:
                                case esriFieldType.esriFieldTypeGeometry:
                                case esriFieldType.esriFieldTypeGlobalID:
                                case esriFieldType.esriFieldTypeRaster:
                                case esriFieldType.esriFieldTypeXML:
                                default:
                                    continue;
                                }
                                if (temp != null)
                                {
                                    list.Add(strtemp);
                                }
                                pFeature = pFeatureCursor.NextFeature();
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (pFeatureCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                    pFeatureCursor = null;
                }
                if (pFeature != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature);
                    pFeature = null;
                }
                WaitForm.Stop();
            }
        }
        private void DoStats()
        {
            List<TreeListNode> list = this.treelist.GetAllCheckedNodes();
            if (list == null)
            {
                return ;
            }

            dttemp = new DataTable();
            dttemp.Columns.AddRange(new DataColumn[]{new DataColumn("PIPELINETYPE"),
                                new DataColumn("FIELDNAME"),new DataColumn("PVALUE"),
                                new DataColumn("LENGTH",typeof(double)),new DataColumn("TOTALLENGTH",typeof(double))});
            dtstats = new DataTable();
            dtstats.Columns.AddRange(new DataColumn[]{new DataColumn("PIPELINETYPE"),new DataColumn("FIELDNAME"),
                                new DataColumn("LENGTH",typeof(double))});
            foreach (TreeListNode node in list)
            {
                 object obj = node.GetValue("NodeObject");
                 if (obj != null && obj is SubClass)
                 {
                     SubClass sc = obj as SubClass;
                     if (sc.Parent == null) continue;
                     string classifyField = sc.Parent.ClassifyField;
                     string[] arrFc2DId = sc.Parent.Fc2D.Split(';');
                     if (arrFc2DId == null) continue;
                     double subclasslength = 0.0;
                     int indexStart = dttemp.Rows.Count;
                     foreach (string fc2DId in arrFc2DId)
                     {
                         DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                         if (dffc == null) continue;
                         FacilityClass facc = dffc.GetFacilityClass();
                         IFeatureClass fc = dffc.GetFeatureClass();
                         if (fc == null || facc == null || facc.Name != "PipeLine") continue;
                         DFDataConfig.Class.FieldInfo fi1 = facc.GetFieldInfoBySystemName("Diameter1");
                         DFDataConfig.Class.FieldInfo fi2 = facc.GetFieldInfoBySystemName("Diameter2");
                         DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength2D");
                         if (fi1 == null || fi2 == null || fiPipeLength == null) continue;
                         int index1 = fc.Fields.FindField(fi1.Name);
                         int index2 = fc.Fields.FindField(fi2.Name);
                         if (index1 == -1 || index2 == -1) continue;
                         int indexPipeLength = fc.Fields.FindField(fiPipeLength.Name);
                         if (indexPipeLength == -1) continue;
                         IField fcfi1 = fc.Fields.get_Field(index1);
                         IField fcfi2 = fc.Fields.get_Field(index2);

                         IQueryFilter filter = new QueryFilter();
                         filter.SubFields = fiPipeLength.Name;
                         foreach (DataRow dr1 in this._dt.Rows)
                         {
                             double mind = double.Parse(dr1["MinDepth"].ToString());
                             double maxd = double.Parse(dr1["MaxDepth"].ToString());
                             string strValue = mind + "-" + maxd;
                             filter.WhereClause = classifyField + "='" + sc.Name + "'" + " and ( " + fi1.Name + " >= " + mind + " and " + fi1.Name + " <= " + maxd
                                + " and " + fi2.Name + " >= " + mind + " and " + fi2.Name + " <= " + maxd + " )";
                             int count = fc.FeatureCount(filter);
                             if (count == 0) continue;
                             bool bHave = false;
                             double subfieldlength = 0.0;
                             IFeatureCursor cursor = null;
                             IFeature feature = null;
                             try
                             {
                                 cursor = fc.Search(filter, true);
                                 while ((feature = cursor.NextFeature()) != null)
                                 {
                                     object tempobj = feature.get_Value(indexPipeLength);
                                     double dtemp = 0.0;
                                     if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp))
                                     {
                                         bHave = true;
                                         subfieldlength += dtemp;
                                     }

                                 }
                             }
                             catch (System.Exception ex)
                             {

                             }

                             if (bHave)
                             {
                                 DataRow dr = dttemp.NewRow();
                                 dr["PIPELINETYPE"] = sc;
                                 dr["FIELDNAME"] = "管径";
                                 dr["PVALUE"] = strValue;
                                 subclasslength += subfieldlength;
                                 dr["LENGTH"] = subfieldlength.ToString("0.00");
                                 dttemp.Rows.Add(dr);

                                 DataRow drs = dtstats.NewRow();
                                 drs["PIPELINETYPE"] = sc;
                                 drs["FIELDNAME"] = strValue;
                                 drs["LENGTH"] = subfieldlength.ToString("0.00");
                                 dtstats.Rows.Add(drs);
                             }
                         }
                     }
                     int indexEnd = dttemp.Rows.Count;
                     for (int i = indexStart; i < indexEnd; i++)
                     {
                         DataRow dr = dttemp.Rows[i];
                         dr["TOTALLENGTH"] = subclasslength.ToString("0.00");
                     }
                 }
            }
        }
Exemplo n.º 19
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            if (this.m_ActiveView.FocusMap.FeatureSelection != null)
            {
                this.m_ActiveView.FocusMap.ClearSelection();
            }
            bool ready = false;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IGeometry pGeo = null;

            _featureList = new List <IFeature>();
            _vertiPoints = new List <VerticalPoint>();
            string mapNum      = "";
            string mapName     = Config.GetConfigValue("SystemName") + "纵断面图";
            double totalLength = 0;

            try
            {
                if (button == 1)
                {
                    WaitForm.Start("正在查询...", "请稍后");
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    ready = true;

                    if (ready)
                    {
                        bool haveone = false;
                        foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        {
                            if (haveone)
                            {
                                break;
                            }
                            foreach (MajorClass mc in lg.MajorClasses)
                            {
                                if (haveone)
                                {
                                    break;
                                }
                                foreach (SubClass sc in mc.SubClasses)
                                {
                                    if (haveone)
                                    {
                                        break;
                                    }
                                    if (!sc.Visible2D)
                                    {
                                        continue;
                                    }
                                    string[] arrFc2DId = mc.Fc2D.Split(';');
                                    if (arrFc2DId == null)
                                    {
                                        continue;
                                    }
                                    IFeatureCursor pFeatureCursor = null;
                                    IFeature       pFeature       = null;
                                    string         fcName         = mc.Name;
                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        if (haveone)
                                        {
                                            break;
                                        }
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        if (facc.Name != "PipeLine")
                                        {
                                            continue;
                                        }
                                        if (fc == null || pGeo == null)
                                        {
                                            continue;
                                        }
                                        ISpatialFilter pSpatialFilter = new SpatialFilter();
                                        pSpatialFilter.Geometry    = pGeo;
                                        pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                        pSpatialFilter.WhereClause = sc.Parent.ClassifyField + " =  '" + sc.Name + "'";
                                        pFeatureCursor             = fc.Search(pSpatialFilter, false);
                                        if (pFeatureCursor == null)
                                        {
                                            continue;
                                        }
                                        while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                        {
                                            if (pFeature.Shape is IPolyline)
                                            {
                                                string diameter;
                                                string road;
                                                string startZ;
                                                string endZ;
                                                string startH;
                                                string endH;
                                                int    indexdia  = pFeature.Fields.FindField("STANDARD");
                                                int    indexroad = pFeature.Fields.FindField("PROAD");
                                                int    indexSZ   = pFeature.Fields.FindField("STARTTOPGC");
                                                int    indexEZ   = pFeature.Fields.FindField("ENDTOPGC");
                                                int    indexSH   = pFeature.Fields.FindField("START_SURF_H");
                                                int    indexEH   = pFeature.Fields.FindField("END_SURF_H");

                                                diameter = pFeature.get_Value(indexdia).ToString();
                                                road     = pFeature.get_Value(indexroad).ToString();
                                                startZ   = pFeature.get_Value(indexSZ).ToString();
                                                endZ     = pFeature.get_Value(indexEZ).ToString();
                                                startH   = pFeature.get_Value(indexSH).ToString();
                                                endH     = pFeature.get_Value(indexEH).ToString();

                                                IPolyline pline  = pFeature.Shape as IPolyline;
                                                IPoint    fPoint = pline.FromPoint;
                                                IPoint    tPoint = pline.ToPoint;
                                                totalLength += pline.Length;
                                                mapNum       = getMapNumforPnt(fPoint);
                                                VerticalPoint vertiPoint1 = new VerticalPoint(fcName, pFeature, fPoint, diameter, road, startZ, startH, true);
                                                _vertiPoints.Add(vertiPoint1);
                                                VerticalPoint vertiPoint2 = new VerticalPoint(fcName, pFeature, tPoint, diameter, road, endZ, endH, false);
                                                _vertiPoints.Add(vertiPoint2);
                                                haveone = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                DrawPipeVerticalSection(_vertiPoints, mapNum, mapName, totalLength);
            }
            catch
            {
            }
        }
Exemplo n.º 20
0
        public override void Run(object sender, EventArgs e)
        {
            string[] arrFc2DId;
            mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
            if (mapView == null)
            {
                return;
            }
            bool bBind = mapView.Bind(this);

            if (!bBind)
            {
                return;
            }
            app = (DF2DApplication)this.Hook;
            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pMapControl = app.Current2DMapControl;

            frmSelType frmType = new frmSelType();

            if (frmType.ShowDialog() == DialogResult.OK)
            {
                List <DF2DFeatureClass> list = new List <DF2DFeatureClass>();
                m_arrPipeType = frmType.PipeType;
                for (int i = 0; i < m_arrPipeType.Count; i++)
                {
                    MajorClass mc = m_arrPipeType[i] as MajorClass;
                    arrFc2DId = mc.Fc2D.Split(';');
                    if (arrFc2DId == null)
                    {
                        continue;
                    }
                    foreach (string fc2DId in arrFc2DId)
                    {
                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                        if (dffc == null || dffc.GetFacilityClassName() != "PipeLine")
                        {
                            continue;
                        }
                        IFeatureClass fc = dffc.GetFeatureClass();
                        if (fc == null)
                        {
                            continue;
                        }
                        //if (fc.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                        //{
                        list.Add(dffc);
                        //}
                    }
                }
                Dictionary <IFeatureClass, DataTable> dict = new Dictionary <IFeatureClass, DataTable>();
                WaitForm.Start("开始拓扑检查..", "请稍候");
                foreach (DF2DFeatureClass dffc in list)
                {
                    IFeatureClass fc = dffc.GetFeatureClass();
                    if (fc == null)
                    {
                        continue;
                    }
                    FacilityClass fac = dffc.GetFacilityClass();
                    if (fac == null)
                    {
                        continue;
                    }
                    List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                    DFDataConfig.Class.FieldInfo        fi        = fac.GetFieldInfoBySystemName("StartHeight2D");
                    int index = fc.FindField(fi.Name);
                    WaitForm.SetCaption("正在检查图层:" + " " + fc.AliasName);
                    if (fi == null || index == -1)
                    {
                        continue;
                    }

                    DFDataConfig.Class.FieldInfo fi1 = fac.GetFieldInfoBySystemName("EndHeight");
                    int index1 = fc.FindField(fi1.Name);
                    if (fi1 == null || index1 == -1)
                    {
                        continue;
                    }

                    DFDataConfig.Class.FieldInfo fi2 = fac.GetFieldInfoBySystemName("StartDep");
                    int index2 = fc.FindField(fi2.Name);
                    if (fi2 == null || index2 == -1)
                    {
                        continue;
                    }

                    DFDataConfig.Class.FieldInfo fi3 = fac.GetFieldInfoBySystemName("EndDep");
                    int index3 = fc.FindField(fi3.Name);
                    if (fi3 == null || index3 == -1)
                    {
                        continue;
                    }

                    DataTable      dt         = GetDataTableByStruture();
                    IFeatureCursor pFeaCursor = fc.Search(null, true);
                    IFeature       pFea       = pFeaCursor.NextFeature();
                    while (pFea != null)
                    {
                        //Console.WriteLine(pFea.OID + " " + fc.AliasName);
                        bool   b1 = false, b2 = false;
                        string obj  = pFea.get_Value(index).ToString();
                        string obj1 = pFea.get_Value(index1).ToString();
                        if (obj != "" && obj1 != "")
                        {
                            double d;
                            if (!double.TryParse(obj1, out d))
                            {
                                d = 0.0;
                            }

                            if (Math.Abs(double.Parse(obj) - double.Parse(obj1)) > 1)
                            {
                                b1 = true;
                            }
                        }
                        string obj2 = pFea.get_Value(index2).ToString();
                        string obj3 = pFea.get_Value(index3).ToString();
                        /* if (obj3 != null) continue;*/
                        if ((obj2 != "") && (obj3 != ""))
                        {
                            double d;
                            if (!double.TryParse(obj2, out d))
                            {
                                d = 0.0;
                            }

                            if (Math.Abs(double.Parse(obj2) - double.Parse(obj3)) > 0.5)
                            {
                                b2 = true;
                            }
                        }
                        if (b1 && b2)
                        {
                            DataRow dr = dt.NewRow();
                            dr["ErrorFeatureID"] = pFea.OID;
                            dr["FeatureofClass"] = fc.AliasName;
                            dr["FeatureofLayer"] = (fc as IDataset).Name;
                            dr["FeatureClass"]   = fc;
                            if (b1 && b2)
                            {
                                dr["ErrorType"] = "管线起止点高程差值超出规范值;管线起止点埋深差值超出规范值";
                            }
                            else if (b1 && !b2)
                            {
                                dr["ErrorType"] = "管线起止点高程差值超出规范值";
                            }
                            else if (b2 && !b1)
                            {
                                dr["ErrorType"] = "管线起止点埋深差值超出规范值";
                            }
                            dt.Rows.Add(dr);
                        }
                        pFea = pFeaCursor.NextFeature();
                    }
                    if (dt.Rows.Count > 0)
                    {
                        dict[fc] = dt;
                    }
                }
                WaitForm.Stop();
                FormCheckResult dlg = new FormCheckResult(dict, m_pMapControl);
                dlg.Text = this.CommandName;
                dlg.Show();
            }
        }
Exemplo n.º 21
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            IGraphicsContainer pGC = m_ActiveView.GraphicsContainer;

            if (this.m_ActiveView.FocusMap.FeatureSelection != null)
            {
                this.m_ActiveView.FocusMap.ClearSelection();
            }
            bool ready = false;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IGeometry pGeo = null;

            try
            {
                if (button == 1)
                {
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    ready = true;
                    if (ready)
                    {
                        bool haveone = false;

                        foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        {
                            foreach (MajorClass mc in lg.MajorClasses)
                            {
                                string[] arrFc2DId = mc.Fc2D.Split(';');
                                if (arrFc2DId == null)
                                {
                                    continue;
                                }
                                IFeatureCursor pFeatureCursor = null;
                                IFeature       pFeature       = null;

                                foreach (string fc2DId in arrFc2DId)
                                {
                                    DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                    if (dffc == null)
                                    {
                                        continue;
                                    }
                                    IFeatureClass fc   = dffc.GetFeatureClass();
                                    FacilityClass facc = dffc.GetFacilityClass();
                                    if (facc.Name != "PipeNode")
                                    {
                                        continue;
                                    }
                                    IFeatureLayer fl = dffc.GetFeatureLayer();
                                    if (fc == null || pGeo == null || fl == null)
                                    {
                                        continue;
                                    }
                                    if (!fl.Visible)
                                    {
                                        continue;
                                    }

                                    ISpatialFilter pSpatialFilter = new SpatialFilter();
                                    pSpatialFilter.Geometry   = pGeo;
                                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                    pFeatureCursor            = fc.Search(pSpatialFilter, false);
                                    if (pFeatureCursor == null)
                                    {
                                        continue;
                                    }
                                    pFeature = pFeatureCursor.NextFeature();
                                    if (pFeature == null)
                                    {
                                        continue;
                                    }
                                    haveone = true;

                                    IGeometry pGeometry = pFeature.Shape as IGeometry;
                                    if (pGeometry.GeometryType == esriGeometryType.esriGeometryPoint)
                                    {
                                        IPoint pPoint = pGeometry as IPoint;
                                        if (this._bFinished)
                                        {
                                            this._bFinished = false;
                                            this._startFCID = fc.FeatureClassID.ToString();
                                            this._startOid  = pFeature.OID;
                                            AddCallout(pPoint, "起点");
                                            app.Current2DMapControl.ActiveView.Refresh();
                                        }
                                        else
                                        {
                                            if (this._startFCID == fc.FeatureClassID.ToString() && this._startOid == pFeature.OID)
                                            {
                                                XtraMessageBox.Show("您选中的是同一个管点设施。", "提示");
                                                return;
                                            }
                                            this._bFinished = true;
                                            AddCallout(pPoint, "终点");
                                            app.Current2DMapControl.ActiveView.Refresh();
                                            if (this._startFCID != fc.FeatureClassID.ToString())
                                            {
                                                XtraMessageBox.Show("您选中的不是同一类管点设施。", "提示");
                                                return;
                                            }
                                            else
                                            {
                                                WaitForm.Start("正在分析...", "请稍后");
                                                TopoClass2D tc = FacilityInfoService2D.GetTopoClassByFeatureClassID(fc.FeatureClassID.ToString());
                                                if (tc == null)
                                                {
                                                    return;
                                                }
                                                TopoNetwork net = tc.GetNetwork();
                                                if (net == null)
                                                {
                                                    WaitForm.Stop();
                                                    XtraMessageBox.Show("构建拓扑网络失败!", "提示");
                                                    return;
                                                }
                                                else
                                                {
                                                    string        startId = this._startFCID + "_" + this._startOid.ToString();
                                                    string        endId   = fc.FeatureClassID.ToString() + "_" + pFeature.OID.ToString();
                                                    List <string> path;
                                                    double        shortestLength = net.SPFA(startId, endId, out path);
                                                    if ((shortestLength > 0.0 && shortestLength != double.MaxValue) || (path != null && path.Count > 0))
                                                    {
                                                        List <IPoint>    listPt   = new List <IPoint>();
                                                        IPointCollection pointCol = new PolylineClass();
                                                        foreach (string nodeId in path)
                                                        {
                                                            int              index    = nodeId.LastIndexOf("_");
                                                            string           fcID     = nodeId.Substring(0, index);
                                                            string           oid      = nodeId.Substring(index + 1, nodeId.Length - index - 1);
                                                            DF2DFeatureClass dffcTemp = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fcID);
                                                            if (dffcTemp == null || dffcTemp.GetFeatureClass() == null)
                                                            {
                                                                continue;
                                                            }
                                                            if (dffcTemp.GetFacilityClassName() != "PipeNode")
                                                            {
                                                                continue;
                                                            }
                                                            IQueryFilter filter = new QueryFilter();
                                                            filter.WhereClause = "OBJECTID =" + oid;
                                                            filter.SubFields   = "OBJECTID ,SHAPE";
                                                            IFeature       feature = null;
                                                            IFeatureCursor cursor  = null;
                                                            try
                                                            {
                                                                cursor = dffcTemp.GetFeatureClass().Search(filter, false);
                                                                while ((feature = cursor.NextFeature()) != null)
                                                                {
                                                                    if (feature.Shape != null && feature.Shape is IGeometry)
                                                                    {
                                                                        IGeometry geo = feature.Shape as IGeometry;
                                                                        switch (geo.GeometryType)
                                                                        {
                                                                        case esriGeometryType.esriGeometryPoint:
                                                                            IPoint pt = geo as IPoint;
                                                                            //pt.Z = pt.Z + 1;
                                                                            listPt.Add(pt);
                                                                            pointCol.AddPoint(pt);
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            catch (System.Exception ex)
                                                            {
                                                            }
                                                            finally
                                                            {
                                                                if (cursor != null)
                                                                {
                                                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                                                    cursor = null;
                                                                }
                                                                if (feature != null)
                                                                {
                                                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(feature);
                                                                    feature = null;
                                                                }
                                                            }
                                                        }
                                                        if (listPt.Count > 0)
                                                        {
                                                            IPolyline         polyline    = pointCol as IPolyline;
                                                            ISimpleLineSymbol pLineSymbol = new SimpleLineSymbol();
                                                            pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                                                            pLineSymbol.Width = 5;
                                                            pLineSymbol.Color = GetRGBColor(0, 230, 240);
                                                            IElement elementL = new LineElement();
                                                            elementL.Geometry = polyline;
                                                            ILineElement pLineElement = elementL as ILineElement;
                                                            pLineElement.Symbol = pLineSymbol;
                                                            pGC.AddElement(elementL, 0);

                                                            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
                                                            simpleMarkerSymbol.Color   = GetRGBColor(255, 0, 0);
                                                            simpleMarkerSymbol.Outline = false;
                                                            simpleMarkerSymbol.Size    = 5;
                                                            simpleMarkerSymbol.Style   = esriSimpleMarkerStyle.esriSMSCircle;

                                                            foreach (IPoint pt in listPt)
                                                            {
                                                                try
                                                                {
                                                                    IMarkerElement pMarkerElement = new MarkerElementClass();
                                                                    pMarkerElement.Symbol = simpleMarkerSymbol;
                                                                    IElement pElement = pMarkerElement as IElement;
                                                                    pElement.Geometry = pt;
                                                                    pGC.AddElement(pElement, 0);
                                                                }
                                                                catch (System.Exception ex)
                                                                {
                                                                    continue;
                                                                }
                                                            }
                                                        }

                                                        app.Current2DMapControl.ActiveView.Refresh();
                                                    }
                                                    else
                                                    {
                                                        WaitForm.Stop();
                                                        XtraMessageBox.Show("两点不连通!", "提示");
                                                        pGC.DeleteAllElements();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (haveone)
                                {
                                    break;
                                }
                            }
                            if (haveone)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                XtraMessageBox.Show("分析出错!", "提示");
            }
            finally
            {
                WaitForm.Stop();
            }
        }
        private DataTable DoStats()
        {
            DataTable dtResult = new DataTable();

            dtResult.TableName = "DataStats";
            dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"),
                                                         new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) });


            string localDataPath = SystemInfo.Instance.LocalDataPath;
            string tmpPath       = "";

            tmpPath = Path.Combine(localDataPath, "Stats");
            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }
            string filePath = tmpPath + "\\全库2D管线统计.xml";
            bool   bHaveXml = false;

            if (File.Exists(filePath))
            {
                dtResult.ReadXml(filePath);
                if (dtResult != null && dtResult.Rows.Count != 0)
                {
                    bHaveXml = true;
                    return(dtResult);
                }
                else
                {
                    bHaveXml = false;
                }
            }
            List <MajorClass> list = LogicDataStructureManage2D.Instance.GetAllMajorClass();

            foreach (MajorClass mc in list)
            {
                string[] arrFc2DId = mc.Fc2D.Split(';');
                if (arrFc2DId == null)
                {
                    continue;
                }
                double majorclasslength = 0.0;
                int    indexStart       = dtResult.Rows.Count;
                double subclasslength   = 0.0;
                foreach (SubClass sc in mc.SubClasses)
                {
                    foreach (string fc2DId in arrFc2DId)
                    {
                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                        if (dffc == null)
                        {
                            continue;
                        }
                        FacilityClass facc = dffc.GetFacilityClass();
                        IFeatureClass fc   = dffc.GetFeatureClass();
                        if (fc == null || facc == null || facc.Name != "PipeLine")
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength2D");
                        if (fiPipeLength == null)
                        {
                            continue;
                        }
                        int indexPipeLength = fc.FindField(fiPipeLength.Name);
                        if (indexPipeLength == -1)
                        {
                            continue;
                        }
                        IField fcfi = fc.Fields.get_Field(indexPipeLength);
                        switch (fcfi.Type)
                        {
                        case esriFieldType.esriFieldTypeBlob:
                        case esriFieldType.esriFieldTypeGeometry:
                        case esriFieldType.esriFieldTypeRaster:
                            continue;
                        }
                        IQueryFilter filter = new QueryFilter();
                        filter.SubFields   = fcfi.Name;
                        filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";
                        IFeatureCursor pFeatureCursor = null;
                        IFeature       pFeature       = null;
                        double         subfieldlength = 0.0;
                        bool           bHave          = false;
                        #region
                        try
                        {
                            pFeatureCursor = fc.Search(filter, true);
                            while ((pFeature = pFeatureCursor.NextFeature()) != null)
                            {
                                object tempobj = pFeature.get_Value(indexPipeLength);
                                double dtemp   = 0.0;
                                if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp))
                                {
                                    bHave           = true;
                                    subfieldlength += dtemp;
                                }
                            }
                        }


                        catch { }
                        finally
                        {
                            if (pFeatureCursor != null)
                            {
                                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                                pFeatureCursor = null;
                            }
                            if (pFeature != null)
                            {
                                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature);
                                pFeature = null;
                            }
                        }
                        #endregion
                        if (bHave)
                        {
                            DataRow dr = dtResult.NewRow();
                            dr["PIPELINETYPE"] = mc;
                            dr["FIELDNAME"]    = "";
                            dr["PVALUE"]       = sc;
                            subclasslength    += subfieldlength;
                            dr["LENGTH"]       = subfieldlength.ToString("0.00");
                            dtResult.Rows.Add(dr);
                        }
                    }
                }
                int indexEnd = dtResult.Rows.Count;
                for (int i = indexStart; i < indexEnd; i++)
                {
                    DataRow dr = dtResult.Rows[i];
                    dr["TOTALLENGTH"] = subclasslength.ToString("0.00");
                }
            }
            if (!bHaveXml)
            {
                dtResult.WriteXml(filePath);
            }
            return(dtResult);
        }
Exemplo n.º 23
0
        public override void Run(object sender, EventArgs e)
        {
            int            i = 0, k;
            string         strDicValue;
            string         strPntID;
            IFeatureClass  Pntfc;
            IFeatureClass  Arcfc;
            IFeatureCursor pFeaCursor;
            IQueryFilter   pFilter = new QueryFilterClass();
            IFeature       pFea;

            string[] arrFc2DId;

            mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
            if (mapView == null)
            {
                return;
            }
            bool bBind = mapView.Bind(this);

            if (!bBind)
            {
                return;
            }
            app = (DF2DApplication)this.Hook;
            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pMapControl = app.Current2DMapControl;
            frmSelType frmType = new frmSelType();

            if (frmType.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    List <DF2DFeatureClass> pPntlist = new List <DF2DFeatureClass>();
                    List <DF2DFeatureClass> pArclist = new List <DF2DFeatureClass>();

                    m_arrPipeType = frmType.PipeType;
                    for (i = 0; i < m_arrPipeType.Count; i++)
                    {
                        MajorClass mc = m_arrPipeType[i] as MajorClass;
                        arrFc2DId = mc.Fc2D.Split(';');
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        foreach (string fc2DId in arrFc2DId)
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            IFeatureClass fc = dffc.GetFeatureClass();
                            if (fc == null)
                            {
                                continue;
                            }
                            if (dffc.GetFacilityClassName() == "PipeNode")
                            {
                                pPntlist.Add(dffc);
                                continue;
                            }
                            if (dffc.GetFacilityClassName() == "PipeLine")
                            {
                                pArclist.Add(dffc);
                                continue;
                            }
                        }
                    }
                    if ((pPntlist == null) || (pArclist == null))
                    {
                        return;
                    }
                    Dictionary <IFeatureClass, DataTable> dict = new Dictionary <IFeatureClass, DataTable>();
                    WaitForm.Start("开始数据一致性检查..", "请稍候");
                    int count = 0;
                    foreach (DF2DFeatureClass Pntdfcc in pPntlist)
                    {
                        DataTable        dt      = GetDataTableByStruture();
                        DF2DFeatureClass Arcdfcc = pArclist[count];
                        Pntfc = Pntdfcc.GetFeatureClass();
                        Arcfc = Arcdfcc.GetFeatureClass();
                        if (Pntfc == null && Arcfc == null)
                        {
                            return;
                        }
                        WaitForm.SetCaption("正在检查图层:" + " " + Pntfc.AliasName);
                        FacilityClass fac = Pntdfcc.GetFacilityClass();
                        if (fac == null)
                        {
                            continue;
                        }
                        FacilityClass facc = Arcdfcc.GetFacilityClass();
                        if (facc == null)
                        {
                            continue;
                        }
                        //List<DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                        DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("LinkType");
                        if (fi == null)
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fi1 = fac.GetFieldInfoBySystemName("Detectid");
                        if (fi1 == null)
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fi2 = facc.GetFieldInfoBySystemName("StartNo");
                        if (fi2 == null)
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fi3 = facc.GetFieldInfoBySystemName("EndNo");
                        if (fi3 == null)
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fi4 = fac.GetFieldInfoBySystemName("UState");
                        if (fi4 == null)
                        {
                            continue;
                        }
                        //                 DFDataConfig.Class.FieldInfo fi5 = facc.GetFieldInfoBySystemName("source");
                        //                 if (fi5 == null) continue;
                        pFeaCursor = Pntfc.Search(null, true);

                        while ((pFea = pFeaCursor.NextFeature()) != null)
                        {
                            bool b1 = false, b2 = false;

                            strPntID    = pFea.get_Value(Pntfc.FindField(fi1.Name)).ToString();
                            strDicValue = pFea.get_Value(Pntfc.FindField(fi.Name)).ToString();


                            if (strDicValue == "三通" || strDicValue == "三分支")
                            {
                                k = 3;
                            }
                            else if (strDicValue == "四通" || strDicValue == "四分支")
                            {
                                k = 4;
                            }
                            else if (strDicValue == "五通" || strDicValue == "五分支")
                            {
                                k = 5;
                            }
                            else if (strDicValue == "六通" || strDicValue == "六分支")
                            {
                                k = 6;
                            }
                            else if (strDicValue == "七通" || strDicValue == "七分支")
                            {
                                k = 7;
                            }
                            else if (strDicValue == "八通" || strDicValue == "八分支")
                            {
                                k = 8;
                            }
                            else
                            {
                                k = 2;
                            }
                            pFilter.WhereClause = fi2.Name + " = '" + strPntID + "' or " + fi3.Name + " = '" + strPntID + "'";
                            if (Arcfc.FeatureCount(pFilter) != k)
                            {
                                b1 = true;
                            }
                            if (Pntfc.FindField(fi4.Name) != -1 && Arcfc.FindField(fi4.Name) != -1)
                            {
                                pFilter.WhereClause = "(" + fi2.Name + " = '" + strPntID + "' or " + fi3.Name + " = '" + strPntID + "') and " + fi4.Name + " <> '" + strDicValue + "'";
                                if (Arcfc.FeatureCount(pFilter) > 0)
                                {
                                    b2 = true;
                                }
                            }



                            DataRow dr = dt.NewRow();
                            dr["ErrorFeatureID"] = pFea.OID;
                            dr["FeatureofClass"] = Pntfc.AliasName;
                            dr["FeatureofLayer"] = (Pntfc as IDataset).Name;
                            dr["FeatureClass"]   = Pntfc;

                            if (b1 && b2)
                            {
                                dr["ErrorType"] = "多通多分支与管点连接管线数量不一致;管点与相连接管线的使用状态不一致";
                            }
                            else if (b1 && !b2)
                            {
                                dr["ErrorType"] = "多通多分支与管点连接管线数量不一致";
                            }
                            else if (!b1 && b2)
                            {
                                dr["ErrorType"] = "管点与相连接管线的使用状态不一致";
                            }
                            dt.Rows.Add(dr);
                            //Console.WriteLine(pFea.OID + " " + Pntfc.AliasName);
                        }

                        if (dt.Rows.Count > 0)
                        {
                            dict[Pntfc] = dt;
                        }
                        count++;
                    }
                    WaitForm.Stop();
                    FormCheckResult dlg = new FormCheckResult(dict, m_pMapControl);
                    dlg.Text = this.CommandName;
                    dlg.Show();
                }
                catch (System.Exception ex)
                {
                }
            }
        }
Exemplo n.º 24
0
        private DataTable DoStats()
        {
            DataTable dtResult = new DataTable();

            dtResult.TableName = "DataStats";
            dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"),
                                                         new DataColumn("NUMBER", typeof(long)), new DataColumn("TOTALNUMBER", typeof(long)) });

            string localDataPath = SystemInfo.Instance.LocalDataPath;
            string tmpPath       = "";

            tmpPath = Path.Combine(localDataPath, "Stats");
            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }
            string filePath = tmpPath + "\\全库2D管点统计.xml";
            bool   bHaveXml = false;

            if (File.Exists(filePath))
            {
                dtResult.ReadXml(filePath);
                if (dtResult != null && dtResult.Rows.Count != 0)
                {
                    bHaveXml = true;
                    return(dtResult);
                }
                else
                {
                    bHaveXml = false;
                }
            }
            List <MajorClass> list = LogicDataStructureManage2D.Instance.GetAllMajorClass();

            foreach (MajorClass mc in list)
            {
                string[] arrFc2DId = mc.Fc2D.Split(';');
                if (arrFc2DId == null)
                {
                    continue;
                }
                long majorclasscount = 0;
                int  indexStart      = dtResult.Rows.Count;
                foreach (SubClass sc in mc.SubClasses)
                {
                    long sccount = 0;
                    bool bHave   = false;
                    foreach (string fc2DId in arrFc2DId)
                    {
                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                        if (dffc == null)
                        {
                            continue;
                        }
                        FacilityClass facc = dffc.GetFacilityClass();
                        IFeatureClass fc   = dffc.GetFeatureClass();
                        if (fc == null || facc == null || facc.Name != "PipeNode")
                        {
                            continue;
                        }
                        IQueryFilter filter = new QueryFilter();
                        filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";

                        int count = fc.FeatureCount(filter);
                        if (count == 0)
                        {
                            continue;
                        }
                        bHave    = true;
                        sccount += count;
                    }
                    if (bHave)
                    {
                        DataRow dr = dtResult.NewRow();
                        dr["PIPENODETYPE"] = mc;
                        dr["FIELDNAME"]    = "";
                        dr["PVALUE"]       = sc;
                        dr["NUMBER"]       = sccount;
                        majorclasscount   += sccount;
                        dtResult.Rows.Add(dr);
                    }
                }
                int indexEnd = dtResult.Rows.Count;
                for (int i = indexStart; i < indexEnd; i++)
                {
                    DataRow dr = dtResult.Rows[i];
                    dr["TOTALNUMBER"] = majorclasscount;
                }
            }
            if (!bHaveXml)
            {
                dtResult.WriteXml(filePath);
            }
            return(dtResult);
        }
Exemplo n.º 25
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IActiveView    m_ActiveView = app.Current2DMapControl.ActiveView;
            IScreenDisplay m_Display    = app.Current2DMapControl.ActiveView.ScreenDisplay;
            IGeometry      pGeo         = null;

            try
            {
                if (button == 1)
                {
                    ISimpleLineSymbol pLineSym = new SimpleLineSymbol();
                    IRgbColor         pColor   = new RgbColorClass();
                    pColor.Red     = 255;
                    pColor.Green   = 255;
                    pColor.Blue    = 0;
                    pLineSym.Color = pColor;
                    pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
                    pLineSym.Width = 2;
                    IRubberBand pRubberBand;
                    pRubberBand = new RubberLineClass();
                    IGeometry pLine = pRubberBand.TrackNew(m_Display, null);

                    object symbol = pLineSym as object;
                    app.Current2DMapControl.DrawShape(pLine, ref symbol);


                    if ((pLine as IPolyline).Length > 500)
                    {
                        XtraMessageBox.Show("横断面线超过500米,分析效率很低,请重新绘制", "提示");
                        return;
                    }
                    WaitForm.Start("正在进行横断面分析...", "请稍后");
                    pGeo = pLine;
                    if (pGeo == null)
                    {
                        return;
                    }

                    string          road1          = "";
                    string          road2          = "";
                    bool            bAlert         = false;
                    double          hmax           = double.MinValue;
                    double          hmin           = double.MaxValue;
                    List <PPLine2D> pplines        = new List <PPLine2D>();
                    IFeatureCursor  pFeatureCursor = null;
                    IFeature        pFeature       = null;

                    foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())
                    {
                        foreach (SubClass sc in mc.SubClasses)
                        {
                            if (!sc.Visible2D)
                            {
                                continue;
                            }
                            string[] arrFc2DId = mc.Fc2D.Split(';');
                            if (arrFc2DId == null)
                            {
                                continue;
                            }
                            foreach (string fc2DId in arrFc2DId)
                            {
                                DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                if (dffc == null)
                                {
                                    continue;
                                }
                                IFeatureClass fc = dffc.GetFeatureClass();
                                if (fc == null)
                                {
                                    continue;
                                }
                                FacilityClass facc = dffc.GetFacilityClass();
                                if (facc.Name != "PipeLine")
                                {
                                    continue;
                                }

                                //查找管径长宽字段,获得该要素类下字段索引值,若为圆管,则长宽相等
                                DFDataConfig.Class.FieldInfo fiDia  = facc.GetFieldInfoBySystemName("Diameter");
                                DFDataConfig.Class.FieldInfo fiDia1 = facc.GetFieldInfoBySystemName("Diameter1");
                                DFDataConfig.Class.FieldInfo fiDia2 = facc.GetFieldInfoBySystemName("Diameter2");
                                int indexDia       = fc.Fields.FindField(fiDia.Name);
                                int indexDiaWith   = fc.Fields.FindField(fiDia1.Name);
                                int indexDiaHeight = fc.Fields.FindField(fiDia2.Name);
                                if (indexDiaWith == -1 || indexDiaHeight == -1 || indexDia == -1)
                                {
                                    continue;
                                }
                                //查找道路字段索引
                                DFDataConfig.Class.FieldInfo fiRoad = facc.GetFieldInfoBySystemName("Road");
                                int indexRoad = fc.Fields.FindField(fiRoad.Name);
                                //查找管线高类别索引
                                DFDataConfig.Class.FieldInfo fiHLB = facc.GetFieldInfoBySystemName("HLB");
                                int indexHLB = fc.Fields.FindField(fiHLB.Name);
                                //二级分类名索引
                                int indexClassify = fc.Fields.FindField(mc.ClassifyField);

                                ISpatialFilter pSpatialFilter = new SpatialFilter();
                                pSpatialFilter.Geometry    = pGeo;
                                pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                pSpatialFilter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";
                                int count = fc.FeatureCount(pSpatialFilter);
                                if (count == 0)
                                {
                                    continue;
                                }
                                pFeatureCursor = fc.Search(pSpatialFilter, true);
                                while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                {
                                    if (indexRoad != -1)
                                    {
                                        if (road2 == "")
                                        {
                                            road1 = pFeature.get_Value(indexRoad).ToString();
                                            road2 = pFeature.get_Value(indexRoad).ToString();
                                        }
                                        else
                                        {
                                            road1 = pFeature.get_Value(indexRoad).ToString();
                                            if (road1 != road2)
                                            {
                                                if (!bAlert)
                                                {
                                                    XtraMessageBox.Show("横断面线跨越多条道路,当前只绘制在【" + road2 + "】上的管线横断面图。", "提示");
                                                    bAlert = true;
                                                }
                                                continue;
                                            }
                                        }
                                    }
                                    //查找管线的起点终点地面高
                                    double startSurfHeight = double.MaxValue;
                                    double endSurfHeight   = double.MaxValue;
                                    DFDataConfig.Class.FieldInfo fiStartSurfHeight = facc.GetFieldInfoBySystemName("StartSurfH");
                                    if (fiStartSurfHeight == null)
                                    {
                                        continue;
                                    }
                                    int indexStartSurfHeight = pFeature.Fields.FindField(fiStartSurfHeight.Name);
                                    if (indexStartSurfHeight == -1)
                                    {
                                        continue;
                                    }

                                    DFDataConfig.Class.FieldInfo fiEndSurfHeight = facc.GetFieldInfoBySystemName("EndSurfH");
                                    if (fiEndSurfHeight == null)
                                    {
                                        continue;
                                    }
                                    int indexEndSurfHeight = pFeature.Fields.FindField(fiEndSurfHeight.Name);
                                    if (indexEndSurfHeight == -1)
                                    {
                                        continue;
                                    }

                                    //若管线属性地面高字段为null,则从DEM取值
                                    if (pFeature.get_Value(indexStartSurfHeight).ToString() == "" || pFeature.get_Value(indexEndSurfHeight).ToString() == "")
                                    {
                                        startSurfHeight = ReadDemRaster.GetH((pFeature.Shape as IPolyline).FromPoint);
                                        endSurfHeight   = ReadDemRaster.GetH((pFeature.Shape as IPolyline).ToPoint);
                                    }
                                    else
                                    {
                                        startSurfHeight = Convert.ToDouble(pFeature.get_Value(indexStartSurfHeight).ToString());
                                        endSurfHeight   = Convert.ToDouble(pFeature.get_Value(indexEndSurfHeight).ToString());
                                    }

                                    //查找管线起点高程和终点高程
                                    double startDepthHeight = double.MaxValue;
                                    double endDepthHeight   = double.MaxValue;
                                    DFDataConfig.Class.FieldInfo fiStartDepthHeight = facc.GetFieldInfoBySystemName("StartHeight2D");
                                    if (fiStartDepthHeight == null)
                                    {
                                        continue;
                                    }
                                    int indexStartDepthHeight = pFeature.Fields.FindField(fiStartDepthHeight.Name);
                                    if (indexStartDepthHeight == -1)
                                    {
                                        continue;
                                    }

                                    DFDataConfig.Class.FieldInfo fiEndDepthHeight = facc.GetFieldInfoBySystemName("EndHeight");
                                    if (fiEndDepthHeight == null)
                                    {
                                        continue;
                                    }
                                    int indexEndDepthHeight = pFeature.Fields.FindField(fiEndDepthHeight.Name);
                                    if (indexEndDepthHeight == -1)
                                    {
                                        continue;
                                    }
                                    startDepthHeight = Convert.ToDouble(pFeature.get_Value(indexStartDepthHeight).ToString());
                                    endDepthHeight   = Convert.ToDouble(pFeature.get_Value(indexEndDepthHeight).ToString());


                                    //计算管线和断面的交点
                                    IGeometry            ppGeo        = pFeature.Shape;
                                    ITopologicalOperator pTopo        = ppGeo as ITopologicalOperator;
                                    IGeometry            geoIntersect = pTopo.Intersect(pGeo, esriGeometryDimension.esriGeometry0Dimension);
                                    if (geoIntersect == null)
                                    {
                                        continue;
                                    }
                                    PPLine2D ppline = new PPLine2D();
                                    if (indexClassify == -1)
                                    {
                                        ppline.facType = mc.Name;
                                    }
                                    else
                                    {
                                        ppline.facType = pFeature.get_Value(indexClassify).ToString();
                                    }
                                    //查找管线的管径,判断其是方管还是圆管
                                    string diameter  = pFeature.get_Value(indexDia).ToString();
                                    string diameter1 = pFeature.get_Value(indexDiaWith).ToString();
                                    string diameter2 = pFeature.get_Value(indexDiaHeight).ToString();

                                    if (diameter.Trim() == "")
                                    {
                                        continue;
                                    }
                                    ppline.dia = diameter;
                                    int indexSplit = diameter.IndexOf('*');
                                    if (indexSplit != -1)
                                    {
                                        ppline.isrect = true;
                                        int  iDia1;
                                        bool bDia1 = int.TryParse(diameter.Substring(0, indexSplit), out iDia1);
                                        if (!bDia1)
                                        {
                                            continue;
                                        }
                                        int  iDia2;
                                        bool bDia2 = int.TryParse(diameter.Substring(indexSplit + 1, diameter.Length - indexSplit - 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)
                                    {
                                        string strhlb = pFeature.get_Value(indexHLB).ToString();
                                        if (strhlb.Contains("内"))
                                        {
                                            hlb = 1;
                                        }
                                        else if (strhlb.Contains("外"))
                                        {
                                            hlb = -1;
                                        }
                                        else
                                        {
                                            hlb = 0;
                                        }
                                        ppline.hlb = hlb;
                                    }
                                    #region  交点为一个
                                    if (geoIntersect.GeometryType == esriGeometryType.esriGeometryPoint)
                                    {
                                        IPolyline polyline    = pFeature.Shape as IPolyline;
                                        IPoint    ptIntersect = geoIntersect as IPoint;
                                        ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y);
                                        ppline.clh        = GetInterPointHeight(ptIntersect, polyline, startDepthHeight, endDepthHeight);
                                        if (ppline.clh > hmax)
                                        {
                                            hmax = ppline.clh;
                                        }
                                        if (ppline.clh < hmin)
                                        {
                                            hmin = ppline.clh;
                                        }
                                        ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight)
                                                     * Math.Sqrt((polyline.FromPoint.X - ptIntersect.X) * (polyline.FromPoint.X - ptIntersect.X)
                                                                 + (polyline.FromPoint.Y - ptIntersect.Y) * (polyline.FromPoint.Y - ptIntersect.Y)) / polyline.Length;
                                        if (ppline.cgh > hmax)
                                        {
                                            hmax = ppline.cgh;
                                        }
                                        if (ppline.cgh < hmin)
                                        {
                                            hmin = ppline.cgh;
                                        }
                                        // 辅助画图
                                        IPolyline l = pGeo as IPolyline;
                                        ppline.startPt = new PPPoint(l.FromPoint.X, l.FromPoint.Y);
                                        pplines.Add(ppline);
                                    }

                                    #endregion
                                    #region  交点为多个
                                    else if (geoIntersect.GeometryType == esriGeometryType.esriGeometryMultipoint)
                                    {
                                        IPolyline        polyline = pFeature.Shape as IPolyline;
                                        IPointCollection geoCol   = geoIntersect as IPointCollection;
                                        for (int i = 0; i < geoCol.PointCount; i++)
                                        {
                                            IPoint ptIntersect = geoCol.get_Point(i);
                                            ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y);
                                            ppline.clh        = GetInterPointHeight(ptIntersect, polyline, startDepthHeight, endDepthHeight);
                                            if (ppline.clh > hmax)
                                            {
                                                hmax = ppline.clh;
                                            }
                                            if (ppline.clh < hmin)
                                            {
                                                hmin = ppline.clh;
                                            }
                                            ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight)
                                                         * Math.Sqrt((polyline.FromPoint.X - ptIntersect.X) * (polyline.FromPoint.X - ptIntersect.X)
                                                                     + (polyline.FromPoint.Y - ptIntersect.Y) * (polyline.FromPoint.Y - ptIntersect.Y)) / polyline.Length;
                                            if (ppline.cgh > hmax)
                                            {
                                                hmax = ppline.cgh;
                                            }
                                            if (ppline.cgh < hmin)
                                            {
                                                hmin = ppline.cgh;
                                            }
                                            // 辅助画图
                                            IPolyline l = pGeo as IPolyline;
                                            ppline.startPt = new PPPoint(l.FromPoint.X, l.FromPoint.Y);
                                            pplines.Add(ppline);
                                        }
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                    WaitForm.Stop();
                    if (pplines.Count < 2)
                    {
                        XtraMessageBox.Show("相交管线少于2个", "提示");
                        return;
                    }
                    pplines.Sort(new PPLineCompare2D());
                    double spacesum = 0.0;
                    for (int i = 1; i < pplines.Count; i++)
                    {
                        PPLine2D line1 = pplines[i - 1];
                        PPLine2D 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
            {
                WaitForm.Stop();
            }
        }
        private Dictionary <string, List <IFeature> > GetPipeLines(IGeometry geo)
        {
            IFeatureCursor cursor  = null;
            IFeature       feature = null;
            Dictionary <string, List <IFeature> > dict = new Dictionary <string, List <IFeature> >();

            try
            {
                foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass()) //对所有二级大类进行遍历
                {
                    string[] arrFc2DId = mc.Fc2D.Split(';');                                      //将二级大类所对应的要素类ID转换为数组
                    if (arrFc2DId == null)
                    {
                        continue;
                    }
                    List <IFeature> lines = new List <IFeature>();
                    bool            bHave = false;
                    foreach (SubClass sc in mc.SubClasses)//对当前二级大类的子类进行遍历
                    {
                        if (!sc.Visible2D)
                        {
                            continue;
                        }
                        foreach (string fc2DId in arrFc2DId)                                                      //遍历二级子类所对应的要素类ID
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC
                            if (dffc == null)
                            {
                                continue;
                            }
                            FacilityClass facc = dffc.GetFacilityClass(); //得到设施类
                            IFeatureClass fc   = dffc.GetFeatureClass();  //得到要素类
                            if (fc == null || facc == null || facc.Name != "PipeLine")
                            {
                                continue;
                            }
                            //DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName(sysName);
                            //if (fi == null) return null ;
                            //this.diameter = fi.Name;
                            ISpatialFilter filter = new SpatialFilter();
                            filter.Geometry = geo;
                            //filter.WhereClause = sc.Parent.ClassifyField + " =  '" + sc.Name + "'";
                            //filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc).Substring(0, UpOrDown.DecorateWhereClasuse(fc).Length - 4);
                            filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;//选择过滤的空间条件
                            if (fc == null || geo == null)
                            {
                                return(null);
                            }
                            cursor = fc.Search(filter, false);
                            while ((feature = cursor.NextFeature()) != null)
                            {
                                if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                {
                                    lines.Add(feature);
                                }
                            }

                            bHave          = true;
                            dict[mc.Alias] = lines;
                            break;
                        }
                        if (bHave)
                        {
                            break;
                        }
                    }
                }
                return(dict);
            }
            catch (System.Exception ex)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (feature != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(feature);
                    feature = null;
                }
            }
        }
Exemplo n.º 27
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            IGraphicsContainer pGC = m_ActiveView.GraphicsContainer;

            if (this.m_ActiveView.FocusMap.FeatureSelection != null)
            {
                this.m_ActiveView.FocusMap.ClearSelection();
            }
            bool ready = false;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IGeometry pGeo      = null;
            int       preCount  = 0;
            int       nextCount = 0;

            try
            {
                if (button == 1)
                {
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    ready = true;
                    if (ready)
                    {
                        bool haveone = false;
                        foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        {
                            if (haveone)
                            {
                                break;
                            }
                            foreach (MajorClass mc in lg.MajorClasses)
                            {
                                if (haveone)
                                {
                                    break;
                                }
                                string[] arrFc2DId = mc.Fc2D.Split(';');
                                if (arrFc2DId == null)
                                {
                                    continue;
                                }
                                IFeatureCursor pFeatureCursor = null;
                                IFeature       pFeature       = null;
                                //DFDataConfig.Class.FieldInfo fi;
                                //int indexFusu = 0;
                                ////string nodefcId = null;
                                foreach (SubClass sc in mc.SubClasses)
                                {
                                    if (haveone)
                                    {
                                        break;
                                    }
                                    if (!sc.Visible2D)
                                    {
                                        continue;
                                    }
                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        if (facc.Name != "PipeLine")
                                        {
                                            continue;
                                        }
                                        ISpatialFilter pSpatialFilter = new SpatialFilter();
                                        pSpatialFilter.Geometry   = pGeo;
                                        pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                        pFeatureCursor            = fc.Search(pSpatialFilter, false);
                                        if (pFeatureCursor == null)
                                        {
                                            continue;
                                        }
                                        pFeature = pFeatureCursor.NextFeature();
                                        if (pFeature == null)
                                        {
                                            continue;
                                        }
                                        IGeometry pGeometry = pFeature.Shape as IGeometry;
                                        if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                                        {
                                            IPolyline pLine = pGeometry as IPolyline;
                                            this._EdgeFCID = fc.FeatureClassID.ToString();
                                            this._EdgeOID  = pFeature.OID;
                                            color          = GetRGBColor(0, 230, 240);
                                            IElement lineElement = LineElementRenderer(pLine, color);
                                            pGC.AddElement(lineElement, 0);
                                        }
                                        haveone = true;
                                        break;
                                    }

                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        IFeatureLayer fl   = dffc.GetFeatureLayer();
                                        if (fc == null || pGeo == null || fl == null)
                                        {
                                            continue;
                                        }
                                        if (!fl.Visible)
                                        {
                                            continue;
                                        }
                                        if (facc.Name != "PipeNode")
                                        {
                                            continue;
                                        }
                                        DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName("Additional");
                                        IFields fiCol     = fc.Fields;
                                        int     indexFusu = fiCol.FindField(fi.Name);

                                        WaitForm.Start("正在分析...", "请稍后");
                                        TopoClass2D tc = FacilityInfoService2D.GetTopoClassByFeatureClassID(fc2DId);
                                        if (tc == null)
                                        {
                                            WaitForm.Stop();
                                            return;
                                        }
                                        TopoNetwork net = tc.GetNetwork();
                                        if (net == null)
                                        {
                                            WaitForm.Stop();
                                            XtraMessageBox.Show("构建拓扑网络失败!", "提示");
                                            return;
                                        }
                                        else
                                        {
                                            HashSet <string> valveIds = new HashSet <string>();
                                            if (!string.IsNullOrEmpty(fc2DId) && ValveManager.Instance.Exists(fc2DId))
                                            {
                                                valveIds = ValveManager.Instance.GetValveIds(fc2DId);
                                            }
                                            else
                                            {
                                                IFeature feature;
                                                string   fusu;
                                                //IQueryFilter filter = new QueryFilter();

                                                //filter.WhereClause = fi.Name + " LIKE '%阀%'";
                                                IFeatureCursor cursor = fc.Search(null, false);
                                                int            n      = fc.FeatureCount(null);
                                                if (indexFusu == 0)
                                                {
                                                    return;
                                                }
                                                while ((feature = cursor.NextFeature()) != null)
                                                {
                                                    //valveIds.Add(fc2DId + "_" + feature.OID.ToString());
                                                    fusu = feature.get_Value(indexFusu).ToString();
                                                    if (fusu == "阀门" || fusu == "阀门井")
                                                    {
                                                        valveIds.Add(fc2DId + "_" + feature.OID.ToString());
                                                    }
                                                }
                                                ValveManager.Instance.Add(fc2DId, valveIds);
                                            }
                                            //string edgeID = this._EdgeFCID + "_" + this._EdgeOID.ToString();
                                            if (EdgeManager.Instance.Exists(this._EdgeFCID, this._EdgeOID.ToString()))
                                            {
                                                edge = EdgeManager.Instance.GetEdgeByID(this._EdgeFCID, this._EdgeOID.ToString());
                                            }
                                            preNode  = edge.PreNode;
                                            nextNode = edge.NextNode;
                                            HashSet <string> recordPre  = new HashSet <string>();
                                            HashSet <string> recordNext = new HashSet <string>();
                                            color = GetRGBColor(255, 0, 0);
                                            net.BGFX(preNode.ID, nextNode.ID, valveIds, ref recordPre, ref recordNext);
                                            if (recordPre.Count <= 0 && recordNext.Count <= 0)
                                            {
                                                continue;
                                            }
                                            preCount  = recordPre.Count;
                                            nextCount = recordNext.Count;
                                            foreach (string s in recordPre)
                                            {
                                                int  id;
                                                Node n = NodeManager.Instance.GetNodeByID(s);
                                                Int32.TryParse(n.FeatureId, out id);
                                                IFeature feature = fc.GetFeature(id);
                                                IPoint   point   = feature.Shape as IPoint;
                                                //color = GetRGBColor(255, 0, 0);
                                                IElement elementpPoint = PointElementRenderer(point, color);
                                                pGC.AddElement(elementpPoint, 0);

                                                IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color);
                                                pGC.AddElement(elementText, 1);
                                                app.Current2DMapControl.CenterAt(point);
                                            }
                                            foreach (string s in recordNext)
                                            {
                                                int  id;
                                                Node n = NodeManager.Instance.GetNodeByID(s);
                                                Int32.TryParse(n.FeatureId, out id);
                                                IFeature feature = fc.GetFeature(id);
                                                IPoint   point   = feature.Shape as IPoint;
                                                color = GetRGBColor(0, 0, 0);
                                                IElement elementpPoint = PointElementRenderer(point, color);
                                                pGC.AddElement(elementpPoint, 0);

                                                IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color);
                                                pGC.AddElement(elementText, 1);
                                                app.Current2DMapControl.CenterAt(point);
                                            }
                                            app.Current2DMapControl.MapScale = 500;
                                            app.Current2DMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                                        }
                                        if (haveone)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
            finally
            {
                WaitForm.Stop();
                XtraMessageBox.Show("上游需关闭阀门:" + preCount + "\n下游需关闭阀门:" + nextCount, "提示");
                SuspendCommand();
            }
        }
Exemplo n.º 28
0
 public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
 {
     try
     {
         IRubberBand band = new RubberRectangularPolygonClass();
         IGeometry   pGeo = band.TrackNew(m_Display, null);
         if (pGeo.IsEmpty)
         {
             IPoint searchPoint = new PointClass();
             searchPoint.PutCoords(mapX, mapY);
             pGeo = DF2DPipe.Class.PublicFunction.DoBuffer(searchPoint, DF2DPipe.Class.PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
             //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
         }
         WaitForm.Start("正在查询,请稍后...");
         foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
         {
             foreach (MajorClass mc in lg.MajorClasses)
             {
                 foreach (SubClass sc in mc.SubClasses)
                 {
                     if (!sc.Visible2D)
                     {
                         continue;
                     }
                     string[] arrFc2DId = mc.Fc2D.Split(';');
                     if (arrFc2DId == null)
                     {
                         continue;
                     }
                     IFeatureCursor pFeatureCursor = null;
                     IFeature       pFeature       = null;
                     foreach (string fc2DId in arrFc2DId)
                     {
                         DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                         if (dffc == null)
                         {
                             continue;
                         }
                         IFeatureClass fc   = dffc.GetFeatureClass();
                         FacilityClass facc = dffc.GetFacilityClass();
                         if (facc.Name != "PipeNode")
                         {
                             continue;
                         }
                         if (fc == null || pGeo == null)
                         {
                             continue;
                         }
                         ISpatialFilter pSpatialFilter = new SpatialFilter();
                         pSpatialFilter.Geometry   = pGeo;
                         pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                         pFeatureCursor            = fc.Search(pSpatialFilter, false);
                         if (pFeatureCursor == null)
                         {
                             continue;
                         }
                         while ((pFeature = pFeatureCursor.NextFeature()) != null)
                         {
                             IPoint pPoint  = (IPoint)pFeature.Shape;
                             string strText = "X:" + pPoint.Y.ToString("F2") + "\n" + "Y:" + pPoint.X.ToString("F2");
                             AddCallout(pPoint, strText);
                         }
                     }
                 }
             }
         }
         app.Current2DMapControl.ActiveView.Refresh();
         WaitForm.Stop();
     }
     catch (System.Exception ex)
     {
         WaitForm.Stop();
     }
 }
Exemplo n.º 29
0
        private DataTable RegionAnalysis(IGeometry geo)
        {
            DataTable dtResult = new DataTable();

            dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"),
                                                         new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) });//初始化统计用数据表的列

            dtstats = new DataTable();
            dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"),
                                                        new DataColumn("LENGTH", typeof(double)) }); //初始化生成统计图表用数据表的列
            foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())        //对所有二级大类进行遍历
            {
                string[] arrFc2DId = mc.Fc2D.Split(';');                                             //将二级大类所对应的要素类ID转换为数组
                if (arrFc2DId == null)
                {
                    continue;
                }
                double majorclasslength = 0.0;
                int    indexStart       = dtResult.Rows.Count; //获得数据表当前的行数
                double subclasslength   = 0.0;
                foreach (SubClass sc in mc.SubClasses)         //对当前二级大类的子类进行遍历
                {
                    if (!sc.Visible2D)
                    {
                        continue;
                    }
                    double subfieldlength = 0.0;
                    bool   bHave          = false;

                    foreach (string fc2DId in arrFc2DId)                                                      //遍历二级子类所对应的要素类ID
                    {
                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC
                        if (dffc == null)
                        {
                            continue;
                        }
                        FacilityClass facc = dffc.GetFacilityClass(); //得到设施类
                        IFeatureClass fc   = dffc.GetFeatureClass();  //得到要素类
                        if (fc == null || facc == null || facc.Name != "PipeLine")
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength2D");//得到设施类的管线长度字段
                        if (fiPipeLength == null)
                        {
                            continue;
                        }

                        IFields pFields         = fc.Fields;                            //得到要素类字段集
                        int     indexPipeLength = pFields.FindField(fiPipeLength.Name); //根据管线长度字段名得到要素类管线长度字段的索引
                        if (indexPipeLength < 0)
                        {
                            continue;
                        }
                        IField         pField = pFields.get_Field(indexPipeLength); //根据管线长度字段索引得到管线长度字段
                        ISpatialFilter filter = new SpatialFilter();                //初始化空间过滤类
                        filter.Geometry    = geo;
                        filter.SubFields   = pField.Name;
                        filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";
                        filter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;//选择过滤的空间条件
                        if (fc == null || geo == null)
                        {
                            return(null);
                        }

                        IFeatureCursor pFeatureCursor = null;
                        IFeature       pFeature       = null;
                        try
                        {
                            pFeatureCursor = fc.Search(filter, false);//获得过滤结果的游标

                            while ((pFeature = pFeatureCursor.NextFeature()) != null)
                            {
                                object tempobj = pFeature.get_Value(indexPipeLength);                  //获得当前要素管线长度字段的值
                                double dtemp   = 0.0;
                                if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp)) //将管线长度转换为double
                                {
                                    bHave           = true;
                                    subfieldlength += dtemp;//累加到当前二级子类总长度
                                }
                            }
                        }
                        catch { }
                        finally
                        {
                            if (pFeatureCursor != null)
                            {
                                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                                pFeatureCursor = null;
                            }
                            if (pFeature != null)
                            {
                                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature);
                                pFeature = null;
                            }
                        }
                        if (bHave)
                        {
                            DataRow dr = dtResult.NewRow();//将对应数据填写到统计用数据表的新行
                            dr["PIPELINETYPE"] = mc;
                            dr["FIELDNAME"]    = "";
                            dr["PVALUE"]       = sc;
                            subclasslength    += subfieldlength;
                            dr["LENGTH"]       = subfieldlength.ToString("0.00");
                            dtResult.Rows.Add(dr);

                            DataRow dr1 = dtstats.NewRow();//将对应数据填写到统计图表用数据表的新行
                            dr1["PIPELINETYPE"] = mc;
                            dr1["FIELDNAME"]    = sc;
                            dr1["LENGTH"]       = subfieldlength.ToString("0.00");
                            dtstats.Rows.Add(dr1);
                        }
                    }
                }
                int indexEnd = dtResult.Rows.Count;
                for (int i = indexStart; i < indexEnd; i++)
                {
                    DataRow dr = dtResult.Rows[i];
                    dr["TOTALLENGTH"] = subclasslength.ToString("0.00");
                }
            }
            return(dtResult);
        }
Exemplo n.º 30
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            IScreenDisplay pScr = m_pActiveView.ScreenDisplay;
            //跟踪画线
            IRubberBand pRB = new RubberLineClass();

            m_pGeoTrack = pRB.TrackNew(pScr, null);
            if ((m_pGeoTrack as IPointCollection).PointCount != 2)
            {
                XtraMessageBox.Show("请使用鼠标制定两点确定扯旗的管线");
                return;
            }
            Element.DeleteElement(m_pActiveView.GraphicsContainer, "cq");
            Element.AddGraphics(m_pActiveView.GraphicsContainer, m_pGeoTrack, GetDefaultSymbol(esriGeometryType.esriGeometryPolyline), "dmx");
            IElement pElement = Element.GetElementByName(m_pMapControl.ActiveView.GraphicsContainer, "cq");

            if (pElement != null)
            {
                m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }

            IFeature             pFeature;
            IGeometry            pGeo;
            IGeometry            pPipeLineGeo;
            IFeatureClass        pFeatureClass;
            IFeatureCursor       pFeaCur;
            ITopologicalOperator pTopo;
            string classify   = "";
            string startNo    = "";
            string endNo      = "";
            string material   = "";
            string coverstyle = "";
            string diameter   = "";
            string road       = "";
            double distance;

            m_IntersectPipes = new List <IntersectPipe>();



            string[] sysFields = new string[] { "Classify", "StartNo", "EndNo", "Material", "CoverStyle", "Diameter", "Road" };
            string[] fields    = new string[] { "类别", "起点号", "终点号", "材质", "埋设方式", "管径", "所在道路" };
            try
            {
                foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())
                {
                    WaitForm.Start("正在查询...", "请稍后");
                    string[] arrFc2DId = mc.Fc2D.Split(';');//将二级大类所对应的要素类ID转换为数组
                    if (arrFc2DId == null)
                    {
                        continue;
                    }

                    foreach (SubClass sc in mc.SubClasses)
                    {
                        if (!sc.Visible2D)
                        {
                            continue;
                        }
                        foreach (string fc2DId in arrFc2DId)                                                      //遍历二级子类所对应的要素类ID
                        {
                            DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC
                            if (dffc == null)
                            {
                                continue;
                            }
                            FacilityClass fcc = dffc.GetFacilityClass();
                            if (fcc.Name != "PipeLine")
                            {
                                continue;
                            }
                            IFeatureLayer fl = dffc.GetFeatureLayer();

                            ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                            pSpatialFilter.Geometry    = m_pGeoTrack;
                            pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                            pSpatialFilter.WhereClause = "SMSCODE =  '" + sc.Name + "'";
                            IFeatureClass fc = dffc.GetFeatureClass();
                            pFeaCur = fc.Search(pSpatialFilter, false);
                            while ((pFeature = pFeaCur.NextFeature()) != null)
                            {
                                foreach (string field in sysFields)
                                {
                                    DFDataConfig.Class.FieldInfo fi = fcc.GetFieldInfoBySystemName(field);
                                    if (fi == null)
                                    {
                                        continue;
                                    }
                                    int    index = fc.Fields.FindField(fi.Name);
                                    object obj   = pFeature.get_Value(index);
                                    switch (field)
                                    {
                                    case "Classify":
                                        classify = obj.ToString();
                                        break;

                                    case "StartNo":
                                        startNo = obj.ToString();
                                        break;

                                    case "EndNo":
                                        endNo = obj.ToString();
                                        break;

                                    case "Material":
                                        material = obj.ToString();
                                        break;

                                    case "CoverStyle":
                                        coverstyle = obj.ToString();
                                        break;

                                    case "Diameter":
                                        diameter = obj.ToString();
                                        break;

                                    case "Road":
                                        road = obj.ToString();
                                        break;
                                    }
                                }
                                IPolyline            pline    = m_pGeoTrack as IPolyline;
                                IPoint               point1   = pline.ToPoint;
                                ITopologicalOperator topo     = pFeature.Shape as ITopologicalOperator;
                                IGeometry            geo      = topo.Intersect(m_pGeoTrack, esriGeometryDimension.esriGeometry0Dimension);
                                IPointCollection     pointCol = geo as IPointCollection;
                                IPoint               point2   = pointCol.get_Point(pointCol.PointCount - 1);
                                distance = GetDistanceOfTwoPoints(point1, point2);
                                IntersectPipe interPipe = new IntersectPipe(pFeature, fl, distance, classify, startNo, endNo, material, coverstyle, diameter, road);
                                m_IntersectPipes.Add(interPipe);
                            }
                        }
                    }
                }
                if (m_IntersectPipes.Count == 0)
                {
                    return;
                }
                List <IntersectPipe> orderList = m_IntersectPipes.OrderBy(i => i.Distance).ToList <IntersectPipe>();
                DrawPipeLabels();

                int n = 0;
                foreach (IntersectPipe interPipe in orderList)
                {
                    WaitForm.SetCaption("正在输出属性,请稍后...");
                    DrawPipeInfo(interPipe, n);
                    ++n;
                }
                WaitForm.Stop();
            }
            catch (System.Exception ex)
            {
                WaitForm.Stop();
            }
        }