这篇是转载的平常心博客,原地址见:http://www.v5cn.cn/?p=171

1、WMSTiledImageLayer类说明

一个WMSTiledImageLayer类对象只能对应一个WMS发布的服务图层,使用WMS服务时需要使用到WMS元数据描述类WMSCapabilities对象,我们使用WMSCapabilites类的静态方法retrieve来获得它的对象。WMSCapabilites对象可以包含WMS服务中所以的图层和图层样式,我们通过把需要显示的图层名称保存到AVList对象中,然后通过WMSCapabilites对象和AVList来创建WMSTiledImageLayer对象。我们可以通过一个请求地址来查看WMS服务所包含的元数据。例如:http://127.0.0.1:8080/geoserver/PostGIS/wms?request=GetGapabilities&Service=WMS 问号后面的地址是固定的,可以但看如下的XML:

  1. <LayerqueryableLayerqueryable="1">
  2. <Name>spearfish</Name>
  3. <Title>spearfish</Title>
  4. <Abstract>Layer-Group type layer: spearfish</Abstract>
  5. <CRS>EPSG:26713</CRS>
  6. <EX_GeographicBoundingBox>
  7. <westBoundLongitude>-103.87791475407893</westBoundLongitude>
  8. <eastBoundLongitude>-103.62278893469492</eastBoundLongitude>
  9. <southBoundLatitude>44.37246687108142</southBoundLatitude>
  10. <northBoundLatitude>44.50235105543566</northBoundLatitude>
  11. </EX_GeographicBoundingBox>
  12. <BoundingBoxCRSBoundingBoxCRS="EPSG:26713"minx="589425.9342365642"miny="4913959.224611808"maxx="609518.6719560538"maxy="4928082.949945881"/>
  13. </Layer>
  14. <LayerqueryableLayerqueryable="1">
  15. <Name>tasmania</Name>
  16. <Title>tasmania</Title>
  17. <Abstract>Layer-Group type layer: tasmania</Abstract>
  18. <CRS>EPSG:4326</CRS>
  19. <EX_GeographicBoundingBox>
  20. <westBoundLongitude>143.83482400000003</westBoundLongitude>
  21. <eastBoundLongitude>148.47914100000003</eastBoundLongitude>
  22. <southBoundLatitude>-43.648056</southBoundLatitude>
  23. <northBoundLatitude>-39.573891</northBoundLatitude>
  24. </EX_GeographicBoundingBox>
  25. <BoundingBoxCRSBoundingBoxCRS="EPSG:4326"minx="-43.648056"miny="143.83482400000003"maxx="-39.573891"maxy="148.47914100000003"/>
  26. </Layer>
  27. <LayerqueryableLayerqueryable="1">
  28. <Name>tiger-ny</Name>
  29. <Title>tiger-ny</Title>
  30. <Abstract>Layer-Group type layer: tiger-ny</Abstract>
  31. <CRS>EPSG:4326</CRS>
  32. <EX_GeographicBoundingBox>
  33. <westBoundLongitude>-74.047185</westBoundLongitude>
  34. <eastBoundLongitude>-73.907005</eastBoundLongitude>
  35. <southBoundLatitude>40.679648</southBoundLatitude>
  36. <northBoundLatitude>40.882078</northBoundLatitude>
  37. </EX_GeographicBoundingBox>
  38. <BoundingBoxCRSBoundingBoxCRS="EPSG:4326"minx="40.679648"miny="-74.047185"maxx="40.882078"maxy="-73.907005"/>
  39. </Layer>
  40. <LayerqueryableLayerqueryable="1">
  41. <Name>省界_region</Name>
  42. <Title>省界_region</Title>
  43. <Abstract/>
  44. <KeywordList>
  45. <Keyword>features</Keyword>
  46. <Keyword>省界_region</Keyword>
  47. </KeywordList>
  48. <CRS>EPSG:4326</CRS>
  49. <CRS>CRS:84</CRS>
  50. <EX_GeographicBoundingBox>
  51. <westBoundLongitude>73.441277</westBoundLongitude>
  52. <eastBoundLongitude>135.08693</eastBoundLongitude>
  53. <southBoundLatitude>18.159829</southBoundLatitude>
  54. <northBoundLatitude>53.561771</northBoundLatitude>
  55. </EX_GeographicBoundingBox>
  56. <BoundingBoxCRSBoundingBoxCRS="CRS:84"minx="73.441277"miny="18.159829"maxx="135.08693"maxy="53.561771"/>
  57. <BoundingBoxCRSBoundingBoxCRS="EPSG:4326"minx="18.159829"miny="73.441277"maxx="53.561771"maxy="135.08693"/>
  58. <Style>
  59. <Name>polygon_x</Name>
  60. <Title>Default Polygon</Title>
  61. <Abstract>A sample style that draws a polygon</Abstract>
  62. <LegendURLwidthLegendURLwidth="20"height="20">
  63. <Format>image/png</Format>
  64. <OnlineResourcexmlns:xlinkOnlineResourcexmlns:xlink="http://www.w3.org/1999/xlink"xlink:type="simple"xlink:href="http://localhost:8080/geoserver/cite/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=%3F%3F_region"/>
  65. </LegendURL>
  66. </Style>
  67. </Layer>

里面的每一个Layer节点都是一个WMS图层。

2、例子

  1. package gov.nasa.worldwindx.v5cn;
  2. import gov.nasa.worldwind.avlist.AVKey;
  3. import gov.nasa.worldwind.avlist.AVList;
  4. import gov.nasa.worldwind.avlist.AVListImpl;
  5. import gov.nasa.worldwind.ogc.wms.WMSCapabilities;
  6. import gov.nasa.worldwind.wms.WMSTiledImageLayer;
  7. import gov.nasa.worldwindx.examples.ApplicationTemplate;
  8. import java.net.URI;
  9. import java.net.URISyntaxException;
  10. public class WMSLayerTest extends ApplicationTemplate {
  11. public static class AppFrame extends ApplicationTemplate.AppFrame{
  12. private static final long serialVersionUID = 1L;
  13. public AppFrame(){
  14. try {
  15. //请求地图的URL
  16. String uri = "http://127.0.0.1:8080/geoserver/PostGIS/wms";
  17. WMSCapabilities caps;
  18. URI serverURI = new URI(uri);
  19. //获得WMSCapabilities对象
  20. caps = WMSCapabilities.retrieve(serverURI);
  21. //解析WMSCapabilities数据
  22. caps.parse();
  23. AVList params = new AVListImpl();
  24. //图层的名称
  25. params.setValue(AVKey.LAYER_NAMES, "planet_osm_line");
  26. //地图服务的协议,这里是OGC:WMS
  27. params.setValue(AVKey.SERVICE_NAME, "OGC:WMS");
  28. //获得地图的uri,也就是上面定义的uri
  29. params.setValue(AVKey.GET_MAP_URL, uri);
  30. //在本地缓存文件的名称
  31. params.setValue(AVKey.DATA_CACHE_NAME, "planet_osm_line");
  32. params.setValue(AVKey.TILE_URL_BUILDER, new WMSTiledImageLayer.URLBuilder(params));
  33. WMSTiledImageLayer imageLayer = new WMSTiledImageLayer(caps,params);
  34. //图层名称
  35. imageLayer.setName("planet_osm_line");
  36. imageLayer.setEnabled(true);
  37. //图层的透明度
  38. imageLayer.setOpacity(1);
  39. //图层的最大显示高度
  40. imageLayer.setMaxActiveAltitude(33500000);
  41. getWwd().getModel().getLayers().add(imageLayer);
  42. getLayerPanel().update(getWwd());
  43. } catch (URISyntaxException e) {
  44. e.printStackTrace();
  45. } catch (Exception e) {
  46. e.printStackTrace();
  47. }
  48. }
  49. }
  50. public static void main(String[] args) {
  51. ApplicationTemplate.start("WMS图层", WMSLayerTest.AppFrame.class);
  52. }
  53. }

请求的URL就是GeoServer中点击【OpenLayers】中的路径:

图层名称就是定义发布服务是的名称,可以在GeoServer中找到。

World Wind Java开发之十三——加载Geoserver发布的WMS服务(转)的更多相关文章

  1. openlayer3 加载geoserver发布的WFS服务

    转自原文 openlayer3加载geoserver发布的WFS服务 openlayers3调用GeoServer发布的wfs 1 参考一 1.1 问题 openlayer3加载WFS存在跨域问题,需 ...

  2. World Wind Java开发之十一——加载热点信息(仿Google Earth)(转)

    在GE的图层中有一个照片图层,在浏览时可以看到各地的一些图片,我们称之为热点信息,如下图所示: 再来看下本文的实现效果: 效果是不是很像呢,其实实现这个很简单,参照examples中的Balloons ...

  3. ArcGIS api fo silverlight学习一(silverlight加载GeoServer发布的WMS地图)

    最好的学习资料ArcGIS api fo silverlight官网:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm 一. ...

  4. skyline加载arcgis发布的wms服务

    function AddWMSLayer(LayerName) {var _WMSUrl =“http://10.0.4.141:6080/arcgis/services/poss1/MapServe ...

  5. 如何在Skyline中加载ArcGISServer发布的WMS和WMTS服务

    如何在Skyline中加载ArcGISServer发布的WMS和WMTS服务? 我这里的测试环境是ArcGISServer10.1和TerraExplorer Pro7.0,主要过程截图如下,

  6. openlayers 3加载GeoServer发布的wfs类型服务

    转:https://blog.csdn.net/u013323965/article/details/52449502 问题产生:      openlayer3加载WFS存在跨域问题,需要用json ...

  7. OSGEarth加载 geoserver 发布 TMS

    geoserver配好数据并用自带的gwc切片好后, 访问 http://localhost:9999/geoserver/gwc/service/tms/1.0.0/ 在OsgEarth的earth ...

  8. World Wind Java开发之六——解析shape文件(转)

    http://blog.csdn.net/giser_whu/article/details/41647117 最近一直忙于导师项目的事情了,几天没更新了,昨天和今天研究了下WWJ解析shp文件的源代 ...

  9. World Wind Java开发之十四——添加WMS地图服务资源(转)

    数据是GIS的核心,没有数据一切无从谈起,Internet上有很多在线WMS地图服务资源,我们可以好好利用这些数据资源,比如天地图.必应地图.NASA.OGC数据服务等等. 在我们国家常用的还是天地图 ...

随机推荐

  1. iscsi使用教程(下)

    动态创建目标 安装iscsi服务端 # yum install -y scsi-target-utils.x86_64 修改配置文件 # mkdir -p ~/volumes # sed -i '$ ...

  2. 初始Java虚拟机

    Java虚拟机内存模型(Java运行在虚拟机之上,虚拟机帮Java屏蔽底层的指令集,让Java能够跨平台运行) 内存模型以及分区,需要详细到每个区放什么? 方法区(method area): 方法信息 ...

  3. c++常考算法知识点汇总

    前言:写这篇博客完全是给自己当做笔记用的,考虑到自己的c++基础不是很踏实,只在大一学了一学期,c++的面向对象等更深的知识也一直没去学.就是想当遇到一些比较小的知识,切不值得用一整篇 博客去记述的时 ...

  4. SAS笔记(4) FIRST.和LAST.临时变量

    FIRST.和LAST.临时变量是SAS很有特色的一点,我在R和Python中暂时没有发现类似的功能(也许它们也有这个功能,我不知道而已).考虑这样一种场景:我们有患者就诊的数据,每一条观测对应一个患 ...

  5. java知识点积累(二)

    4.条件运算符(三元运算符): String type = score<60?"不及格":"及格"; int i = (string=="hel ...

  6. 清北刷题冲刺 10-31 a.m

    集合 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ], ...

  7. 清北刷题冲刺 10-28 p.m

    水题(贪心) (water) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK出了道水题. 这个水题是这样的:有两副牌,每副牌都有n张. 对于第一副牌的每 ...

  8. 洛谷P3527 [POI2011]MET-Meteors(整体二分)

    传送门 整体二分 先二分一个答案,判断是否可行,把可行的全都扔到左边,不可行的扔到右边 判断是否可行用树状数组就行 具体细节看代码好了 整体二分细节真多……也可能是我大脑已经退化了? //minamo ...

  9. iPhone摄影中的深度捕捉(WWDC2017-Session 507)

    507是深度媒体相关的概念层面的内容.主要为下面4个部分: Depth and disparity on iPhone 7 Plus Streaming depth data from the cam ...

  10. 为什么Python如此慢

    Python当前人气暴涨.它在DevOps,数据科学,Web开发和安全领域均有使用. 但是在速度方面没有赢得美誉. 这里有关于Python比较其他语言如,Java, C#, Go, JavaScrip ...