World Wind Java开发之十三——加载Geoserver发布的WMS服务(转)
这篇是转载的平常心博客,原地址见: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:
- <LayerqueryableLayerqueryable="1">
- <Name>spearfish</Name>
- <Title>spearfish</Title>
- <Abstract>Layer-Group type layer: spearfish</Abstract>
- <CRS>EPSG:26713</CRS>
- <EX_GeographicBoundingBox>
- <westBoundLongitude>-103.87791475407893</westBoundLongitude>
- <eastBoundLongitude>-103.62278893469492</eastBoundLongitude>
- <southBoundLatitude>44.37246687108142</southBoundLatitude>
- <northBoundLatitude>44.50235105543566</northBoundLatitude>
- </EX_GeographicBoundingBox>
- <BoundingBoxCRSBoundingBoxCRS="EPSG:26713"minx="589425.9342365642"miny="4913959.224611808"maxx="609518.6719560538"maxy="4928082.949945881"/>
- </Layer>
- <LayerqueryableLayerqueryable="1">
- <Name>tasmania</Name>
- <Title>tasmania</Title>
- <Abstract>Layer-Group type layer: tasmania</Abstract>
- <CRS>EPSG:4326</CRS>
- <EX_GeographicBoundingBox>
- <westBoundLongitude>143.83482400000003</westBoundLongitude>
- <eastBoundLongitude>148.47914100000003</eastBoundLongitude>
- <southBoundLatitude>-43.648056</southBoundLatitude>
- <northBoundLatitude>-39.573891</northBoundLatitude>
- </EX_GeographicBoundingBox>
- <BoundingBoxCRSBoundingBoxCRS="EPSG:4326"minx="-43.648056"miny="143.83482400000003"maxx="-39.573891"maxy="148.47914100000003"/>
- </Layer>
- <LayerqueryableLayerqueryable="1">
- <Name>tiger-ny</Name>
- <Title>tiger-ny</Title>
- <Abstract>Layer-Group type layer: tiger-ny</Abstract>
- <CRS>EPSG:4326</CRS>
- <EX_GeographicBoundingBox>
- <westBoundLongitude>-74.047185</westBoundLongitude>
- <eastBoundLongitude>-73.907005</eastBoundLongitude>
- <southBoundLatitude>40.679648</southBoundLatitude>
- <northBoundLatitude>40.882078</northBoundLatitude>
- </EX_GeographicBoundingBox>
- <BoundingBoxCRSBoundingBoxCRS="EPSG:4326"minx="40.679648"miny="-74.047185"maxx="40.882078"maxy="-73.907005"/>
- </Layer>
- <LayerqueryableLayerqueryable="1">
- <Name>省界_region</Name>
- <Title>省界_region</Title>
- <Abstract/>
- <KeywordList>
- <Keyword>features</Keyword>
- <Keyword>省界_region</Keyword>
- </KeywordList>
- <CRS>EPSG:4326</CRS>
- <CRS>CRS:84</CRS>
- <EX_GeographicBoundingBox>
- <westBoundLongitude>73.441277</westBoundLongitude>
- <eastBoundLongitude>135.08693</eastBoundLongitude>
- <southBoundLatitude>18.159829</southBoundLatitude>
- <northBoundLatitude>53.561771</northBoundLatitude>
- </EX_GeographicBoundingBox>
- <BoundingBoxCRSBoundingBoxCRS="CRS:84"minx="73.441277"miny="18.159829"maxx="135.08693"maxy="53.561771"/>
- <BoundingBoxCRSBoundingBoxCRS="EPSG:4326"minx="18.159829"miny="73.441277"maxx="53.561771"maxy="135.08693"/>
- <Style>
- <Name>polygon_x</Name>
- <Title>Default Polygon</Title>
- <Abstract>A sample style that draws a polygon</Abstract>
- <LegendURLwidthLegendURLwidth="20"height="20">
- <Format>image/png</Format>
- <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"/>
- </LegendURL>
- </Style>
- </Layer>
里面的每一个Layer节点都是一个WMS图层。
2、例子
- package gov.nasa.worldwindx.v5cn;
- import gov.nasa.worldwind.avlist.AVKey;
- import gov.nasa.worldwind.avlist.AVList;
- import gov.nasa.worldwind.avlist.AVListImpl;
- import gov.nasa.worldwind.ogc.wms.WMSCapabilities;
- import gov.nasa.worldwind.wms.WMSTiledImageLayer;
- import gov.nasa.worldwindx.examples.ApplicationTemplate;
- import java.net.URI;
- import java.net.URISyntaxException;
- public class WMSLayerTest extends ApplicationTemplate {
- public static class AppFrame extends ApplicationTemplate.AppFrame{
- private static final long serialVersionUID = 1L;
- public AppFrame(){
- try {
- //请求地图的URL
- String uri = "http://127.0.0.1:8080/geoserver/PostGIS/wms";
- WMSCapabilities caps;
- URI serverURI = new URI(uri);
- //获得WMSCapabilities对象
- caps = WMSCapabilities.retrieve(serverURI);
- //解析WMSCapabilities数据
- caps.parse();
- AVList params = new AVListImpl();
- //图层的名称
- params.setValue(AVKey.LAYER_NAMES, "planet_osm_line");
- //地图服务的协议,这里是OGC:WMS
- params.setValue(AVKey.SERVICE_NAME, "OGC:WMS");
- //获得地图的uri,也就是上面定义的uri
- params.setValue(AVKey.GET_MAP_URL, uri);
- //在本地缓存文件的名称
- params.setValue(AVKey.DATA_CACHE_NAME, "planet_osm_line");
- params.setValue(AVKey.TILE_URL_BUILDER, new WMSTiledImageLayer.URLBuilder(params));
- WMSTiledImageLayer imageLayer = new WMSTiledImageLayer(caps,params);
- //图层名称
- imageLayer.setName("planet_osm_line");
- imageLayer.setEnabled(true);
- //图层的透明度
- imageLayer.setOpacity(1);
- //图层的最大显示高度
- imageLayer.setMaxActiveAltitude(33500000);
- getWwd().getModel().getLayers().add(imageLayer);
- getLayerPanel().update(getWwd());
- } catch (URISyntaxException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- public static void main(String[] args) {
- ApplicationTemplate.start("WMS图层", WMSLayerTest.AppFrame.class);
- }
- }
请求的URL就是GeoServer中点击【OpenLayers】中的路径:
图层名称就是定义发布服务是的名称,可以在GeoServer中找到。
World Wind Java开发之十三——加载Geoserver发布的WMS服务(转)的更多相关文章
- openlayer3 加载geoserver发布的WFS服务
转自原文 openlayer3加载geoserver发布的WFS服务 openlayers3调用GeoServer发布的wfs 1 参考一 1.1 问题 openlayer3加载WFS存在跨域问题,需 ...
- World Wind Java开发之十一——加载热点信息(仿Google Earth)(转)
在GE的图层中有一个照片图层,在浏览时可以看到各地的一些图片,我们称之为热点信息,如下图所示: 再来看下本文的实现效果: 效果是不是很像呢,其实实现这个很简单,参照examples中的Balloons ...
- ArcGIS api fo silverlight学习一(silverlight加载GeoServer发布的WMS地图)
最好的学习资料ArcGIS api fo silverlight官网:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm 一. ...
- skyline加载arcgis发布的wms服务
function AddWMSLayer(LayerName) {var _WMSUrl =“http://10.0.4.141:6080/arcgis/services/poss1/MapServe ...
- 如何在Skyline中加载ArcGISServer发布的WMS和WMTS服务
如何在Skyline中加载ArcGISServer发布的WMS和WMTS服务? 我这里的测试环境是ArcGISServer10.1和TerraExplorer Pro7.0,主要过程截图如下,
- openlayers 3加载GeoServer发布的wfs类型服务
转:https://blog.csdn.net/u013323965/article/details/52449502 问题产生: openlayer3加载WFS存在跨域问题,需要用json ...
- OSGEarth加载 geoserver 发布 TMS
geoserver配好数据并用自带的gwc切片好后, 访问 http://localhost:9999/geoserver/gwc/service/tms/1.0.0/ 在OsgEarth的earth ...
- World Wind Java开发之六——解析shape文件(转)
http://blog.csdn.net/giser_whu/article/details/41647117 最近一直忙于导师项目的事情了,几天没更新了,昨天和今天研究了下WWJ解析shp文件的源代 ...
- World Wind Java开发之十四——添加WMS地图服务资源(转)
数据是GIS的核心,没有数据一切无从谈起,Internet上有很多在线WMS地图服务资源,我们可以好好利用这些数据资源,比如天地图.必应地图.NASA.OGC数据服务等等. 在我们国家常用的还是天地图 ...
随机推荐
- Go:表驱动单元测试
Go:表驱动单元测试 单元测试相当的重要,这几天实习由于单元测试没写好所以被骂了emmm 痛定思痛,立刻上网学习了一下,总算达到了预期的效果,所以写一篇文章记录一下 首先安装gotests $go g ...
- Codeforces Round #507 (Div. 2)C(贪心,逆向遍历,构造)
#include<bits/stdc++.h>using namespace std;int order[300007];long long t[300007],ans[300007];i ...
- (PHP)redis Zset(有序集合 sorted set)操作
/** * * Zset操作 * sorted set操作 * 有序集合 * sorted set 它在set的基础上增加了一个顺序属性,这一属性在修改添加元素的时候可以指定,每次指定后,zset会自 ...
- Ajax原生请求及Json基础
1.基本结构 <script type="text/javascript"> // 创建XMLHttpRequest对象 var request = new XMLHt ...
- [Xcode 实际操作]四、常用控件-(6)UISwitch开关控件的使用
目录:[Swift]Xcode实际操作 本文将演示开关控件的基本用法. 开关控件有两个互斥的选项,它是用来打开或关闭选项的控件. 在项目导航区,打开视图控制器的代码文件[ViewController. ...
- 关于特殊目录如com null无法删除的处理办法
1.把以下批处理做成一个del.bat放在桌面 del /f /a /q \\?\%1 rd /s /q \\?\%1 2.需要删除的文件或者文件夹拉到这个文件上就可以了 可以删除没有属性项目中没有安 ...
- Spring AOP 自定义注解实现统一日志管理
一.AOP的基本概念: AOP,面向切面编程,常用于日志,事务,权限等业务处理.AOP是OOP的延续,是软件开发中的一个热点,也是Spring框架中的一个重要内容(Spring核心之一),是函数式编程 ...
- springboot和Druid整合配置数据源
@Configuration public class DruidConfiguration { @ConfigurationProperties(prefix = "spring.data ...
- Django 03 模板路径、模板变量、常用的过滤器
Django 03 模板路径.模板变量.常用的过滤器 一.模板路径 #1.在每个app下面添加一个templates文件 #2.在项目views.py里面第33行INSTALLED_APPS里面添加上 ...
- [Leetcode]011. Container With Most Water
public class Solution { public int maxArea(int[] height) { int left = 0, right = height.length - 1; ...