OGC—WMS详细介绍(arcgis server举例)
目录
一、引言
一直用arcgis javascript的二次开发,经常使用它的一些服务WMS、WMTS、WFS、MapService等,并没有深入了解这些服务内部机制,直到最近学习了geoserver,由于毕竟它是开源的要遵循行业老大OGC制定的标准,这样通用性比较强一些,所以发的服务基本都是WMS、WTMS、WFS、WCS==
so了解这些东西是必须的了,后悔当时没有跟遥感院第一美男老师好好学啊,现在开始看着还是懵逼状态,硬着头皮看完梳理了一下==
二、WMS服务发布
这里可以用geoserver发布,也可以用arcgisserver或者mapserver,由于我经常使用arcgis,这里用了arcgis server发布的。发布很简单==
这里只要比正常发布的时候多勾个选项就可以了。
发布后的服务如下图:
三、WMS服务中的操作
WMS requests can perform the following operations:
Operation | Description |
Exceptions | If an exception occur |
GetCapabilities | Retrieves metadata about the service, including supported operations and parameters, and a list of the available layers |
GetMap | Retrieves a map image for a specified area and content |
GetFeatureInfo(optional) | Retrieves the underlying data, including geometry and attribute values, for a pixel location on a map |
DescribeLayer(optional) | Indicates the WFS or WCS to retrieve additional information about the layer. |
GetLegendGraphic(optional) |
3.1GetCapabilities(获取服务中的要素类及支持的操作)
3.1.1基本介绍
The GetCapabilities operation requests metadata about the operations, services, and data (“capabilities”) that are offered by a WMS server.
The parameters for the GetCapabilities operation are:
Parameter | Required? | Description |
service | Yes | Service name. Value is WMS. |
version | Yes | Service version. Value is one of 1.0.0, 1.1.0, 1.1.1, 1.3. |
request | Yes | Operation name. Value is GetCapabilities. |
3.1.2举例介绍
请求方式:http://localhost:6080/arcgis/services/tttt/tt/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
这里主要就是三个参数,request就是WMS的操作方法,这里是GetCapabilities
请求结果:
这里看着比较复杂,一下子肯定看不懂,后面可以慢慢理解,这个内容很有用的==
<WMS_Capabilities xmlns="http://www.opengis.net/wms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:esri_wms="http://www.esri.com/wms" version="1.3.0" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.esri.com/wms http://localhost:6080/arcgis/services/tttt/tt/MapServer/WmsServer?version=1.3.0%26service=WMS%26request=GetSchemaExtension">
<Service>
<Name>
<![CDATA[ WMS ]]>
</Name>
<Title>
<![CDATA[ tttt_tt ]]>
</Title>
<Abstract>WMS</Abstract>
<KeywordList>
<Keyword>
<![CDATA[ ]]>
</Keyword>
</KeywordList>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://localhost:6080/arcgis/services/tttt/tt/MapServer/WmsServer?"/>
<ContactInformation>
<ContactPersonPrimary>
<ContactPerson>
<![CDATA[ ]]>
</ContactPerson>
<ContactOrganization>
<![CDATA[ ]]>
</ContactOrganization>
</ContactPersonPrimary>
<ContactPosition>
<![CDATA[ ]]>
</ContactPosition>
<ContactAddress>
<AddressType>
<![CDATA[ ]]>
</AddressType>
<Address>
<![CDATA[ ]]>
</Address>
<City>
<![CDATA[ ]]>
</City>
<StateOrProvince>
<![CDATA[ ]]>
</StateOrProvince>
<PostCode>
<![CDATA[ ]]>
</PostCode>
<Country>
<![CDATA[ ]]>
</Country>
</ContactAddress>
<ContactVoiceTelephone>
<![CDATA[ ]]>
</ContactVoiceTelephone>
<ContactFacsimileTelephone>
<![CDATA[ ]]>
</ContactFacsimileTelephone>
<ContactElectronicMailAddress>
<![CDATA[ ]]>
</ContactElectronicMailAddress>
</ContactInformation>
<Fees>
<![CDATA[ ]]>
</Fees>
<AccessConstraints>
<![CDATA[ ]]>
</AccessConstraints>
<MaxWidth>4096</MaxWidth>
<MaxHeight>4096</MaxHeight>
</Service>
<Capability>
<Request>
<GetCapabilities>
<Format>application/vnd.ogc.wms_xml</Format>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://localhost:6080/arcgis/services/tttt/tt/MapServer/WmsServer?"/>
</Get>
</HTTP>
</DCPType>
</GetCapabilities>
<GetMap>
<Format>image/bmp</Format>
<Format>image/jpeg</Format>
<Format>image/tiff</Format>
<Format>image/png</Format>
<Format>image/png8</Format>
<Format>image/png24</Format>
<Format>image/png32</Format>
<Format>image/gif</Format>
<Format>image/svg+xml</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://localhost:6080/arcgis/services/tttt/tt/MapServer/WmsServer?"/>
</Get>
</HTTP>
</DCPType>
</GetMap>
<GetFeatureInfo>
<Format>application/vnd.esri.wms_raw_xml</Format>
<Format>application/vnd.esri.wms_featureinfo_xml</Format>
<Format>application/vnd.ogc.wms_xml</Format>
<Format>text/xml</Format>
<Format>text/html</Format>
<Format>text/plain</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://localhost:6080/arcgis/services/tttt/tt/MapServer/WmsServer?"/>
</Get>
</HTTP>
</DCPType>
</GetFeatureInfo>
<esri_wms:GetStyles>
<Format>application/vnd.ogc.sld+xml</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://localhost:6080/arcgis/services/tttt/tt/MapServer/WmsServer?"/>
</Get>
</HTTP>
</DCPType>
</esri_wms:GetStyles>
</Request>
<Exception>
<Format>application/vnd.ogc.se_xml</Format>
<Format>application/vnd.ogc.se_inimage</Format>
<Format>application/vnd.ogc.se_blank</Format>
<Format>text/xml</Format>
<Format>XML</Format>
</Exception>
<Layer>
<Title>
<![CDATA[ Layers ]]>
</Title>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:32650</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>72.000005</westBoundLongitude>
<eastBoundLongitude>136.586229</eastBoundLongitude>
<southBoundLatitude>5.321307</southBoundLatitude>
<northBoundLatitude>53.732456</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="72.000005" miny="5.321307" maxx="136.586229" maxy="53.732456"/>
<BoundingBox CRS="EPSG:4326" minx="5.321307" miny="72.000005" maxx="53.732456" maxy="136.586229"/>
<BoundingBox CRS="EPSG:32650" minx="-3349539.763368" miny="699938.732971" maxx="1835172.302520" maxy="5953755.302927"/>
<Layer queryable="1">
<Name>0</Name>
<Title>
<![CDATA[ utm_wgs84 ]]>
</Title>
<Abstract>
<![CDATA[ utm_wgs84 ]]>
</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:32650</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>72.000005</westBoundLongitude>
<eastBoundLongitude>136.586229</eastBoundLongitude>
<southBoundLatitude>5.321307</southBoundLatitude>
<northBoundLatitude>53.732456</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="72.000005" miny="5.321307" maxx="136.586229" maxy="53.732456"/>
<BoundingBox CRS="EPSG:4326" minx="5.321307" miny="72.000005" maxx="53.732456" maxy="136.586229"/>
<BoundingBox CRS="EPSG:32650" minx="-3349539.763368" miny="699938.732971" maxx="1835172.302520" maxy="5953755.302927"/>
<Style>
<Name>default</Name>
<Title>0</Title>
<LegendURL width="16" height="16">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost:6080/arcgis/services/tttt/tt/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=0" xlink:type="simple"/>
</LegendURL>
</Style>
</Layer>
</Layer>
</Capability>
</WMS_Capabilities>
3.2GetMap(获取地图)
The GetMap operation requests that the server generate a map. The core parameters specify one or more layers and styles to appear on the map, a bounding box for the map extent, a target spatial reference system, and a width, height, and format for the output.
The information needed to specify values for parameters such as layers, styles and srs can
be obtained from the Capabilities document.
The response is a map image, or other map output artifact, depending on the format requested. GeoServer provides a wide variety of output formats, described in WMS
output formats.
The standard parameters for the GetMap operation are:
Parameter | Required? | Description |
service | Yes | Service name. Value is WMS. |
version | Yes | Service version. Value is one of 1.0.0, 1.1.0, 1.1.1, 1.3. |
request | Yes | Operation name. Value is GetMap. |
layers | Yes | Layers to display on map. Value is a comma-separated list of layer names. |
styles | Yes | Styles in which layers are to be rendered. Value is a comma-separated list of style names, or empty if default styling is required. Style names may be empty in the list, to use default layer styling. |
srs or crs | Yes | Spatial Reference System for map output. Value is in form EPSG:nnn.crs is the parameter key used in WMS 1.3.0. |
bbox | Yes | Bounding box for map extent. Value is minx,miny,maxx,maxy in units of the SRS. |
width | Yes | Width of map output, in pixels. |
height | Yes | Height of map output, in pixels. |
format | Yes | Format for the map output. See WMS output formats for supported values. |
transparent | No | Whether the map background should be transparent. Values are trueor false. Default is false |
bgcolor | No | Background color for the map image. Value is in the form RRGGBB. Default is FFFFFF (white). |
exceptions | No | Format in which to report exceptions. Default value is application/vnd.ogc.se_xml. |
time | No | Time value or range for map data. See Time Support in GeoServer WMS for more information. |
sld | No | A URL referencing a StyledLayerDescriptor XML file which controls or enhances map layers and styling |
sld_body | No | A URL-encoded StyledLayerDescriptor XML document which controls or enhances map layers and styling |
请求方式:http://localhost:6080/arcgis/services/tttt/tt/MapServer/WMSServer?version=1.3.0&request=getmap&layers=0&styles=default&crs=4326&bbox=110,35,120,45&width=300&height=300&format=image/png
3.3GetFeatureInfo(根据地图上的像素点获取更详细的要素信息,类似Identify功能)
3.3.1基本介绍
The GetFeatureInfo operation requests the spatial and attribute data for the features at a given location on a map. It is similar to the WFS GetFeature operation,
but less flexible in both input and output. Since GeoServer provides a WFS service we recommend using it instead of GetFeatureInfo whenever
possible.
The one advantage of GetFeatureInfo is
that the request uses an (x,y) pixel value from a returned WMS image. This is easier to use for a naive client that is not able to perform true geographic referencing.
The standard parameters for the GetFeatureInfo operation are:
Parameter | Required? | Description |
service | Yes | Service name. Value is WMS. |
version | Yes | Service version. Value is one of 1.0.0, 1.1.0, 1.1.1, 1.3. |
request | Yes | Operation name. Value is GetFeatureInfo. |
layers | Yes | See GetMap |
styles | Yes | See GetMap |
srs or crs | Yes | See GetMap |
bbox | Yes | See GetMap |
width | Yes | See GetMap |
height | Yes | See GetMap |
query_layers | Yes | Comma-separated list of one or more layers to query. |
info_format | No | Format for the feature information response. See below for values. |
feature_count | No | Maximum number of features to return. Default is 1. |
x or i | Yes | X ordinate of query point on map, in pixels. 0 is left side. i is the parameter key used in WMS 1.3.0. |
y or j | Yes | Y ordinate of query point on map, in pixels. 0 is the top. j is the parameter key used in WMS 1.3.0. |
exceptions | No | Format in which to report exceptions. The default value is application/vnd.ogc.se_xml. |
3.3.2举例介绍
请求方式:http://localhost:6080/arcgis/services/tttt/tt/MapServer/WMSServer?VERSION=1.3.0&REQUEST=GetFeatureInfo&QUERY_LAYERS=0&BBOX=110,35,120,45&crs=4326&INFO_FORMAT=text/html&I=200&J=100&WIDTH=256&HEIGHT=256
这里需要注意的参数QUERY_LAYERS请求的图层,BBOX图片的范围,INFO_FORMAT返回数据格式,I图片的像素横坐标,J图片像素纵坐标,width与height同getmap函数一样。同理这里的参数都可以在GetCapabilities中查找到奥==
还有一点要注意的是version版本问题要注意对上,网上很多资料由于版本不一致导致不能使用,并不是写错了==
请求结果:
四、总结
- 学习WMS迫在眉睫;
- arcgis server发布WMS服务;
- WMS中的三种操作方法介绍与举例;
转载自:https://blog.csdn.net/xcymorningsun/article/details/60575543