WMS
WMS 介绍
WMS(Web Map Service) 是一种动态绘制地图的网络服务标准,由开放地理空间联盟(Open Geospatial Consortium,OGC)制定。
WMS 主要定义了三种操作:
- GetCapabilities - 获取服务的元数据
- GetMap - 获取地图图像
- GetFeatureInfo - 请求关于地图要素的信息(可选)
作为基本 WMS 服务,必须至少支持 GetCapabilities 和 GetMap 操作;如果作为可查询 WMS,则需要支持可选的 GetFeaturelnfo 操作。对于样式化图层描述符 WMS 服务,还有两种可选的操作,一个是请求图例符号操作,即 GetLegendGraphic;第二个是请求用户定义的样式 操作,即 GetStyles。
WMS 获取地图图像的工作原理:
- 客户端请求:客户端(例如 Web 浏览器或 GIS 软件)向 WMS 服务器发送一个请求,这个请求包含了生成地图所需的参数,如地图的坐标范围、图层、样式、比例尺和输出格式等。
- 服务端处理:WMS 服务器根据请求参数,处理地图数据,生成一幅地图图像。
- 返回地图图像:服务器将生成的地图图像以图片格式(如 PNG, JPEG 等)返回给客户端。
WMS 规范文献: 了解规范的细节
GetCapabilites 介绍
GetCapabilities 操作返回服务的能力文档,以了解服务器提供的服务详情,例如支持哪些图层、样式、坐标系统和输出格式等。
以 GeoServer 的 wms 为例 http://localhost:8090/geoserver/tiger/wms?request=GetCapabilities
由于内容很多,这里只显示部分关键内容
<WMS_Capabilities version="1.3.0" updateSequence="294" xmlns="http://www.opengis.net/wms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wms http://localhost:8090/geoserver/schemas/wms/1.3.0/capabilities_1_3_0.xsd">
<Service>
<Name>WMS</Name>
<Title>GeoServer Web Map Service</Title>
<Abstract>A compliant implementation of WMS plus most of the SLD extension (dynamic styling). Can also generate PDF, SVG, KML, GeoRSS</Abstract>
<KeywordList>
<Keyword>WMS</Keyword>
<Keyword>GEOSERVER</Keyword>
</KeywordList>
<OnlineResource xlink:type="simple" xlink:href="http://geoserver.org"/>
</Service>
<Capability>
<Request>
<GetCapabilities>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xlink:href="http://localhost:8090/geoserver/tiger/ows?SERVICE=WMS&"/>
</Get>
<Post>
<OnlineResource xlink:type="simple" xlink:href="http://localhost:8090/geoserver/tiger/ows?SERVICE=WMS&"/>
</Post>
</HTTP>
</DCPType>
</GetCapabilities>
<GetMap>
<Format>image/png</Format>
<Format>application/atom+xml</Format>
<Format>application/json;type=utfgrid</Format>
<Format>application/pdf</Format>
<Format>application/rss+xml</Format>
<Format>application/vnd.google-earth.kml+xml</Format>
<Format>application/vnd.google-earth.kml+xml;mode=networklink</Format>
<Format>application/vnd.google-earth.kmz</Format>
<Format>image/geotiff</Format>
<Format>image/geotiff8</Format>
<Format>image/gif</Format>
<Format>image/jpeg</Format>
<Format>image/png; mode=8bit</Format>
<Format>image/svg+xml</Format>
<Format>image/tiff</Format>
<Format>image/tiff8</Format>
<Format>image/vnd.jpeg-png</Format>
<Format>image/vnd.jpeg-png8</Format>
<Format>text/html; subtype=openlayers</Format>
<Format>text/html; subtype=openlayers2</Format>
<Format>text/html; subtype=openlayers3</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xlink:href="http://localhost:8090/geoserver/tiger/ows?SERVICE=WMS&"/>
</Get>
</HTTP>
</DCPType>
</GetMap>
<GetFeatureInfo>
<Format>text/plain</Format>
<Format>application/vnd.ogc.gml</Format>
<Format>text/xml</Format>
<Format>application/vnd.ogc.gml/3.1.1</Format>
<Format>text/xml; subtype=gml/3.1.1</Format>
<Format>text/html</Format>
<Format>application/json</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xlink:href="http://localhost:8090/geoserver/tiger/ows?SERVICE=WMS&"/>
</Get>
</HTTP>
</DCPType>
</GetFeatureInfo>
</Request>
<Layer>
<Title>GeoServer Web Map Service</Title>
<Abstract>A compliant implementation of WMS plus most of the SLD extension (dynamic styling). Can also generate PDF, SVG, KML, GeoRSS</Abstract>
<!--All supported EPSG projections:-->
<CRS>AUTO:42001</CRS>
<CRS>AUTO:42002</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-180.0</westBoundLongitude>
<eastBoundLongitude>180.0</eastBoundLongitude>
<southBoundLatitude>-90.0</southBoundLatitude>
<northBoundLatitude>90.0</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="-180.0" miny="-90.0" maxx="180.0" maxy="90.0"/>
<Layer queryable="1" opaque="0">
<Name>giant_polygon</Name>
<Title>World rectangle</Title>
<Abstract>A simple rectangular polygon covering most of the world, it's only used for the purpose of providing a background (WMS bgcolor could be used instead)</Abstract>
<KeywordList>
<Keyword>DS_giant_polygon</Keyword>
<Keyword>giant_polygon</Keyword>
</KeywordList>
<CRS>EPSG:4326</CRS>
<CRS>CRS:84</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-180.0</westBoundLongitude>
<eastBoundLongitude>180.0</eastBoundLongitude>
<southBoundLatitude>-90.0</southBoundLatitude>
<northBoundLatitude>90.0</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="-180.0" miny="-90.0" maxx="180.0" maxy="90.0"/>
<BoundingBox CRS="EPSG:4326" minx="-90.0" miny="-180.0" maxx="90.0" maxy="180.0"/>
<Style>
<Name>giant_polygon</Name>
<Title>Border-less gray fill</Title>
<Abstract>Light gray polygon fill without a border</Abstract>
<LegendURL width="20" height="20">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://localhost:8090/geoserver/tiger/ows?service=WMS&version=1.3.0&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=giant_polygon"/>
</LegendURL>
</Style>
</Layer>
</Layer>
</Capability>
</WMS_Capabilities>
其中 <Service></Service> 描述了该服务的名称、关键词以及联系信息、线上地址等基本信息。
<Capability></Capability> 描述了服务支持的操作以及包含的图层。其中<Request></Request> 之间描述了支持的操作,可以看到这里支持 GetCapabilities、GetMap、GetFeatureInfo。
<Layer></Layer>之间罗列了该服务所包含的所有图层数据。
GetMap
GetMap 获取地图图像,
必填参数列表:
| 参数名 | 示例 | 是否必填 | 描述 |
|---|---|---|---|
| VERSION | 1.3.0 | 是 | 版本 |
| REQUEST | GetMap | 是 | 执行 getMap 操作 |
| LAYERS | layername | 是 | 一个或多个图层,使用,分割 |
| STYLES | 是 | 一个或多个样式,使用,分割,可传'' | |
| CRS | EPSG:4326 | 是 | 坐标系统 |
| BBOX | 是 | minx,miny,maxx,maxy | |
| WIDTH | 120 | 是 | 输出宽度 |
| HEIGHT | 120 | 是 | 输出高度 |
可选参数 参考 规范文献的 7.3
GetFeatureInfo
请求地图要素信息
必填参数列表:
| 参数名 | 示例 | 是否必填 | 描述 |
|---|---|---|---|
| VERSION | 1.3.0 | 是 | 版本 |
| REQUEST | GetFeatureInfo | 是 | 执行 GetFeatureInfo 操作 |
| QUERY_LAYERS | layer_list | 是 | 待查询的图层列表,多个使用,分割 |
| INFO_FORMAT | output_format | 是 | 要素信息的返回格式 |
| I | pixel_column | 是 | X 坐标 |
| J | pixcel_row | 是 | Y 坐标 |
| <map_request_copy> | ... | 是 | GetMap 请求参数 |