Ejemplo n.º 1
0
        private void ClassQuery(MajorClass mc, MajorClass mctemp, ISpatialFilter filter, IGeometry geo)
        {
            if (mc == null || filter == null || geo == null)
            {
                return;
            }
            string[] arrFc3DId = mc.Fc3D.Split(';');
            if (arrFc3DId == null)
            {
                return;
            }
            foreach (SubClass sc in mc.SubClasses)
            {
                if (!sc.Visible3D)
                {
                    continue;
                }
                bool bHave = false;
                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)
                    {
                        continue;
                    }

                    filter.WhereClause = "GroupId = " + sc.GroupId;
                    int count = fc.GetCount(filter);
                    if (count == 0)
                    {
                        continue;
                    }
                    bHave    = true;
                    bHaveRes = true;

                    if (bHave)
                    {
                        break;
                    }
                }
                if (bHave)
                {
                    SubClass sctemp = new SubClass(sc.Name, sc.GroupId, sc.Parent);
                    sctemp.Visible3D = sc.Visible3D;
                    mctemp.SubClasses.Add(sctemp);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            RestoreEnv();
            this._dt.Rows.Clear();
            string str = this.teRoadName.Text.Trim();
            object obj = this.cmbFCs.SelectedItem;

            WaitForm.Start("正在搜索...", "请稍后");
            try
            {
                if (obj == null)
                {
                    List <DF3DFeatureClass> list = Dictionary3DTable.Instance.GetFeatureClassByFacilityClassName("Road");
                    if (list != null && list.Count != 0)
                    {
                        foreach (DF3DFeatureClass dffc in list)
                        {
                            IFeatureClass fc  = dffc.GetFeatureClass();
                            FacilityClass fac = dffc.GetFacilityClass();
                            if (fc != null && fac != null)
                            {
                                SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str);
                            }
                        }
                    }
                }
                else
                {
                    if (obj is DF3DFeatureClass)
                    {
                        DF3DFeatureClass dffc = obj as DF3DFeatureClass;
                        IFeatureClass    fc   = dffc.GetFeatureClass();
                        FacilityClass    fac  = dffc.GetFacilityClass();
                        if (fc != null && fac != null)
                        {
                            SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str);
                        }
                    }
                }
            }
            catch (Exception ex) { }
            WaitForm.Stop();
        }
Ejemplo n.º 3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            RestoreEnv();
            this._dt.Rows.Clear();
            string str = this.teName.Text.Trim();
            object obj = this.cmbFCs.SelectedItem;

            WaitForm.Start("正在搜索...", "请稍后");
            try
            {
                if (obj != null && obj is DF3DFeatureClass)
                {
                    DF3DFeatureClass dffc = obj as DF3DFeatureClass;
                    IFeatureClass    fc   = dffc.GetFeatureClass();
                    FacilityClass    fac  = dffc.GetFacilityClass();
                    if (fc != null && fac != null)
                    {
                        SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str);
                    }
                }
            }
            catch (Exception ex) { }
            WaitForm.Stop();
        }
Ejemplo n.º 4
0
        private void LoadProperty()
        {
            try
            {
                DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer;
                if (featureClassInfo == null)
                {
                    return;
                }

                IFeatureClass fc = featureClassInfo.GetFeatureClass();
                if (fc == null)
                {
                    return;
                }
                IFieldInfoCollection fiCol = fc.GetFields();
                if (fiCol == null)
                {
                    return;
                }
                FacilityClass fac = featureClassInfo.GetFacilityClass();

                if (fac == null)
                {
                    for (int i = 0; i < fiCol.Count; i++)
                    {
                        IFieldInfo fi = fiCol.Get(i);
                        if (fi.Name == fc.FidFieldName)
                        {
                            continue;
                        }

                        switch (fi.FieldType)
                        {
                        case gviFieldType.gviFieldBlob:
                        case gviFieldType.gviFieldGeometry:
                        case gviFieldType.gviFieldUnknown:
                            continue;

                        //case gviFieldType.gviFieldFloat:
                        //case gviFieldType.gviFieldDouble:
                        //    break;
                        //case gviFieldType.gviFieldFID:
                        //case gviFieldType.gviFieldUUID:
                        //case gviFieldType.gviFieldInt16:
                        //case gviFieldType.gviFieldInt32:
                        //case gviFieldType.gviFieldInt64:
                        //    break;
                        //case gviFieldType.gviFieldString:
                        //    break;
                        //case gviFieldType.gviFieldDate:
                        default:
                            DataRow dr = this._dt.NewRow();
                            dr["FN"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias;
                            dr["FV"] = null;
                            dr["F"]  = fi;
                            this._dt.Rows.Add(dr);
                            break;
                        }
                    }
                }
                else
                {
                    List <DFDataConfig.Class.FieldInfo> list = fac.FieldInfoCollection;
                    if (list != null)
                    {
                        foreach (DFDataConfig.Class.FieldInfo fi1 in list)
                        {
                            if (!fi1.CanQuery)
                            {
                                continue;
                            }
                            int index = fiCol.IndexOf(fi1.Name);
                            if (index == -1)
                            {
                                continue;
                            }
                            IFieldInfo fi = fiCol.Get(index);
                            if (fi == null)
                            {
                                continue;
                            }
                            switch (fi.FieldType)
                            {
                            case gviFieldType.gviFieldBlob:
                            case gviFieldType.gviFieldGeometry:
                            case gviFieldType.gviFieldUnknown:
                                continue;

                            //case gviFieldType.gviFieldFloat:
                            //case gviFieldType.gviFieldDouble:
                            //    break;
                            //case gviFieldType.gviFieldFID:
                            //case gviFieldType.gviFieldUUID:
                            //case gviFieldType.gviFieldInt16:
                            //case gviFieldType.gviFieldInt32:
                            //case gviFieldType.gviFieldInt64:
                            //    break;
                            //case gviFieldType.gviFieldString:
                            //    break;
                            //case gviFieldType.gviFieldDate:
                            default:
                                DataRow dr = this._dt.NewRow();
                                dr["FN"] = fi1.ToString();
                                dr["FV"] = null;
                                dr["F"]  = fi;
                                this._dt.Rows.Add(dr);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 5
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);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void GetData()
        {
            string   whereClause = _dict[_currentClass];
            SubClass sc          = _currentClass;

            if (sc.Parent == null)
            {
                return;
            }
            string[] arrFc3DId = sc.Parent.Fc3D.Split(';');
            if (arrFc3DId == null)
            {
                return;
            }
            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;
                }
                List <DFDataConfig.Class.FieldInfo> facFields = facc.FieldInfoCollection;
                if (facFields == null || facFields.Count == 0)
                {
                    return;
                }

                ISpatialFilter filter = new SpatialFilter();
                filter.SpatialRel    = gviSpatialRel.gviSpatialRelIntersects;
                filter.Geometry      = this._geo;
                filter.GeometryField = "FootPrint";
                filter.WhereClause   = whereClause;
                _count = fc.GetCount(filter);
                if (_num > _count || _count == 0)
                {
                    return;
                }

                filter.ResultBeginIndex = _num - 1;
                filter.ResultLimit      = 1;
                IFdeCursor cursor = null;
                IRowBuffer row    = null;
                try
                {
                    cursor = fc.Search(filter, false);
                    if ((row = cursor.NextRow()) != null)
                    {
                        #region 定位
                        int geoindex = row.FieldIndex("Geometry");
                        if (geoindex == -1 || !(row.GetValue(geoindex) is IModelPoint))
                        {
                            continue;
                        }
                        DF3DApplication app = DF3DApplication.Application;
                        if (app != null && app.Current3DMapControl != null)
                        {
                            IModelPoint       geo = row.GetValue(geoindex) as IModelPoint;
                            IModelPointSymbol mps = new ModelPointSymbol();
                            mps.SetResourceDataSet(fc.FeatureDataSet);
                            IRenderGeometry render = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(geo, mps, app.Current3DMapControl.ProjectTree.RootID);
                            //app.Current3DMapControl.Camera.FlyToObject(render.Guid, gviActionCode.gviActionJump);
                            render.Glow(5000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(render.Guid, 5000);

                            ITableLabel tl = DrawTool.CreateTableLabel1(1);
                            tl.TitleText = "属性查询";
                            tl.SetRecord(0, 0, dffc.ToString());
                            IPoint ptTL          = null;
                            int    geoshapeindex = row.FieldIndex("Shape");
                            if (geoshapeindex != -1)
                            {
                                if (!row.IsNull(geoshapeindex))
                                {
                                    IGeometry geoShape = row.GetValue(geoshapeindex) as IGeometry;
                                    if (geoShape.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                                    {
                                        double         x         = 0;
                                        double         y         = 0;
                                        double         z         = 0;
                                        IMultiPolyline mPolyline = geoShape as IMultiPolyline;
                                        for (int m = 0; m < mPolyline.GeometryCount; m++)
                                        {
                                            IPolyline polyline = mPolyline.GetPolyline(m);
                                            IPoint    pttemp   = polyline.Midpoint;
                                            x += pttemp.X;
                                            y += pttemp.Y;
                                            z += pttemp.Z;
                                        }
                                        x      = x / mPolyline.GeometryCount;
                                        y      = y / mPolyline.GeometryCount;
                                        z      = z / mPolyline.GeometryCount;
                                        ptTL   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                        ptTL.X = x;
                                        ptTL.Y = y;
                                        ptTL.Z = z;
                                    }
                                    else if (geoShape.GeometryType == gviGeometryType.gviGeometryMultiPolygon)
                                    {
                                        double        x        = 0;
                                        double        y        = 0;
                                        double        z        = 0;
                                        IMultiPolygon mPolygon = geoShape as IMultiPolygon;
                                        for (int m = 0; m < mPolygon.GeometryCount; m++)
                                        {
                                            IPolygon polygon = mPolygon.GetPolygon(m);
                                            IPoint   pttemp  = polygon.Centroid;
                                            x += pttemp.X;
                                            y += pttemp.Y;
                                            z += pttemp.Z;
                                        }
                                        x      = x / mPolygon.GeometryCount;
                                        y      = y / mPolygon.GeometryCount;
                                        z      = z / mPolygon.GeometryCount;
                                        ptTL   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                        ptTL.X = x;
                                        ptTL.Y = y;
                                        ptTL.Z = z;
                                    }
                                    else if (geoShape.GeometryType == gviGeometryType.gviGeometryPolyline)
                                    {
                                        ptTL = (geoShape as IPolyline).Midpoint;
                                    }
                                    else if (geoShape.GeometryType == gviGeometryType.gviGeometryPoint)
                                    {
                                        ptTL = geoShape as IPoint;
                                    }
                                    else if (geoShape.GeometryType == gviGeometryType.gviGeometryPolygon)
                                    {
                                        ptTL = (geoShape as IPolygon).Centroid;
                                    }
                                }
                            }
                            if (ptTL != null)
                            {
                                tl.Position = ptTL;
                            }
                            else
                            {
                                tl.Position = geo;
                            }
                            app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo);
                            app.Current3DMapControl.ObjectManager.DelayDelete(tl.Guid, 5000);
                        }

                        #endregion

                        foreach (DFDataConfig.Class.FieldInfo facField in facFields)
                        {
                            if (!facField.CanQuery)
                            {
                                continue;
                            }
                            int index = row.FieldIndex(facField.Name);
                            if (index != -1 && !row.IsNull(index))
                            {
                                object     obj  = row.GetValue(index);
                                string     str  = "";
                                IFieldInfo fiFC = row.Fields.Get(index);
                                switch (fiFC.FieldType)
                                {
                                case gviFieldType.gviFieldBlob:
                                case gviFieldType.gviFieldUnknown:
                                case gviFieldType.gviFieldGeometry:
                                    continue;

                                case gviFieldType.gviFieldFloat:
                                case gviFieldType.gviFieldDouble:
                                    double d;
                                    if (double.TryParse(obj.ToString(), out d))
                                    {
                                        str = d.ToString("0.00");
                                    }
                                    break;

                                default:
                                    str = obj.ToString();
                                    break;
                                }
                                DataRow dr = this._dtShow.NewRow();
                                dr["Property"] = facField.ToString();
                                dr["Value"]    = str;
                                this._dtShow.Rows.Add(dr);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    if (cursor != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                        cursor = null;
                    }
                    if (row != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                        row = null;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void GetData()
        {
            if (this.cbLayer.SelectedItem == null)
            {
                return;
            }
            DF3DFeatureClass dffc = this.cbLayer.SelectedItem as DF3DFeatureClass;

            if (dffc == null)
            {
                return;
            }
            IFeatureClass fc = dffc.GetFeatureClass();

            if (fc == null)
            {
                return;
            }

            if (_num > _count || _count == 0)
            {
                return;
            }

            ISpatialFilter filter = this._filter;

            filter.ResultBeginIndex = _num - 1;
            filter.ResultLimit      = 1;
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                cursor = fc.Search(filter, false);
                if ((row = cursor.NextRow()) != null)
                {
                    #region 定位
                    int             geoindex = row.FieldIndex("Geometry");
                    DF3DApplication app      = DF3DApplication.Application;
                    if (geoindex != -1 && !row.IsNull(geoindex) && app != null && app.Current3DMapControl != null)
                    {
                        ISurfaceSymbol ss = new SurfaceSymbolClass();
                        ss.Color = 0xcc00ff00;
                        ICurveSymbol cs = new CurveSymbolClass();
                        cs.Color          = 0xff00ff00;
                        cs.Width          = -5;
                        ss.BoundarySymbol = cs;
                        ISimplePointSymbol ps = new SimplePointSymbol();
                        ps.Size      = SystemInfo.Instance.SymbolSize;
                        ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                        IGeometry geo  = row.GetValue(geoindex) as IGeometry;
                        IPoint    ptTL = null;
                        if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                        {
                            double         x         = 0;
                            double         y         = 0;
                            double         z         = 0;
                            IMultiPolyline mPolyline = geo as IMultiPolyline;
                            for (int m = 0; m < mPolyline.GeometryCount; m++)
                            {
                                IPolyline polyline = mPolyline.GetPolyline(m);
                                IPoint    pttemp   = polyline.Midpoint;
                                x += pttemp.X;
                                y += pttemp.Y;
                                z += pttemp.Z;
                            }
                            x      = x / mPolyline.GeometryCount;
                            y      = y / mPolyline.GeometryCount;
                            z      = z / mPolyline.GeometryCount;
                            ptTL   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            ptTL.X = x;
                            ptTL.Y = y;
                            ptTL.Z = z;
                            IRenderMultiPolyline rMPolyline = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolyline(mPolyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                            rMPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                            rMPolyline.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rMPolyline.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rMPolyline.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolygon)
                        {
                            double        x        = 0;
                            double        y        = 0;
                            double        z        = 0;
                            IMultiPolygon mPolygon = geo as IMultiPolygon;
                            for (int m = 0; m < mPolygon.GeometryCount; m++)
                            {
                                IPolygon polygon = mPolygon.GetPolygon(m);
                                IPoint   pttemp  = polygon.Centroid;
                                x += pttemp.X;
                                y += pttemp.Y;
                                z += pttemp.Z;
                            }
                            x      = x / mPolygon.GeometryCount;
                            y      = y / mPolygon.GeometryCount;
                            z      = z / mPolygon.GeometryCount;
                            ptTL   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            ptTL.X = x;
                            ptTL.Y = y;
                            ptTL.Z = z;
                            IRenderMultiPolygon rMPolygon = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(mPolygon, ss, app.Current3DMapControl.ProjectTree.RootID);
                            rMPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                            rMPolygon.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rMPolygon.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rMPolygon.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                        {
                            IPolyline polyline = geo as IPolyline;
                            ptTL = polyline.Midpoint;
                            IRenderPolyline rPolyline = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                            rPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                            rPolyline.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rPolyline.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rPolyline.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryPoint)
                        {
                            IPoint point = geo as IPoint;
                            ptTL = point;
                            IRenderPoint rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(point, ps, app.Current3DMapControl.ProjectTree.RootID);
                            rPoint.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rPoint.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rPoint.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryPolygon)
                        {
                            IPolygon polygon = geo as IPolygon;
                            ptTL = polygon.Centroid;
                            IRenderPolygon rPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon, ss, app.Current3DMapControl.ProjectTree.RootID);
                            rPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                            rPolygon.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rPolygon.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rPolygon.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint)
                        {
                            ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            IModelPoint mp = geo as IModelPoint;
                            ptTL.X = mp.X;
                            ptTL.Y = mp.Y;
                            ptTL.Z = mp.Z;
                            IModelPointSymbol mps = new ModelPointSymbol();
                            mps.SetResourceDataSet(fc.FeatureDataSet);
                            IRenderGeometry render = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(mp, mps, app.Current3DMapControl.ProjectTree.RootID);
                            render.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(render.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(render.Guid, gviActionCode.gviActionJump);
                        }
                        if (ptTL != null)
                        {
                            ITableLabel tl = DrawTool.CreateTableLabel1(1);
                            tl.TitleText = "属性查询";
                            tl.SetRecord(0, 0, dffc.ToString());
                            if (ptTL != null)
                            {
                                tl.Position = ptTL;
                            }
                            app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo);
                            app.Current3DMapControl.ObjectManager.DelayDelete(tl.Guid, 8000);
                        }
                    }
                    #endregion
                    FacilityClass facc = dffc.GetFacilityClass();
                    if (facc == null)
                    {
                        IFieldInfoCollection fiCol = fc.GetFields();
                        for (int i = 0; i < fiCol.Count; i++)
                        {
                            IFieldInfo fi  = fiCol.Get(i);
                            object     obj = row.GetValue(i);
                            string     str = "";
                            switch (fi.FieldType)
                            {
                            case gviFieldType.gviFieldBlob:
                            case gviFieldType.gviFieldUnknown:
                            case gviFieldType.gviFieldGeometry:
                                continue;

                            case gviFieldType.gviFieldFloat:
                            case gviFieldType.gviFieldDouble:
                                double d;
                                if (double.TryParse(obj.ToString(), out d))
                                {
                                    str = d.ToString("0.00");
                                }
                                break;

                            default:
                                str = obj.ToString();
                                break;
                            }
                            DataRow dr = this._dtShow.NewRow();
                            dr["Property"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias;
                            dr["Value"]    = str;
                            this._dtShow.Rows.Add(dr);
                        }
                    }
                    else
                    {
                        List <DFDataConfig.Class.FieldInfo> facFields = facc.FieldInfoCollection;
                        if (facFields != null)
                        {
                            foreach (DFDataConfig.Class.FieldInfo facField in facFields)
                            {
                                if (!facField.CanQuery)
                                {
                                    continue;
                                }
                                int index = row.FieldIndex(facField.Name);
                                if (index != -1 && !row.IsNull(index))
                                {
                                    object     obj  = row.GetValue(index);
                                    string     str  = "";
                                    IFieldInfo fiFC = row.Fields.Get(index);
                                    switch (fiFC.FieldType)
                                    {
                                    case gviFieldType.gviFieldBlob:
                                    case gviFieldType.gviFieldUnknown:
                                    case gviFieldType.gviFieldGeometry:
                                        continue;

                                    case gviFieldType.gviFieldFloat:
                                    case gviFieldType.gviFieldDouble:
                                        double d;
                                        if (double.TryParse(obj.ToString(), out d))
                                        {
                                            str = d.ToString("0.00");
                                        }
                                        break;

                                    default:
                                        str = obj.ToString();
                                        break;
                                    }
                                    DataRow dr = this._dtShow.NewRow();
                                    dr["Property"] = facField.ToString();
                                    dr["Value"]    = str;
                                    this._dtShow.Rows.Add(dr);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
Ejemplo n.º 8
0
        private DataTable DoStats()
        {
            DataTable dtResult = new DataTable();

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

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

            tmpPath = Path.Combine(localDataPath, "Stats");
            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }
            string filePath = tmpPath + "\\全库3D管点统计.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 = LogicDataStructureManage3D.Instance.GetAllMajorClass();

            foreach (MajorClass mc in list)
            {
                string[] arrFc3DId = mc.Fc3D.Split(';');
                if (arrFc3DId == null)
                {
                    continue;
                }
                long majorclasscount = 0;
                int  indexStart      = dtResult.Rows.Count;
                foreach (SubClass sc in mc.SubClasses)
                {
                    long sccount = 0;
                    bool bHave   = false;
                    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 != "PipeNode")
                        {
                            continue;
                        }
                        IQueryFilter filter = new QueryFilter();
                        filter.WhereClause = "GroupId = " + sc.GroupId;
                        int count = fc.GetCount(filter);
                        if (count == 0)
                        {
                            continue;
                        }
                        bHave    = true;
                        sccount += count;
                    }
                    if (bHave)
                    {
                        DataRow dr = dtResult.NewRow();
                        dr["PIPENODETYPE"] = mc;
                        dr["FIELDNAME"]    = "";
                        dr["PVALUE"]       = sc;
                        dr["NUMBER"]       = sccount;
                        majorclasscount   += sccount;
                        dtResult.Rows.Add(dr);
                    }
                }
                int indexEnd = dtResult.Rows.Count;
                for (int i = indexStart; i < indexEnd; i++)
                {
                    DataRow dr = dtResult.Rows[i];
                    dr["TOTALNUMBER"] = majorclasscount;
                }
            }
            if (!bHaveXml)
            {
                dtResult.WriteXml(filePath);
            }
            return(dtResult);
        }
Ejemplo n.º 9
0
        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
            {
            }
        }
Ejemplo n.º 10
0
        private void OnFinishedDraw()
        {
            if (this._drawTool != null && this._drawTool.GeoType == DrawType.Polygon && this._drawTool.GetGeo() != null)
            {
                try
                {
                    WaitForm.Start("正在空间查询...", "请稍后");

                    List <MajorClass> listMCs = LogicDataStructureManage3D.Instance.GetAllMajorClass();
                    if (listMCs != null)
                    {
                        ISpatialFilter filter = new SpatialFilterClass();
                        filter.Geometry      = this._drawTool.GetGeo();
                        filter.GeometryField = "FootPrint";
                        filter.SpatialRel    = gviSpatialRel.gviSpatialRelContains;
                        Dictionary <MajorClass, List <IRowBuffer> > dict = new Dictionary <MajorClass, List <IRowBuffer> >();
                        foreach (MajorClass mc in listMCs)
                        {
                            IRowBuffer row    = null;
                            IFdeCursor cursor = null;
                            try
                            {
                                string[] arrFc3DId = mc.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();
                                    IFeatureLayer fl   = dffc.GetFeatureLayer();
                                    if (fl == null || fc == null || facc == null || facc.Name != "PipeLine")
                                    {
                                        continue;
                                    }
                                    if (fl.VisibleMask == gviViewportMask.gviViewNone)
                                    {
                                        continue;
                                    }
                                    int count = fc.GetCount(filter);
                                    if (count == 0)
                                    {
                                        break;
                                    }
                                    List <IRowBuffer> list = new List <IRowBuffer>();
                                    cursor = fc.Search(filter, false);
                                    while ((row = cursor.NextRow()) != null)
                                    {
                                        list.Add(row);
                                    }
                                    dict[mc] = list;
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            finally
                            {
                                if (row != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                                    row = null;
                                }
                                if (cursor != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                    cursor = null;
                                }
                            }
                        }
                        WaitForm.Stop();
                        if (dict.Count == 0)
                        {
                            XtraMessageBox.Show("该区域内没有管线", "提示");
                            return;
                        }
                        FrmPipelineCross dlg = new FrmPipelineCross(dict);
                        dlg.Show();
                    }
                }
                catch (Exception ex)
                {
                    WaitForm.Stop();
                }
                finally
                {
                }
            }
        }
Ejemplo n.º 11
0
        private DataTable RegionAnalysis()
        {
            IGeometry geo = this._drawTool.GetGeo();

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

            filter.Geometry      = geo;
            filter.SpatialRel    = gviSpatialRel.gviSpatialRelEnvelope;
            filter.GeometryField = "Geometry";
            DataTable dtResult = new DataTable();

            dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("PVALUE"),
                                                         new DataColumn("NUMBER", typeof(long)), new DataColumn("TOTALNUMBER", typeof(long)) });
            foreach (MajorClass mc in LogicDataStructureManage3D.Instance.GetAllMajorClass())
            {
                string[] arrFc3DId = mc.Fc3D.Split(';');
                if (arrFc3DId == null)
                {
                    continue;
                }
                long majorclasscount = 0;
                int  indexStart      = dtResult.Rows.Count;
                foreach (SubClass sc in mc.SubClasses)
                {
                    if (!sc.Visible3D)
                    {
                        continue;
                    }
                    long sccount = 0;
                    bool bHave   = false;
                    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 != "PipeNode")
                        {
                            continue;
                        }
                        int geometryIndex = fc.GetFields().IndexOf("Geometry");
                        if (geometryIndex == -1)
                        {
                            continue;
                        }
                        filter.WhereClause = "GroupId = " + sc.GroupId;
                        filter.SubFields   = "Geometry";

                        int count = fc.GetCount(filter);
                        if (count == 0)
                        {
                            continue;
                        }
                        int loop = (int)Math.Ceiling(count / 800.0);
                        for (int k = 1; k <= loop; k++)
                        {
                            if (k == 1)
                            {
                                filter.ResultBeginIndex = 0;
                            }
                            else
                            {
                                filter.ResultBeginIndex = (k - 1) * 800;
                            }
                            filter.ResultLimit = 800;
                            IFdeCursor cursor = fc.Search(filter, true);
                            IRowBuffer row    = null;
                            while ((row = cursor.NextRow()) != null)
                            {
                                IModelPoint modelPoint = row.GetValue(0) as IModelPoint;
                                if ((geo as IRelationalOperator2D).Contains2D(modelPoint))
                                {
                                    sccount++;
                                    bHave = true;
                                }
                            }
                        }
                    }
                    if (bHave)
                    {
                        DataRow dr = dtResult.NewRow();
                        dr["PIPENODETYPE"] = mc;
                        dr["PVALUE"]       = sc;
                        dr["NUMBER"]       = sccount;
                        majorclasscount   += sccount;
                        dtResult.Rows.Add(dr);
                    }
                }
                int indexEnd = dtResult.Rows.Count;
                for (int i = indexStart; i < indexEnd; i++)
                {
                    DataRow dr = dtResult.Rows[i];
                    dr["TOTALNUMBER"] = majorclasscount;
                }
            }
            return(dtResult);
        }
        private void DoQuery()
        {
            List <TreeListNode> list = this.treelist.GetAllCheckedNodes();

            if (list == null)
            {
                XtraMessageBox.Show("请勾选图层树。", "提示");
                return;
            }

            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 fiStartDepth = facc.GetFieldInfoBySystemName("BuildYear");
                        if (fiStartDepth == null)
                        {
                            continue;
                        }
                        int indexStartDepth = fc.GetFields().IndexOf(fiStartDepth.Name);
                        if (indexStartDepth == -1)
                        {
                            continue;
                        }
                        IFieldInfo fcfiStartDepth = fc.GetFields().Get(indexStartDepth);
                        switch (fcfiStartDepth.FieldType)
                        {
                        case gviFieldType.gviFieldBlob:
                        case gviFieldType.gviFieldGeometry:
                        case gviFieldType.gviFieldUnknown:
                            continue;
                        }

                        string whereCluase = "";
                        foreach (DataRow dr in this._dt.Rows)
                        {
                            double mind = double.Parse(dr["MinDepth"].ToString());
                            double maxd = double.Parse(dr["MaxDepth"].ToString());
                            whereCluase += "( " + fcfiStartDepth.Name + " >= '" + mind + "' and " + fcfiStartDepth.Name + " <= '" + maxd + "' )";
                            whereCluase += " or ";
                        }
                        if (this._dt.Rows.Count == 0)
                        {
                            whereCluase = "GroupId = " + sc.GroupId;
                        }
                        else
                        {
                            whereCluase = "GroupId = " + sc.GroupId + " and (" + whereCluase.Substring(0, whereCluase.Length - 4) + ")";
                        }

                        _dict.Add(sc, whereCluase);
                    }
                }
            }
        }
Ejemplo n.º 13
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 + "\\全库3D管线统计.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 = LogicDataStructureManage3D.Instance.GetAllMajorClass();

            foreach (MajorClass mc in list)
            {
                string[] arrFc3DId = mc.Fc3D.Split(';');
                if (arrFc3DId == null)
                {
                    continue;
                }
                double majorclasslength = 0.0;
                int    indexStart       = dtResult.Rows.Count;
                foreach (SubClass sc in mc.SubClasses)
                {
                    double subclasslength = 0.0;
                    bool   bHave          = false;
                    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 != "PipeLine")
                        {
                            continue;
                        }
                        DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength");
                        if (fiPipeLength == null)
                        {
                            continue;
                        }
                        int indexPipeLength = fc.GetFields().IndexOf(fiPipeLength.Name);
                        if (indexPipeLength == -1)
                        {
                            continue;
                        }

                        IQueryFilter filter = new QueryFilter();
                        filter.SubFields   = fiPipeLength.Name;
                        filter.WhereClause = "GroupId = " + sc.GroupId;
                        int count = fc.GetCount(filter);
                        if (count == 0)
                        {
                            continue;
                        }
                        int loop = (int)Math.Ceiling(count / 800.0);
                        for (int k = 1; k <= loop; k++)
                        {
                            if (k == 1)
                            {
                                filter.ResultBeginIndex = 0;
                            }
                            else
                            {
                                filter.ResultBeginIndex = (k - 1) * 800;
                            }
                            filter.ResultLimit = 800;
                            IFdeCursor cur    = null;
                            IRowBuffer rowBuf = null;
                            try
                            {
                                cur = fc.Search(filter, true);
                                while ((rowBuf = cur.NextRow()) != null)
                                {
                                    if (!rowBuf.IsNull(0))
                                    {
                                        object tempobj = rowBuf.GetValue(0);
                                        double dtemp   = 0.0;
                                        if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp))
                                        {
                                            subclasslength += dtemp;
                                            bHave           = true;
                                        }
                                    }
                                }
                            }
                            catch { }
                            finally
                            {
                                if (cur != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
                                    cur = null;
                                }
                                if (rowBuf != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rowBuf);
                                    rowBuf = null;
                                }
                            }
                        }
                    }
                    if (bHave)
                    {
                        DataRow dr = dtResult.NewRow();
                        dr["PIPELINETYPE"] = mc;
                        dr["FIELDNAME"]    = "";
                        dr["PVALUE"]       = sc;
                        dr["LENGTH"]       = subclasslength.ToString("0.00");
                        majorclasslength  += subclasslength;
                        dtResult.Rows.Add(dr);
                    }
                }
                int indexEnd = dtResult.Rows.Count;
                for (int i = indexStart; i < indexEnd; i++)
                {
                    DataRow dr = dtResult.Rows[i];
                    dr["TOTALLENGTH"] = majorclasslength.ToString("0.00");
                }
            }
            if (!bHaveXml)
            {
                dtResult.WriteXml(filePath);
            }
            return(dtResult);
        }
Ejemplo n.º 14
0
        private void LineQuery()
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

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

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

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

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

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


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

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

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

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

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

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

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

            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IQueryFilter filter = new QueryFilter();
                filter.WhereClause = fc.FidFieldName + "=" + featureId;
                if (fc.GetCount(filter) == 0)
                {
                    return(null);
                }
                cursor = fc.Search(filter, false);
                if (cursor == null)
                {
                    return(null);
                }
                row = cursor.NextRow();
                if (row == null)
                {
                    return(null);
                }

                FacilityClass               facClass = dffc.GetFacilityClass();
                IFieldInfoCollection        fiCol    = row.Fields;
                Dictionary <string, string> dict     = new Dictionary <string, string>();

                if (facClass == null)
                {
                    for (int i = 0; i < fiCol.Count; i++)
                    {
                        IFieldInfo fi  = row.Fields.Get(i);
                        object     obj = row.GetValue(i);
                        if (obj == null)
                        {
                            continue;
                        }
                        string str = "";
                        switch (fi.FieldType)
                        {
                        case gviFieldType.gviFieldBlob:
                        case gviFieldType.gviFieldUnknown:
                        case gviFieldType.gviFieldGeometry:
                            break;

                        case gviFieldType.gviFieldFloat:
                        case gviFieldType.gviFieldDouble:
                            double d;
                            if (double.TryParse(obj.ToString(), out d))
                            {
                                str = d.ToString("0.00");
                            }
                            break;

                        default:
                            str = obj.ToString();
                            break;
                        }
                        if (!string.IsNullOrEmpty(str.Trim()))
                        {
                            string temp = (string.IsNullOrEmpty(fi.Alias)) ? fi.Name : fi.Alias;
                            dict[temp] = str;
                        }
                    }
                }
                else
                {
                    foreach (DFDataConfig.Class.FieldInfo fi in facClass.FieldInfoCollection)
                    {
                        if (!fi.CanQuery)
                        {
                            continue;
                        }
                        int index = row.Fields.IndexOf(fi.Name);
                        if (index == -1)
                        {
                            continue;
                        }
                        object obj = row.GetValue(index);
                        if (obj == null)
                        {
                            continue;
                        }
                        IFieldInfo fiFC = row.Fields.Get(index);
                        string     str  = "";
                        switch (fiFC.FieldType)
                        {
                        case gviFieldType.gviFieldBlob:
                        case gviFieldType.gviFieldUnknown:
                        case gviFieldType.gviFieldGeometry:
                            break;

                        case gviFieldType.gviFieldFloat:
                        case gviFieldType.gviFieldDouble:
                            double d;
                            if (double.TryParse(obj.ToString(), out d))
                            {
                                str = d.ToString("0.00");
                            }
                            break;

                        default:
                            str = obj.ToString();
                            break;
                        }
                        if (!string.IsNullOrEmpty(str.Trim()))
                        {
                            string temp = (string.IsNullOrEmpty(fi.Alias)) ? fi.Name : fi.Alias;
                            dict[temp] = str;
                        }
                    }
                }
                return(dict);
            }
            catch (Exception ex)
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
                return(null);
            }
        }
Ejemplo n.º 16
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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
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();
            }
        }
Ejemplo n.º 18
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;
                }
            }
        }
        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);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private void ClassQuery(MajorClass mc, MajorClass mctemp, ISpatialFilter filter, IGeometry geo)
        {
            if (mc == null || filter == null || geo == null)
            {
                return;
            }
            string[] arrFc3DId = mc.Fc3D.Split(';');
            if (arrFc3DId == null)
            {
                return;
            }
            foreach (SubClass sc in mc.SubClasses)
            {
                if (!sc.Visible3D)
                {
                    continue;
                }
                bool bHave = false;
                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)
                    {
                        continue;
                    }
                    int geometryIndex = fc.GetFields().IndexOf("Geometry");
                    if (geometryIndex == -1)
                    {
                        continue;
                    }

                    filter.WhereClause = "GroupId = " + sc.GroupId;
                    filter.SubFields   = "Geometry";
                    int count = fc.GetCount(filter);
                    if (count == 0)
                    {
                        continue;
                    }
                    int loop = (int)Math.Ceiling(count / 800.0);
                    for (int k = 1; k <= loop; k++)
                    {
                        if (k == 1)
                        {
                            filter.ResultBeginIndex = 0;
                        }
                        else
                        {
                            filter.ResultBeginIndex = (k - 1) * 800;
                        }
                        filter.ResultLimit = 800;
                        IFdeCursor cursor = fc.Search(filter, true);
                        IRowBuffer row    = null;
                        while ((row = cursor.NextRow()) != null)
                        {
                            IModelPoint modelPoint = row.GetValue(0) as IModelPoint;
                            if ((geo as IRelationalOperator2D).Contains2D(modelPoint))
                            {
                                bHave    = true;
                                bHaveRes = true;
                                break;
                            }
                        }
                        if (bHave)
                        {
                            break;
                        }
                    }
                }
                if (bHave)
                {
                    SubClass sctemp = new SubClass(sc.Name, sc.GroupId, sc.Parent);
                    sctemp.Visible3D = sc.Visible3D;
                    mctemp.SubClasses.Add(sctemp);
                }
            }
        }