Exemplo n.º 1
0
        private void GetArrPipe()
        {
            //Load_LyrLstToArray();
            IFeature             pFeature;
            IGeometry            pGeo;
            IGeometry            pPipeLineGeo;
            IFeatureClass        pFeatureClass;
            IFeatureCursor       pFeaCur;
            ITopologicalOperator pTopo;

            m_pArrLineLayers.Clear();
            m_pArrIntersectPnt.Clear();
            m_pArrPipes.Clear();
            string scName = "";

            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();
                        m_pArrLineLayers.Add(fl);

                        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)
                        {
                            m_pArrPipes.Add(pFeature);
                        }
                    }
                }
            }
            //根据交点的X坐标,将管线排序
            double           t;
            IFeature         f;
            IPointCollection p;

            double[] sortX = new double[m_pArrIntersectPnt.Count];
            for (int k = 0; k < m_pArrIntersectPnt.Count; k++)
            {
                p        = m_pArrIntersectPnt[k] as IPointCollection;
                sortX[k] = p.get_Point(0).X;
            }
            for (int j = sortX.Length - 1; j > 0; j--)
            {
                for (int i = 0; i < j; i++)
                {
                    if (sortX[i] > sortX[i + 1])
                    {
                        t            = sortX[i];
                        sortX[i]     = sortX[i + 1];
                        sortX[i + 1] = t;

                        f = m_pArrPipes[i] as IFeature;
                        m_pArrPipes[i]     = m_pArrPipes[i + 1];
                        m_pArrPipes[i + 1] = f;
                    }
                }
            }
        }
Exemplo n.º 2
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.º 3
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();
            }
        }
Exemplo n.º 4
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();
     }
 }
        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.º 6
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.º 7
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.º 8
0
        private void DataArcCheck()
        {
            //管线线表数据规范性检查
            int            i, j, k;
            string         strFld;
            string         strDicValue;
            IFeatureClass  pFeaClass;
            IFeatureCursor pFeaCursor;
            IQueryFilter   pFilter = new QueryFilterClass();
            //Dictionary<IFeatureClass, DataTable> dict = new Dictionary<IFeatureClass, DataTable>();
            IFeature pFea;

            string[] arrFc2DId;
            List <DF2DFeatureClass> List = new List <DF2DFeatureClass>();

            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 || dffc.GetFacilityClassName() != "PipeLine")
                    {
                        continue;
                    }
                    IFeatureClass fc = dffc.GetFeatureClass();
                    if (fc == null)
                    {
                        continue;
                    }
                    //if (fc.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                    //{
                    List.Add(dffc);
                    //}
                }
            }

            //List<DF2DFeatureClass> List = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine");
            if (List == null)
            {
                return;
            }
            WaitForm.Start("开始检查..", "请稍后");
            foreach (DF2DFeatureClass dfcc in List)
            {
                bool   b1 = false, b2 = false, b3 = false, b4 = false;
                string strPipeClass;
                pFeaClass = dfcc.GetFeatureClass();
                if (pFeaClass == null)
                {
                    continue;
                }
                WaitForm.SetCaption("正在检查:" + pFeaClass.AliasName);
                FacilityClass fac = dfcc.GetFacilityClass();
                if (fac == null)
                {
                    continue;
                }
                List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                DFDataConfig.Class.FieldInfo        fi        = fac.GetFieldInfoBySystemName("StartHeight2D");
                if (fi == null)
                {
                    continue;
                }
                DFDataConfig.Class.FieldInfo fi1 = fac.GetFieldInfoBySystemName("EndHeight");
                if (fi1 == null)
                {
                    continue;
                }
                DFDataConfig.Class.FieldInfo fi2 = fac.GetFieldInfoBySystemName("StartDep");
                if (fi2 == null)
                {
                    continue;
                }
                DFDataConfig.Class.FieldInfo fi3 = fac.GetFieldInfoBySystemName("EndDep");
                if (fi3 == null)
                {
                    continue;
                }
                DFDataConfig.Class.FieldInfo fi4 = fac.GetFieldInfoBySystemName("CoverStyle");
                if (fi4 == null)
                {
                    continue;
                }
                DFDataConfig.Class.FieldInfo fi5 = fac.GetFieldInfoBySystemName("Diameter");
                if (fi5 == null)
                {
                    continue;
                }
                if (pFeaClass.AliasName.Contains("燃气"))
                {
                    strPipeClass = "BP";
                }
                else if (pFeaClass.AliasName.Contains("下水"))
                {
                    strPipeClass = "DP";
                }
                else if (pFeaClass.AliasName.Contains("电力"))
                {
                    strPipeClass = "EP";
                }
                else if (pFeaClass.AliasName.Contains("上水") || pFeaClass.AliasName.Contains("给水"))
                {
                    strPipeClass = "FP";
                }
                else if (pFeaClass.AliasName.Contains("热力"))
                {
                    strPipeClass = "HP";
                }
                else if (pFeaClass.AliasName.Contains("通信"))
                {
                    strPipeClass = "TP";
                }
                else if (pFeaClass.AliasName.Contains("工业"))
                {
                    strPipeClass = "IOP";
                }
                else
                {
                    strPipeClass = "";
                }
                //数据字典字段值检查
                DataTable dt = GetDataTableByStruture();
                //遍历字段
                for (j = 0; j < ArcField.Length; j++)
                {
                    if (fac.GetFieldInfoBySystemName(ArcField[j]) == null)
                    {
                        continue;
                    }
                    //获取数据字典中的对应值
                    strFld      = fac.GetFieldInfoNameBySystemName(ArcField[j]);
                    strDicValue = GetValueFromDictionary(strPipeClass, strFld);

                    if (strDicValue != "空")
                    {
                        if (strDicValue.Contains(","))
                        {
                            string   strWhere = "(";
                            string[] s        = strDicValue.Split(new char[] { ',' });
                            for (k = 0; k < s.Length; k++)
                            {
                                strWhere += "'" + s[k] + "',";
                            }
                            strWhere.Remove(strWhere.LastIndexOf(","));
                            strWhere           += ")";
                            pFilter.WhereClause = strFld + " not in" + strWhere;
                        }
                        else
                        {
                            pFilter.WhereClause = strFld + "<>'" + strDicValue + "'";
                        }

                        pFeaCursor = pFeaClass.Search(pFilter, true);
                        while ((pFea = pFeaCursor.NextFeature()) != null)
                        {
                            DataRow dr = dt.NewRow();
                            dr["ErrorFeatureID"] = pFea.OID;
                            dr["FeatureofClass"] = pFeaClass.AliasName;
                            dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                            dr["FeatureClass"]   = pFeaClass;
                            dr["ErrorType"]      = "【" + strFld + "】字段值不属于数据字典";
                            dt.Rows.Add(dr);
                            //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
                    }
                    //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;
                }
                //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;

                pFilter.WhereClause = fi.Name + "= -999 or " + fi1.Name + "= -999";
                pFeaCursor          = pFeaClass.Search(pFilter, true);
                while ((pFea = pFeaCursor.NextFeature()) != null)
                {
                    DataRow dr = dt.NewRow();
                    dr["ErrorFeatureID"] = pFea.OID;
                    dr["FeatureofClass"] = pFeaClass.AliasName;
                    dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                    dr["ErrorType"]      = "【管线高程】字段值不能为-999";
                    dr["FeatureClass"]   = pFeaClass;
                    dt.Rows.Add(dr);
                    //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
                //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;

                //管线埋深(只针对管线,管点不需要检查)
                if (strPipeClass == "BP")
                {
                    pFilter.WhereClause = "(" + fi2.Name + "< 0 or " + fi2.Name + "> 3) or (" + fi3.Name + "< 0 or " + fi3.Name + "> 3)";
                    pFeaCursor          = pFeaClass.Search(pFilter, true);
                    while ((pFea = pFeaCursor.NextFeature()) != null)
                    {
                        DataRow dr = dt.NewRow();
                        dr["ErrorFeatureID"] = pFea.OID;
                        dr["FeatureofClass"] = pFeaClass.AliasName;
                        dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                        dr["FeatureClass"]   = pFeaClass;
                        dr["ErrorType"]      = "【管线埋深】字段值不在规范值范围内";
                        dt.Rows.Add(dr);
                        //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
                    //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;
                }
                else
                {
                    //'直埋', '管埋', '管块'
                    pFilter.WhereClause = fi4.Name + " in ('直埋','管埋','管块') and (" + fi2.Name + "< 0 or " + fi2.Name + "> 10) or (" + fi3.Name + "< 0 or " + fi3.Name + "> 10)";
                    pFeaCursor          = pFeaClass.Search(pFilter, true);
                    while ((pFea = pFeaCursor.NextFeature()) != null)
                    {
                        DataRow dr = dt.NewRow();
                        dr["ErrorFeatureID"] = pFea.OID;
                        dr["FeatureofClass"] = pFeaClass.AliasName;
                        dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                        dr["FeatureClass"]   = pFeaClass;
                        dr["ErrorType"]      = "【管线埋深】字段值不在规范值范围内";
                        dt.Rows.Add(dr);
                        //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
                    //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;
                }
                //'架空'

                pFilter.WhereClause = fi4.Name + "='架空' and (" + fi2.Name + ">0 or " + fi3.Name + ">0)";
                pFeaCursor          = pFeaClass.Search(pFilter, true);
                while ((pFea = pFeaCursor.NextFeature()) != null)
                {
                    DataRow dr = dt.NewRow();
                    dr["ErrorFeatureID"] = pFea.OID;
                    dr["FeatureofClass"] = pFeaClass.AliasName;
                    dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                    dr["FeatureClass"]   = pFeaClass;
                    dr["ErrorType"]      = "【管线埋深】字段值不在规范值范围内";
                    dt.Rows.Add(dr);
                    //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
                //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;

                pFilter.WhereClause = fi4.Name + "='管沟'";
                pFeaCursor          = pFeaClass.Search(pFilter, true);
                while ((pFea = pFeaCursor.NextFeature()) != null)
                {
                    string s = pFea.get_Value(pFeaClass.FindField(fi5.Name)).ToString();
                    if (s.Contains("*"))
                    {
                        if (s.Contains("*"))
                        {
                            double d  = Convert.ToDouble(s.Substring(s.IndexOf("*") + 1));
                            double d1 = Convert.ToDouble(pFea.get_Value(pFeaClass.FindField(fi2.Name)).ToString());
                            double d2 = Convert.ToDouble(pFea.get_Value(pFeaClass.FindField(fi3.Name)).ToString());
                            if (d1 < d || d2 < d)
                            {
                                DataRow dr = dt.NewRow();
                                dr["ErrorFeatureID"] = pFea.OID;
                                dr["FeatureofClass"] = pFeaClass.AliasName;
                                dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                                dr["FeatureClass"]   = pFeaClass;
                                dr["ErrorType"]      = "【管线埋深】字段值不在规范值范围内";
                                dt.Rows.Add(dr);
                                //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                            }
                        }
                    }
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
                //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;

                //管径
                if (strPipeClass == "BP" || strPipeClass == "FP")
                {
                    pFilter.WhereClause = "ISNUMERIC(" + fi5.Name + ")=1";
                }
                else
                {
                    //直埋、管埋
                    pFilter.WhereClause = fi4.Name + " in ('直埋','管埋') and " + "ISNUMERIC(" + fi5.Name + ")=1";
                    pFeaCursor          = pFeaClass.Search(pFilter, true);
                    while ((pFea = pFeaCursor.NextFeature()) != null)
                    {
                        DataRow dr = dt.NewRow();
                        dr["ErrorFeatureID"] = pFea.OID;
                        dr["FeatureofClass"] = pFeaClass.AliasName;
                        dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                        dr["FeatureClass"]   = pFeaClass;
                        dr["ErrorType"]      = "【管线规格】字段值不在规范值范围内";
                        dt.Rows.Add(dr);
                        //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                    }

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
                    //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;
                }

                pFilter.WhereClause = fi4.Name + " in ('管块','管沟') and " + fi5.Name + " like '%*%'";
                pFeaCursor          = pFeaClass.Search(pFilter, true);
                while ((pFea = pFeaCursor.NextFeature()) != null)
                {
                    DataRow dr = dt.NewRow();
                    dr["ErrorFeatureID"] = pFea.OID;
                    dr["FeatureofClass"] = pFeaClass.AliasName;
                    dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                    dr["FeatureClass"]   = pFeaClass;
                    dr["ErrorType"]      = "【管线规格】字段值不在规范值范围内";
                    dt.Rows.Add(dr);
                    //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);

                dt = ReturnMergeData(dt);
                if (dt.Rows.Count > 0)
                {
                    dict[pFeaClass] = dt;
                }
            }
        }
Exemplo n.º 9
0
        public DataTable DoQuery(DF2DFeatureClass dffc, IGeometry pGeo)
        {
            List <int>       intlist        = new List <int>();
            DataTable        dt             = new DataTable();
            IFeatureClass    fc             = dffc.GetFeatureClass();
            FacilityClass    fac            = dffc.GetFacilityClass();
            List <FieldInfo> ficol          = fac.FieldInfoCollection;
            ISpatialFilter   pSpatialFilter = new SpatialFilterClass();

            pSpatialFilter.Geometry   = pGeo;
            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureCursor featureCursor = fc.Search(pSpatialFilter, false);
            IFeature       pfeature      = featureCursor.NextFeature();

            if (fc == null || pfeature == null)
            {
                return(null);
            }

            for (int i = 0; i < fc.Fields.FieldCount; i++)
            {
                IField pField = fc.Fields.get_Field(i);
                foreach (FieldInfo f in ficol)
                {
                    if (pField.Name == f.Name && f.CanQuery)
                    {
                        DataColumn dc = new DataColumn(pField.AliasName, Type.GetType("System.String"));

                        intlist.Add(i);
                        //pfname.Add(pField.Name);
                        dt.Columns.Add(dc);
                    }
                }
            }
            while (pfeature != null)
            {
                if (dt.Columns.Count > 0 && intlist.Count == dt.Columns.Count)
                {
                    DataRow dr = dt.NewRow();
                    string  str;

                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        //int index = pfeature.Fields.FindField(pfname[i]);
                        if (pfeature.get_Value(intlist[i]) == null)
                        {
                            continue;
                        }
                        else
                        {
                            str = pfeature.get_Value(intlist[i]).ToString();
                        }
                        dr[dt.Columns[i].ColumnName] = str;
                    }
                    dt.Rows.Add(dr);
                }



                pfeature = featureCursor.NextFeature();
            }
            return(dt);
        }
        private void DoQuery()
        {
            List <TreeListNode> list = this.treelist.GetAllCheckedNodes();

            if (list == null)
            {
                XtraMessageBox.Show("请勾选图层树。", "提示");
                return;
            }
            string widemax   = this.spWMax.Text;
            string widemin   = this.spWMin.Text;
            string heightmax = this.spHMax.Text;
            string heightmin = this.spHMin.Text;

            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;
                    }
                    IFeature       pFeature      = null;
                    IFeatureCursor pFeatureCusor = null;
                    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 != this._facType)
                        {
                            continue;
                        }

                        DFDataConfig.Class.FieldInfo fi1 = facc.GetFieldInfoBySystemName("Diameter1");
                        DFDataConfig.Class.FieldInfo fi2 = facc.GetFieldInfoBySystemName("Diameter2");
                        if (fi1 == null || fi2 == null)
                        {
                            continue;
                        }
                        int index1 = fc.Fields.FindField(fi1.Name);
                        int index2 = fc.Fields.FindField(fi2.Name);
                        if (index1 == -1 || index2 == -1)
                        {
                            continue;
                        }

                        string clause = "";
                        if (heightmax == "" || heightmin == "")
                        {
                            clause += fi1.Name + " <= " + widemax + " and " + fi1.Name + " >= " + widemin;
                        }
                        else if (widemax == "" || widemin == "")
                        {
                            clause += '(' + fi2.Name + " <= " + heightmax + " and " + fi2.Name + " >= " + heightmin + " and " + fi2.Name + " > " + "0" + ')' + " or " + '(' + fi1.Name + " <= " + heightmax + " and " + fi1.Name + " >= " + heightmin + " and " + fi2.Name + " = " + "0" + ')';
                        }
                        else
                        {
                            clause += '(' + fi1.Name + " <= " + widemax + " and " + fi1.Name + " >= " + widemin + ')' + " and " + '(' + '(' + fi2.Name + " <= " + heightmax + " and " + fi2.Name + " >= " + heightmin + " and " + fi2.Name + " > " + "0" + ')' + " or " + '(' + fi1.Name + " <= " + heightmax + " and " + fi1.Name + " >= " + heightmin + " and " + fi2.Name + " = " + "0" + ')' + ')';
                        }
                        clause = clause.Substring(0, clause.Length);
                        string whereClause = classifyField + "='" + sc.Name + "'" + " and ( " + clause + " )";

                        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 index = pFeature.Fields.FindField(col.ColumnName);
                                if (index < 0)
                                {
                                    continue;
                                }
                                object obj1 = pFeature.get_Value(index);
                                string str  = "";
                                if (obj1 != null)
                                {
                                    IField field = pFeature.Fields.get_Field(index);
                                    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;
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        private void DataPntCheck()
        {
            //管线点表数据规范性检查

            int            i, j, k;
            string         strFld;
            string         strDicValue;
            IFeatureClass  pFeaClass;
            IFeatureCursor pFeaCursor;
            IQueryFilter   pFilter = new QueryFilterClass();
            IFeature       pFea;

            string[] arrFc2DId;

            //Dictionary<IFeatureClass, DataTable> dict = new Dictionary<IFeatureClass, DataTable>();

            List <DF2DFeatureClass> list = new List <DF2DFeatureClass>();

            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 || dffc.GetFacilityClassName() != "PipeNode")
                    {
                        continue;
                    }
                    IFeatureClass fc = dffc.GetFeatureClass();
                    if (fc == null)
                    {
                        continue;
                    }
                    //if (fc.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
                    //{
                    list.Add(dffc);
                    //}
                }
            }

            //List<DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode");
            if (list == null)
            {
                return;
            }
            WaitForm.Start("开始数据规范性检查..", "请稍候");
            foreach (DF2DFeatureClass dfcc in list)
            {
                bool   b1 = false, b2 = false, b3 = false, b4 = false;
                string strPipeClass;
                pFeaClass = dfcc.GetFeatureClass();
                if (pFeaClass == null)
                {
                    continue;
                }
                WaitForm.SetCaption("正在检查图层:" + " " + pFeaClass.AliasName);
                FacilityClass fac = dfcc.GetFacilityClass();
                if (fac == null)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("SurfHeight2D");
                if (fi == null)
                {
                    continue;
                }
                DFDataConfig.Class.FieldInfo fi1 = fac.GetFieldInfoBySystemName("WellDep");
                if (fi1 == null)
                {
                    continue;
                }
                DFDataConfig.Class.FieldInfo fi2 = fac.GetFieldInfoBySystemName("Additional");
                if (fi2 == null)
                {
                    continue;
                }

                if (pFeaClass.AliasName.Contains("燃气"))
                {
                    strPipeClass = "BP";
                }
                else if (pFeaClass.AliasName.Contains("下水"))
                {
                    strPipeClass = "DP";
                }
                else if (pFeaClass.AliasName.Contains("电力"))
                {
                    strPipeClass = "EP";
                }
                else if (pFeaClass.AliasName.Contains("上水"))
                {
                    strPipeClass = "FP";
                }
                else if (pFeaClass.AliasName.Contains("热力"))
                {
                    strPipeClass = "HP";
                }
                else if (pFeaClass.AliasName.Contains("通信"))
                {
                    strPipeClass = "TP";
                }
                else if (pFeaClass.AliasName.Contains("工业"))
                {
                    strPipeClass = "IOP";
                }
                else
                {
                    strPipeClass = "";
                }
                // 数据字典字段值检查
                DataTable dt = GetDataTableByStruture();

                //遍历字段
                for (j = 0; j < PntField.Length; j++)
                {
                    if (fac.GetFieldInfoBySystemName(PntField[j]) == null)
                    {
                        continue;
                    }

                    //获取数据字典中的对应值
                    strFld      = fac.GetFieldInfoNameBySystemName(PntField[j]);
                    strDicValue = GetValueFromDictionary(strPipeClass, strFld);

                    if (strDicValue != "空")
                    {
                        if (strDicValue.Contains(","))
                        {
                            string   strWhere = "(";
                            string[] s        = strDicValue.Split(new char[] { ',' });
                            for (k = 0; k < s.Length; k++)
                            {
                                strWhere += "'" + s[k] + "',";
                            }
                            strWhere.Remove(strWhere.LastIndexOf(","));
                            strWhere           += ")";
                            pFilter.WhereClause = strFld + " not in" + strWhere;
                        }
                        else
                        {
                            pFilter.WhereClause = strFld + "<>'" + strDicValue + "'";
                        }
                        pFeaCursor = pFeaClass.Search(pFilter, true);
                        pFea       = null;

                        while ((pFea = pFeaCursor.NextFeature()) != null)
                        {
                            b1 = true;
                            DataRow dr = dt.NewRow();
                            dr["ErrorFeatureID"] = pFea.OID;
                            dr["FeatureofClass"] = pFeaClass.AliasName;
                            dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                            dr["FeatureClass"]   = pFeaClass;
                            dr["ErrorType"]      = "【" + strFld + "】字段值不属于数据字典";
                            dt.Rows.Add(dr);
                            //Console.WriteLine(pFea.OID + " " + pFeaClass.AliasName);
                        }
                    }
                    if (dt.Rows.Count > 0)
                    {
                        dict[pFeaClass] = dt;
                    }
                }
                pFilter.WhereClause = fi.Name + "=-999";
                pFeaCursor          = pFeaClass.Search(pFilter, true);
                pFea = pFeaCursor.NextFeature();
                while (pFea != null)
                {
                    b2 = true;
                    DataRow dr = dt.NewRow();
                    dr["ErrorFeatureID"] = pFea.OID;
                    dr["FeatureofClass"] = pFeaClass.AliasName;
                    dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                    dr["FeatureClass"]   = pFeaClass;
                    dr["ErrorType"]      = "【地面高程】字段值不能为-999";
                    dt.Rows.Add(dr);
                    pFea = pFeaCursor.NextFeature();
                }

                //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;

                if (strPipeClass == "BP")
                {
                    pFilter.WhereClause = fi1.Name + "< 0 or " + fi1.Name + "> 3";
                }
                else if (strPipeClass == "IOP")
                {
                    pFilter.WhereClause = fi1.Name + "< 0 or " + fi1.Name + "> 5";
                }
                else
                {
                    pFilter.WhereClause = fi1.Name + "< 0 or " + fi1.Name + "> 10";
                }
                pFeaCursor = pFeaClass.Search(pFilter, true);
                while ((pFea = pFeaCursor.NextFeature()) != null)
                {
                    b3 = true;
                    DataRow dr = dt.NewRow();
                    dr["ErrorFeatureID"] = pFea.OID;
                    dr["FeatureofClass"] = pFeaClass.AliasName;
                    dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                    dr["FeatureClass"]   = pFeaClass;
                    dr["ErrorType"]      = "【井底深】字段值不在规范值范围内";
                    dt.Rows.Add(dr);
                }

                //if (dt.Rows.Count > 0) dict[pFeaClass] = dt;

                pFilter.WhereClause = fi2.Name + " in ('阀门井','水表井','消防井','水源井','净水池','检修井','清水池','雨水检修井','污水检修井','跌水井','雨水篦',"
                                      + "'测试井','人孔','手孔','排气井','凝水井','通风井') and len(" + fi1.Name + ")=0";

                pFeaCursor = pFeaClass.Search(pFilter, true);
                while ((pFea = pFeaCursor.NextFeature()) != null)
                {
                    b4 = true;
                    DataRow dr = dt.NewRow();
                    dr["ErrorFeatureID"] = pFea.OID;
                    dr["FeatureofClass"] = pFeaClass.AliasName;
                    dr["FeatureofLayer"] = (pFeaClass as IDataset).Name;
                    dr["FeatureClass"]   = pFeaClass;
                    dr["ErrorType"]      = "【井底深】字段值不应为空";
                    dt.Rows.Add(dr);
                }

                dt = ReturnMergeData(dt);
                if (dt.Rows.Count > 0)
                {
                    dict[pFeaClass] = dt;
                }
            }
        }
Exemplo n.º 12
0
        private void treeLayer_AfterCheckNode(object sender, NodeEventArgs e)
        {
            this.teValue.Text = "";
            this.listBoxControlValues.Items.Clear();
            this.selectFeatureClass.Clear();
            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;
                        selectFeatureClass.Add(dffc);
                        IFeatureClass fc  = dffc.GetFeatureClass();
                        FacilityClass fac = dffc.GetFacilityClass();
                        if (fc == null || fac == null)
                        {
                            continue;
                        }
                        //List<FieldInfo> list1 = dffc.GetFacilityClass().FieldInfoCollection;
                        //for (IField f in fc.Fields)
                        //{
                        //    foreach (FieldInfo fi in list1)
                        //    {
                        //        if (fi.Name = f.Name && fi.CanQuery)
                        //        {

                        //        }
                        //    }
                        //}

                        DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName(this._sysFieldName);
                        fieldName = fi.Name;
                        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();
                        }
                    }
                }
                if (list.Count > 0)
                {
                    foreach (string str2 in from v in list.Distinct <string>() orderby v select v)
                    {
                        if (!string.IsNullOrEmpty(str2))
                        {
                            this.listBoxControlValues.Items.Add(str2);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 13
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;
            IFeatureCursor pFeatureCursor = null;
            IFeature       pFeature       = 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;
                    }

                    WaitForm.Start("正在进行纵断面分析...", "请稍后");
                    string          road1   = "";
                    string          road2   = "";
                    bool            bAlert  = false;
                    double          hmax    = double.MinValue;
                    double          hmin    = double.MaxValue;
                    List <PPLine2D> pplines = new List <PPLine2D>();

                    bool haveone             = false;
                    List <MajorClass> listMC = LogicDataStructureManage2D.Instance.GetAllMajorClass();
                    foreach (MajorClass mc in listMC)
                    {
                        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;
                            }
                            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 = UpOrDown.DecorateWhereClasuse(fc) + sc.Parent.ClassifyField + " =  '" + sc.Name + "'";
                                pFeatureCursor             = fc.Search(pSpatialFilter, true);
                                if (pFeatureCursor == null)
                                {
                                    continue;
                                }
                                pFeature = pFeatureCursor.NextFeature();
                                if (pFeature == null)
                                {
                                    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);

                                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());


                                //查找管线的管径,判断其是方管还是圆管
                                string diameter  = pFeature.get_Value(indexDia).ToString();
                                string diameter1 = pFeature.get_Value(indexDiaWith).ToString();
                                string diameter2 = pFeature.get_Value(indexDiaHeight).ToString();

                                IPolyline pline      = pFeature.Shape as IPolyline;
                                IPoint    startpoint = pline.FromPoint;
                                IPoint    endpoint   = pline.ToPoint;
                                IPoint[]  points     = new IPoint[] { startpoint, endpoint };
                                for (int i = 0; i < points.Length; i++)
                                {
                                    PPLine2D ppline = new PPLine2D();
                                    if (indexClassify == -1)
                                    {
                                        ppline.facType = mc.Name;
                                    }
                                    else
                                    {
                                        ppline.facType = pFeature.get_Value(indexClassify).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 - indexDia - 1), out iDia2);
                                        if (!bDia2)
                                        {
                                            continue;
                                        }
                                        ppline.gj.Add(iDia1);
                                        ppline.gj.Add(iDia2);
                                    }
                                    else
                                    {
                                        ppline.isrect = false;
                                        int  iDia;
                                        bool bDia = int.TryParse(diameter, out iDia);
                                        if (!bDia)
                                        {
                                            continue;
                                        }
                                        ppline.gj.Add(iDia);
                                        ppline.gj.Add(iDia);
                                    }
                                    //判断管线高方式
                                    int hlb = 0;
                                    if (indexHLB != -1)
                                    {
                                        string strhlb = pFeature.get_Value(indexHLB).ToString();
                                        if (strhlb.Contains("内"))
                                        {
                                            hlb = 1;
                                        }
                                        else if (strhlb.Contains("外"))
                                        {
                                            hlb = -1;
                                        }
                                        else
                                        {
                                            hlb = 0;
                                        }
                                        ppline.hlb = hlb;
                                    }
                                    ppline.interPoint = new PPPoint(points[i].X, points[i].Y);
                                    if (i == 0)
                                    {
                                        ppline.clh = startDepthHeight;
                                        UpdateH(ppline.clh, ref hmax, ref hmin);
                                        ppline.cgh = startSurfHeight;
                                        UpdateH(ppline.cgh, ref hmax, ref hmin);
                                    }
                                    else
                                    {
                                        ppline.clh = endDepthHeight;
                                        UpdateH(ppline.clh, ref hmax, ref hmin);
                                        ppline.cgh = endSurfHeight;
                                        UpdateH(ppline.cgh, ref hmax, ref hmin);
                                    }
                                    // 辅助画图
                                    double deltaX = points[1].X - points[0].X;
                                    double deltaY = points[1].Y - points[0].Y;
                                    ppline.startPt = new PPPoint(points[0].X - deltaX, points[0].Y - deltaY);
                                    pplines.Add(ppline);
                                }
                            }
                        }
                    }
                    WaitForm.Stop();
                    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("纵断面分析结果", 1);
                    dialog.SetInfo(mapName, mapNum, pplines, hmax, hmin, spacesum, road2);
                    dialog.Show();
                }
            }
            catch (System.Exception ex)
            {
                WaitForm.Stop();
            }
            finally
            {
                if (pFeatureCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                    pFeatureCursor = null;
                }
                if (pFeature != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature);
                    pFeature = null;
                }
            }
        }
Exemplo n.º 14
0
        private void DoStats()
        {
            try
            {
                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();
                if (this.treelist.GetAllCheckedNodes() != null)
                {
                    long majorclasscount = 0;
                    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;
                            }
                            //if (sc.Name == "其他") continue;
                            string[] arrFc2DId = sc.Parent.Fc2D.Split(';');
                            if (arrFc2DId == null)
                            {
                                continue;
                            }


                            int indexStart = dtResult.Rows.Count;
                            int indexEnd   = dtResult.Rows.Count;

                            long sccount    = 0;
                            long valuecount = 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;
                                }
                                DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName(this._sysFieldName);
                                IQueryFilter filter             = new QueryFilter();
                                if (valuelist.Count <= 0)
                                {
                                    continue;
                                }
                                foreach (string strValue in valuelist)
                                {
                                    filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + sc.Parent.ClassifyField + " =  '" + sc.Name + "' and " + fi.Name + " = " + strValue;;
                                    int count = fc.FeatureCount(filter);
                                    if (count == 0)
                                    {
                                        continue;
                                    }
                                    bHave = true;

                                    if (bHave)
                                    {
                                        DataRow dr = dtResult.NewRow();
                                        dr["PIPENODETYPE"] = sc;
                                        dr["FIELDNAME"]    = "";
                                        dr["PVALUE"]       = strValue;
                                        dr["NUMBER"]       = count;
                                        sccount           += count;
                                        dtResult.Rows.Add(dr);
                                        bHave = false;

                                        DataRow dr1 = dtstats.NewRow();
                                        dr1["PIPENODETYPE"] = sc;
                                        dr1["FIELDNAME"]    = strValue;
                                        dr1["NUMBER"]       = count;
                                        dtstats.Rows.Add(dr1);
                                    }
                                }
                            }
                            majorclasscount += sccount;
                            indexEnd         = dtResult.Rows.Count;
                            for (int i = indexStart; i < indexEnd; i++)
                            {
                                DataRow dr = dtResult.Rows[i];
                                dr["TOTALNUMBER"] = sccount;
                            }
                        }
                    }
                    //for (int i = 0; i < dtResult.Rows.Count; i++)
                    //{
                    //    DataRow dr = dtResult.Rows[i];
                    //    dr["TOTALNUMBER"] = majorclasscount;
                    //}
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 15
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.º 16
0
        public DataTable DoQuery(string property, string propName, DF2DFeatureClass dffc)
        {
            DataTable    dt          = new DataTable();
            IQueryFilter queryFilter = new QueryFilterClass();
            List <int>   intlist     = new List <int>();
            //List<string> pfname = new List<string>();

            IFeatureClass    fc    = dffc.GetFeatureClass();
            FacilityClass    fac   = dffc.GetFacilityClass();
            List <FieldInfo> ficol = fac.FieldInfoCollection;

            //queryFilter.SubFields = prop;
            queryFilter.WhereClause = propName + "=" + "'" + property + "'";
            IFeatureCursor featureCursor = fc.Search(queryFilter, false);
            IFeature       pfeature      = featureCursor.NextFeature();

            if (fc == null || pfeature == null)
            {
                return(null);
            }

            for (int i = 0; i < fc.Fields.FieldCount; i++)
            {
                IField pField = fc.Fields.get_Field(i);
                foreach (FieldInfo f in ficol)
                {
                    if (pField.Name == f.Name && f.CanQuery)
                    {
                        DataColumn dc = new DataColumn(pField.AliasName, Type.GetType("System.String"));

                        intlist.Add(i);
                        //pfname.Add(pField.Name);
                        dt.Columns.Add(dc);
                    }
                }



                //DataRow dr = dt.NewRow();
                //dr[dc] = pfeature.get_Value(i).ToString();

                //DataRow dr = dt.NewRow();
                //dr[dc1] = pField.AliasName;
                //dr[dc2] = pfeature.get_Value(i);
                //dt.Rows.Add(dr);
            }

            while (pfeature != null)
            {
                if (dt.Columns.Count > 0 && intlist.Count == dt.Columns.Count)
                {
                    DataRow dr = dt.NewRow();
                    string  str;

                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        //int index = pfeature.Fields.FindField(pfname[i]);
                        if (pfeature.get_Value(intlist[i]) == null)
                        {
                            continue;
                        }
                        else
                        {
                            str = pfeature.get_Value(intlist[i]).ToString();
                        }
                        dr[dt.Columns[i].ColumnName] = str;
                    }
                    dt.Rows.Add(dr);
                }



                pfeature = featureCursor.NextFeature();
            }
            return(dt);
        }
        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.º 18
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            this._dict.Clear();
            bool ready = true;

            if (app == null || app.Current2DMapControl == null || app.Workbench == null)
            {
                return;
            }
            app.Workbench.SetMenuEnable(true);
            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;

                    //pColor = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16);
                    IRubberBand pRubberBand;
                    pRubberBand = new RubberLineClass();
                    IGeometry pLine;
                    pLine = pRubberBand.TrackNew(m_Display, null);
                    //IPolyline pLine = app.Current2DMapControl.TrackLine() as IPolyline;

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

                    WaitForm.Start("正在查询...", "请稍后");
                    //if (GlobalValue.System_Selection_Environment(m_ActiveView).CombinationMethod == 0)//new selection
                    //{
                    //    this.m_ActiveView.FocusMap.ClearSelection();
                    //}
                    pGeo = PublicFunction.DoBuffer(pLine,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    //m_ActiveView.FocusMap.SelectByShape(pGeo, GlobalValue.System_Selection_Environment(m_ActiveView), false);

                    //if (m_ActiveView.FocusMap.SelectionCount > 0)
                    //{

                    //    ready = true;
                    //    m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    //}
                    //else
                    //{
                    //    m_ActiveView.Refresh();
                    //}


                    if (ready)
                    {
                        //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        //{
                        foreach (MajorClass mc in FrmMajorClass.Instance.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;
                                    string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";

                                    pSpatialFilter.WhereClause = whereClause;
                                    pFeatureCursor             = fc.Search(pSpatialFilter, false);
                                    if (pFeatureCursor == null)
                                    {
                                        continue;
                                    }
                                    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 = pFeatureCursor.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.Add(sc.Name, dt);
                                    }
                                }
                            }
                        }
                    }
                }
                WaitForm.Stop();
                try
                {
                    this._uPanel               = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height);
                    this._dockPanel            = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right);
                    this._dockPanel.Visibility = DockVisibility.Visible;
                    this._dockPanel.FloatSize  = new System.Drawing.Size(this._width, this._height);
                    this._dockPanel.Width      = this._width;
                    this._dockPanel.Height     = this._height;
                    if (this._ucPropInfo2D == null)
                    {
                        this._ucPropInfo2D = new UCPropertyInfo2D();
                    }
                    this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill;
                    this._uPanel.RegisterEvent(new PanelClose(this.Close));
                    this._dockPanel.Controls.Add(this._ucPropInfo2D);
                    this._ucPropInfo2D.Init();
                    this._ucPropInfo2D.SetPropertyInfo(this._dict);
                }
                catch
                {
                }

                //}
            }
            catch
            {
            }
        }
        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);
        }
        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);
        }
        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.º 22
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;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 23
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();
            }
        }
Exemplo n.º 24
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.º 25
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();
            }
        }
Exemplo n.º 26
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.º 27
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.º 28
0
        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.Active    View.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)
            {
            }
        }
        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.º 30
0
        //程序检查
        private void DataIntegrityCheck()
        {
            int    i, j, n;
            string strFieldName;

            string[] arrFc2DId;
            object   val;
            IFeature pFea;
            //IFeatureClass pFeaClass;
            IFeatureCursor pCur;

            List <DF2DFeatureClass> listPnt = new List <DF2DFeatureClass>();
            List <DF2DFeatureClass> listArc = new List <DF2DFeatureClass>();

            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")
                    {
                        listPnt.Add(dffc);
                    }
                    if (dffc.GetFacilityClassName() == "PipeLine")
                    {
                        listArc.Add(dffc);
                    }
                }
            }
            //遍历所有点表检查
            if (m_arrPntField.Count > 0)
            {
                //List<DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode");
                if (listPnt == null)
                {
                    return;
                }
                WaitForm.Start("开始数据完整性检查..", "请稍候");
                foreach (DF2DFeatureClass dffc in listPnt)
                {
                    DataTable     dt = GetDataTableByStruture();
                    IFeatureClass fc = dffc.GetFeatureClass();
                    if (fc == null)
                    {
                        continue;
                    }
                    WaitForm.SetCaption("正在检查图层:" + " " + fc.AliasName);
                    pCur = fc.Search(null, true);
                    while ((pFea = pCur.NextFeature()) != null)
                    {
                        for (j = 0; j < m_arrPntField.Count; j++)
                        {
                            strFieldName = m_arrPntField[j].ToString();
                            if (fc.FindField(strFieldName) > 0)
                            {
                                val = pFea.get_Value(fc.FindField(strFieldName));
                                if (val.ToString() == "" || val == DBNull.Value)
                                {
                                    DataRow dr = dt.NewRow();
                                    dr["ErrorFeatureID"] = pFea.OID;
                                    dr["FeatureofClass"] = fc.AliasName;
                                    dr["FeatureofLayer"] = (fc as IDataset).Name;
                                    dr["FeatureClass"]   = fc;
                                    dr["ErrorType"]      = "【" + strFieldName + "】字段为空";
                                    dt.Rows.Add(dr);
                                }
                            }
                        }
                    }
                    if (dt.Rows.Count > 0)
                    {
                        dict[fc] = dt;
                    }
                }

                //if (dict.Count == 0)
                //{

                //    XtraMessageBox.Show("提示表格数据为空!");

                //}
            }

            //遍历所有线表检查
            if (m_arrArcField.Count > 0)
            {
                //List<DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine");
                if (listArc == null)
                {
                    return;
                }

                foreach (DF2DFeatureClass dfcc in listArc)
                {
                    DataTable     dt = GetDataTableByStruture();
                    IFeatureClass fc = dfcc.GetFeatureClass();
                    if (fc == null)
                    {
                        return;
                    }
                    WaitForm.SetCaption(fc.AliasName);
                    pCur = fc.Search(null, true);
                    while ((pFea = pCur.NextFeature()) != null)
                    {
                        for (j = 0; j < m_arrArcField.Count; j++)
                        {
                            strFieldName = m_arrArcField[j].ToString();
                            if (fc.FindField(strFieldName) > 0)
                            {
                                val = pFea.get_Value(fc.FindField(strFieldName));
                                if (val.ToString() == "" || val == DBNull.Value)
                                {
                                    DataRow dr = dt.NewRow();
                                    dr["ErrorFeatureID"] = pFea.OID;
                                    dr["FeatureofClass"] = fc.AliasName;
                                    dr["FeatureofLayer"] = (fc as IDataset).Name;
                                    dr["FeatureClass"]   = fc;
                                    dr["ErrorType"]      = "【" + strFieldName + "】字段为空";
                                    dt.Rows.Add(dr);
                                }
                            }
                        }
                    }
                    if (dt.Rows.Count > 0)
                    {
                        dict[fc] = dt;
                    }
                }

                //if (dict.Count == 0)
                //{

                //    XtraMessageBox.Show("提示表格数据为空!");

                //}
            }
        }