Example #1
0
 public void Add(DF3DFeatureClass fc)
 {
     if (this.Exists(fc))
     {
         return;
     }
     this.listFC.Add(fc);
 }
Example #2
0
 public void SetRender(TreeNodeFeatureClass treeNode, DF3DFeatureClass dffc)
 {
     if (treeNode == null || dffc == null)
     {
         return;
     }
     try
     {
         IFeatureClass fc = dffc.GetFeatureClass();
         if (fc == null)
         {
             return;
         }
         IFeatureLayer fl = dffc.GetFeatureLayer();
         if (fl == null)
         {
             return;
         }
         string name        = string.IsNullOrEmpty(fc.AliasName) ? fc.Name : fc.AliasName;
         string xmlFileName = renderPath + name + ".xml";
         if (File.Exists(xmlFileName))
         {
             XmlDocument xmlDoc = new XmlDocument();
             xmlDoc.Load(xmlFileName);
             if (xmlDoc != null)
             {
                 XmlNode featureLayerNode = xmlDoc.SelectSingleNode("FeatureLayer");
                 if (featureLayerNode == null)
                 {
                     return;
                 }
                 XmlNode         geometryRenderNode = featureLayerNode.SelectSingleNode("GeometryRender");
                 IGeometryRender geoRender          = GetGeoRender(geometryRenderNode);
                 XmlNode         textRenderNode     = featureLayerNode.SelectSingleNode("TextRender");
                 ITextRender     textRender         = GetTextRender(textRenderNode);
                 fl.SetTextRender(textRender);
                 fl.SetGeometryRender(geoRender);
                 treeNode.Visible = false;
             }
         }
     }
     catch (Exception ex) { }
 }
Example #3
0
        public static void AddAndVisualizeBaseData(IConnectionInfo ci, string geoColumnName, TreeList parentTree, bool bNeedFly = false, bool bTempData = true)
        {
            try
            {
                if (ci == null || parentTree == null)
                {
                    return;
                }
                if (bTempData)
                {
                    WaitForm.Start("正在加载三维数据,请稍后...", "提示");
                }

                DF3DApplication app = DF3DApplication.Application;
                if (app == null || app.Current3DMapControl == null)
                {
                    return;
                }
                AxRenderControl    d3        = app.Current3DMapControl;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                if (!dsFactory.HasDataSource(ci))
                {
                    return;
                }
                IDataSource ds = dsFactory.OpenDataSource(ci);
                if (ds == null)
                {
                    return;
                }
                //TreeNodeDatabase tnDatabase = new TreeNodeDatabase()
                //{
                //    Name = ci.ConnectionType == gviConnectionType.gviConnectionFireBird2x ? System.IO.Path.GetFileNameWithoutExtension(ci.Database) : ci.Database,
                //    CustomValue = ds,
                //    Temp = bTempData
                //};
                //tnDatabase.OwnNode = parentTree.AppendNode(new object[] { tnDatabase.Name }, (TreeListNode)null);
                //tnDatabase.Visible = true;

                string[] setnames = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                for (int j = 0; j < setnames.Length; j++)
                {
                    IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[j]);

                    string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                    if (fcnames.Length == 0)
                    {
                        continue;
                    }

                    TreeNodeDataset tnDataset = new TreeNodeDataset()
                    {
                        Name        = dataset.Alias,
                        CustomValue = dataset,
                        Temp        = bTempData
                    };
                    tnDataset.OwnNode = parentTree.AppendNode(new object[] { tnDataset.Name }, (TreeListNode)null);
                    //tnDatabase.Add(tnDataset);

                    foreach (string name in fcnames)
                    {
                        IFeatureClass fc = dataset.OpenFeatureClass(name);
                        if (fc == null)
                        {
                            continue;
                        }
                        TreeNodeFeatureClass tnFeatureClass = new TreeNodeFeatureClass(fc.GuidString)
                        {
                            Name        = fc.AliasName,
                            CustomValue = fc,
                            Temp        = bTempData
                        };
                        tnDataset.Add(tnFeatureClass);

                        IFieldInfoCollection fieldinfos = fc.GetFields();
                        if (fieldinfos == null)
                        {
                            continue;
                        }
                        int index = fieldinfos.IndexOf(geoColumnName);
                        if (index == -1)
                        {
                        }
                        else
                        {
                            IFieldInfo fieldinfo = fieldinfos.Get(index);
                            if (null == fieldinfo)
                            {
                                continue;
                            }
                            IGeometryDef  geometryDef = fieldinfo.GeometryDef;
                            IFeatureLayer fl          = null;
                            if (null != geometryDef)
                            {
                                fl = d3.ObjectManager.CreateFeatureLayer(fc, fieldinfo.Name, null, null, d3.ProjectTree.RootID);
                                tnFeatureClass.SetVisualFeatureLayer(fl);
                                switch (geometryDef.GeometryColumnType)
                                {
                                case gviGeometryColumnType.gviGeometryColumnModelPoint:
                                    tnFeatureClass.Visible    = true;
                                    tnFeatureClass.ImageIndex = 3;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPOI:
                                case gviGeometryColumnType.gviGeometryColumnPoint:
                                    tnFeatureClass.Visible    = false;
                                    tnFeatureClass.ImageIndex = 4;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPolyline:
                                    tnFeatureClass.Visible    = false;
                                    tnFeatureClass.ImageIndex = 5;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPolygon:
                                    tnFeatureClass.Visible    = false;
                                    tnFeatureClass.ImageIndex = 6;
                                    break;
                                }
                            }

                            // 加入管理类
                            if (!bTempData && fl != null)
                            {
                                DF3DFeatureClass dfFC = new DF3DFeatureClass(fc);
                                dfFC.SetFeatureLayer(fl);
                                dfFC.SetTreeLayer(tnFeatureClass);
                                Render3D.Instance.SetRender(tnFeatureClass, dfFC);
                                DF3DFeatureClassManager.Instance.Add(dfFC);
                            }


                            if (fl != null && bNeedFly)
                            {
                                IEulerAngle angle = new EulerAngle();
                                angle.Set(0, -20, 0);
                                d3.Camera.SetCamera(fl.Envelope.Center, angle, gviSetCameraFlags.gviSetCameraNoFlags);
                                bNeedFly = false;
                            }
                        }
                    }
                    tnDataset.CollapseAll();
                }
                //tnDatabase.CollapseAll();

                //ds.Close();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("加载三维数据失败,请检查数据是否被占用或链接是否有错误。", "提示");
                LoggingService.Error("加载三维数据失败:" + ex.Message);
            }
            finally
            {
                if (bTempData)
                {
                    WaitForm.Stop();
                }
            }
        }
Example #4
0
        public static void VisualizePipeData(Dictionary <string, IFeatureClass> fcs, Dictionary <string, string> relation, string geoColumnName, IGroupLayer groupLayer, Dictionary <string, string> pipeCatelog, Dictionary <string, string> childPipeCatelog, Dictionary <string, IRowBuffer> infos, bool bNeedFly = false, bool bTempData = true)
        {
            try
            {
                foreach (KeyValuePair <string, string> kv in childPipeCatelog)
                {
                    string code  = kv.Key.ToString();
                    string pcode = kv.Value.ToString();
                    if (!relation.ContainsKey(code) && pcode != "-1")
                    {
                        Dictionary <string, string> cchildPipeCatelog = FindChildRelationByPCode(code, pipeCatelog);
                        if (cchildPipeCatelog == null || cchildPipeCatelog.Count == 0)
                        {
                            continue;
                        }
                        IRowBuffer row  = infos[code];
                        string     name = row.GetValue(row.FieldIndex("Name")).ToString();
                        Group      g    = new Group()
                        {
                            Name        = name,
                            CustomValue = row,
                            Temp        = bTempData
                        };
                        g.Visible = true;
                        groupLayer.Add(g);
                        VisualizePipeData(fcs, relation, geoColumnName, g, pipeCatelog, cchildPipeCatelog, infos, bNeedFly, bTempData);
                    }
                    else if (relation.ContainsKey(code) && fcs.ContainsKey(relation[code]))
                    {
                        DF3DApplication app = DF3DApplication.Application;
                        if (app == null || app.Current3DMapControl == null)
                        {
                            return;
                        }
                        AxRenderControl d3   = app.Current3DMapControl;
                        IRowBuffer      row  = infos[code];
                        string          name = row.GetValue(row.FieldIndex("Name")).ToString();

                        IFeatureClass        fc             = fcs[relation[code]];
                        TreeNodeFeatureClass tnFeatureClass = new TreeNodeFeatureClass()
                        {
                            Name        = name,
                            CustomValue = fc,
                            //Tag = row,
                            Temp = bTempData
                        };
                        groupLayer.Add(tnFeatureClass);

                        IFieldInfoCollection fieldinfos = fc.GetFields();
                        if (fieldinfos == null)
                        {
                            continue;
                        }
                        int index = fieldinfos.IndexOf(geoColumnName);
                        if (index == -1)
                        {
                        }
                        else
                        {
                            IFieldInfo fieldinfo = fieldinfos.Get(index);
                            if (null == fieldinfo)
                            {
                                continue;
                            }
                            IGeometryDef  geometryDef = fieldinfo.GeometryDef;
                            IFeatureLayer fl          = null;
                            if (null != geometryDef)
                            {
                                fl = d3.ObjectManager.CreateFeatureLayer(fc, fieldinfo.Name, null, null, d3.ProjectTree.RootID);
                                tnFeatureClass.SetVisualFeatureLayer(fl);
                                tnFeatureClass.Visible = true;
                                switch (geometryDef.GeometryColumnType)
                                {
                                case gviGeometryColumnType.gviGeometryColumnModelPoint:
                                    tnFeatureClass.ImageIndex = 3;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPOI:
                                case gviGeometryColumnType.gviGeometryColumnPoint:
                                    tnFeatureClass.ImageIndex = 4;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPolyline:
                                    tnFeatureClass.ImageIndex = 5;
                                    break;

                                case gviGeometryColumnType.gviGeometryColumnPolygon:
                                    tnFeatureClass.ImageIndex = 6;
                                    break;
                                }
                            }
                            if (fl != null && !bTempData)
                            {
                                DF3DFeatureClass dfFC = new DF3DFeatureClass(fcs[relation[code]]);
                                if (dfFC == null)
                                {
                                    continue;
                                }
                                DF3DFeatureClassManager.Instance.Add(dfFC);
                            }
                            if (fl != null && bNeedFly)
                            {
                                IEulerAngle angle = new EulerAngle();
                                angle.Set(0, -20, 0);
                                d3.Camera.SetCamera(fl.Envelope.Center, angle, gviSetCameraFlags.gviSetCameraNoFlags);
                                bNeedFly = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #5
0
 public bool Exists(DF3DFeatureClass fc)
 {
     return(Exists(fc.GetFeatureClass().Guid.ToString()));
 }