Beispiel #1
0
 private void DisplayOnDistrict(string DistrictName)
 {
     if (m_SkylineHook.SGWorld.Project.Name != "")
     {
         try
         {
             int LayerID = m_SkylineHook.SGWorld.ProjectTree.FindItem("分区");
             if (LayerID >= 0)
             {
                 int ModelID = m_SkylineHook.SGWorld.ProjectTree.FindItem(ConfigurationManager.AppSettings["LayerPath"]);
                 if (ModelID >= 0)
                 {
                     //根据DistricName从分区shp表中读取相应Code,再将SGModel中相应Code的模型显示出来
                     ILayer61        DistrictLayer = m_SkylineHook.SGWorld.ProjectTree.GetLayer(LayerID);
                     IFeatureGroup61 Polygons      = DistrictLayer.FeatureGroups.Polygon;
                     string          Code          = "all";
                     foreach (IFeature61 a in Polygons)
                     {
                         if (a.FeatureAttributes.GetFeatureAttribute("Name").Value == DistrictName)
                         {
                             Code = a.FeatureAttributes.GetFeatureAttribute("Code").Value;
                         }
                     }
                     ILayer61        ModelLayer = m_SkylineHook.SGWorld.ProjectTree.GetLayer(ModelID);
                     IFeatureGroup61 Models     = ModelLayer.FeatureGroups.Point;
                     //MessageBox.Show(Models.GetProperty("File Name").ToString());
                     foreach (IFeature61 m in Models)
                     {
                         if (Code == "all")
                         {
                             m.FeatureAttributes.GetFeatureAttribute("Display").Value = m.FeatureAttributes.GetFeatureAttribute("ModelPath").Value;
                         }
                         else
                         {
                             if (m.FeatureAttributes.GetFeatureAttribute("Code").Value == Code)
                             {
                                 m.FeatureAttributes.GetFeatureAttribute("Display").Value = m.FeatureAttributes.GetFeatureAttribute("ModelPath").Value;
                             }
                             else
                             {
                                 m.FeatureAttributes.GetFeatureAttribute("Display").Value = "";
                             }
                         }
                     }
                     ModelLayer.Save();
                     ModelLayer.Refresh();
                     //由于Display字段变化,二次加载时可能无法全部显示
                 }
             }
         }
         catch
         {
             MessageBox.Show("对不起,分区显示过程出现了错误!这通常是由于配置不当引起的。");
         }
     }
 }
Beispiel #2
0
        private void ViewVersion()
        {
            try
            {
                int      GroupID  = this.m_Hook.ProjectTree.FindItem(strLabel);
                ILayer61 lyrModel = this.m_Hook.ProjectTree.GetLayer(GroupID);

                lyrModel.DataSourceInfo.ConnectionString = string.Format("FileName={0};TEPlugName=OGR;", m_SelectedVersion.VersionFile);
                lyrModel.Refresh();
            }
            catch
            {
                XtraMessageBox.Show("对不起,预览操作出现了错误,这通常是因为配置不当引起的。");
            }
        }
Beispiel #3
0
        /// <summary>
        /// 添加Shape文件
        /// </summary>
        /// <param name="FilePath"></param>
        /// <param name="layerName"></param>
        public void LoadShapeFile(ISGWorld61 sgworld, string FilePath, string layerName, int GroupID)
        {
            if (string.IsNullOrEmpty(FilePath))
            {
                return;
            }
            if (File.Exists(FilePath))
            {
                string   connnstr = "FileName=" + FilePath + ";TEPlugName=OGR;";
                ILayer61 layer61  = null;
                layer61 = sgworld.Creator.CreateFeatureLayer(layerName, connnstr, GroupID);

                // 2013-04-11 张航宇
                // 当坐标系不一致时,Streaming=false会使Load方法出错
                layer61.Streaming = true;
                layer61.Load();

                string wellKtext = sgworld.CoordServices.ChooseCSDialog("", "");
                layer61.CoordinateSystem.WellKnownText = wellKtext;
                //layer61.Streaming = false;

                // 2013-04-11 张航宇
                // 若坐标系不一致,则skyline会自动弹出投影对话框
                //if (MessageBox.Show("是否投影?", "SUNZ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                //{
                //    layer61.Reproject = true;
                //}
                //else
                //{
                //    layer61.Reproject = false;
                //}
                layer61.DataSourceInfo.Attributes.ImportAll = true;
                layer61.Refresh();
            }
            /*****20130227杨漾(添加文件有效性判断,去掉trycatch,上层trycatch(MainForm)处理)*****/
        }
Beispiel #4
0
        public override void OnClick()
        {
            m_Flag = !m_Flag;
            if (m_Flag)
            {
                m_UcCompare.FinishCompare();
                m_UcCompare.ControlMode = enum3DControlMode.One;
            }
            else
            {
                if (m_UcCompare == null)
                {
                    Control parent = m_SkylineHook.Window.Parent;
                    parent.Controls.Remove(m_SkylineHook.Window);
                    m_UcCompare = new UCSchemaCompare(m_SkylineHook.Window as AxTerraExplorerX.AxTE3DWindow);
                    m_UcCompare.CreateHooker(out Program.sgworld, out teTopRight, out teBottomLeft, out teBottomRight);
                    parent.Controls.Add(m_UcCompare);
                    m_UcCompare.Dock = DockStyle.Fill;
                }

                if (Bussiness.Environment.m_Project.Schemas == null)
                {
                    return;
                }

                // 加载fly
                string flyURL = Bussiness.Environment.m_Project.File;
                string flyURL1 = null, flyURL2 = null, flyURL3 = null;
                string urlTopRight = null, urlBottomLeft = null, urlBottomRight = null;

                enum3DControlMode modeCurrent = enum3DControlMode.One;
                // 设置屏模式
                if (Bussiness.Environment.m_Project.Schemas.Count > 0 && Bussiness.Environment.m_Project.Schemas.Count < 4)
                {
                    modeCurrent = (enum3DControlMode)(Bussiness.Environment.m_Project.Schemas.Count);
                    if (modeCurrent == enum3DControlMode.Tow)
                    {
                        flyURL2       = flyURL;
                        urlBottomLeft = Bussiness.Environment.m_Project.Schemas[0].File;
                    }
                    if (modeCurrent == enum3DControlMode.Three)
                    {
                        flyURL1        = flyURL;
                        flyURL3        = flyURL;
                        urlTopRight    = Bussiness.Environment.m_Project.Schemas[0].File;
                        urlBottomRight = Bussiness.Environment.m_Project.Schemas[1].File;
                    }
                    if (modeCurrent == enum3DControlMode.Four)
                    {
                        urlTopRight    = Bussiness.Environment.m_Project.Schemas[0].File;
                        urlBottomLeft  = Bussiness.Environment.m_Project.Schemas[1].File;
                        urlBottomRight = Bussiness.Environment.m_Project.Schemas[2].File;
                        flyURL1        = flyURL;
                        flyURL2        = flyURL;
                        flyURL3        = flyURL;
                    }
                }
                m_UcCompare.CompareSchema(flyURL1, flyURL2, flyURL3);


                try
                {
                    // 修改模型shp
                    string   strLabel = ConfigurationManager.AppSettings["LayerPath"];
                    int      GroupID  = -1;
                    ILayer61 lyrModel = null;
                    if (!string.IsNullOrWhiteSpace(urlTopRight))
                    {
                        GroupID = teTopRight.ProjectTree.FindItem(strLabel);
                        if (GroupID > 0)
                        {
                            lyrModel = teTopRight.ProjectTree.GetLayer(GroupID);
                            lyrModel.DataSourceInfo.ConnectionString = string.Format("FileName={0};TEPlugName=OGR;", urlTopRight);
                            lyrModel.Save();
                            lyrModel.Refresh();
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(urlBottomLeft))
                    {
                        GroupID = teBottomLeft.ProjectTree.FindItem(strLabel);
                        if (GroupID > 0)
                        {
                            lyrModel = teBottomLeft.ProjectTree.GetLayer(GroupID);
                            lyrModel.DataSourceInfo.ConnectionString = string.Format("FileName={0};TEPlugName=OGR;", urlBottomLeft);
                            lyrModel.Save();
                            lyrModel.Refresh();
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(urlBottomRight))
                    {
                        GroupID = teBottomRight.ProjectTree.FindItem(strLabel);
                        if (GroupID > 0)
                        {
                            lyrModel = teBottomRight.ProjectTree.GetLayer(GroupID);
                            lyrModel.DataSourceInfo.ConnectionString = string.Format("FileName={0};TEPlugName=OGR;", urlBottomRight);
                            lyrModel.Save();
                            lyrModel.Refresh();
                        }
                    }

                    m_UcCompare.ControlMode = modeCurrent;
                }
                catch
                {
                    MessageBox.Show("抱歉,出错了,很可能的原因是方案模型文件不存在或移动了");
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// 左键单击事件
        /// 获取建筑物信息
        /// </summary>
        /// <param name="Flags"></param>
        /// <param name="X"></param>mo
        /// <param name="Y"></param>
        /// <param name="pbHandled"></param>
        void TE_OnLButtonDown(int Flags, int X, int Y, ref object pbHandled)
        {
            try
            {
                int modelLayerID = Hook.ProjectTree.FindItem(ConfigurationManager.AppSettings["LayerPath"]);


                // 模型复原
                // 显示
                int groupID = Hook.ProjectTree.FindItem(Pipe_Group_Name);
                if (groupID > 0)
                {
                    Hook.ProjectTree.DeleteItem(groupID);
                }
                if (m_FeatureSelected != null)
                {
                    //m_FeatureSelected.FeatureAttributes.GetFeatureAttribute("MODELNAME").Value = m_ModelName;

                    if (modelLayerID > 0)
                    {
                        ILayer61 lyrModel = Hook.ProjectTree.GetLayer(modelLayerID);
                        lyrModel.Filter = "";
                        //lyrModel.Refresh();
                        //lyrModel.Save();
                        //lyrModel.Refresh();
                    }
                }


                // 开始新的
                // 取到模型
                object longitude, latitude, objectID, height, objType;
                objType = 17;
                Program.pRender.ScreenToWorld(X, Y, ref objType, out longitude, out height, out latitude, out objectID);
                if (objectID.ToString() == "")
                {
                    objType = 16;
                    Program.pRender.ScreenToWorld(X, Y, ref objType, out longitude, out height, out latitude, out objectID);
                }

                if (objectID.ToString() == "")
                {
                    return;
                }

                groupID = Hook.ProjectTree.CreateGroup(Pipe_Group_Name);

                ITerraExplorerObject61 teOjbect = Program.pCreator6.GetObject(objectID as string);
                m_FeatureSelected = teOjbect as IFeature61;
                if (m_FeatureSelected == null)
                {
                    return;
                }

                m_ModelName = m_FeatureSelected.FeatureAttributes.GetFeatureAttribute(m_ModelField).Value;

                string strFile = System.IO.Path.Combine(ConfigurationManager.AppSettings["ModelPath"], m_ModelName);

                IPoint pSel = m_FeatureSelected.Geometry as IPoint;

                ITerrainModel61 m_Model = Hook.Creator.CreateModel(Hook.Creator.CreatePosition(pSel.X, pSel.Y), strFile, 1, ModelTypeCode.MT_NORMAL, groupID, "Temp");

                m_Model.Visibility.Show = false;
                if (m_Model == null)
                {
                    return;
                }

                m_AnalysisResult = false;
                string strPipedFileList = ConfigurationManager.AppSettings["PipedFileList"];
                strPipedFileList = strPipedFileList.ToLower();

                m_HoleBox = m_Model.Terrain.BBox;
                Hook.Creator.DeleteObject(m_Model.ID);

                double[] points =
                {
                    m_HoleBox.MinX, m_HoleBox.MinY, 0,
                    m_HoleBox.MaxX, m_HoleBox.MinY, 0,
                    m_HoleBox.MaxX, m_HoleBox.MaxY, 0,
                    m_HoleBox.MinX, m_HoleBox.MaxY, 0
                };

                IPolygon polygonHole = Hook.Creator.GeometryCreator.CreatePolygonGeometry(points);


                Hook.Creator.CreateHoleOnTerrain(polygonHole as IGeometry, groupID, Pipe_Hole_Name);

                if (strPipedFileList.Contains(m_ModelName.ToLower()))
                {
                    m_AnalysisResult = true;
                }

                // 隐藏
                // m_FeatureSelected.FeatureAttributes.GetFeatureAttribute("MODELNAME").Value = "";
                if (modelLayerID > 0)
                {
                    ILayer61 lyrModel = Hook.ProjectTree.GetLayer(modelLayerID);
                    //lyrModel.Save();
                    lyrModel.Filter = string.Format("{0} <> '{1}'", m_ModelField, m_ModelName);
                    lyrModel.Refresh();
                }
            }
            catch (Exception ex)
            {
                HasError = true;
            }
            finally
            {
                if (Analysised != null)
                {
                    Analysised.Invoke();
                }
                EndPipeAnalysis();
            }
        }