当前位置: 代码迷 >> 综合 >> 搭建world wind WMS server(For world wind c# with LandSATSRTM30)之client配置
  详细解决方案

搭建world wind WMS server(For world wind c# with LandSATSRTM30)之client配置

热度:5   发布时间:2024-01-06 05:57:08.0

Client配置

1.       For LandSAT

你可以参考WorldWind/bin/Debug/Config/Earth/@images.tmplandsat的结构和landsat下载数据中esta.xml中的相关参数,自行添加client配置文件或修改现有配置文件。请将配置文件放在WorldWind/bin/Debug/Config/Earth/目录下。

 

需要注意的是请选择WMSAccessor(而不是ImageTileService)作为ImageAccessor的子节点。

      <ImageAccessor>

        <LevelZeroTileSizeDegrees>2.25</LevelZeroTileSizeDegrees>

        <NumberLevels>2</NumberLevels>

        <TextureSizePixels>512</TextureSizePixels>

        <ImageFileExtension>png</ImageFileExtension>

        <WMSAccessor>

          <ServerGetMapUrl>http://10.11.5.23:8085/wms</ServerGetMapUrl>

          <ServiceName>OGC:WMS</ServiceName>

          <Version>1.3.0</Version>

          <ImageFormat>image/png</ImageFormat>

          <WMSLayerName>esat</WMSLayerName>

          <UseTransparency>true</UseTransparency>

          <ServerLogoFilePath>Data/Icons/Interface/earth-western.png</ServerLogoFilePath>

        </WMSAccessor>

      </ImageAccessor>

 

整个配置文件示例如下:

<?xml version="1.0" encoding="UTF-8"?>

<LayerSet Name="Local WMS" ShowOnlyOneLayer="false" ShowAtStartup="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LayerSet.xsd">

     <ChildLayerSet Name="Imagery" ShowOnlyOneLayer="false" ShowAtStartup="true">

    <QuadTileSet ShowAtStartup="true">

      <Name>LandSAT</Name>

      <DistanceAboveSurface>0</DistanceAboveSurface>

      <BoundingBox>

        <North>

          <Value>84.0</Value>

        </North>

        <South>

          <Value>-60.0</Value>

        </South>

        <West>

          <Value>-180.0</Value>

        </West>

        <East>

          <Value>180.0</Value>

        </East>

      </BoundingBox>

      <TerrainMapped>true</TerrainMapped>

      <ImageAccessor>

        <LevelZeroTileSizeDegrees>2.25</LevelZeroTileSizeDegrees>

        <NumberLevels>2</NumberLevels>

        <TextureSizePixels>512</TextureSizePixels>

        <ImageFileExtension>png</ImageFileExtension>

        <WMSAccessor>

          <ServerGetMapUrl>http://10.11.5.23:8085/wms</ServerGetMapUrl>

          <ServiceName>OGC:WMS</ServiceName>

          <Version>1.3.0</Version>

          <ImageFormat>image/png</ImageFormat>

          <WMSLayerName>esat</WMSLayerName>

          <UseTransparency>true</UseTransparency>

          <ServerLogoFilePath>Data/Icons/Interface/earth-western.png</ServerLogoFilePath>

        </WMSAccessor>

      </ImageAccessor>

      <ExtendedInformation>

        <ToolBarImage>Data/Icons/Interface/nlt-landsat-pseudo.png</ToolBarImage>

      </ExtendedInformation>

    </QuadTileSet>

     </ChildLayerSet>

</LayerSet>

 

 

2.       For SRTM

World wind c#版目前是不支持通过wms的方式访问SRTM的。因此

?  修改代码是的ww能够支持wms的访问方式。

?  修改client配置文件。

 

修改代码

?  修改TerrainTileServic

添加成员变量及属性

        protected string m_serverType;

        protected bool m_isWMS;

        protected bool m_isCompressed;

       public string ServerType

        {

            get

            {

                return m_serverType;

            }

        }

 

        public bool IsWMS

        {

            get

            {

                return m_isWMS;

            }

        }

 

        public bool IsCompressed

        {

            get

            {

                return m_isCompressed;

            }

        }       

 

修改构造函数

 

         public TerrainTileService(

              string serverUrl,

              string dataSet,

              double levelZeroTileSizeDegrees,

              int samplesPerTile,

              string fileExtension,

              int numberLevels,

              string terrainTileDirectory,

              TimeSpan terrainTileRetryInterval,

              string dataType,

            string serverType,

            string compressionType)

 

         {

              m_serverUrl = serverUrl;

              m_dataSet = dataSet;

              m_levelZeroTileSizeDegrees = levelZeroTileSizeDegrees;

              m_samplesPerTile = samplesPerTile;

              m_numberLevels = numberLevels;

              m_fileExtension = fileExtension.Replace(".","");

              m_terrainTileDirectory = terrainTileDirectory;

              if(!Directory.Exists(m_terrainTileDirectory))

                   Directory.CreateDirectory(m_terrainTileDirectory);

              m_terrainTileRetryInterval = terrainTileRetryInterval;

              m_dataType = dataType;

              m_serverType = serverType;

              m_isWMS = m_serverType==null || !m_serverType.Contains("WMS") ? false : true;

              m_isCompressed = compressionType == null || compressionType.Length == 0 ? false : true;

         }

 

 

 

 

?  修改TerrainDownloadRequest

         public TerrainDownloadRequest(TerrainTile tile, TerrainTileService owner, int row, int col, int targetLevel) : base(owner)

         {

              TerrainTile = tile;

            if (owner.IsWMS)

            {

                download.Url = String.Format(CultureInfo.InvariantCulture,

                    "{0}?request=GetMap&layers={1}&level={2}&bbox={3},{4},{5},{6}&Format=image/{7}&width=150&height=150&srs=EPSG:4326&Version=1.30&styles=",

                    owner.ServerUrl,

                    owner.DataSet,

                    targetLevel,tile.West,tile.South,tile.East,tile.North,owner.FileExtension);

            }

            else

            {

                download.Url = String.Format(CultureInfo.InvariantCulture,

                    "{0}?T={1}&L={2}&X={3}&Y={4}",

                    owner.ServerUrl,

                    owner.DataSet,

                    targetLevel, col, row);

            }

         }

 

         protected void ProcessFile()

         {

            if (download.ContentType == ContentTypeZip)

{

          ……

}

else if (download.ContentType == ContentType7z || download.ContentType == ContentTypeXCompressed)

{

          ……

}

            else if(download.SavedFilePath.EndsWith(".tmp"))

            {

                String fileName = download.SavedFilePath.Substring(0,download.SavedFilePath.Length-4);

                if (!File.Exists(download.SavedFilePath))

                {

                    return;

                }

 

                if (File.Exists(fileName))

                {

                    File.Delete(fileName);

                }

 

                File.Move(download.SavedFilePath, fileName);

            }

           

}

 

?  修改ConfigurationLoader:getTerrainAccessorsFromXPathNodeIterator及其他调用TerrainTileService的地方

 

compressionType = getInnerTextFromFirstChild(tileServiceIter.Current.Select("CompressonType"));

serverType = getInnerTextFromFirstChild(tileServiceIter.Current.Select("ServerType"));

 

                       TerrainTileService tts = new TerrainTileService(

                            serverUrl,

                            dataSetName,

                            levelZeroTileSizeDegrees,

                            (int)samplesPerTile,

                            fileExtension,

                            (int)numberLevels,

                            Path.Combine(cacheDirectory, terrainAccessorName),

                            World.Settings.TerrainTileRetryInterval,

                            dataFormat,

                        serverType,

                        compressionType);

修改client配置文件

Srtm的设置是通过WorldWind/bin/Debug/Config/Earth.xml来配置的。

新增<ServerType></ServerType>节点指定server的类型,如果是wms的,直接填写wms,否则可以不填。

整个配置文件示例如下:

<?xml version="1.0" encoding="UTF-8"?>

<World Name="Earth" EquatorialRadius="6378137.0" LayerDirectory="Earth" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="WorldXmlDescriptor.xsd">

     <TerrainAccessor Name="nasa SRTM30">

         <TerrainTileService>

              <ServerUrl>http://10.11.5.23:8085/wms</ServerUrl>

              <DataSetName>srtm30</DataSetName>

              <LevelZeroTileSizeDegrees>20</LevelZeroTileSizeDegrees>

              <NumberLevels>12</NumberLevels>

              <SamplesPerTile>150</SamplesPerTile>

              <DataFormat>Int16</DataFormat>

              <FileExtension>bil</FileExtension>

      <CompressonType></CompressonType>

      <ServerType>WMS</ServerType>

         </TerrainTileService>

         <LatLonBoundingBox>

              <North>

                   <Value>90.0</Value>

              </North>

              <South>

 

  相关解决方案