コード例 #1
0
        private void AddHField(IFeatureClass fc)
        {
            FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("GCD");

            DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Height");
            if (fi == null)
            {
                return;
            }

            int index = fc.FindField(fi.Name);

            if (index == -1)
            {
                IField     Field      = new FieldClass();
                IFieldEdit pFieldEdit = Field as IFieldEdit;
                pFieldEdit.Name_2 = "HEIGHT";
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                fc.AddField(Field);
            }
            else
            {
                return;
            }
        }
コード例 #2
0
        private void query()
        {
            if (this.cmbLayer.SelectedItem == null)
            {
                return;
            }
            DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass;
            IFeatureClass    fc   = dffc.GetFeatureClass();

            if (fc == null)
            {
                return;
            }
            ISpatialFilter filter = new SpatialFilter();

            #region
            if (this.cmbField.SelectedItem == null)
            {
                filter.WhereClause = "1=1";
            }
            else
            {
                if (this.cmbField.SelectedItem is DFDataConfig.Class.FieldInfo)
                {
                    DFDataConfig.Class.FieldInfo fi = this.cmbField.SelectedItem as DFDataConfig.Class.FieldInfo;
                    if (oper == " like ")
                    {
                        filter.WhereClause = fi.Name + " like '%" + this.teFieldValue.Text + "%'";
                    }
                    else
                    {
                        if (fi.DataType.ToLower() == "decimal")
                        {
                            filter.WhereClause = fi.Name + oper + this.teFieldValue.Text;
                        }
                        else
                        {
                            filter.WhereClause = fi.Name + oper + "'" + this.teFieldValue.Text + "'";
                        }
                    }
                }
                else
                {
                    filter.WhereClause = "1!=1";
                }
            }
            #endregion
            int count = fc.GetCount(filter);
            if (count == 0)
            {
                XtraMessageBox.Show("查询结果为空", "提示");
                return;
            }
            this._dffc        = dffc;
            this._filter      = filter;
            this._total       = count;
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
コード例 #3
0
 private void cbProperty_SelectedIndexChanged(object sender, EventArgs e)
 {
     this._sysFieldName = "";
     if (this.cbProperty.SelectedItem != null)
     {
         DFDataConfig.Class.FieldInfo fi = this.cbProperty.SelectedItem as DFDataConfig.Class.FieldInfo;
         this._sysFieldName = fi.SystemName;
     }
     treelist_AfterCheckNode(null, null);
 }
コード例 #4
0
        private IGeoDataset GetBeforeGeo(IFeatureClass fc, IGeometry geo)
        {
            try
            {
                WaitForm.SetCaption("正在生成栅格表面...");
                IInterpolationOp3 pInterpolationOp = new RasterInterpolationOpClass();

                IFields       fields            = fc.Fields;
                FacilityClass fac               = FacilityClassManager.Instance.GetFacilityClassByName("GCD");
                DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Altitude");
                if (fi == null)
                {
                    return(null);
                }

                int index = fields.FindField(fi.Name);
                if (index == -1)
                {
                    return(null);
                }
                IField field = fields.get_Field(index);

                ISpatialFilter filter = new SpatialFilter();
                filter.Geometry   = geo;
                filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                int count = fc.FeatureCount(filter);
                if (count == 0)
                {
                    return(null);
                }
                IFeatureClassDescriptor pFcd = new FeatureClassDescriptorClass();
                pFcd.Create(fc, filter, field.Name);

                //定义搜索半径
                IRasterRadius pRadius = new RasterRadiusClass();
                object        Missing = Type.Missing;
                pRadius.SetVariable(12, ref Missing);

                //设置栅格图像的单位大小
                object cellSizeProvider         = 5;
                IRasterAnalysisEnvironment pEnv = pInterpolationOp as IRasterAnalysisEnvironment;
                pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellSizeProvider);
                IGeoDataset outGeoDataset = pInterpolationOp.IDW(pFcd as IGeoDataset, 2, pRadius, ref Missing);
                return(outGeoDataset);
            }
            catch (System.Exception ex)
            {
                return(null);

                WaitForm.Stop();
            }
        }
コード例 #5
0
        public override void Run(object sender, EventArgs e)
        {
            List <DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode");

            if (list == null)
            {
                return;
            }
            foreach (DF2DFeatureClass dffc in list)
            {
                IFeatureClass fc = dffc.GetFeatureClass();
                if (fc.AliasName == "给水_点")
                {
                    FacilityClass fac = dffc.GetFacilityClass();
                    if (fac == null)
                    {
                        continue;
                    }
                    fi = fac.GetFieldInfoBySystemName("Additional");
                    break;
                }
            }
            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;
            m_FocusMap    = m_pMapControl.ActiveView.FocusMap;
            m_pActiveView = (IActiveView)this.m_FocusMap;
        }
コード例 #6
0
        private void ShowFlowDirect(IFeatureLayerPickResult pr)
        {
            if (pr == null)
            {
                return;
            }
            IRowBuffer row    = null;
            IFdeCursor cursor = null;

            try
            {
                int fid = pr.FeatureId;
                DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(pr.FeatureLayer.FeatureClassId.ToString());
                if (dffc == null)
                {
                    return;
                }
                IFeatureClass fc  = dffc.GetFeatureClass();
                FacilityClass fac = dffc.GetFacilityClass();
                if (fc == null || fac == null || fac.Name != "PipeLine")
                {
                    return;
                }
                DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("FlowDirect");
                if (fi == null)
                {
                    return;
                }
                IFieldInfoCollection fiCol = fc.GetFields();
                int index = fiCol.IndexOf(fi.Name);
                if (index == -1)
                {
                    return;
                }
                int indexShape = fiCol.IndexOf("Shape");

                IQueryFilter filter = new QueryFilter();
                filter.WhereClause = "oid=" + fid;
                cursor             = fc.Search(filter, false);
                row = cursor.NextRow();
                if (row == null)
                {
                    return;
                }

                IPolyline line = null;
                if (indexShape != -1 && !row.IsNull(indexShape))
                {
                    object obj = row.GetValue(indexShape);
                    if (obj != null && obj is IPolyline)
                    {
                        line = obj as IPolyline;
                    }
                }
                string flowDirectValue = "0";
                int    type            = 1;// 1表示具有流向字段;2表示从高到低
                if (!row.IsNull(index))
                {
                    flowDirectValue = row.GetValue(index).ToString();
                    if (flowDirectValue != "0" && flowDirectValue != "1")
                    {
                        flowDirectValue = "0";
                    }
                    type = 1;
                }
                else if (line != null)
                {
                    if (line.StartPoint.Z > line.EndPoint.Z)
                    {
                        flowDirectValue = "0";
                    }
                    else
                    {
                        flowDirectValue = "1";
                    }
                    type = 2;
                }
                if (line == null)
                {
                    return;
                }

                if (this._isAuth)
                {
                    #region 流向渲染1
                    FacClassReg reg = FacilityInfoService.GetFacClassRegByFeatureClassID(fc.Guid.ToString());
                    if (reg == null)
                    {
                        return;
                    }
                    TopoClass tc = FacilityInfoService.GetTopoClassByFacClassCode(reg.FacClassCode);
                    if (tc == null)
                    {
                        return;
                    }
                    FacStyleClass        style          = null;
                    List <FacStyleClass> facilityStyles = FacilityInfoService.GetFacStyleByFacClassCode(reg.FacClassCode);
                    if ((facilityStyles != null) && (facilityStyles.Count > 0))
                    {
                        style = facilityStyles[0];
                    }
                    PipeLineFac       plfac = new PipeLineFac(reg, style, row, tc);
                    IRenderModelPoint rmp   = null;
                    DrawGeometry.Ocx = DF3DApplication.Application.Current3DMapControl;
                    plfac.ShowFlowDirection(int.Parse(flowDirectValue), out rmp);
                    if (rmp != null)
                    {
                        this._listRender.Add(rmp.Guid);
                    }
                    #endregion
                }
                else
                {
                    #region 流向渲染2
                    IEulerAngle angle    = DF3DApplication.Application.Current3DMapControl.Camera.GetAimingAngles2(line.StartPoint, line.EndPoint);
                    double      dia      = 0.0;
                    string      diaField = fac.GetFieldInfoNameBySystemName("Diameter");
                    int         indexDia = fiCol.IndexOf(diaField);
                    if (indexDia != -1 && !row.IsNull(indexDia))
                    {
                        string diaStr    = row.GetValue(indexDia).ToString();
                        int    indexDia1 = diaStr.ToString().IndexOf('*');
                        if (indexDia1 != -1)
                        {
                            var dia1 = int.Parse(diaStr.ToString().Substring(0, indexDia1));
                            var dia2 = int.Parse(diaStr.ToString().Substring(indexDia1 + 1, diaStr.ToString().Length));
                            dia = ((dia1 > dia2) ? dia1 : dia2) * 0.001;
                        }
                        else
                        {
                            dia = int.Parse(diaStr) * 0.001;
                        }
                    }
                    List <IPoint> points = new List <IPoint>();
                    if (flowDirectValue == "0")
                    {
                        for (int i = 0; i < line.PointCount; i++)
                        {
                            IPoint pt = line.GetPoint(i);
                            pt.Z += dia / 2;
                            points.Add(pt);
                        }
                    }
                    else if (flowDirectValue == "1")
                    {
                        for (int i = line.PointCount - 1; i >= 0; i--)
                        {
                            IPoint pt = line.GetPoint(i);
                            pt.Z += dia / 2;
                            points.Add(pt);
                        }
                    }
                    for (int i = 0; i < points.Count - 1; i++)
                    {
                        IPoint pt1 = points[i];
                        var    pt2 = points[i + 1];

                        double delt = 0;
                        double _rate, _distance;
                        if (!(Math.Abs(dia) < 0.0000001))
                        {
                            delt = 2.0 * dia;
                            if (dia <= 0.5 && dia >= 0.3)
                            {
                                _rate     = 7 * dia;
                                _distance = 3 * dia / 0.4;
                            }
                            else if (dia < 0.3 && dia > 0.1)
                            {
                                _rate     = 12 * dia;
                                _distance = 6 * dia / 0.4;
                            }
                            else if (dia <= 0.1)
                            {
                                _rate     = 22 * dia;
                                _distance = 9 * dia / 0.4;
                            }
                            else
                            {
                                _rate     = 3.5 * dia;
                                _distance = 1.5 * dia / 0.4;
                            }
                        }
                        else
                        {
                            _rate     = 2.0;
                            _distance = 3.0;
                            //z = maxZ + 0.2;
                            delt = 0.2;
                        }
                        List <IPoint> list = DisPerseLine(pt1, pt2, _distance);
                        if (list.Count < 2)
                        {
                            return;
                        }
                        List <IPoint>    list1   = new List <IPoint>();
                        IGeometryFactory geoFact = new GeometryFactoryClass();
                        for (int j = 0; j < list.Count - 1; j++)
                        {
                            IPoint p = geoFact.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            p.X = (list[j].X + list[j + 1].X) / 2;
                            p.Y = (list[j].Y + list[j + 1].Y) / 2;
                            p.Z = (list[j].Z + list[j + 1].Z) / 2;
                            list1.Add(p);
                        }

                        for (var m = 0; m < list1.Count; m++)
                        {
                            IPosition pos = new PositionClass();
                            pos.X            = list1[m].X;
                            pos.Y            = list1[m].Y;
                            pos.Altitude     = list1[m].Z + delt;
                            pos.AltitudeType = gviAltitudeType.gviAltitudeTerrainAbsolute;
                            pos.Heading      = angle.Heading;
                            pos.Tilt         = angle.Tilt;
                            pos.Roll         = angle.Roll;
                            UInt32 color;
                            if (type == 1)
                            {
                                color = 0xFFFFFF00;
                            }
                            else
                            {
                                color = 0xFF00FFFF;
                            }
                            ITerrainArrow rArrow = DF3DApplication.Application.Current3DMapControl.ObjectManager.CreateArrow(pos, 0.8 * _rate, 3, color, color, DF3DApplication.Application.Current3DMapControl.ProjectTree.RootID);
                            this._listRender.Add(rArrow.Guid);
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
コード例 #7
0
ファイル: UCPipeVertical.cs プロジェクト: wwcc19870805/DIFGIS
        private void btnAnalysis_Click(object sender, EventArgs e)
        {
            try
            {
                if (this._dt.Rows.Count < 2)
                {
                    XtraMessageBox.Show("点数少于2个", "提示");
                    return;
                }
                IPoint startPt = this._dt.Rows[0]["InterPoint"] as IPoint;
                if (startPt == null)
                {
                    return;
                }

                WaitForm.Start("正在进行纵断面分析...", "请稍后");
                DF3DApplication app = DF3DApplication.Application;
                if (app == null || app.Current3DMapControl == null)
                {
                    return;
                }

                string        road1   = "";
                string        road2   = "";
                bool          bAlert  = false;
                double        hmax    = double.MinValue;
                double        hmin    = double.MaxValue;
                List <PPLine> pplines = new List <PPLine>();
                foreach (DataRow dr in this._dt.Rows)
                {
                    IFeatureClass fc = dr["FeatureClass"] as IFeatureClass;
                    MajorClass    mc = dr["PipeType"] as MajorClass;
                    if (fc == null || mc == null)
                    {
                        continue;
                    }
                    DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc.GuidString);
                    if (dffc == null)
                    {
                        continue;
                    }
                    FacilityClass fac = dffc.GetFacilityClass();
                    if (fac == null || fac.Name != "PipeLine")
                    {
                        continue;
                    }

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

                    int        fid    = int.Parse(dr["Fid"].ToString());
                    IFdeCursor cursor = null;
                    IRowBuffer row    = null;
                    try
                    {
                        IQueryFilter filter = new QueryFilter();
                        filter.WhereClause = "oid=" + fid;
                        cursor             = fc.Search(filter, false);
                        if ((row = cursor.NextRow()) != null)
                        {
                            if (indexRoad != -1 && !row.IsNull(indexRoad))
                            {
                                if (road2 == "")
                                {
                                    road1 = row.GetValue(indexRoad).ToString();
                                    road2 = row.GetValue(indexRoad).ToString();
                                }
                                else
                                {
                                    road1 = row.GetValue(indexRoad).ToString();
                                    if (road1 != road2)
                                    {
                                        if (!bAlert)
                                        {
                                            XtraMessageBox.Show("跨越多条道路,当前只绘制在【" + road2 + "】上的管线纵断面图。", "提示");
                                            bAlert = true;
                                        }
                                        continue;
                                    }
                                }
                            }


                            double startSurfHeight = double.MaxValue;
                            double endSurfHeight   = double.MaxValue;
                            if (!app.Current3DMapControl.Terrain.IsRegistered)
                            {
                                DFDataConfig.Class.FieldInfo fiStartSurfHeight = fac.GetFieldInfoBySystemName("StartSurfHeight");
                                if (fiStartSurfHeight == null)
                                {
                                    continue;
                                }
                                int indexStartSurfHeight = fields.IndexOf(fiStartSurfHeight.Name);
                                if (indexStartSurfHeight == -1)
                                {
                                    continue;
                                }
                                DFDataConfig.Class.FieldInfo fiEndSurfHeight = fac.GetFieldInfoBySystemName("EndSurfHeight");
                                if (fiEndSurfHeight == null)
                                {
                                    continue;
                                }
                                int indexEndSurfHeight = fields.IndexOf(fiEndSurfHeight.Name);
                                if (indexEndSurfHeight == -1)
                                {
                                    continue;
                                }
                                if (!row.IsNull(indexStartSurfHeight))
                                {
                                    startSurfHeight = double.Parse(row.GetValue(indexStartSurfHeight).ToString());
                                }
                                if (!row.IsNull(indexEndSurfHeight))
                                {
                                    endSurfHeight = double.Parse(row.GetValue(indexEndSurfHeight).ToString());
                                }
                            }
                            if (!row.IsNull(indexShape) && !row.IsNull(indexFootPrint))
                            {
                                object objFootPrint = row.GetValue(indexFootPrint);
                                object objShape     = row.GetValue(indexShape);
                                if (objFootPrint is IPolyline && objShape is IPolyline)
                                {
                                    IPolyline polylineFootPrint = objFootPrint as IPolyline;
                                    IPolyline polylineShape     = objShape as IPolyline;
                                    PPLine    ppline            = new PPLine();
                                    if (indexClassify == -1 || row.IsNull(indexClassify))
                                    {
                                        ppline.facType = mc.Name;
                                    }
                                    else
                                    {
                                        ppline.facType = row.GetValue(indexClassify).ToString();
                                    }
                                    if (!row.IsNull(indexDiameter))
                                    {
                                        string diameter = row.GetValue(indexDiameter).ToString();
                                        if (diameter.Trim() == "")
                                        {
                                            continue;
                                        }
                                        ppline.dia = diameter;
                                        int indexDia = diameter.IndexOf('*');
                                        if (indexDia != -1)
                                        {
                                            ppline.isrect = true;
                                            int  iDia1;
                                            bool bDia1 = int.TryParse(diameter.Substring(0, indexDia), out iDia1);
                                            if (!bDia1)
                                            {
                                                continue;
                                            }
                                            int  iDia2;
                                            bool bDia2 = int.TryParse(diameter.Substring(indexDia + 1, diameter.Length - indexDia - 1), out iDia2);
                                            if (!bDia2)
                                            {
                                                continue;
                                            }
                                            ppline.gj.Add(iDia1);
                                            ppline.gj.Add(iDia2);
                                        }
                                        else
                                        {
                                            ppline.isrect = false;
                                            int  iDia;
                                            bool bDia = int.TryParse(diameter, out iDia);
                                            if (!bDia)
                                            {
                                                continue;
                                            }
                                            ppline.gj.Add(iDia);
                                            ppline.gj.Add(iDia);
                                        }
                                    }
                                    int hlb = 0;
                                    if (indexHLB != -1 && !row.IsNull(indexHLB))
                                    {
                                        string strhlb = row.GetValue(indexHLB).ToString();
                                        if (strhlb.Contains("内"))
                                        {
                                            hlb = 1;
                                        }
                                        else if (strhlb.Contains("外"))
                                        {
                                            hlb = -1;
                                        }
                                        else
                                        {
                                            hlb = 0;
                                        }
                                        ppline.hlb = hlb;
                                    }
                                    IPoint ptIntersect = dr["InterPoint"] as IPoint;
                                    ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y, ptIntersect.Z);
                                    ppline.clh        = GetInterPointHeight(ptIntersect, polylineShape, polylineFootPrint);
                                    if (ppline.clh > hmax)
                                    {
                                        hmax = ppline.clh;
                                    }
                                    if (ppline.clh < hmin)
                                    {
                                        hmin = ppline.clh;
                                    }
                                    if (app.Current3DMapControl.Terrain.IsRegistered)
                                    {
                                        ppline.cgh = app.Current3DMapControl.Terrain.GetElevation(ptIntersect.X, ptIntersect.Y, Gvitech.CityMaker.RenderControl.gviGetElevationType.gviGetElevationFromDatabase);
                                    }
                                    else
                                    {
                                        ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight)
                                                     * Math.Sqrt((polylineFootPrint.StartPoint.X - ptIntersect.X) * (polylineFootPrint.StartPoint.X - ptIntersect.X)
                                                                 + (polylineFootPrint.StartPoint.Y - ptIntersect.Y) * (polylineFootPrint.StartPoint.Y - ptIntersect.Y)) / polylineFootPrint.Length;
                                    }
                                    if (ppline.cgh > hmax)
                                    {
                                        hmax = ppline.cgh;
                                    }
                                    if (ppline.cgh < hmin)
                                    {
                                        hmin = ppline.cgh;
                                    }
                                    // 辅助画图
                                    ppline.startPt = new PPPoint(startPt.X, startPt.Y, startPt.Z);
                                    pplines.Add(ppline);
                                }
                            }
                        }
                    }
                    catch (Exception ex) { }
                    finally
                    {
                        if (cursor != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                            cursor = null;
                        }
                        if (row != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                            row = null;
                        }
                    }
                }
                WaitForm.Stop();
                if (pplines.Count < 2)
                {
                    XtraMessageBox.Show("点数少于2个", "提示");
                    return;
                }
                pplines.Sort(new PPLineCompare());
                double spacesum = 0.0;
                for (int i = 1; i < pplines.Count; i++)
                {
                    PPLine line1 = pplines[i - 1];
                    PPLine line2 = pplines[i];
                    line2.space = Math.Sqrt((line1.interPoint.X - line2.interPoint.X) * (line1.interPoint.X - line2.interPoint.X)
                                            + (line1.interPoint.Y - line2.interPoint.Y) * (line1.interPoint.Y - line2.interPoint.Y));
                    spacesum += line2.space;
                }
                ;
                var                str1    = (pplines[0].interPoint.X / 1000).ToString("0.00");
                var                str2    = (pplines[0].interPoint.Y / 1000).ToString("0.00");
                string             mapNum  = str2 + "-" + str1;
                string             mapName = SystemInfo.Instance.SystemFullName + "纵断面图";
                FrmSectionAnalysis dialog  = new FrmSectionAnalysis("纵断面分析结果", 1);
                dialog.SetInfo(mapName, mapNum, pplines, hmax, hmin, spacesum, road2);
                dialog.Show();
            }
            catch (Exception ex)
            {
                WaitForm.Stop();
            }
            finally
            {
            }
        }
コード例 #8
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();
            }
        }
コード例 #9
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)
            {
            }
        }
コード例 #10
0
        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");
                     }
                 }
            }
        }
コード例 #11
0
        private void CircleQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            WaitForm.Start("正在搜索...", "请稍后");
            try
            {
                FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("PipeNode");
                if (fac == null)
                {
                    return;
                }
                DFDataConfig.Class.FieldInfo field = fac.GetFieldInfoBySystemName("Additional");
                if (field == null)
                {
                    return;
                }
                ISpatialFilter filter = new SpatialFilterClass();
                filter.SubFields = "oid,Geometry,FootPrint";
                string configFH        = Config.GetConfigValue("FireHydrantName");
                string fireHydrantName = "'" + configFH + "'";
                filter.WhereClause   = field.Name + " in (" + fireHydrantName + ")";
                filter.Geometry      = this._drawTool.GetGeo().Clone2(gviVertexAttribute.gviVertexAttributeNone);
                filter.GeometryField = "FootPrint";
                filter.SpatialRel    = gviSpatialRel.gviSpatialRelContains;

                List <DF3DFeatureClass> list = DF3DFeatureClassManager.Instance.GetFeatureClassByFacilityClassName("PipeNode");
                if (list == null)
                {
                    return;
                }

                foreach (DF3DFeatureClass dffc in list)
                {
                    IFeatureClass fc = dffc.GetFeatureClass();

                    if (fc == null)
                    {
                        continue;
                    }
                    MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fc.GuidString);
                    if (mc != null && mc.Name != "GS")
                    {
                        continue;
                    }

                    IFdeCursor cursor = null;
                    IRowBuffer row    = null;
                    try
                    {
                        cursor = fc.Search(filter, false);
                        while ((row = cursor.NextRow()) != null)
                        {
                            if (!row.IsNull(1))
                            {
                                IGeometry geo = row.GetValue(1) as IGeometry;
                                switch (geo.GeometryType)
                                {
                                case gviGeometryType.gviGeometryPoint:
                                    IPoint pt  = geo as IPoint;
                                    IPOI   poi = (new GeometryFactoryClass()).CreateGeometry(gviGeometryType.gviGeometryPOI, gviVertexAttribute.gviVertexAttributeZ) as IPOI;
                                    poi.X         = pt.X;
                                    poi.Y         = pt.Y;
                                    poi.Z         = pt.Z + 2;
                                    poi.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\POI\\fireHydrant.png");
                                    poi.Size      = SystemInfo.Instance.SymbolSize;
                                    poi.ShowName  = false;
                                    IRenderPOI rpoi = app.Current3DMapControl.ObjectManager.CreateRenderPOI(poi);
                                    this._listRGuid.Add(rpoi.Guid);
                                    continue;

                                case gviGeometryType.gviGeometryModelPoint:
                                    IModelPoint pt1  = geo as IModelPoint;
                                    IPOI        poi1 = (new GeometryFactoryClass()).CreateGeometry(gviGeometryType.gviGeometryPOI, gviVertexAttribute.gviVertexAttributeZ) as IPOI;
                                    poi1.X         = pt1.X;
                                    poi1.Y         = pt1.Y;
                                    poi1.Z         = pt1.Z + 2;
                                    poi1.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\POI\\fireHydrant.png");
                                    poi1.Size      = SystemInfo.Instance.SymbolSize;
                                    poi1.ShowName  = false;
                                    IRenderPOI rpoi1 = app.Current3DMapControl.ObjectManager.CreateRenderPOI(poi1);
                                    this._listRGuid.Add(rpoi1.Guid);
                                    continue;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        if (cursor != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                            cursor = null;
                        }
                        if (row != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                            row = null;
                        }
                    }
                }
            }
            catch (Exception ex) { }
            finally
            {
                WaitForm.Stop();
            }
        }
コード例 #12
0
        public override void Run(object sender, EventArgs e)
        {
            int            i = 0, k;
            string         strDicValue;
            string         strPntID;
            IFeatureClass  Pntfc;
            IFeatureClass  Arcfc;
            IFeatureCursor pFeaCursor;
            IQueryFilter   pFilter = new QueryFilterClass();
            IFeature       pFea;

            string[] arrFc2DId;

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

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

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

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

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

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


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



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

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

                        if (dt.Rows.Count > 0)
                        {
                            dict[Pntfc] = dt;
                        }
                        count++;
                    }
                    WaitForm.Stop();
                    FormCheckResult dlg = new FormCheckResult(dict, m_pMapControl);
                    dlg.Text = this.CommandName;
                    dlg.Show();
                }
                catch (System.Exception ex)
                {
                }
            }
        }
コード例 #13
0
 public override void Init()
 {
     try
     {
         base.Init();
         FacilityClass fac = this._facClassReg.FacilityType;
         if (fac == null)
         {
             return;
         }
         DFDataConfig.Class.FieldInfo fi = null;
         bool bHaveTopHeight             = false;
         bool bHaveBottomHeight          = false;
         fi = fac.GetFieldInfoBySystemName("TopHeight");
         if (fi != null)
         {
             int index = this._rowInfo.FieldIndex(fi.Name);
             if (index != -1)
             {
                 this._topHeight = Fac.GetDouble(this._rowInfo, index);
                 bHaveTopHeight  = true;
             }
         }
         fi = fac.GetFieldInfoBySystemName("BottomHeight");
         if (fi != null)
         {
             int index = this._rowInfo.FieldIndex(fi.Name);
             if (index != -1)
             {
                 this._bottomHeight = Fac.GetDouble(this._rowInfo, index);
                 bHaveBottomHeight  = true;
             }
         }
         if (!(bHaveBottomHeight && bHaveTopHeight))
         {
             bool bHaveSurfHeight  = false;
             bool bHaveTopDepth    = false;
             bool bHaveBottomDepth = false;
             fi = fac.GetFieldInfoBySystemName("SurfHeight");
             if (fi != null)
             {
                 int index = this._rowInfo.FieldIndex(fi.Name);
                 if (index != -1)
                 {
                     this._surfH     = Fac.GetDouble(this._rowInfo, index);
                     bHaveSurfHeight = true;
                 }
             }
             if (bHaveSurfHeight)
             {
                 fi = fac.GetFieldInfoBySystemName("TopDepth");
                 if (fi != null)
                 {
                     int index = this._rowInfo.FieldIndex(fi.Name);
                     if (index != -1)
                     {
                         this._topDeep   = Fac.GetDouble(this._rowInfo, index);
                         bHaveTopDepth   = true;
                         this._topHeight = this._surfH - this._topDeep;
                     }
                     else
                     {
                         this._topHeight = 0.0;
                     }
                 }
                 else
                 {
                     this._topHeight = 0.0;
                 }
                 fi = fac.GetFieldInfoBySystemName("BottomDepth");
                 if (fi != null)
                 {
                     int index = this._rowInfo.FieldIndex(fi.Name);
                     if (index != -1)
                     {
                         this._bottomDeep   = Fac.GetDouble(this._rowInfo, index);
                         bHaveBottomDepth   = true;
                         this._bottomHeight = this._surfH - this._bottomDeep;
                     }
                     else
                     {
                         this._bottomHeight = 0.0;
                     }
                 }
                 else
                 {
                     this._bottomHeight = 0.0;
                 }
             }
             else
             {
                 this._topHeight    = 0.0;
                 this._bottomHeight = 0.0;
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #14
0
        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);
        }
コード例 #15
0
        DFDataConfig.Class.FieldInfo fi, fi1, fi2, fi3, fi4, fi5, fi6;//管线字段信息

        public override void Run(object sender, EventArgs e)
        {
            Map2DCommandManager.Push(this);
            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;
            m_pActiveView = this.m_pMapControl.ActiveView;
            m_pMap        = m_pMapControl.ActiveView.FocusMap;
            List <DF2DFeatureClass> st = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine");

            if (st == null)
            {
                return;
            }
            foreach (DF2DFeatureClass dfcc in st)
            {
                IFeatureClass fc = dfcc.GetFeatureClass();
                if (fc == null)
                {
                    continue;
                }
                FacilityClass fac = dfcc.GetFacilityClass();
                if (fac == null)
                {
                    continue;
                }
                List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                fi = fac.GetFieldInfoBySystemName("classify");
                if (fi == null || fi.CanQuery == false)
                {
                    continue;
                }
                fi1 = fac.GetFieldInfoBySystemName("snodeid");
                if (fi1 == null || fi1.CanQuery == false)
                {
                    continue;
                }
                fi2 = fac.GetFieldInfoBySystemName("enodeid");
                if (fi2 == null || fi2.CanQuery == false)
                {
                    continue;
                }
                fi3 = fac.GetFieldInfoBySystemName("matter");
                if (fi3 == null || fi3.CanQuery == false)
                {
                    continue;
                }
                fi4 = fac.GetFieldInfoBySystemName("coverstsle");
                if (fi4 == null || fi4.CanQuery == false)
                {
                    continue;
                }
                fi5 = fac.GetFieldInfoBySystemName("standard");
                if (fi5 == null || fi5.CanQuery == false)
                {
                    continue;
                }
                fi6 = fac.GetFieldInfoBySystemName("proad");
                if (fi6 == null || fi6.CanQuery == false)
                {
                    continue;
                }
            }
            m_pMapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
        }
コード例 #16
0
        public override void Run(object sender, EventArgs e)
        {
            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;
            List <DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine");
            Dictionary <IFeatureClass, DataTable> dict = new Dictionary <IFeatureClass, DataTable>();

            WaitForm.Start("开始管线预警检查..", "请稍后");
            foreach (DF2DFeatureClass dffc in list)
            {
                IQueryFilter  pFilter = new QueryFilterClass();
                IFeatureClass fc      = dffc.GetFeatureClass();
                if (fc == null)
                {
                    continue;
                }
                WaitForm.SetCaption("正在检查图层:" + " " + fc.AliasName);
                FacilityClass fac = dffc.GetFacilityClass();
                if (fac == null)
                {
                    continue;
                }
                List <DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection;
                DFDataConfig.Class.FieldInfo        fi        = fac.GetFieldInfoBySystemName("Material");
                int index = fc.FindField(fi.Name);
                if (fi == null || index == -1)
                {
                    continue;
                }

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

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

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

                DFDataConfig.Class.FieldInfo fi4 = fac.GetFieldInfoBySystemName("Road");
                int index4 = fc.FindField(fi4.Name);
                if (fi4 == null || index4 == -1)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi5 = fac.GetFieldInfoBySystemName("Diameter");
                int index5 = fc.FindField(fi5.Name);
                if (fi5 == null || index5 == -1)
                {
                    continue;
                }

                DFDataConfig.Class.FieldInfo fi6 = fac.GetFieldInfoBySystemName("PipeLength2D");
                int index6 = fc.FindField(fi6.Name);
                if (fi6 == null || index6 == -1)
                {
                    continue;
                }

                DataTable dt      = GetDataTableByStruture();
                string    Strtime = DateTime.Now.Year.ToString();
                double    time    = double.Parse(Strtime);


                IFeatureCursor pFeaCursor = fc.Search(null, true);
                IFeature       pFea       = pFeaCursor.NextFeature();
                while (pFea != null)
                {
                    string stryear = pFea.get_Value(index2).ToString();
                    if (stryear == "")
                    {
                        stryear = "0";
                    }
                    double year       = double.Parse(stryear);
                    string matter     = pFea.get_Value(index).ToString();
                    string usestate   = pFea.get_Value(index1).ToString();
                    string ownerby    = pFea.get_Value(index3).ToString();
                    string proad      = pFea.get_Value(index4).ToString();
                    string standard   = pFea.get_Value(index5).ToString();
                    string pipelength = pFea.get_Value(index6).ToString();
                    double yeartime   = time - year;
                    yearXtime = 20 - yeartime;
                    DataRow dr = dt.NewRow();
                    dr["FeatureID"]    = pFea.OID;
                    dr["Matter"]       = matter;
                    dr["UseState"]     = usestate;
                    dr["StartTime"]    = year;
                    dr["UseTime"]      = yeartime;
                    dr["OwnerBy"]      = ownerby;
                    dr["Proad"]        = proad;
                    dr["Standard"]     = standard;
                    dr["FeatureClass"] = fc;
                    dr["PipeLength"]   = pipelength;
                    if (yearXtime > 0 && yearXtime <= 2)
                    {
                        dr["TimeAlert"] = yearXtime;
                        dt.Rows.Add(dr);
                    }
                    else if (yearXtime > 2 && yearXtime <= 5)
                    {
                        dr["TimeAlert"] = yearXtime;
                        dt.Rows.Add(dr);
                    }
                    else if (yearXtime < 0)
                    {
                        dr["TimeAlert"] = Math.Abs(yearXtime);
                        dt.Rows.Add(dr);
                    }
                    pFea = pFeaCursor.NextFeature();
                }
                if (dt.Rows.Count > 0)
                {
                    dict[fc] = dt;
                }
            }

            if (dict.Count == 0)
            {
                XtraMessageBox.Show("提示表格数据为空!");
                return;
            }
            WaitForm.Stop();
            FrmPipeAlert dlg = new FrmPipeAlert(dict, m_pMapControl);

            dlg.Text = this.CommandName;
            dlg.Show();
        }
コード例 #17
0
ファイル: PipeNodeFac.cs プロジェクト: wwcc19870805/DIFGIS
        public override void Init()
        {
            try
            {
                base.Init();
                FacilityClass fac = this._facClassReg.FacilityType;
                if (fac == null)
                {
                    return;
                }
                DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Height");
                if (fi != null)
                {
                    int index = this._rowInfo.FieldIndex(fi.Name);
                    if (index != -1)
                    {
                        this._height = Fac.GetDouble(this._rowInfo, index);
                    }
                }
                fi = fac.GetFieldInfoBySystemName("SurfHeight");
                if (fi != null)
                {
                    int index = this._rowInfo.FieldIndex(fi.Name);
                    if (index != -1)
                    {
                        this._surfH = Fac.GetDouble(this._rowInfo, index);
                    }
                }
                bool bHaveTopHeight = false;
                fi = fac.GetFieldInfoBySystemName("TopHeight");
                if (fi != null)
                {
                    int index = this._rowInfo.FieldIndex(fi.Name);
                    if (index != -1)
                    {
                        this._topH     = Fac.GetDouble(this._rowInfo, index);
                        bHaveTopHeight = true;
                    }
                }
                bool bHaveBottomHeight = false;
                fi = fac.GetFieldInfoBySystemName("BottomHeight");
                if (fi != null)
                {
                    int index = this._rowInfo.FieldIndex(fi.Name);
                    if (index != -1)
                    {
                        this._bottomH     = Fac.GetDouble(this._rowInfo, index);
                        bHaveBottomHeight = true;
                    }
                }
                if (!bHaveTopHeight && bHaveBottomHeight)
                {
                    this._topH = this.SurfH;
                }

                fi = fac.GetFieldInfoBySystemName("Direction");
                if (fi != null)
                {
                    int index = this._rowInfo.FieldIndex(fi.Name);
                    if (index != -1)
                    {
                        this._angleZ = Fac.GetDouble(this._rowInfo, index);
                    }
                }
                fi = fac.GetFieldInfoBySystemName("Additional");
                if (fi != null)
                {
                    int index = this._rowInfo.FieldIndex(fi.Name);
                    if (index != -1)
                    {
                        this._fusu = Fac.GetString(this._rowInfo, index);
                    }
                }
                fi = fac.GetFieldInfoBySystemName("Pitch");
                if (fi != null)
                {
                    int index = this._rowInfo.FieldIndex(fi.Name);
                    if (index != -1)
                    {
                        this._pitch = Fac.GetDouble(this._rowInfo, index);
                    }
                }
                fi = fac.GetFieldInfoBySystemName("Yaw");
                if (fi != null)
                {
                    int index = this._rowInfo.FieldIndex(fi.Name);
                    if (index != -1)
                    {
                        this._yaw = Fac.GetDouble(this._rowInfo, index);
                    }
                }
                if (this._style != null)
                {
                    if (this._style.Name.Contains("井") || this._style.Name.Contains("篦"))
                    {
                        this._IsWell  = true;
                        this._IsValve = false;
                        // 重新设置模型点Z坐标
                        if (base._geoGroup[1] != null && (base._geoGroup[1] as IPoint) != null)
                        {
                            IPoint pointValue = base._geoGroup[1] as IPoint;
                            if (this._topH != null && this._bottomH != null)
                            {
                                pointValue.Z = (this._topH + this._bottomH) / 2.0;
                            }
                            base._geoGroup[1] = pointValue;
                            base.SetValue("Shape", base._geoGroup[1]);
                        }
                    }
                    if (!this._IsWell && this._style.Name.Contains("阀"))
                    {
                        this._IsValve = true;
                        this._IsWell  = false;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #18
0
ファイル: CmdTopoCheck.cs プロジェクト: wwcc19870805/DIFGIS
        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();
            }
        }
コード例 #19
0
        private IGeoDataset GetAfterGeo(IFeatureClass fc, IGeometry geo)
        {
            try
            {
                WaitForm.SetCaption("正在计算填挖表面...");
                ISpatialFilter pSpatialFilter = new SpatialFilter();
                pSpatialFilter.Geometry   = geo;
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                int count = fc.FeatureCount(pSpatialFilter);
                if (count == 0)
                {
                    return(null);
                }
                IFeatureCursor cursor = fc.Search(pSpatialFilter, true);
                IFeature       feature;
                FacilityClass  fac = FacilityClassManager.Instance.GetFacilityClassByName("GCD");
                DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Height");
                if (fi == null)
                {
                    return(null);
                }
                while ((feature = cursor.NextFeature()) != null)
                {
                    int index = feature.Fields.FindField(fi.Name);
                    if (index == -1)
                    {
                        continue;
                    }
                    feature.set_Value(index, h);
                    feature.Store();
                }

                IInterpolationOp3 pInterpolationOp = new RasterInterpolationOpClass();

                //IFields fields = fc.Fields;
                //int index1 = fields.FindField("HEIGHT");
                //if (index1 == -1) return null;
                //IField field = fields.get_Field(index1);

                IFeatureClassDescriptor pFcd = new FeatureClassDescriptorClass();
                pFcd.Create(fc, pSpatialFilter, fi.Name);

                //定义搜索半径
                IRasterRadius pRadius = new RasterRadiusClass();
                object        Missing = Type.Missing;
                pRadius.SetVariable(12, ref Missing);

                //设置栅格图像的单位大小
                object cellSizeProvider         = 5;
                IRasterAnalysisEnvironment pEnv = pInterpolationOp as IRasterAnalysisEnvironment;
                pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellSizeProvider);
                IGeoDataset outGeoDataset = pInterpolationOp.IDW(pFcd as IGeoDataset, 2, pRadius, ref Missing);
                return(outGeoDataset);
            }
            catch (System.Exception ex)
            {
                return(null);

                WaitForm.Stop();
            }
        }
コード例 #20
0
        private void treelist_AfterCheckNode(object sender, NodeEventArgs e)
        {
            this.teValue.Text = "";
            this.listBoxControlValues.Items.Clear();
            if (string.IsNullOrEmpty(this._sysFieldName))
            {
                return;
            }
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                WaitForm.Start("正在加载列表...", "请稍后");
                HashSet <string> list   = new HashSet <string>();
                bool             bBreak = false;
                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 cacheType = sc.Parent.Name + "_" + sc.GroupId + "_3D_" + this._sysFieldName;
                        object objCache  = CacheHelper.GetCache(cacheType);
                        if (objCache != null && objCache is HashSet <string> )
                        {
                            HashSet <string> temphs = objCache as HashSet <string>;
                            foreach (string tempstr in temphs)
                            {
                                list.Add(tempstr);
                            }
                            continue;
                        }
                        HashSet <string> listsc    = new HashSet <string>();
                        string[]         arrFc3DId = sc.Parent.Fc3D.Split(';');
                        if (arrFc3DId == null)
                        {
                            continue;
                        }
                        foreach (string fc3DId in arrFc3DId)
                        {
                            DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId);
                            if (dffc == null)
                            {
                                continue;
                            }
                            FacilityClass facClass = dffc.GetFacilityClass();
                            IFeatureClass fc       = dffc.GetFeatureClass();
                            if (fc == null || facClass == null || facClass.Name != this._facType)
                            {
                                continue;
                            }
                            DFDataConfig.Class.FieldInfo fi = facClass.GetFieldInfoBySystemName(this._sysFieldName);
                            if (fi == null)
                            {
                                continue;
                            }
                            IFieldInfoCollection fiCol = fc.GetFields();
                            int index = fiCol.IndexOf(fi.Name);
                            if (index < 0)
                            {
                                continue;
                            }
                            Gvitech.CityMaker.FdeCore.FieldInfo gfi = (Gvitech.CityMaker.FdeCore.FieldInfo)fiCol.Get(index);
                            IQueryFilter filter = new QueryFilter();
                            filter.SubFields        = gfi.Name;
                            filter.ResultBeginIndex = 0;
                            filter.ResultLimit      = 1;
                            while (true)
                            {
                                string strTempClause = gfi.Name + " is not null and ";
                                string fClause       = strTempClause;
                                foreach (string strtemp in listsc)
                                {
                                    fClause += gfi.Name + " <> " + strtemp + " and ";
                                }
                                fClause            = fClause.Substring(0, fClause.Length - 5);
                                filter.WhereClause = "GroupId = " + sc.GroupId + " and " + fClause;

                                cursor = fc.Search(filter, true);
                                if ((row = cursor.NextRow()) != null)
                                {
                                    if (row.IsNull(0))
                                    {
                                        break;
                                    }
                                    object temp    = row.GetValue(0);
                                    string strtemp = "";
                                    switch (gfi.FieldType)
                                    {
                                    case gviFieldType.gviFieldFID:
                                    case gviFieldType.gviFieldFloat:
                                    case gviFieldType.gviFieldDouble:
                                    case gviFieldType.gviFieldInt16:
                                    case gviFieldType.gviFieldInt32:
                                    case gviFieldType.gviFieldInt64:
                                        strtemp = temp.ToString();
                                        break;

                                    case gviFieldType.gviFieldDate:
                                    case gviFieldType.gviFieldString:
                                    case gviFieldType.gviFieldUUID:
                                        strtemp = "'" + temp.ToString() + "'";
                                        break;

                                    case gviFieldType.gviFieldBlob:
                                    case gviFieldType.gviFieldGeometry:
                                    case gviFieldType.gviFieldUnknown:
                                    default:
                                        continue;
                                    }
                                    if (temp != null)
                                    {
                                        list.Add(strtemp);
                                        listsc.Add(strtemp);
                                        if (list.Count > 10)
                                        {
                                            bBreak = true;
                                            break;// 列举10个
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            if (bBreak)
                            {
                                break;
                            }
                        }
                        CacheHelper.SetCache(cacheType, listsc);
                    }
                    if (bBreak)
                    {
                        break;
                    }
                }
                foreach (string str2 in list)
                {
                    //if (!(string.IsNullOrEmpty(str2)))
                    //{
                    this.listBoxControlValues.Items.Add(str2);
                    //}
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
                WaitForm.Stop();
            }
        }
コード例 #21
0
        public static HashSet <string> GetValveIdsByFCGuid(string fcGuid)
        {
            if (ValveManager.Instance.Exists(fcGuid))
            {
                return(ValveManager.Instance.GetValveIds(fcGuid));
            }
            if (DF3DPipeCreateApp.App.PipeLib == null)
            {
                return(null);
            }
            IFeatureClass fc     = null;
            IQueryFilter  filter = null;
            IFdeCursor    cursor = null;
            IRowBuffer    buffer = null;

            try
            {
                if (dictFC.ContainsKey(fcGuid) && dictFC[fcGuid] != null)
                {
                    fc = dictFC[fcGuid];
                }
                else
                {
                    IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_GEO_Actuality");
                    if (fds == null)
                    {
                        return(null);
                    }
                    string[] fcNames = fds.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                    if (fcNames == null)
                    {
                        return(null);
                    }
                    foreach (string fcName in fcNames)
                    {
                        IFeatureClass fcTemp = fds.OpenFeatureClass(fcName);
                        if (fcTemp.GuidString == fcGuid)
                        {
                            fc = fcTemp;
                            break;
                        }
                    }
                    if (fc == null)
                    {
                        return(null);
                    }
                    FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("PipeNode");
                    if (fac == null)
                    {
                        return(null);
                    }
                    DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Additional");
                    if (fi == null)
                    {
                        return(null);
                    }

                    filter = new QueryFilterClass
                    {
                        SubFields   = "oid," + fi.Name,
                        WhereClause = fi.Name + " LIKE '%阀%'"//改
                    };
                    int count = fc.GetCount(filter);
                    if (count == 0)
                    {
                        return(null);
                    }
                    cursor = fc.Search(filter, false);
                    HashSet <string> hsRes = new HashSet <string>();
                    while ((buffer = cursor.NextRow()) != null)
                    {
                        hsRes.Add(fc.GuidString + "_" + buffer.GetValue(0).ToString());
                    }
                    ValveManager.Instance.Add(fcGuid, hsRes);
                    return(hsRes);
                }
                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (buffer != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer);
                    buffer = null;
                }
            }
        }
コード例 #22
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

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

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

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

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

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

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

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

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

                                                IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color);
                                                pGC.AddElement(elementText, 1);
                                                app.Current2DMapControl.CenterAt(point);
                                            }
                                            app.Current2DMapControl.MapScale = 500;
                                            app.Current2DMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                                        }
                                        if (haveone)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
            finally
            {
                WaitForm.Stop();
                XtraMessageBox.Show("上游需关闭阀门:" + preCount + "\n下游需关闭阀门:" + nextCount, "提示");
                SuspendCommand();
            }
        }
コード例 #23
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;

            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)
            {
            }
        }
コード例 #24
0
        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[] arrFc3DId = sc.Parent.Fc3D.Split(';');
                    if (arrFc3DId == null)
                    {
                        continue;
                    }
                    foreach (string fc3DId in arrFc3DId)
                    {
                        DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId);
                        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.GetFields().IndexOf(fi1.Name);
                        int index2 = fc.GetFields().IndexOf(fi2.Name);
                        if (index1 == -1 || index2 == -1)
                        {
                            continue;
                        }
                        IFieldInfo fcfi1 = fc.GetFields().Get(index1);
                        switch (fcfi1.FieldType)
                        {
                        case gviFieldType.gviFieldBlob:
                        case gviFieldType.gviFieldGeometry:
                        case gviFieldType.gviFieldUnknown:
                            continue;
                        }
                        IFieldInfo fcfi2 = fc.GetFields().Get(index2);
                        switch (fcfi2.FieldType)
                        {
                        case gviFieldType.gviFieldBlob:
                        case gviFieldType.gviFieldGeometry:
                        case gviFieldType.gviFieldUnknown:
                            continue;
                        }
                        string clause = "";
                        if (heightmax == heightmin)
                        {
                            clause = "(" + fcfi1.Name + " <= " + widemax + " and " + fcfi1.Name + " >= " + widemin + ") and " + fcfi2.Name + "=0 or " + fcfi2.Name + " is null";
                        }
                        else
                        {
                            clause = "(" + fcfi1.Name + " <= " + widemax + " and " + fcfi1.Name + " >= " + widemin + ") and (" + fcfi2.Name + " <= " + heightmax + " and " + fcfi2.Name + " >= " + heightmin + ") and " + fcfi2.Name + " <> 0 and " + fcfi2.Name + " is not null";
                        }
                        string whereClause = "GroupId = " + sc.GroupId + " and ( " + clause + " )";
                        _dict.Add(sc, whereClause);
                    }
                }
            }
        }
コード例 #25
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);
                }
            }

            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[] arrFc3DId = sc.Parent.Fc3D.Split(';');
                        if (arrFc3DId == null)
                        {
                            continue;
                        }
                        foreach (string fc3DId in arrFc3DId)
                        {
                            DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId);
                            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 fi = facc.GetFieldInfoBySystemName(this._sysFieldName);
                            if (fi == null)
                            {
                                continue;
                            }
                            int index = fc.GetFields().IndexOf(fi.Name);
                            if (index == -1)
                            {
                                continue;
                            }
                            IFieldInfo fcfi = fc.GetFields().Get(index);
                            switch (fcfi.FieldType)
                            {
                            case gviFieldType.gviFieldBlob:
                            case gviFieldType.gviFieldGeometry:
                            case gviFieldType.gviFieldUnknown:
                                continue;
                            }
                            string[] arr1 = value.Split(';');
                            if (arr1 == null || arr1.Length == 0)
                            {
                                continue;
                            }
                            string temp1 = "(";
                            foreach (string str1 in arr1)
                            {
                                temp1 += str1 + ",";
                            }
                            if (temp1 == "(")
                            {
                                temp1 = "()";
                            }
                            else
                            {
                                temp1 = temp1.Substring(0, temp1.Length - 1) + ")";
                            }
                            string strWhereClause = "GroupId = " + sc.GroupId + " and (" + fi.Name + " in " + temp1 + ")";

                            _dict.Add(sc, strWhereClause);
                        }
                    }
                }
            }
        }
コード例 #26
0
        private void cmbLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.cmbField.Properties.Items.Clear();
            this.cmbField.SelectedIndex = -1;
            this.teFieldValue.Text      = null;
            this.lbcFieldValues.Items.Clear();
            if (this.cmbLayer.SelectedItem == null)
            {
                return;
            }
            DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass;
            IFeatureClass    fc   = dffc.GetFeatureClass();

            if (fc == null)
            {
                return;
            }
            FacilityClass fac = dffc.GetFacilityClass();

            if (fac == null)
            {
                IFieldInfoCollection fiCol = fc.GetFields();
                if (fiCol != null)
                {
                    for (int i = 0; i < fiCol.Count; i++)
                    {
                        IFieldInfo fi = fiCol.Get(i);
                        if (fi.FieldType == gviFieldType.gviFieldUnknown || fi.FieldType == gviFieldType.gviFieldGeometry || fi.FieldType == gviFieldType.gviFieldBlob)
                        {
                            continue;
                        }
                        string dataType = "";
                        switch (fi.FieldType)
                        {
                        case gviFieldType.gviFieldDouble:
                        case gviFieldType.gviFieldFID:
                        case gviFieldType.gviFieldFloat:
                        case gviFieldType.gviFieldInt16:
                        case gviFieldType.gviFieldInt32:
                        case gviFieldType.gviFieldInt64:
                        case gviFieldType.gviFieldUUID:
                            dataType = "Decimal";
                            break;

                        case gviFieldType.gviFieldDate:
                        case gviFieldType.gviFieldString:
                            dataType = "String";
                            break;

                        default:
                            break;
                        }
                        DFDataConfig.Class.FieldInfo fi1 = new DFDataConfig.Class.FieldInfo(fi.Name, fi.Alias, "", "", true, false, false, dataType);
                        this.cmbField.Properties.Items.Add(fi1);
                    }
                }
            }
            else
            {
                List <DFDataConfig.Class.FieldInfo> list = fac.FieldInfoCollection;
                if (list != null)
                {
                    foreach (DFDataConfig.Class.FieldInfo fi in list)
                    {
                        if (!fi.CanQuery)
                        {
                            continue;
                        }
                        this.cmbField.Properties.Items.Add(fi);
                    }
                }
            }
        }
コード例 #27
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

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

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

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


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

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

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

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

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

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

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

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

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


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

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

                                    #endregion
                                    #region  交点为多个
                                    else if (geoIntersect.GeometryType == esriGeometryType.esriGeometryMultipoint)
                                    {
                                        IPolyline        polyline = pFeature.Shape as IPolyline;
                                        IPointCollection geoCol   = geoIntersect as IPointCollection;
                                        for (int i = 0; i < geoCol.PointCount; i++)
                                        {
                                            IPoint ptIntersect = geoCol.get_Point(i);
                                            ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y);
                                            ppline.clh        = GetInterPointHeight(ptIntersect, polyline, startDepthHeight, endDepthHeight);
                                            if (ppline.clh > hmax)
                                            {
                                                hmax = ppline.clh;
                                            }
                                            if (ppline.clh < hmin)
                                            {
                                                hmin = ppline.clh;
                                            }
                                            ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight)
                                                         * Math.Sqrt((polyline.FromPoint.X - ptIntersect.X) * (polyline.FromPoint.X - ptIntersect.X)
                                                                     + (polyline.FromPoint.Y - ptIntersect.Y) * (polyline.FromPoint.Y - ptIntersect.Y)) / polyline.Length;
                                            if (ppline.cgh > hmax)
                                            {
                                                hmax = ppline.cgh;
                                            }
                                            if (ppline.cgh < hmin)
                                            {
                                                hmin = ppline.cgh;
                                            }
                                            // 辅助画图
                                            IPolyline l = pGeo as IPolyline;
                                            ppline.startPt = new PPPoint(l.FromPoint.X, l.FromPoint.Y);
                                            pplines.Add(ppline);
                                        }
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                    WaitForm.Stop();
                    if (pplines.Count < 2)
                    {
                        XtraMessageBox.Show("相交管线少于2个", "提示");
                        return;
                    }
                    pplines.Sort(new PPLineCompare2D());
                    double spacesum = 0.0;
                    for (int i = 1; i < pplines.Count; i++)
                    {
                        PPLine2D line1 = pplines[i - 1];
                        PPLine2D line2 = pplines[i];
                        line2.space = Math.Sqrt((line1.interPoint.X - line2.interPoint.X) * (line1.interPoint.X - line2.interPoint.X)
                                                + (line1.interPoint.Y - line2.interPoint.Y) * (line1.interPoint.Y - line2.interPoint.Y));
                        spacesum += line2.space;
                    }
                    ;
                    var                str1    = (pplines[0].interPoint.X / 1000).ToString("0.00");
                    var                str2    = (pplines[0].interPoint.Y / 1000).ToString("0.00");
                    string             mapNum  = str2 + "-" + str1;
                    string             mapName = SystemInfo.Instance.SystemFullName + "横断面图";
                    FrmSectionAnalysis dialog  = new FrmSectionAnalysis("横断面分析结果", 0);
                    dialog.SetInfo(mapName, mapNum, pplines, hmax, hmin, spacesum, road2);
                    dialog.Show();
                }
            }
            catch
            {
                WaitForm.Stop();
            }
        }
コード例 #28
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();
            }
        }
コード例 #29
0
        private DataTable RegionAnalysis(IGeometry geo)
        {
            DataTable dtResult = new DataTable();

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

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

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

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

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

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

                            DataRow dr1 = dtstats.NewRow();//将对应数据填写到统计图表用数据表的新行
                            dr1["PIPELINETYPE"] = mc;
                            dr1["FIELDNAME"]    = sc;
                            dr1["LENGTH"]       = subfieldlength.ToString("0.00");
                            dtstats.Rows.Add(dr1);
                        }
                    }
                }
                int indexEnd = dtResult.Rows.Count;
                for (int i = indexStart; i < indexEnd; i++)
                {
                    DataRow dr = dtResult.Rows[i];
                    dr["TOTALLENGTH"] = subclasslength.ToString("0.00");
                }
            }
            return(dtResult);
        }
コード例 #30
0
        private void DoStats()
        {
            if (string.IsNullOrEmpty(this._sysFieldName))
            {
                return;
            }
            //string value = this.cbProperty.Text.Trim();
            //if (value.Length > 1)
            //{
            //    int lastindex = value.LastIndexOf(';');
            //    if (lastindex == (value.Length - 1))
            //        value = value.Substring(0, value.Length - 1);
            //}
            dttemp = new DataTable();
            dttemp.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"),
                                                       new DataColumn("FIELDNAME"), new DataColumn("PVALUE"),
                                                       new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) });
            dtstats = new DataTable();
            dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"),
                                                        new DataColumn("LENGTH", typeof(double)) });

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

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


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


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

                                    DataRow dr1 = dtstats.NewRow();
                                    dr1["PIPELINETYPE"] = sc;
                                    dr1["FIELDNAME"]    = strValue;
                                    dr1["LENGTH"]       = subfieldlength.ToString("0.00");
                                    dtstats.Rows.Add(dr1);
                                }
                            }
                        }
                        int indexEnd = dttemp.Rows.Count;
                        for (int i = indexStart; i < indexEnd; i++)
                        {
                            DataRow dr = dttemp.Rows[i];
                            dr["TOTALLENGTH"] = subclasslength.ToString("0.00");
                        }
                    }
                }
            }
        }