示例#1
0
        /// <summary>
        /// 加载WFS矢量地图服务
        /// </summary>
        /// <param name="WFSURl">获取范围URL</param>
        /// <param name="URl">服务URL</param>
        /// <param name="ServerName">服务名称</param>
        public void LoadWFS(ISGWorld61 sgworld, string WFSURl, string URl, string ServerName)
        {
            XmlDocument doc = new XmlDocument();

            doc = GetXMLFromUrl(WFSURl);

            XmlNodeList Childrennodes = doc.ChildNodes;
            XmlNode     Childrennode  = Childrennodes[1];
            XmlNode     FeatureType   = Childrennode.ChildNodes[3].FirstChild;

            string LayerName = FeatureType.FirstChild.InnerXml;
            string Connstr   = URl;

            Connstr = "Server=" + Connstr + ";User=admin;WFSVersion=1.0.0;LayerName=";
            // string Connstr = "Server=http://gisserver:8399/arcgis/services/line2/MapServer/WFSServer;User=admin;WFSVersion=1.0.0;LayerName=line2:WGSline1;TEPlugName=WFS;";
            Connstr = Connstr + "" + LayerName + "" + ";TEPlugName=WFS;";
            try
            {
                ILayer61 pILayer   = sgworld.Creator.CreateFeatureLayer(ServerName, Connstr, 0);
                string   wellKtext = sgworld.CoordServices.ChooseCSDialog("", "");
                pILayer.CoordinateSystem.WellKnownText = wellKtext;

                pILayer.Reproject = true;
                pILayer.Load();
            }
            catch (Exception ex)
            {
                MessageBox.Show("该服务地址不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        public FrmTrafficRoute(TerraExplorerClass te,TerraExplorerX.ISGWorld61 sgWorld)
        {
            InitializeComponent();

            m_TerraExplorer = te;
            m_SGWorld = sgWorld;
            lblStatus.Text = "";
        }
示例#3
0
        public FrmTrafficRoute(TerraExplorerClass te, TerraExplorerX.ISGWorld61 sgWorld)
        {
            InitializeComponent();

            m_TerraExplorer = te;
            m_SGWorld       = sgWorld;
            lblStatus.Text  = "";
        }
示例#4
0
 /// <summary>
 /// 加载SDE图层
 /// </summary>
 /// <param name="layerName">图层名</param>
 /// <param name="server">sde服务IP</param>
 /// <param name="user">用户名</param>
 /// <param name="password">密码</param>
 public void ConnArcSDE(ISGWorld61 sgworld, string layerName, string server, string user, string password)
 {
     try
     {
         ILayer61 pILayer = sgworld.Creator.CreateFeatureLayer(layerName, "Server=" + server + ";User="******";Password="******";LayerName=" + layerName + ";Instance=5151/tcp;TEPlugName=arcsde;", 0);//在根目录下装载shp数据
         pILayer.Load();
     }
     catch (Exception)
     {
     }
 }
示例#5
0
        /// <summary>
        /// 加载SDE图层
        /// </summary>
        /// <param name="layerName">图层名</param>
        /// <param name="server">sde服务IP</param>
        /// <param name="user">用户名</param>
        /// <param name="password">密码</param>
        public void ConnArcSDE(ISGWorld61 sgworld, string layerName,string server,string user ,string password)
        {
            try
            {
                ILayer61 pILayer = sgworld.Creator.CreateFeatureLayer(layerName, "Server=" + server + ";User="******";Password="******";LayerName=" + layerName + ";Instance=5151/tcp;TEPlugName=arcsde;", 0);//在根目录下装载shp数据
                pILayer.Load();
            }
            catch (Exception)
            {

            }
        }
示例#6
0
        /// <summary>
        /// 加载WMS服务
        /// </summary>
        /// <param name="EXURl">解析范围用的URL</param>
        /// <param name="URl">服务地址</param>
        /// <param name="ServerName">服务名称</param>
        public void LoadWMS(ISGWorld61 sgworld, string EXURl, string URl, string ServerName)
        {
            XmlDocument doc = new XmlDocument();

            doc = GetXMLFromUrl(EXURl);
            if (doc == null)
            {
            }
            XmlNode Capnode = null;

            XmlNodeList Childrennodes = doc.ChildNodes;

            foreach (XmlNode item in Childrennodes)
            {
                if (item.Name == "WMS_Capabilities")
                {
                    Capnode = item.LastChild;
                    break;
                }
            }

            XmlNode Exnode     = Capnode.LastChild;//layer
            XmlNode Extentnode = Exnode.ChildNodes[3];

            double[] extentArr = new double[4];
            extentArr[0] = Convert.ToDouble(Extentnode.ChildNodes[0].InnerText);
            extentArr[1] = Convert.ToDouble(Extentnode.ChildNodes[1].InnerText);
            extentArr[2] = Convert.ToDouble(Extentnode.ChildNodes[2].InnerText);
            extentArr[3] = Convert.ToDouble(Extentnode.ChildNodes[3].InnerText);

            string name    = ServerName;
            var    wmsFile = "[INFO]" + "\n" +
                             "Meters=0" + "\n" +
                             "MPP=2.68220901489258E-06" + "\n" +
                             "Url=" + URl + "&request=GetMap&Version=1.1.1&Service=WMS&SRS=EPSG:4326&BBOX=0,0,0,0&HEIGHT=256&WIDTH=256&Styles=&Format=image/png&TRANSPARENT=FALSE" + "\n" +
                             "xul=" + extentArr[0] + "\n" +
                             "ylr=" + extentArr[2] + "\n" +
                             "xlr=" + extentArr[1] + "\n" +
                             "yul=" + extentArr[3] + "\n";

            try
            {
                var newlayer = sgworld.Creator.CreateImageryLayer(name, extentArr[0], extentArr[3], extentArr[1], extentArr[2], "<EXT><ExtInfo><![CDATA[" + wmsFile + "]]></ExtInfo><ExtType>wms</ExtType></EXT>", "gisplg.rct", 0, name);

                newlayer.UseNull   = true;
                newlayer.NullValue = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show("该服务地址不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#7
0
        private string m_VisibleArea = ConfigurationManager.AppSettings["ViewshedVisible"]; //Visible Area

        #endregion Fields

        #region Constructors

        public FrmViewshed(ISGWorld61 hook ,ITerraExplorer te)
        {
            InitializeComponent();

            this.m_Hook = hook;
            this.m_EventHook = hook as _ISGWorld61Events_Event;
            this.m_TerraExplorer = te;
            this.m_GroupID = this.m_Hook.ProjectTree.FindItem("视域分析");
            if (this.m_GroupID <= 0)
            {
                this.m_GroupID = this.m_Hook.ProjectTree.CreateGroup("视域分析");
            }

            // 绑定
            Bound();
        }
示例#8
0
        public FrmViewshed(ISGWorld61 hook, TerraExplorerClass te)
        {
            InitializeComponent();

            this.m_Hook          = hook;
            this.m_EventHook     = hook as _ISGWorld61Events_Event;
            this.m_TerraExplorer = te;
            this.m_GroupID       = this.m_Hook.ProjectTree.FindItem("视域分析");
            if (this.m_GroupID <= 0)
            {
                this.m_GroupID = this.m_Hook.ProjectTree.CreateGroup("视域分析");
            }

            // 绑定
            Bound();
        }
示例#9
0
 /// <summary>
 /// 加载OracleSpatial数据
 /// </summary>
 /// <param name="server">服务IP地址</param>
 /// <param name="username">用户名</param>
 /// <param name="password">密码</param>
 /// <param name="layername">图层名</param>
 public void ConnOracleSpatialDatabase(ISGWorld61 sgworld, string server, string username, string password, string layername)
 {
     string ConnStr = "OGRConnectionString=OCI:" + username + "/" + password + "@" + server + ":" + layername + ";";
     ILayer61 layer61 = sgworld.Creator.CreateFeatureLayer(layername, ConnStr, 0);
     layer61.Streaming = false;
     try
     {
         string wellKtext = sgworld.CoordServices.ChooseCSDialog("", "");
         layer61.CoordinateSystem.WellKnownText = wellKtext;
         layer61.Reproject = true;
         layer61.Load();
     }
     catch (Exception)
     {
         layer61.Load();
     }
 }
示例#10
0
        /// <summary>
        /// 加载OracleSpatial数据
        /// </summary>
        /// <param name="server">服务IP地址</param>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="layername">图层名</param>
        public void ConnOracleSpatialDatabase(ISGWorld61 sgworld, string server, string username, string password, string layername)
        {
            string   ConnStr = "OGRConnectionString=OCI:" + username + "/" + password + "@" + server + ":" + layername + ";";
            ILayer61 layer61 = sgworld.Creator.CreateFeatureLayer(layername, ConnStr, 0);

            layer61.Streaming = false;
            try
            {
                string wellKtext = sgworld.CoordServices.ChooseCSDialog("", "");
                layer61.CoordinateSystem.WellKnownText = wellKtext;
                layer61.Reproject = true;
                layer61.Load();
            }
            catch (Exception)
            {
                layer61.Load();
            }
        }
示例#11
0
        public TEHookHelper(ITerraExplorer51 teExplorer, ISGWorld61 sgWorld)
        {
            this.TerrainExplorer = teExplorer;
            this.SGWorld = sgWorld;

            // 绑定事件到ESRI的ITool
            _ISGWorld61Events_Event sgWorldEvent = this.SGWorld as _ISGWorld61Events_Event;
            sgWorldEvent.OnRButtonDown += new _ISGWorld61Events_OnRButtonDownEventHandler(sgWorldEvent_OnRButtonDown);
            sgWorldEvent.OnLButtonDown += new _ISGWorld61Events_OnLButtonDownEventHandler(sgWorldEvent_OnLButtonDown);
            sgWorldEvent.OnMButtonDown += new _ISGWorld61Events_OnMButtonDownEventHandler(sgWorldEvent_OnMButtonDown);

            sgWorldEvent.OnLButtonUp += new _ISGWorld61Events_OnLButtonUpEventHandler(sgWorldEvent_OnLButtonUp);
            sgWorldEvent.OnRButtonUp += new _ISGWorld61Events_OnRButtonUpEventHandler(sgWorldEvent_OnRButtonUp);
            sgWorldEvent.OnMButtonUp += new _ISGWorld61Events_OnMButtonUpEventHandler(sgWorldEvent_OnMButtonUp);

            sgWorldEvent.OnLButtonDblClk += new _ISGWorld61Events_OnLButtonDblClkEventHandler(sgWorldEvent_OnLButtonDblClk);
            sgWorldEvent.OnRButtonDblClk += new _ISGWorld61Events_OnRButtonDblClkEventHandler(sgWorldEvent_OnRButtonDblClk);
            sgWorldEvent.OnMButtonDblClk += new _ISGWorld61Events_OnMButtonDblClkEventHandler(sgWorldEvent_OnMButtonDblClk);
        }
示例#12
0
        public TEHookHelper(ITerraExplorer51 teExplorer, ISGWorld61 sgWorld)
        {
            this.TerrainExplorer = teExplorer;
            this.SGWorld         = sgWorld;


            // 绑定事件到ESRI的ITool
            _ISGWorld61Events_Event sgWorldEvent = this.SGWorld as _ISGWorld61Events_Event;

            sgWorldEvent.OnRButtonDown += new _ISGWorld61Events_OnRButtonDownEventHandler(sgWorldEvent_OnRButtonDown);
            sgWorldEvent.OnLButtonDown += new _ISGWorld61Events_OnLButtonDownEventHandler(sgWorldEvent_OnLButtonDown);
            sgWorldEvent.OnMButtonDown += new _ISGWorld61Events_OnMButtonDownEventHandler(sgWorldEvent_OnMButtonDown);

            sgWorldEvent.OnLButtonUp += new _ISGWorld61Events_OnLButtonUpEventHandler(sgWorldEvent_OnLButtonUp);
            sgWorldEvent.OnRButtonUp += new _ISGWorld61Events_OnRButtonUpEventHandler(sgWorldEvent_OnRButtonUp);
            sgWorldEvent.OnMButtonUp += new _ISGWorld61Events_OnMButtonUpEventHandler(sgWorldEvent_OnMButtonUp);

            sgWorldEvent.OnLButtonDblClk += new _ISGWorld61Events_OnLButtonDblClkEventHandler(sgWorldEvent_OnLButtonDblClk);
            sgWorldEvent.OnRButtonDblClk += new _ISGWorld61Events_OnRButtonDblClkEventHandler(sgWorldEvent_OnRButtonDblClk);
            sgWorldEvent.OnMButtonDblClk += new _ISGWorld61Events_OnMButtonDblClkEventHandler(sgWorldEvent_OnMButtonDblClk);
        }
示例#13
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)处理)*****/
        }
示例#14
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)处理)*****/
        }
示例#15
0
        /// <summary>
        /// 加载shape文件添加模型
        /// 模型数据要与shape在同一路径下
        /// 2012-09-21 张航宇
        /// 添加Z修正 -56
        /// </summary>
        /// <param name="FileName"></param>
        /// 
        public void LoadShapeAdd3model(ISGWorld61 sgworld,ITerraExplorer te, string FileName)
        {
            IInformationTree5 infoTree5 = te as IInformationTree5;
            if (string.IsNullOrEmpty(FileName))
            {
                return;
            }
            if (File.Exists(FileName))
            {
                bool PathType = true;
                string PathFileName = "";
                string GroupName = "模型组群" + System.Guid.NewGuid().ToString().Substring(0, 6);
                infoTree5.CreateGroup(GroupName, 0);
                int GroupID = sgworld.ProjectTree.FindItem(GroupName);
                string ModelFilename = "";
                string UNModelFilename = "";
                string _XMLLayerInfo = "<PlugData>" +

                "<PlugType>shape</PlugType>" +

                "<LayerName>" + FileName + "</LayerName>" +

                "<Server></Server>" +

                "<user></user>" +

                "<password></password>" +

                "<TableName></TableName>" +

                "<AttributesToLoad>*</AttributesToLoad >" +

                "<Feature>1</Feature >" +

                "<Annotation>1</Annotation>" +

                "<SaveItems>0</SaveItems>" +

                "<GroupKey>LAT-LONG</GroupKey>" +

                "<SysKey>LAT-LONG</SysKey>" +

                "<DatumKey>WGS84</DatumKey>" +

                "<UnitKey>METERS</UnitKey>" +

                "<UseZValue>0</UseZValue>" +

                "<AltitudeUnit>Meters</AltitudeUnit>" +

                "<Reproject>1</Reproject>" +

                "<StreamedLayer>0</StreamedLayer></PlugData >";
                ILayer5 iLyr = infoTree5.CreateLayer("3DModleGoto", _XMLLayerInfo, GroupID);//在根目录下装载shp数据
                iLyr.Load();
                IFeature61 sqfeature61 = null;
                int itemid = sgworld.ProjectTree.FindItem("" + GroupName + "\\3DModleGoto");

                ILayer61 m_layer61 = sgworld.ProjectTree.GetLayer(itemid);
                m_layer61.Streaming = false;

                IFeatureGroups61 pFeatureGroups61 = m_layer61.FeatureGroups;

                IFeatureGroup61 pFeatureGroup61 = pFeatureGroups61.Point as IFeatureGroup61;
                if (pFeatureGroup61 == null)
                {
                    MessageBox.Show("当前操作要求是正确的点图层");
                    return;
                }
                else
                {
                    if (pFeatureGroup61.Count == 0)
                    {
                        MessageBox.Show("图层为空!");
                        return;
                    }
                    else
                    {
                        sqfeature61 = pFeatureGroup61[0] as IFeature61;
                        IFeatureAttributes61 m_FeatureAttributes = sqfeature61.FeatureAttributes;
                        int AttributesCount = m_FeatureAttributes.Count;
                        string[] FiledArry = new string[AttributesCount];
                        for (int f = 0; f < AttributesCount; f++)
                        {
                            IFeatureAttribute61 m_FeatureAttribute = m_FeatureAttributes[f] as IFeatureAttribute61;
                            FiledArry[f] = m_FeatureAttribute.Name;
                        }
                        Skyline.Core.UI.FrmAddModelShape pFrmAddModelShape = new Skyline.Core.UI.FrmAddModelShape();
                        pFrmAddModelShape.GetFiledName = FiledArry;
                        pFrmAddModelShape.ShowDialog();
                        PathFileName = pFrmAddModelShape.Filed;
                        PathType = pFrmAddModelShape.PathType;
                        pFrmAddModelShape.Dispose();

                        int m_FeatureCount = pFeatureGroup61.Count;
                        int ImportFeatureCount = pFeatureGroup61.Count;
                        for (int i = 0; i < m_FeatureCount; i++)
                        {
                            sqfeature61 = pFeatureGroup61[i] as IFeature61;
                            IFeatureAttributes61 _FeatureAttributes = sqfeature61.FeatureAttributes;
                            TerraExplorerX.IGeometry _Geometry = sqfeature61.GeometryZ;
                            TerraExplorerX.IPoint pPoint = _Geometry as TerraExplorerX.IPoint;
                            //IPosition61 TPosition61 = sgworld.Window.PixelToWorld(pPoint.X, pPoint.Y, WorldPointType.WPT_ALL).Position;
                            IPosition61 TPosition61 =sgworld.Creator.CreatePosition(pPoint.X, pPoint.Y, -56, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, 0);
                            IFeatureAttribute61 _FeatureAttribute = _FeatureAttributes.GetFeatureAttribute(PathFileName);
                            UNModelFilename = _FeatureAttribute.Value.ToString();
                            if (PathType)
                            {
                                ModelFilename = System.IO.Path.GetDirectoryName(FileName) + "\\" + UNModelFilename;
                            }
                            else
                            {
                                ModelFilename = UNModelFilename;
                            }

                            try
                            {
                               sgworld.Creator.CreateModel(TPosition61, ModelFilename, 1, ModelTypeCode.MT_NORMAL, GroupID, UNModelFilename);
                            }
                            catch
                            {
                                ImportFeatureCount--;
                                continue;
                            }

                        }
                        MessageBox.Show(ImportFeatureCount + "个模型加载成功," + (m_FeatureCount - ImportFeatureCount) + "个模型加载失败!");

                        /****20130227杨漾(添加文件有效性判断,分步判断图层有效性,增加加载统计情况提示)****/

                    }
                }
            }
        }
示例#16
0
        /// <summary>
        /// 创建等高线*.shp文件的主方法
        /// </summary>
        /// <param name="lux">左上投影x坐标</param>
        /// <param name="luy">左上投影y坐标</param>
        /// <param name="luz">左上投影z坐标</param>
        /// <param name="rlx">右下投影x坐标</param>
        /// <param name="rly">右下投影y坐标</param>
        /// <param name="rlz">右下投影z坐标</param>
        /// <param name="m_interval">采样间隔</param>
        /// <returns>等高线*.shp文件的文件名</returns>
        public string CreateContourShape(ISGWorld61 sgworld, double lux, double luy, double luz, double rlx, double rly, double rlz,double m_interval)
        {
            double width = sgworld.CoordServices.GetDistance(lux, luy, rlx, luy);
            double hight = sgworld.CoordServices.GetDistance(lux, luy, lux, rly);
            if (width<5||hight<10)
            {
                MessageBox.Show("范围过小!","SUNZ",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                return null;

            }
            if ((width/1000)*(hight/1000)>40)
            {
                if (MessageBox.Show("范围超出40平分公里,系统计算时间比较长,是否继续?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK)
                {

                }
                else
                {
                    return null;
                }
            }
            this.Interval = m_interval;
            this.Random = System.Guid.NewGuid().ToString().Substring(0, 6).ToLower();
            CopyFolder(Application.StartupPath + "\\Convert\\TemPoints", Application.StartupPath + "\\Convert\\PointsResult\\" + this.Random);
            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
            IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(Application.StartupPath + "\\Convert\\PointsResult\\" + this.Random, 0);
            IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(Application.StartupPath + "\\Convert\\PointsResult\\" + Random + "\\TemPointLayer.shp"));
            IFeatureClassWrite fr = (IFeatureClassWrite)pFeatureClass;
            IWorkspaceEdit w = (pFeatureClass as IDataset).Workspace as IWorkspaceEdit;
            IFeature f;
            w.StartEditing(true);
            w.StartEditOperation();
            int EastPointCount = (int)(width / 5);
            int NothPointCount = (int)(hight / 5);
            for (int j = 0; j < NothPointCount; j++)
            {
                ESRI.ArcGIS.Geometry.IPoint p;
                p = new ESRI.ArcGIS.Geometry.PointClass();
                ESRI.ArcGIS.Geometry.IZAware iz = p as ESRI.ArcGIS.Geometry.IZAware;
                iz.ZAware = true;
                p.X = lux;
                p.Y = luy;
                p.Z = luz;

                ESRI.ArcGIS.Geometry.IGeometry peo;
                peo = p;
                f = pFeatureClass.CreateFeature();
                f.Shape = peo;
                f.set_Value(3, p.Z);
                f.Store();
                fr.WriteFeature(f);

                for (int i = 0; i < EastPointCount; i++)
                {

                    IPosition61 positionLU = null;
                    ICoord2D pPoint = null;
                    if ((j + 2) % 2 == 0)
                    {
                        pPoint = sgworld.CoordServices.MoveCoord(lux, luy, 5, 0);
                    }
                    else
                    {
                        pPoint = sgworld.CoordServices.MoveCoord(lux, luy, -5, 0);
                    }

                    IWorldPointInfo61 pW = sgworld.Terrain.GetGroundHeightInfo(pPoint.X, pPoint.Y, AccuracyLevel.ACCURACY_BEST_FROM_MEMORY, true);
                    positionLU = pW.Position;
                    luz = positionLU.Altitude;
                    lux = positionLU.X;
                    luy = positionLU.Y;
                    p = new ESRI.ArcGIS.Geometry.PointClass();
                    iz = p as ESRI.ArcGIS.Geometry.IZAware;
                    iz.ZAware = true;
                    p.X = lux;
                    p.Y = luy;
                    p.Z = luz;
                    peo = p;
                    f = pFeatureClass.CreateFeature();
                    f.Shape = peo;
                    f.set_Value(3, p.Z);
                    f.Store();
                    fr.WriteFeature(f);

                }
                ICoord2D pPointL = sgworld.CoordServices.MoveCoord(lux, luy, 0, -5);
                IWorldPointInfo61 pWL = sgworld.Terrain.GetGroundHeightInfo(pPointL.X, pPointL.Y, AccuracyLevel.ACCURACY_FORCE_BEST_RENDERED, true);
                luz = pWL.Position.Altitude;
                lux = pWL.Position.X;
                luy = pWL.Position.Y;

            }
            w.StopEditOperation();
            w.StopEditing(true);
            CreateTinFromFeature(pFeatureClass);
            return this.Random;
        }
示例#17
0
        /// <summary>
        /// 加载shape文件添加模型
        /// 模型数据要与shape在同一路径下
        /// 2012-09-21 张航宇
        /// 添加Z修正 -56
        /// </summary>
        /// <param name="FileName"></param>
        ///
        public void LoadShapeAdd3model(ISGWorld61 sgworld, ITerraExplorer te, string FileName)
        {
            IInformationTree5 infoTree5 = te as IInformationTree5;

            if (string.IsNullOrEmpty(FileName))
            {
                return;
            }
            if (File.Exists(FileName))
            {
                bool   PathType     = true;
                string PathFileName = "";
                string GroupName    = "模型组群" + System.Guid.NewGuid().ToString().Substring(0, 6);
                infoTree5.CreateGroup(GroupName, 0);
                int    GroupID         = sgworld.ProjectTree.FindItem(GroupName);
                string ModelFilename   = "";
                string UNModelFilename = "";
                string _XMLLayerInfo   = "<PlugData>" +

                                         "<PlugType>shape</PlugType>" +

                                         "<LayerName>" + FileName + "</LayerName>" +

                                         "<Server></Server>" +

                                         "<user></user>" +

                                         "<password></password>" +

                                         "<TableName></TableName>" +

                                         "<AttributesToLoad>*</AttributesToLoad >" +

                                         "<Feature>1</Feature >" +

                                         "<Annotation>1</Annotation>" +

                                         "<SaveItems>0</SaveItems>" +

                                         "<GroupKey>LAT-LONG</GroupKey>" +

                                         "<SysKey>LAT-LONG</SysKey>" +

                                         "<DatumKey>WGS84</DatumKey>" +

                                         "<UnitKey>METERS</UnitKey>" +

                                         "<UseZValue>0</UseZValue>" +

                                         "<AltitudeUnit>Meters</AltitudeUnit>" +

                                         "<Reproject>1</Reproject>" +

                                         "<StreamedLayer>0</StreamedLayer></PlugData >";
                ILayer5 iLyr = infoTree5.CreateLayer("3DModleGoto", _XMLLayerInfo, GroupID);//在根目录下装载shp数据
                iLyr.Load();
                IFeature61 sqfeature61 = null;
                int        itemid      = sgworld.ProjectTree.FindItem("" + GroupName + "\\3DModleGoto");

                ILayer61 m_layer61 = sgworld.ProjectTree.GetLayer(itemid);
                m_layer61.Streaming = false;

                IFeatureGroups61 pFeatureGroups61 = m_layer61.FeatureGroups;

                IFeatureGroup61 pFeatureGroup61 = pFeatureGroups61.Point as IFeatureGroup61;
                if (pFeatureGroup61 == null)
                {
                    MessageBox.Show("当前操作要求是正确的点图层");
                    return;
                }
                else
                {
                    if (pFeatureGroup61.Count == 0)
                    {
                        MessageBox.Show("图层为空!");
                        return;
                    }
                    else
                    {
                        sqfeature61 = pFeatureGroup61[0] as IFeature61;
                        IFeatureAttributes61 m_FeatureAttributes = sqfeature61.FeatureAttributes;
                        int      AttributesCount = m_FeatureAttributes.Count;
                        string[] FiledArry       = new string[AttributesCount];
                        for (int f = 0; f < AttributesCount; f++)
                        {
                            IFeatureAttribute61 m_FeatureAttribute = m_FeatureAttributes[f] as IFeatureAttribute61;
                            FiledArry[f] = m_FeatureAttribute.Name;
                        }
                        Skyline.Core.UI.FrmAddModelShape pFrmAddModelShape = new Skyline.Core.UI.FrmAddModelShape();
                        pFrmAddModelShape.GetFiledName = FiledArry;
                        pFrmAddModelShape.ShowDialog();
                        PathFileName = pFrmAddModelShape.Filed;
                        PathType     = pFrmAddModelShape.PathType;
                        pFrmAddModelShape.Dispose();

                        int m_FeatureCount     = pFeatureGroup61.Count;
                        int ImportFeatureCount = pFeatureGroup61.Count;
                        for (int i = 0; i < m_FeatureCount; i++)
                        {
                            sqfeature61 = pFeatureGroup61[i] as IFeature61;
                            IFeatureAttributes61     _FeatureAttributes = sqfeature61.FeatureAttributes;
                            TerraExplorerX.IGeometry _Geometry          = sqfeature61.GeometryZ;
                            TerraExplorerX.IPoint    pPoint             = _Geometry as TerraExplorerX.IPoint;
                            //IPosition61 TPosition61 = sgworld.Window.PixelToWorld(pPoint.X, pPoint.Y, WorldPointType.WPT_ALL).Position;
                            IPosition61         TPosition61       = sgworld.Creator.CreatePosition(pPoint.X, pPoint.Y, -56, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, 0);
                            IFeatureAttribute61 _FeatureAttribute = _FeatureAttributes.GetFeatureAttribute(PathFileName);
                            UNModelFilename = _FeatureAttribute.Value.ToString();
                            if (PathType)
                            {
                                ModelFilename = System.IO.Path.GetDirectoryName(FileName) + "\\" + UNModelFilename;
                            }
                            else
                            {
                                ModelFilename = UNModelFilename;
                            }

                            try
                            {
                                sgworld.Creator.CreateModel(TPosition61, ModelFilename, 1, ModelTypeCode.MT_NORMAL, GroupID, UNModelFilename);
                            }
                            catch
                            {
                                ImportFeatureCount--;
                                continue;
                            }
                        }
                        MessageBox.Show(ImportFeatureCount + "个模型加载成功," + (m_FeatureCount - ImportFeatureCount) + "个模型加载失败!");

                        /****20130227杨漾(添加文件有效性判断,分步判断图层有效性,增加加载统计情况提示)****/
                    }
                }
            }
        }
示例#18
0
        /// <summary>
        /// 加载WFS矢量地图服务
        /// </summary>
        /// <param name="WFSURl">获取范围URL</param>
        /// <param name="URl">服务URL</param>
        /// <param name="ServerName">服务名称</param>
        public void LoadWFS(ISGWorld61 sgworld, string WFSURl,string URl,string ServerName)
        {
            XmlDocument doc = new XmlDocument();

            doc = GetXMLFromUrl(WFSURl);

            XmlNodeList Childrennodes = doc.ChildNodes;
            XmlNode Childrennode = Childrennodes[1];
            XmlNode FeatureType = Childrennode.ChildNodes[3].FirstChild;

            string LayerName = FeatureType.FirstChild.InnerXml;
            string Connstr = URl;
            Connstr ="Server="+ Connstr + ";User=admin;WFSVersion=1.0.0;LayerName=";
            // string Connstr = "Server=http://gisserver:8399/arcgis/services/line2/MapServer/WFSServer;User=admin;WFSVersion=1.0.0;LayerName=line2:WGSline1;TEPlugName=WFS;";
            Connstr = Connstr + "" + LayerName + "" + ";TEPlugName=WFS;";
            try
            {
                ILayer61 pILayer = sgworld.Creator.CreateFeatureLayer(ServerName, Connstr, 0);
                string wellKtext = sgworld.CoordServices.ChooseCSDialog("", "");
                pILayer.CoordinateSystem.WellKnownText = wellKtext;

                pILayer.Reproject = true;
                pILayer.Load();
            }
            catch (Exception ex)
            {
                MessageBox.Show("该服务地址不正确!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            }
        }
示例#19
0
 public static object returnValue(ISGWorld61 sgWorld, CommandParam ICommandID)
 {
     return(sgWorld.Command.GetValue((int)ICommandID));
 }
示例#20
0
 public static void RunMenuCommand(ISGWorld61 sgWorld, CommandParam ICommandID, CommandParam pCommandID)
 {
     sgWorld.Command.Execute((int)ICommandID, (int)pCommandID);
 }
示例#21
0
        /// <summary>
        /// 加载WMS服务
        /// </summary>
        /// <param name="EXURl">解析范围用的URL</param>
        /// <param name="URl">服务地址</param>
        /// <param name="ServerName">服务名称</param>
        public void LoadWMS(ISGWorld61 sgworld, string EXURl, string URl,string ServerName)
        {
            XmlDocument doc = new XmlDocument();

            doc = GetXMLFromUrl(EXURl);
            if (doc == null)
            {

            }
            XmlNode Capnode = null;

            XmlNodeList Childrennodes = doc.ChildNodes;
            foreach (XmlNode item in Childrennodes)
            {
                if (item.Name =="WMS_Capabilities")
                {
                    Capnode = item.LastChild;
                    break;
                }
            }

            XmlNode Exnode = Capnode.LastChild;//layer
            XmlNode Extentnode = Exnode.ChildNodes[3];
            double[] extentArr = new double[4];
            extentArr[0] = Convert.ToDouble(Extentnode.ChildNodes[0].InnerText);
            extentArr[1] = Convert.ToDouble(Extentnode.ChildNodes[1].InnerText);
            extentArr[2] = Convert.ToDouble(Extentnode.ChildNodes[2].InnerText);
            extentArr[3] = Convert.ToDouble(Extentnode.ChildNodes[3].InnerText);

            string name = ServerName;
            var wmsFile = "[INFO]" + "\n" +
            "Meters=0" + "\n" +
            "MPP=2.68220901489258E-06" + "\n" +
            "Url=" + URl + "&request=GetMap&Version=1.1.1&Service=WMS&SRS=EPSG:4326&BBOX=0,0,0,0&HEIGHT=256&WIDTH=256&Styles=&Format=image/png&TRANSPARENT=FALSE" + "\n" +
            "xul=" + extentArr[0] + "\n" +
            "ylr=" + extentArr[2] + "\n" +
            "xlr=" + extentArr[1] + "\n" +
            "yul=" + extentArr[3] + "\n";
            try
            {
                var newlayer = sgworld.Creator.CreateImageryLayer(name, extentArr[0], extentArr[3], extentArr[1], extentArr[2], "<EXT><ExtInfo><![CDATA[" + wmsFile + "]]></ExtInfo><ExtType>wms</ExtType></EXT>", "gisplg.rct", 0, name);

                newlayer.UseNull = true;
                newlayer.NullValue = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show("该服务地址不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            }
        }
示例#22
0
 public static object returnValue(ISGWorld61 sgWorld,CommandParam ICommandID)
 {
     return sgWorld.Command.GetValue((int)ICommandID);
 }
示例#23
0
        /// <summary>
        /// 创建等高线*.shp文件的主方法
        /// </summary>
        /// <param name="lux">左上投影x坐标</param>
        /// <param name="luy">左上投影y坐标</param>
        /// <param name="luz">左上投影z坐标</param>
        /// <param name="rlx">右下投影x坐标</param>
        /// <param name="rly">右下投影y坐标</param>
        /// <param name="rlz">右下投影z坐标</param>
        /// <param name="m_interval">采样间隔</param>
        /// <returns>等高线*.shp文件的文件名</returns>
        public string CreateContourShape(ISGWorld61 sgworld, double lux, double luy, double luz, double rlx, double rly, double rlz, double m_interval)
        {
            double width = sgworld.CoordServices.GetDistance(lux, luy, rlx, luy);
            double hight = sgworld.CoordServices.GetDistance(lux, luy, lux, rly);

            if (width < 5 || hight < 10)
            {
                MessageBox.Show("范围过小!", "SUNZ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(null);
            }
            if ((width / 1000) * (hight / 1000) > 40)
            {
                if (MessageBox.Show("范围超出40平分公里,系统计算时间比较长,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                }
                else
                {
                    return(null);
                }
            }
            this.Interval = m_interval;
            this.Random   = System.Guid.NewGuid().ToString().Substring(0, 6).ToLower();
            CopyFolder(Application.StartupPath + "\\Convert\\TemPoints", Application.StartupPath + "\\Convert\\PointsResult\\" + this.Random);
            IWorkspaceFactory  pWorkspaceFactory = new ShapefileWorkspaceFactory();
            IWorkspace         pWorkspace        = pWorkspaceFactory.OpenFromFile(Application.StartupPath + "\\Convert\\PointsResult\\" + this.Random, 0);
            IFeatureWorkspace  pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            IFeatureClass      pFeatureClass     = pFeatureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(Application.StartupPath + "\\Convert\\PointsResult\\" + Random + "\\TemPointLayer.shp"));
            IFeatureClassWrite fr = (IFeatureClassWrite)pFeatureClass;
            IWorkspaceEdit     w  = (pFeatureClass as IDataset).Workspace as IWorkspaceEdit;
            IFeature           f;

            w.StartEditing(true);
            w.StartEditOperation();
            int EastPointCount = (int)(width / 5);
            int NothPointCount = (int)(hight / 5);

            for (int j = 0; j < NothPointCount; j++)
            {
                ESRI.ArcGIS.Geometry.IPoint p;
                p = new ESRI.ArcGIS.Geometry.PointClass();
                ESRI.ArcGIS.Geometry.IZAware iz = p as ESRI.ArcGIS.Geometry.IZAware;
                iz.ZAware = true;
                p.X       = lux;
                p.Y       = luy;
                p.Z       = luz;

                ESRI.ArcGIS.Geometry.IGeometry peo;
                peo     = p;
                f       = pFeatureClass.CreateFeature();
                f.Shape = peo;
                f.set_Value(3, p.Z);
                f.Store();
                fr.WriteFeature(f);

                for (int i = 0; i < EastPointCount; i++)
                {
                    IPosition61 positionLU = null;
                    ICoord2D    pPoint     = null;
                    if ((j + 2) % 2 == 0)
                    {
                        pPoint = sgworld.CoordServices.MoveCoord(lux, luy, 5, 0);
                    }
                    else
                    {
                        pPoint = sgworld.CoordServices.MoveCoord(lux, luy, -5, 0);
                    }

                    IWorldPointInfo61 pW = sgworld.Terrain.GetGroundHeightInfo(pPoint.X, pPoint.Y, AccuracyLevel.ACCURACY_BEST_FROM_MEMORY, true);
                    positionLU = pW.Position;
                    luz        = positionLU.Altitude;
                    lux        = positionLU.X;
                    luy        = positionLU.Y;
                    p          = new ESRI.ArcGIS.Geometry.PointClass();
                    iz         = p as ESRI.ArcGIS.Geometry.IZAware;
                    iz.ZAware  = true;
                    p.X        = lux;
                    p.Y        = luy;
                    p.Z        = luz;
                    peo        = p;
                    f          = pFeatureClass.CreateFeature();
                    f.Shape    = peo;
                    f.set_Value(3, p.Z);
                    f.Store();
                    fr.WriteFeature(f);
                }
                ICoord2D          pPointL = sgworld.CoordServices.MoveCoord(lux, luy, 0, -5);
                IWorldPointInfo61 pWL     = sgworld.Terrain.GetGroundHeightInfo(pPointL.X, pPointL.Y, AccuracyLevel.ACCURACY_FORCE_BEST_RENDERED, true);
                luz = pWL.Position.Altitude;
                lux = pWL.Position.X;
                luy = pWL.Position.Y;
            }
            w.StopEditOperation();
            w.StopEditing(true);
            CreateTinFromFeature(pFeatureClass);
            return(this.Random);
        }
示例#24
0
 public static void RunMenuCommand(ISGWorld61 sgWorld, CommandParam ICommandID, CommandParam pCommandID)
 {
     sgWorld.Command.Execute((int)ICommandID, (int)pCommandID);
 }