Example #1
0
        private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int           featureId       = int.Parse((sender as DataGridView).CurrentRow.Cells[0].Value.ToString());
            IFeatureClass curFeatureClass = null;

            foreach (IFeatureClass fc in fcMap.Keys)
            {
                curFeatureClass = fc;
                IRowBuffer fdeRow = curFeatureClass.GetRow(featureId);
                if (fdeRow != null)
                {
                    int nPos = fdeRow.FieldIndex("Geometry");
                    if (nPos != -1 && !fdeRow.IsNull(nPos))
                    {
                        IPOI   mp  = fdeRow.GetValue(nPos) as IPOI; // 从库中读取值
                        IPoint pos = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                        pos.Position   = mp.Position;
                        pos.SpatialCRS = mp.SpatialCRS;
                        IEulerAngle angle = new EulerAngle();
                        angle.Heading = 0;
                        angle.Tilt    = -60;
                        angle.Roll    = 0;
                        this.axRenderControl1.Camera.LookAt2(pos, 3000, angle);
                        this.axRenderControl1.FeatureManager.UnhighlightAll();
                        this.axRenderControl1.FeatureManager.HighlightFeature(curFeatureClass, int.Parse(fdeRow.GetValue(0).ToString()), System.Drawing.Color.Yellow);

                        mp.ImageName = (strMediaPath + @"\png\lan.png");
                        IRenderPOI rpoi = this.axRenderControl1.ObjectManager.CreateRenderPOI(mp);
                        rpoi.Highlight(System.Drawing.Color.Red);
                        this.axRenderControl1.ObjectManager.DelayDelete(rpoi.Guid, 60000);
                    }
                }
            }
        }
        // 读数据库获取逻辑树xml内容
        private byte[] GetLogicTreeContent(IFeatureDataSet dataset)
        {
            byte[] strContent = null;
            try
            {
                IQueryDef qd = dataset.DataSource.CreateQueryDef();
                qd.AddSubField("content");

                qd.Tables      = new string[] { "cm_logictree", "cm_group" };
                qd.WhereClause = string.Format("cm_group.groupuid = cm_logictree.groupid " + " and cm_group.DataSet = '{0}'", dataset.Name);
                IFdeCursor cursor = qd.Execute(false);

                IRowBuffer row = null;
                if ((row = cursor.NextRow()) != null)
                {
                    //content
                    int nPose = row.FieldIndex("content");
                    if (nPose != -1 || row.IsNull(nPose))
                    {
                        IBinaryBuffer bb = row.GetValue(nPose) as IBinaryBuffer;
                        strContent = (byte[])bb.AsByteArray();
                    }
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return(null);
            }

            return(strContent);
        }
Example #3
0
        public int GetMaxOID(IFeatureClass fc)
        {
            int maxOID = -1;

            if (fc == null)
            {
                return(maxOID);
            }
            QueryFilter filter = new QueryFilter();

            filter.AddSubField("max(oid) as MaxID");
            IFdeCursor cur = fc.Search(filter, true);
            IRowBuffer row = cur.NextRow();

            //Marshal.ReleaseComObject(cur);
            if (row == null)
            {
                return(maxOID);
            }

            if (row.IsNull(0))
            {
                return(maxOID);
            }

            maxOID = int.Parse(row.GetValue(0).ToString());

            return(maxOID);
        }
Example #4
0
 public static string GetString(IRowBuffer r, int nPos)
 {
     if (((r != null) && (nPos != -1)) && !r.IsNull(nPos))
     {
         return(r.GetValue(nPos).ToString());
     }
     return("");
 }
Example #5
0
 public static IGeometry GetGeometry(IRowBuffer r, int nPos)
 {
     if (((r == null) || (nPos == -1)) || r.IsNull(nPos))
     {
         return(null);
     }
     return(r.GetValue(nPos) as IGeometry);
 }
        public static TopoClass GetTopoClassByFacClassCode(string facClassCode)
        {
            if (DF3DPipeCreateApp.App.TemplateLib == null)
            {
                return(null);
            }
            IFdeCursor   o      = null;
            IRowBuffer   buffer = null;
            IQueryFilter filter = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_Catalog");
                if (oc == null)
                {
                    return(null);
                }
                filter = new QueryFilterClass
                {
                    WhereClause = string.Format("Code = '{0}'", facClassCode),
                    SubFields   = "TopoLayerId"
                };
                o      = oc.Search(filter, true);
                buffer = o.NextRow();
                if (buffer != null)
                {
                    if (buffer.IsNull(0))
                    {
                        return(null);
                    }
                    return(FacilityInfoService.GetTopoClassByObjectId(buffer.GetValue(0).ToString()));
                }
                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (o != null)
                {
                    Marshal.ReleaseComObject(o);
                    o = null;
                }
                if (buffer != null)
                {
                    Marshal.ReleaseComObject(buffer);
                    buffer = null;
                }
            }
        }
Example #7
0
        public static double GetDouble(IRowBuffer r, int nPos)
        {
            double result = 0.0;

            if (((r != null) && (nPos != -1)) && !r.IsNull(nPos))
            {
                double.TryParse(r.GetValue(nPos).ToString(), out result);
            }
            return(result);
        }
Example #8
0
        public static int GetInt(IRowBuffer r, int nPos)
        {
            int result = 0;

            if (((r != null) && (nPos != -1)) && !r.IsNull(nPos))
            {
                int.TryParse(r.GetValue(nPos).ToString(), out result);
            }
            return(result);
        }
Example #9
0
 private void GetResultSet(IFeatureClass fc, IQueryFilter filter, DataTable dt)
 {
     if (fc != null)
     {
         IFdeCursor cursor = null;
         try
         {
             if (filter != null)
             {
                 filter.PostfixClause = "order by oid asc";
             }
             // 查找所有记录
             cursor = fc.Search(filter, true);
             if (cursor != null)
             {
                 dt.BeginLoadData();
                 IRowBuffer fdeRow = null;
                 DataRow    dr     = null;
                 while ((fdeRow = cursor.NextRow()) != null)
                 {
                     dr = dt.NewRow();
                     for (int i = 0; i < dt.Columns.Count; ++i)
                     {
                         string strColName = dt.Columns[i].ColumnName;
                         int    nPos       = fdeRow.FieldIndex(strColName);
                         if (nPos == -1 || fdeRow.IsNull(nPos))
                         {
                             continue;
                         }
                         object v = fdeRow.GetValue(nPos);  // 从库中读取值
                         dr[i] = v;
                     }
                     dt.Rows.Add(dr);
                 }
                 dt.EndLoadData();
             }
             // 通过解析逻辑树获取GroupId对应的GroupName
             GroupId2LayerName(dt, fc.FeatureDataSet);
         }
         catch (COMException ex)
         {
             System.Diagnostics.Trace.WriteLine(ex.Message);
         }
         finally
         {
             if (cursor != null)
             {
                 //Marshal.ReleaseComObject(cursor);
                 cursor = null;
             }
         }
     }
 }
        private void InitData()
        {
            try
            {
                this.cbxFacilityStyle.SelectedIndex = -1;
                this.listStyles.SelectedIndex       = -1;
                DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer;
                if (dffc == null)
                {
                    return;
                }

                int count = SelectCollection.Instance().GetCount(false);
                if (count == 1)
                {
                    HashMap hm = SelectCollection.Instance().GetSelectGeometrys();
                    if (hm != null && hm.Count == 1)
                    {
                        IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection;
                        if (rowBufferCollection.Count == 1)
                        {
                            IRowBuffer rowBuffer = rowBufferCollection.Get(0);
                            int        index     = rowBuffer.FieldIndex("StyleId");
                            if (index != -1 && !rowBuffer.IsNull(index))
                            {
                                string styleId = rowBuffer.GetValue(index).ToString();
                                for (int i = 0; i < this.cbxFacilityStyle.Properties.Items.Count; i++)
                                {
                                    FacStyleClass fsc = this.cbxFacilityStyle.Properties.Items[i] as FacStyleClass;
                                    if (fsc.ObjectId == styleId)
                                    {
                                        this.cbxFacilityStyle.SelectedIndex = i;
                                        this.listStyles.SelectedIndex       = i;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #11
0
        private void ClickQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }
            try
            {
                IFeatureLayer fl = this._drawTool.GetSelectFeatureLayerPickResult().FeatureLayer;
                if (fl == null)
                {
                    return;
                }
                int           featureId = this._drawTool.GetSelectFeatureLayerPickResult().FeatureId;
                FacilityClass facc      = Dictionary3DTable.Instance.GetFacilityClassByDFFeatureClassID(fl.FeatureClassId.ToString());
                if (facc == null || facc.Name != "PipeNode")
                {
                    XtraMessageBox.Show("您选中的不是管点设施,请选择管点设施。", "提示");
                    return;
                }
                DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fl.FeatureClassId.ToString());
                if (dffc == null || dffc.GetFeatureClass() == null)
                {
                    return;
                }
                IFeatureClass fc = dffc.GetFeatureClass();
                if (this._bFinished)
                {
                    Clear();
                    this._startFCGuid = fc.Guid.ToString();
                    this._startOid    = featureId;
                    this._bFinished   = false;

                    ILabel label = app.Current3DMapControl.ObjectManager.CreateLabel(app.Current3DMapControl.ProjectTree.RootID);
                    label.Text = "起点";
                    ITextSymbol ts = new TextSymbol();
                    ts.TextAttribute.TextSize  = SystemInfo.Instance.TextSize;
                    ts.TextAttribute.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16);
                    label.TextSymbol           = ts;
                    label.Position             = this._drawTool.GetSelectPoint();
                    this._listRGuid.Add(label.Guid);
                }
                else
                {
                    if (this._startFCGuid == fc.Guid.ToString() && this._startOid == featureId)
                    {
                        XtraMessageBox.Show("您选中的是同一个管点设施。", "提示");
                        return;
                    }
                    this._bFinished = true;
                    ILabel label = app.Current3DMapControl.ObjectManager.CreateLabel(app.Current3DMapControl.ProjectTree.RootID);
                    label.Text = "终点";
                    ITextSymbol ts = new TextSymbol();
                    ts.TextAttribute.TextSize  = SystemInfo.Instance.TextSize;
                    ts.TextAttribute.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16);
                    label.TextSymbol           = ts;
                    label.Position             = this._drawTool.GetSelectPoint();
                    this._listRGuid.Add(label.Guid);
                    if (this._startFCGuid != fc.Guid.ToString())
                    {
                        XtraMessageBox.Show("您选中的不是同一类管点设施。", "提示");
                        return;
                    }
                    else
                    {
                        WaitForm.Start("正在分析...", "请稍后");
                        FacClassReg reg = FacilityInfoService.GetFacClassRegByFeatureClassID(fc.Guid.ToString());
                        if (reg == null)
                        {
                            return;
                        }
                        TopoClass tc = FacilityInfoService.GetTopoClassByFacClassCode(reg.FacClassCode);
                        if (tc == null)
                        {
                            return;
                        }
                        TopoNetwork net = tc.GetNetwork();
                        if (net == null)
                        {
                            XtraMessageBox.Show("构建拓扑网络失败!", "提示");
                            return;
                        }
                        else
                        {
                            string        startId = this._startFCGuid + "_" + this._startOid.ToString();
                            string        endId   = fc.Guid.ToString() + "_" + featureId.ToString();
                            List <string> path;
                            double        shortestLength = net.SPFA(startId, endId, out path);
                            if ((shortestLength > 0.0 && shortestLength != double.MaxValue) || (path != null && path.Count > 0))
                            {
                                List <IPoint> listPt = new List <IPoint>();
                                foreach (string nodeId in path)
                                {
                                    int              index    = nodeId.LastIndexOf("_");
                                    string           fcguid   = nodeId.Substring(0, index);
                                    string           oid      = nodeId.Substring(index + 1, nodeId.Length - index - 1);
                                    DF3DFeatureClass dffcTemp = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fcguid);
                                    if (dffcTemp == null || dffcTemp.GetFeatureClass() == null)
                                    {
                                        continue;
                                    }
                                    if (dffcTemp.GetFacilityClassName() != "PipeNode")
                                    {
                                        continue;
                                    }
                                    IQueryFilter filter = new QueryFilter();
                                    filter.WhereClause = "oid = " + oid;
                                    filter.SubFields   = "oid,Shape";
                                    IRowBuffer row    = null;
                                    IFdeCursor cursor = null;
                                    try
                                    {
                                        cursor = dffcTemp.GetFeatureClass().Search(filter, false);
                                        while ((row = cursor.NextRow()) != null)
                                        {
                                            if (!row.IsNull(1) && (row.GetValue(1) is IGeometry))
                                            {
                                                IGeometry geo = row.GetValue(1) as IGeometry;
                                                switch (geo.GeometryType)
                                                {
                                                case gviGeometryType.gviGeometryPoint:
                                                    IPoint pt = geo as IPoint;
                                                    pt.Z = pt.Z + 1;
                                                    listPt.Add(pt);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    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;
                                        }
                                    }
                                }
                                IPolyline polyline = (new GeometryFactory()).CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                                foreach (IPoint pt in listPt)
                                {
                                    ISimplePointSymbol ps = new SimplePointSymbol();
                                    ps.Size      = 5;
                                    ps.Style     = gviSimplePointStyle.gviSimplePointCircle;
                                    ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                                    IRenderPoint rp = app.Current3DMapControl.ObjectManager.CreateRenderPoint(pt, ps, app.Current3DMapControl.ProjectTree.RootID);
                                    rp.Glow(5000);
                                    polyline.AppendPoint(pt);
                                    this._listRGuid.Add(rp.Guid);
                                }
                                ICurveSymbol cs = new CurveSymbol();
                                cs.Color = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16);
                                cs.Width = -5;
                                IRenderPolyline rpl = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                                rpl.Glow(5000);
                                this._listRGuid.Add(rpl.Guid);
                            }
                            else
                            {
                                XtraMessageBox.Show("两点不连通!", "提示");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("分析出错!", "提示");
            }
            finally
            {
                WaitForm.Stop();
            }
        }
Example #12
0
        public List <PipeLineFac> GetTopoPipeLine()
        {
            if (this._tc == null)
            {
                return(null);
            }
            if (DF3DPipeCreateApp.App.PipeLib == null)
            {
                return(null);
            }
            IQueryFilter filter = null;
            IFdeCursor   o      = null;
            IRowBuffer   r      = null;
            Dictionary <string, List <int> > dictionary  = null;
            Dictionary <string, FacClassReg> dictReg     = null;
            Dictionary <int, int>            dictionary2 = null;
            List <PipeLineFac> list = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IFeatureClass class2 = fds.OpenFeatureClass(this._tc.TopoTable);
                if (class2 == null)
                {
                    return(null);
                }
                filter = new QueryFilterClass
                {
                    WhereClause = string.Format("(P_FacClass = '{0}' and PNode = {1}) or (E_FacClass = '{0}' and ENode = {1})", this._facClassReg.FeatureClassId, base._oid),
                    SubFields   = "oid,A_FacClass,Edge,PNode,ENode"
                };
                int count = class2.GetCount(filter);
                if (count == 0)
                {
                    return(null);
                }
                dictionary  = new Dictionary <string, List <int> >();
                dictionary2 = new Dictionary <int, int>();
                dictReg     = new Dictionary <string, FacClassReg>();
                o           = class2.Search(filter, true);
                while ((r = o.NextRow()) != null)
                {
                    if (!r.IsNull(1) && !r.IsNull(2))
                    {
                        FacClassReg reg = GetFacClassReg(r.GetValue(1).ToString());
                        if (!dictionary.ContainsKey(reg.FacClassCode))
                        {
                            dictionary.Add(reg.FacClassCode, new List <int>());
                            dictReg.Add(reg.FacClassCode, reg);
                        }
                        dictionary[reg.FacClassCode].Add(Fac.GetInt(r, 2));
                        if (Fac.GetInt(r, 3) == this._oid)
                        {
                            dictionary2.Add(Fac.GetInt(r, 2), 0);
                        }
                        else
                        {
                            dictionary2.Add(Fac.GetInt(r, 2), 1);
                        }
                    }
                }
                if (dictionary.Count == 0)
                {
                    return(null);
                }
                list = new List <PipeLineFac>();
                foreach (KeyValuePair <string, List <int> > pair in dictionary)
                {
                    FacClassReg reg = dictReg[pair.Key];
                    if (reg.FacilityType.Name == "PipeLine")
                    {
                        IFeatureClass class3 = reg.GetFeatureClass();
                        o = class3.GetRows(pair.Value.ToArray(), false);
                        while ((r = o.NextRow()) != null)
                        {
                            int index = r.FieldIndex("StyleId");
                            if (index == -1)
                            {
                                continue;
                            }
                            FacStyleClass style = GetFacStyleByID(r.GetValue(index).ToString());
                            if (style != null)
                            {
                                PipeLineFac line = new PipeLineFac(reg, style, r, this._tc);
                                line.Tag = dictionary2[line.FeatureId];
                                list.Add(line);
                            }
                        }
                    }
                }
                return(list);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (o != null)
                {
                    Marshal.ReleaseComObject(o);
                    o = null;
                }
                if (r != null)
                {
                    Marshal.ReleaseComObject(r);
                    r = null;
                }
            }
        }
Example #13
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;
                    }
                }
            }
        }
Example #14
0
        /// <summary>
        /// 定位和闪烁
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int           featureId       = int.Parse((sender as DataGridView).CurrentRow.Cells[0].Value.ToString());
            IFeatureClass curFeatureClass = null;

            switch (tabControl1.SelectedTab.Name)
            {
            case "tabPage0Road":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Road")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;

            case "tabPage1Building":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Building")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;

            case "tabPage2Trees":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Trees")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;

            case "tabPage3Facility":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Facility")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;

            case "tabPage4LandScape":
            {
                foreach (IFeatureClass fc in fcMap.Keys)
                {
                    if (fc.Name == "Landscape")
                    {
                        curFeatureClass = fc;
                    }
                }
            }
            break;
            }

            string       filterString = string.Format("oid={0}", featureId);
            IQueryFilter filter       = new QueryFilter();

            filter.WhereClause = filterString;
            IFdeCursor cursor = null;

            try
            {
                cursor = curFeatureClass.Search(filter, true);
                if (cursor != null)
                {
                    IRowBuffer fdeRow = null;
                    if ((fdeRow = cursor.NextRow()) != null)
                    {
                        int nPos = fdeRow.FieldIndex("Geometry");
                        if (nPos != -1 && !fdeRow.IsNull(nPos))
                        {
                            IModelPoint       mp     = fdeRow.GetValue(nPos) as IModelPoint; // 从库中读取值
                            IModelPointSymbol symbol = new ModelPointSymbol();
                            symbol.SetResourceDataSet(curFeatureClass.FeatureDataSet);
                            IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, symbol, rootId);
                            if (rmp != null)
                            {
                                // 定位
                                this.axRenderControl1.Camera.FlyToObject(rmp.Guid, gviActionCode.gviActionJump);
                                // 闪烁
                                rmp.Glow(2000);
                                this.axRenderControl1.ObjectManager.DelayDelete(rmp.Guid, 2000);
                            }
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
            }
        }
Example #15
0
        private TextureClass GetTextureClass(string objectId)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IDataSource ds = DF3DPipeCreateApp.App.TemplateLib;
                if (ds == null)
                {
                    return(null);
                }
                IFeatureDataSet fds = ds.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_TextureInfo");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause = "ObjectId = '" + objectId + "'"
                };
                cursor = oc.Search(filter, true);
                if ((row = cursor.NextRow()) != null)
                {
                    int    id = -1;
                    string name = "", objectid = "", groupid = "", code = "", comment = "";
                    Image  thumbnail = null;
                    int    index     = row.FieldIndex("oid");
                    if (index != -1 && !row.IsNull(index))
                    {
                        id = Convert.ToInt32(row.GetValue(index).ToString());
                    }
                    index = row.FieldIndex("Name");
                    if (index != -1 && !row.IsNull(index))
                    {
                        name = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("ObjectId");
                    if (index != -1 && !row.IsNull(index))
                    {
                        objectid = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("GroupId");
                    if (index != -1 && !row.IsNull(index))
                    {
                        groupid = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("Code");
                    if (index != -1 && !row.IsNull(index))
                    {
                        code = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("Comment");
                    if (index != -1 && !row.IsNull(index))
                    {
                        comment = row.GetValue(index).ToString();
                    }
                    index = row.FieldIndex("Thumbnail");
                    if (index != -1 && !row.IsNull(index))
                    {
                        IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer;
                        if (row != null)
                        {
                            MemoryStream stream = new MemoryStream(b.AsByteArray());
                            thumbnail = Image.FromStream(stream);
                        }
                    }
                    if (id != -1 && thumbnail != null)
                    {
                        TextureClass cc = new TextureClass();
                        cc.Id        = id; cc.Name = name; cc.Group = groupid;
                        cc.ObjectId  = objectid; cc.Code = code; cc.Comment = comment;
                        cc.Thumbnail = thumbnail;
                        return(cc);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
Example #16
0
        private void cmbField_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                this.lbcFieldValues.Items.Clear();
                this.teFieldValue.Text = "";
                if (this.cmbField.SelectedItem == null)
                {
                    return;
                }
                if (this.cmbLayer.SelectedItem == null)
                {
                    return;
                }
                DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass;
                IFeatureClass    fc   = dffc.GetFeatureClass();
                if (fc == null)
                {
                    return;
                }
                string fieldName = "";
                if (this.cmbField.SelectedItem is DFDataConfig.Class.FieldInfo)
                {
                    fieldName = (this.cmbField.SelectedItem as DFDataConfig.Class.FieldInfo).Name;
                }
                if (fieldName == "")
                {
                    return;
                }

                HashSet <string> list      = new HashSet <string>();
                string           cacheType = fc.GuidString + "_3D_" + fieldName;
                object           objCache  = CacheHelper.GetCache(cacheType);
                if (objCache != null && objCache is HashSet <string> )
                {
                    HashSet <string> temphs = objCache as HashSet <string>;
                    foreach (string str in temphs)
                    {
                        this.lbcFieldValues.Items.Add(str);
                    }
                    return;
                }
                #region
                IRowBuffer row    = null;
                IFdeCursor cursor = null;
                try
                {
                    int  index   = fc.GetFields().IndexOf(fieldName);
                    bool bString = true;
                    if (index != -1)
                    {
                        IFieldInfo fi = fc.GetFields().Get(index);
                        switch (fi.FieldType)
                        {
                        case gviFieldType.gviFieldDouble:
                        case gviFieldType.gviFieldFID:
                        case gviFieldType.gviFieldFloat:
                        case gviFieldType.gviFieldInt16:
                        case gviFieldType.gviFieldInt32:
                        case gviFieldType.gviFieldInt64:
                        case gviFieldType.gviFieldUUID:
                            bString = false;
                            break;

                        case gviFieldType.gviFieldDate:
                        case gviFieldType.gviFieldString:
                            bString = true;
                            break;

                        default:
                            break;
                        }
                    }
                    IQueryFilter filter = new QueryFilter();
                    filter.SubFields        = fieldName;
                    filter.ResultBeginIndex = 0;
                    filter.ResultLimit      = 1;
                    while (true)
                    {
                        string strTempClause = fieldName + " is not null and ";
                        string fClause       = strTempClause;
                        foreach (string strtemp in list)
                        {
                            if (bString)
                            {
                                fClause += fieldName + " <> '" + strtemp + "' and ";
                            }
                            else
                            {
                                fClause += fieldName + " <> " + strtemp + " and ";
                            }
                        }
                        fClause            = fClause.Substring(0, fClause.Length - 5);
                        filter.WhereClause = fClause;

                        cursor = fc.Search(filter, true);
                        if ((row = cursor.NextRow()) != null)
                        {
                            if (row.IsNull(0))
                            {
                                break;
                            }
                            object temp    = row.GetValue(0);
                            string strtemp = temp.ToString();
                            if (temp != null)
                            {
                                list.Add(strtemp);
                                if (list.Count > 10)
                                {
                                    break;// 列举10个
                                }
                            }
                            if (cursor != null)
                            {
                                System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                cursor = null;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    CacheHelper.SetCache(cacheType, list);
                }
                catch (Exception Exception)
                {
                }
                finally
                {
                    if (cursor != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                        cursor = null;
                    }
                    if (row != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                        row = null;
                    }
                }
                #endregion
                foreach (string str in list)
                {
                    this.lbcFieldValues.Items.Add(str);
                }
            }
            catch (Exception Exception)
            {
            }
        }
        private void CircleQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

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

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

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

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

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

                                case gviGeometryType.gviGeometryModelPoint:
                                    IModelPoint pt1  = geo as IModelPoint;
                                    IPOI        poi1 = (new GeometryFactoryClass()).CreateGeometry(gviGeometryType.gviGeometryPOI, gviVertexAttribute.gviVertexAttributeZ) as IPOI;
                                    poi1.X         = pt1.X;
                                    poi1.Y         = pt1.Y;
                                    poi1.Z         = pt1.Z + 2;
                                    poi1.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\POI\\fireHydrant.png");
                                    poi1.Size      = SystemInfo.Instance.SymbolSize;
                                    poi1.ShowName  = false;
                                    IRenderPOI rpoi1 = app.Current3DMapControl.ObjectManager.CreateRenderPOI(poi1);
                                    this._listRGuid.Add(rpoi1.Guid);
                                    continue;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        if (cursor != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                            cursor = null;
                        }
                        if (row != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                            row = null;
                        }
                    }
                }
            }
            catch (Exception ex) { }
            finally
            {
                WaitForm.Stop();
            }
        }
Example #18
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            try
            {
                if (this._dt.Rows.Count == 0)
                {
                    return;
                }
                if (!this.ceConnectMajorClass.Checked && !this.ceConnectFacility.Checked)
                {
                    return;
                }
                WaitForm.Start("三维数据关联设置启动...", "请稍后", new Size(400, 50));
                CheckRowGroup();
                WaitForm.SetCaption("设施类关联设置进行中...");
                // 设置设施类
                HashSet <FacilityClass> listFac = _checkFacCList;
                if (listFac != null && this.ceConnectFacility.Checked)
                {
                    foreach (FacilityClass fac in listFac)
                    {
                        string strTemp = "";
                        foreach (DataRow dr in this._dt.Rows)
                        {
                            if (!(bool)dr["CheckState"])
                            {
                                continue;
                            }
                            IFeatureClass featureClass = dr["FeatureClass"] as IFeatureClass;
                            if (featureClass == null)
                            {
                                continue;
                            }
                            FacilityClass fcc = dr["FacilityClass"] as FacilityClass;
                            if (fcc == fac)
                            {
                                strTemp += featureClass.GuidString + ";";
                            }
                        }
                        if (this._facDoc != null)
                        {
                            XmlNode node = this._facDoc.SelectSingleNode(".//FacilityClass[@name=\"" + fac.Name + "\"]");
                            if (node != null)
                            {
                                if (node.Attributes["fc3D"] == null)
                                {
                                    XmlAttribute attr = this._facDoc.CreateAttribute("fc3D");
                                    node.Attributes.Append(attr);
                                }
                                node.Attributes["fc3D"].Value = strTemp;
                            }
                            this._facDoc.Save(this._xmlFacFilePath);
                        }
                    }
                }
                //设施大类所属
                WaitForm.SetCaption("所属大类关联设置进行中...");
                HashSet <MajorClass> listMC = _checkMCList;
                if (listMC != null && this.ceConnectMajorClass.Checked)
                {
                    foreach (MajorClass mc in listMC)
                    {
                        string strTemp = "";
                        List <IFeatureClass> listFc = new List <IFeatureClass>();
                        foreach (DataRow dr in this._dt.Rows)
                        {
                            if (!(bool)dr["CheckState"])
                            {
                                continue;
                            }
                            IFeatureClass featureClass = dr["FeatureClass"] as IFeatureClass;
                            if (featureClass == null)
                            {
                                continue;
                            }
                            MajorClass mcc = dr["MajorClass"] as MajorClass;
                            if (mcc == mc)
                            {
                                strTemp += featureClass.GuidString + ";";
                                listFc.Add(featureClass);
                            }
                        }
                        if (this._logicDoc != null)
                        {
                            XmlNode node = this._logicDoc.SelectSingleNode(".//MajorClass[@name=\"" + mc.Name + "\"]");
                            if (node != null)
                            {
                                if (node.Attributes["fc3D"] == null)
                                {
                                    XmlAttribute attr = this._logicDoc.CreateAttribute("fc3D");
                                    node.Attributes.Append(attr);
                                }
                                node.Attributes["fc3D"].Value = strTemp;
                            }
                            for (int i = node.ChildNodes.Count - 1; i >= 0; i--)
                            {
                                XmlNode childNode = node.ChildNodes[i];
                                node.RemoveChild(childNode);
                            }
                            //foreach (XmlNode childNode in node.ChildNodes)
                            //{
                            //    node.RemoveChild(childNode);
                            //}

                            // 二级分组
                            WaitForm.SetCaption("小类分组中...");
                            IQueryFilter     filter   = null;
                            IFdeCursor       cursor   = null;
                            IRowBuffer       row      = null;
                            HashSet <string> hsValues = new HashSet <string>();
                            try
                            {
                                foreach (IFeatureClass fc in listFc)
                                {
                                    WaitForm.SetCaption("要素类【" + (string.IsNullOrEmpty(fc.AliasName) ? fc.Name : fc.AliasName) + "】分组中...");
                                    if (fc.GetFields().IndexOf(mc.ClassifyField) == -1)
                                    {
                                        continue;
                                    }
                                    if (fc.GetFields().IndexOf("GroupId") == -1)
                                    {
                                        continue;
                                    }
                                    filter           = new QueryFilter();
                                    filter.SubFields = mc.ClassifyField;
                                    cursor           = fc.Search(filter, true);

                                    while ((row = cursor.NextRow()) != null)
                                    {
                                        if (!row.IsNull(0))
                                        {
                                            hsValues.Add(row.GetValue(0).ToString());
                                        }
                                    }
                                    if (cursor != null)
                                    {
                                        System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                        cursor = null;
                                    }
                                    if (row != null)
                                    {
                                        System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                                        row = null;
                                    }
                                    fc.SubTypeFieldName = "";
                                    fc.SubTypeFieldName = "GroupId";
                                }
                                // 重设groupid
                                WaitForm.SetCaption("启动重置GroupId...");
                                foreach (IFeatureClass fc in listFc)
                                {
                                    string strfcname = (string.IsNullOrEmpty(fc.AliasName) ? fc.Name : fc.AliasName);
                                    WaitForm.SetCaption("要素类【" + strfcname + "】重置GroupId中...");
                                    if (fc.GetFields().IndexOf(mc.ClassifyField) == -1)
                                    {
                                        continue;
                                    }
                                    if (fc.GetFields().IndexOf("GroupId") == -1)
                                    {
                                        continue;
                                    }
                                    filter           = new QueryFilter();
                                    filter.SubFields = "GroupId,oid";
                                    int groupid = -1;
                                    foreach (string str in hsValues)
                                    {
                                        groupid++;
                                        filter.WhereClause = mc.ClassifyField + " = '" + str + "'";
                                        int fccount = fc.GetCount(filter);
                                        if (fccount == 0)
                                        {
                                            continue;
                                        }
                                        int counttemp = 0;
                                        cursor = fc.Update(filter);
                                        while ((row = cursor.NextRow()) != null)
                                        {
                                            row.SetValue(0, groupid);
                                            cursor.UpdateRow(row);
                                            counttemp++;
                                            WaitForm.SetCaption("要素类【" + strfcname + "】子类【" + str + "】(" + counttemp + "/" + fccount + ")重置GroupId中...");
                                        }
                                        if (cursor != null)
                                        {
                                            System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                            cursor = null;
                                        }
                                        if (row != null)
                                        {
                                            System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                                            row = null;
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                            finally
                            {
                                if (cursor != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                    cursor = null;
                                }
                                if (row != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                                    row = null;
                                }
                                if (filter != null)
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(filter);
                                    row = null;
                                }
                            }
                            WaitForm.SetCaption("分组信息写入配置文件中...");
                            int index = -1;
                            foreach (string str in hsValues)
                            {
                                index++;
                                XmlElement ele = this._logicDoc.CreateElement("SubClass");
                                ele.SetAttribute("name", str);
                                ele.SetAttribute("groupid", index.ToString());
                                node.AppendChild(ele);
                                foreach (IFeatureClass fc in listFc)
                                {
                                    if (fc.GetFields().IndexOf(mc.ClassifyField) == -1)
                                    {
                                        continue;
                                    }
                                    if (fc.GetFields().IndexOf("GroupId") == -1)
                                    {
                                        continue;
                                    }
                                    SubTypeInfo sti = new SubTypeInfo();
                                    sti.Code = index;
                                    sti.Name = str;
                                    fc.AddSubType(sti);
                                }
                            }
                            //XmlElement ele1 = this._logicDoc.CreateElement("SubClass");
                            //ele1.SetAttribute("name", "其他");
                            //ele1.SetAttribute("groupid", index.ToString());
                            //node.AppendChild(ele1);

                            this._logicDoc.Save(this._xmlLogicFilePath);
                        }
                    }
                }
                WaitForm.Stop();
                XtraMessageBox.Show("设置成功!", "提示");
            }
            catch (Exception ex)
            {
                WaitForm.Stop();
                XtraMessageBox.Show("设置失败!", "提示");
            }
        }
Example #19
0
        private void ExecuteUndoRedo(IUndoRedoResultCollection Coll)
        {
            if (Coll != null)
            {
                int nCount = Coll.Count;
                if (nCount == 0)
                    return;
                for (int i = 0; i < nCount; ++i)
                {
                    IUndoRedoResult result = Coll.Get(i) as IUndoRedoResult;
                    if (result == null)
                        continue;
                    IObjectClass oc = result.ObjectClass;
                    IRowBufferCollection Rows = result.RowBuffers;
                    List<int> insert_updata_Ids = new List<int>();
                    if (Rows != null)
                    {
                        for (int j = 0; j < Rows.Count;j ++ )
                        {
                            IRowBuffer row = Rows.Get(j);
                            if (row.IsNull(0))
                                continue;
                            insert_updata_Ids.Add(Convert.ToInt32(row.GetValue(0)));
                        }
                    }

                    gviCommandType type = result.Type;
                    switch (type)
                    {
                        case gviCommandType.gviCommandInsert:  //Insert
                            {
                                this.axRenderControl1.FeatureManager.CreateFeatures(oc as IFeatureClass, Rows);
                                this.axRenderControl1.FeatureManager.UnhighlightAll();
                                this.axRenderControl1.FeatureManager.HighlightFeatures(oc as IFeatureClass, insert_updata_Ids.ToArray(), System.Drawing.Color.Red);
                            }
                            break;
                        case gviCommandType.gviCommandDelete:  //Delete
                            {
                                int[] OidArray = result.FidArray;
                                this.axRenderControl1.FeatureManager.DeleteFeatures(oc as IFeatureClass, OidArray);
                            }
                            break;
                        case gviCommandType.gviCommandUpdate:  //Update
                            {
                                this.axRenderControl1.FeatureManager.EditFeatures(oc as IFeatureClass, Rows);
                                this.axRenderControl1.FeatureManager.UnhighlightAll();
                                this.axRenderControl1.FeatureManager.HighlightFeatures(oc as IFeatureClass, insert_updata_Ids.ToArray(), System.Drawing.Color.Red);
                            }
                            break;
                    }
                    if (Rows != null)
                    {
                        Rows.Clear();
                        //Marshal.ReleaseComObject(Rows);
                    }
                    //Marshal.ReleaseComObject(oc);
                    //Marshal.ReleaseComObject(result);
                }
                //Marshal.ReleaseComObject(Coll);
            }
        }
        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);
        }
Example #21
0
        private void GetResultSet(IFeatureClass fc, IQueryFilter filter, DataTable dt)
        {
            if (fc != null)
            {
                IFdeCursor cursor = null;
                try
                {
                    if (filter != null)
                    {
                        filter.PostfixClause = "order by oid asc";
                    }
                    // 查找所有记录
                    cursor = fc.Search(filter, true);
                    if (cursor != null)
                    {
                        dt.BeginLoadData();
                        IRowBuffer fdeRow = null;
                        DataRow    dr     = null;
                        while ((fdeRow = cursor.NextRow()) != null)
                        {
                            dr = dt.NewRow();
                            for (int i = 0; i < dt.Columns.Count; ++i)
                            {
                                string strColName = dt.Columns[i].ColumnName;
                                int    nPos       = fdeRow.FieldIndex(strColName);
                                if (nPos == -1 || fdeRow.IsNull(nPos))
                                {
                                    continue;
                                }
                                object v = fdeRow.GetValue(nPos);  // 从库中读取值
                                dr[i] = v;

                                if (i == 0)
                                {
                                    // 创建管子
                                    int       geoPos = fdeRow.FieldIndex("Geometry");
                                    IGeometry geo    = (IGeometry)fdeRow.GetValue(geoPos);
                                    if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                                    {
                                        IPolyline       pl  = (IPolyline)fdeRow.GetValue(geoPos);
                                        IRenderPipeLine rpl = this.axRenderControl1.ObjectManager.CreateRenderPipeLine(pl, rootId);
                                        rpl.Radius = 10;
                                        rpl.Color  = System.Drawing.Color.Red;
                                        ArrayList rpls = new ArrayList();
                                        rpls.Add(rpl);
                                        pipeMap.Add(v, rpls);
                                    }
                                    else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                                    {
                                        IMultiPolyline multiPolyline = geo as IMultiPolyline;
                                        ArrayList      rpls          = new ArrayList();
                                        for (int g = 0; g < multiPolyline.GeometryCount; g++)
                                        {
                                            IPolyline       plIndex = multiPolyline.GetGeometry(g) as IPolyline;
                                            IRenderPipeLine rpl     = this.axRenderControl1.ObjectManager.CreateRenderPipeLine(plIndex, rootId);
                                            rpl.Radius = 10;
                                            rpl.Color  = System.Drawing.Color.Red;
                                            rpls.Add(rpl);
                                        }
                                        pipeMap.Add(v, rpls);
                                    }
                                }
                            }
                            dt.Rows.Add(dr);
                        }
                        dt.EndLoadData();
                    }
                }
                catch (COMException ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                }
                finally
                {
                    if (cursor != null)
                    {
                        cursor.Dispose();
                        cursor = null;
                    }
                }
            }
        }
Example #22
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
            {
            }
        }
        public static List <FacStyleClass> GetFacStyleByFacClassCode(string fcCode)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause = string.Format("FacClassCode = '{0}'", fcCode)
                };
                cursor = oc.Search(filter, true);
                List <FacStyleClass> list = new List <FacStyleClass>();
                while ((row = cursor.NextRow()) != null)
                {
                    StyleType     type;
                    FacStyleClass fs = null;
                    if (row.FieldIndex("StyleType") >= 0 && Enum.TryParse <StyleType>(row.GetValue(row.FieldIndex("StyleType")).ToString(), out type))
                    {
                        Dictionary <string, string> dictionary = null;
                        if (row.FieldIndex("StyleInfo") >= 0)
                        {
                            object obj = row.GetValue(row.FieldIndex("StyleInfo"));
                            if (obj != null)
                            {
                                IBinaryBuffer buffer2 = row.GetValue(row.FieldIndex("StyleInfo")) as IBinaryBuffer;
                                if (buffer2 != null)
                                {
                                    dictionary = JsonTool.JsonToObject <Dictionary <string, string> >(Encoding.UTF8.GetString(buffer2.AsByteArray()));
                                }
                            }
                        }
                        switch (type)
                        {
                        case StyleType.PipeNodeStyle:
                            fs = new PipeNodeStyleClass(dictionary);
                            break;

                        case StyleType.PipeLineStyle:
                            fs = new PipeLineStyleClass(dictionary);
                            break;

                        case StyleType.PipeBuildStyle:
                            fs = new PipeBuildStyleClass(dictionary);
                            break;
                        }
                    }
                    if (fs == null)
                    {
                        continue;
                    }
                    if (row.FieldIndex("oid") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("oid"));
                        if (obj != null)
                        {
                            fs.Id = int.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("ObjectId") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("ObjectId"));
                        if (obj != null)
                        {
                            fs.ObjectId = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("FacClassCode") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FacClassCode"));
                        if (obj != null)
                        {
                            fs.FacClassCode = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Name") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Name"));
                        if (obj != null)
                        {
                            fs.Name = obj.ToString();
                        }
                    }
                    int index = row.FieldIndex("Thumbnail");
                    if (index != -1 && !row.IsNull(index))
                    {
                        IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer;
                        if (row != null)
                        {
                            MemoryStream stream = new MemoryStream(b.AsByteArray());
                            fs.Thumbnail = Image.FromStream(stream);
                        }
                    }
                    list.Add(fs);
                }
                return(list);
            }
            catch (Exception exception)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
Example #24
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;
                }
            }
        }
Example #25
0
        public TopoNetwork GetNetwork()
        {
            if (TopoNetworkManager.Instance.Exists(this._objectId))
            {
                return(TopoNetworkManager.Instance.GetTopoNetWorkByObjectId(this._objectId));
            }

            if (DF3DPipeCreateApp.App.PipeLib == null)
            {
                return(null);
            }
            TopoNetwork   network = null;
            IFeatureClass class2  = null;
            IQueryFilter  filter  = null;
            IFdeCursor    cursor  = null;
            IRowBuffer    buffer  = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                class2 = fds.OpenFeatureClass(this._topotable);
                filter = new QueryFilterClass
                {
                    SubFields = "A_FacClass,Edge,P_FacClass,PNode,E_FacClass,ENode,Geometry"
                };

                Dictionary <string, Node> dictNode = new Dictionary <string, Node>();  // 点字典
                int totalcount = class2.GetCount(null);
                int loop       = (int)Math.Ceiling((decimal)(totalcount / 1000.0));
                for (int i = 1; i <= loop; i++)
                {
                    if (i == 1)
                    {
                        filter.ResultBeginIndex = 0;
                    }
                    else
                    {
                        filter.ResultBeginIndex = (i - 1) * 1000;
                    }
                    filter.ResultLimit = 1000;
                    cursor             = class2.Search(filter, true);
                    while ((buffer = cursor.NextRow()) != null)
                    {
                        string edgeFC, edgeOid, snodeFC, snodeOid, enodeFC, enodeOid;
                        if (!buffer.IsNull(0))
                        {
                            edgeFC = buffer.GetValue(0).ToString();
                        }
                        else
                        {
                            edgeFC = "0";
                        }

                        if (!buffer.IsNull(1))
                        {
                            edgeOid = buffer.GetValue(1).ToString();
                        }
                        else
                        {
                            edgeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant();
                        }

                        if (!buffer.IsNull(2))
                        {
                            snodeFC = buffer.GetValue(2).ToString();
                        }
                        else
                        {
                            snodeFC = "0";
                        }

                        if (!buffer.IsNull(3))
                        {
                            snodeOid = buffer.GetValue(3).ToString();
                        }
                        else
                        {
                            snodeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant();
                        }

                        if (!buffer.IsNull(4))
                        {
                            enodeFC = buffer.GetValue(4).ToString();
                        }
                        else
                        {
                            enodeFC = "0";
                        }

                        if (!buffer.IsNull(5))
                        {
                            enodeOid = buffer.GetValue(5).ToString();
                        }
                        else
                        {
                            enodeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant();
                        }

                        double edgeLength = double.MaxValue;
                        if (!buffer.IsNull(6) && buffer.GetValue(6) is IPolyline)
                        {
                            IPolyline line = buffer.GetValue(6) as IPolyline;
                            edgeLength = line.Length;
                        }

                        Node   sn  = null;
                        Node   en  = null;
                        string key = snodeFC + "_" + snodeOid;
                        if (!dictNode.ContainsKey(key))
                        {
                            if (NodeManager.Instance.GetNodeByID(key) == null)
                            {
                                sn = new Node(snodeFC, snodeOid);
                                NodeManager.Instance.Add(sn);
                            }
                            else
                            {
                                sn = NodeManager.Instance.GetNodeByID(key);
                            }
                            dictNode.Add(key, sn);
                        }
                        else
                        {
                            sn = dictNode[key];
                        }
                        key = enodeFC + "_" + enodeOid;
                        if (!dictNode.ContainsKey(key))
                        {
                            if (NodeManager.Instance.GetNodeByID(key) == null)
                            {
                                en = new Node(enodeFC, enodeOid);
                                NodeManager.Instance.Add(en);
                            }
                            else
                            {
                                en = NodeManager.Instance.GetNodeByID(key);
                            }
                            dictNode.Add(key, en);
                        }
                        else
                        {
                            en = dictNode[key];
                        }
                        if (sn == null || en == null)
                        {
                            continue;
                        }
                        Edge e = new Edge(edgeFC, edgeOid, sn, en, edgeLength);
                        EdgeManager.Instance.Add(e);
                    }
                }
                network = new TopoNetwork(this._objectId, dictNode);
                TopoNetworkManager.Instance.Add(this.ObjectId, network);
                return(network);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (buffer != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer);
                    buffer = null;
                }
            }
        }
Example #26
0
        private void InitialView()
        {
            try
            {
                IRowBuffer           myRow      = fc.GetRow(fid);
                IFieldInfoCollection fieldinfos = fc.GetFields();
                for (int i = 0; i < fieldinfos.Count; i++)
                {
                    int        iRowIndex = -1;
                    IFieldInfo fieldinfo = fieldinfos.Get(i);
                    if (null == fieldinfo)
                    {
                        continue;
                    }
                    if (fieldinfo.FieldType == gviFieldType.gviFieldGeometry)
                    {
                        if (myRow.IsNull(i))
                        {
                            iRowIndex = this.dgv_FieldValue.Rows.Add(new object[] { fieldinfo.Name, null });
                            continue;
                        }
                        IGeometry geo      = myRow.GetValue(i) as IGeometry;
                        string    geoValue = null;
                        if (geo != null)
                        {
                            switch (geo.GeometryType)
                            {
                            case gviGeometryType.gviGeometryModelPoint:
                                geoValue = "ModelPoint";
                                break;

                            case gviGeometryType.gviGeometryPoint:
                                geoValue = "Point";
                                break;

                            case gviGeometryType.gviGeometryMultiPoint:
                                geoValue = "MultiPoint";
                                break;

                            case gviGeometryType.gviGeometryPolyline:
                                geoValue = "Polyline";
                                break;

                            case gviGeometryType.gviGeometryMultiPolyline:
                                geoValue = "MultiPolyline";
                                break;

                            case gviGeometryType.gviGeometryPolygon:
                                geoValue = "Polygon";
                                break;

                            case gviGeometryType.gviGeometryMultiPolygon:
                                geoValue = "MultiPolygon";
                                break;
                            }
                        }
                        iRowIndex = this.dgv_FieldValue.Rows.Add(new object[] { fieldinfo.Name, geoValue });
                    }
                    else if (fieldinfo.FieldType == gviFieldType.gviFieldFID)
                    {
                        iRowIndex = this.dgv_FieldValue.Rows.Add(new object[] { fieldinfo.Name, myRow.GetValue(i) });
                    }
                    else
                    {
                        IDomain fieldDomain = fieldinfo.Domain;
                        if (fieldDomain != null && fieldDomain.DomainType == gviDomainType.gviDomainCodedValue)
                        {
                            DataGridViewComboBoxCell comCell = new DataGridViewComboBoxCell();
                            comCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
                            comCell.Items.Clear();
                            comCell.Items.Add("");
                            Dictionary <object, string> codeValue = this.GetDomainCodeValuePair(fieldDomain);
                            comCell.Items.AddRange(codeValue.Values.ToArray());
                            iRowIndex = this.dgv_FieldValue.Rows.Add();
                            DataGridViewRow myViewRow = this.dgv_FieldValue.Rows[iRowIndex];
                            myViewRow.Cells[1] = comCell;
                            object oCodeValue = myRow.GetValue(i);
                            if (codeValue.ContainsKey(oCodeValue))
                            {
                                myViewRow.SetValues(new object[] { fieldinfo.Name, codeValue[oCodeValue] });
                            }
                            else
                            {
                                myViewRow.SetValues(new object[] { fieldinfo.Name, oCodeValue });
                            }
                        }
                        else
                        {
                            iRowIndex = this.dgv_FieldValue.Rows.Add(new object[] { fieldinfo.Name, myRow.GetValue(i) });
                        }
                    }
                    this.dgv_FieldValue.Rows[iRowIndex].Tag = new EditField(fieldinfo, i);
                }
                this.dgv_FieldValue.Tag = myRow;
            }
            catch (COMException comEx)
            {
                MessageBox.Show(comEx.Message);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }
        }
Example #27
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();
            }
        }
Example #28
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;
                }
            }
        }
Example #29
0
        private DataTable GetTextureInfo()
        {
            DataTable  table  = null;
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                table = new DataTable("TextureInfo");
                table.Columns.Add("Name", typeof(string));
                table.Columns.Add("ObjectId", typeof(string));
                table.Columns.Add("Thumbnail", typeof(object));

                IFeatureDataSet fds = this._ds.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_TextureInfo");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause   = "GroupId != '-1'",
                    SubFields     = "Name,ObjectId,Thumbnail",
                    PostfixClause = "order by Name asc"
                };
                cursor = oc.Search(filter, true);
                while ((row = cursor.NextRow()) != null)
                {
                    DataRow dtRow = table.NewRow();
                    dtRow["Name"]     = row.GetValue(0).ToString();
                    dtRow["ObjectId"] = row.GetValue(1).ToString();
                    if (!row.IsNull(2))
                    {
                        try
                        {
                            IBinaryBuffer buffer2 = row.GetValue(2) as IBinaryBuffer;
                            if (buffer2 != null)
                            {
                                MemoryStream stream = new MemoryStream(buffer2.AsByteArray());
                                dtRow["Thumbnail"] = Image.FromStream(stream);
                            }
                        }
                        catch (Exception exception)
                        {
                        }
                    }
                    table.Rows.Add(dtRow);
                }
                return(table);
            }
            catch (Exception exception)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
Example #30
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;
                }
            }
        }