GeoServer中WMS、WFS的请求规范

转自:http://www.cnblogs.com/naaoveGIS/

1.背景

1.1WMS简介

Web地图服务(WMS)利用具有地理空间位置信息的数据制作地图。其中将地图定义为地理数据可视的表现。这个规范定义了三个操作:GetCapabitities返回服务级元数据,它是对服务信息内容和要求参数的一种描述; GetMap返回一个地图影像,其地理空间参考和大小参数是明确定义了的;GetFeatureInfo(可选)返回显示在地图上的某些特殊要素的信息。

GeoServer官网上对其WMS规范的描述地址为http://docs.geoserver.org/stable/en/user/services/wms/index.html

1.2WFS简介

Web要素服务(WFS)返回的是要素级的GML编码,并提供对要素的增加、修改、删除等事务操作,是对Web地图服务的进一步深入。OGC Web要素服务允许客户端从多个Web要素服务中取得使用地理标记语言(GML)编码的地理空间数据,这个远东定义了五个操作:GetCapabilites返回Web要素服务性能描述文档(用XML描述);DescribeFeatureType返回描述可以提供服务的任何要素结构的XML文档;GetFeature为一个获取要素实例的请求提供服务;Transaction为事务请求提供服务;LockFeature处理在一个事务期间对一个或多个要素类型实例上锁的请求。

GeoServer官网上对其WFS规范的描述地址为http://docs.geoserver.org/stable/en/user/services/wfs/index.html

2.WMS请求规范详解

2.1GetCapabitities(返回服务级元数据)

URL例子:

http://localhost:8680/geoserver/wms?service=wms&version=1.1.1&request=GetCapabilities

参数意义:

image

返回结果:

其返回结果为一个描述性XML文档,包含了以下三个要素:

image

2.2GetMap(获取影像)

URL例子:

http://localhost:8680/geoserver/urbanlayer/wms?LAYERS=urbanlayer%3ADIJI&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A3857&BBOX=10008053.503544,5274522.8578226,10039584.01305,5292493.614536&WIDTH=579&HEIGHT=330

参数意义:

image

这里对返回的格式(format)有如下选择:

image

返回结果:

image

注意:此请求同样支持XML格式请求,如下:

image

2.3GetFeatureInfo(返回要素信息)

URL例子:

http://localhost:8680/geoserver/urbanlayer/wms?REQUEST=GetFeatureInfo&EXCEPTIONS=application%2Fvnd.ogc.se_xml&BBOX=10008053.503544%2C5274522.857823%2C10039584.01305%2C5292493.614536&SERVICE=WMS&INFO_FORMAT=text/plain&QUERY_LAYERS=urbanlayer%3ADIJI&FEATURE_COUNT=50&Layers=urbanlayer%3ADIJI&WIDTH=579&HEIGHT=330&format=image%2Fpng&styles=&srs=EPSG%3A3857&version=1.1.1&x=315&y=147

参数意义:

image

这里对返回的文本格式(info_format)有如下选择:

image

返回结果(忽略中文乱码):

image

3.WFS请求规范

3.1GetCapabilities(返回服务描述文档)

URL例子:

http://localhost:8680/geoserver/wfs?service=wfs&version=1.1.0&request=GetCapabilities

参数意义:

image

返回结果:

返回的结果为描述性XML,包含以下五个主要部分:

image

3.2DescribeFeatureType(返回图层描述信息)

URL例子:

http://localhost:8680/geoserver/urbanlayer/ows?service=wfs&version=1.0.0&request=DescribeFeatureType&typeName=DIJI

参数意义:

image

返回结果:

image

3.3GetFeature(获取图层要素)

3.3.1GET查询

这里首先给出一个例子:

image

http://localhost:8080/eGovaGISV14//home/gis/proxy.htm?http://192.168.101.14/geoserver/urbanlayer/wfs?request=GetFeature&version=1.1.0&typename=jianfudanhistory&Filter=%3CFilter%20xmlns:ogc=%22http://www.opengis.net/ogc%22%20xmlns:gml=%22http://www.opengis.net/gml%22%3E%3CIntersects%3E%20%3CPropertyName%3Ethe_geom%3C/PropertyName%3E%20%3Cgml:Envelope%20srsName=%22EPSG:4326%22%3E%09%20%3Cgml:lowerCorner%3E120.1762573834964%2030.280899047851562%3C/gml:lowerCorner%3E%20%09%20%3Cgml:upperCorner%3E120.18999029365265%2030.294631958007812%3C/gml:upperCorner%3E%20%3C/gml:Envelope%3E%3C/Intersects%3E%3C/Filter%3E&outputformat=json

此请求常见的参数有:typeNames,featureID,propertyName,Filter, count, sortBy。其中Filter参数最为重要,主要负责进行选择过滤。关于Filter的具体描述可参考:http://docs.geoserver.org/stable/en/user/filter/function.html

返回结果为:

{"type":"FeatureCollection","features":[{"type":"Feature","id":"jianfudan.322","geometry":{"type":"MultiPolygon","coordinates":[[[[30.276436000822056,120.20021],[30.275750000822033,120.20021],[30.22768400082126,120.22562],[30.245537000821543,120.17343000000001],[30.276436000822056,120.20021]]]]},"geometry_name":"the_geom","properties":{"limitid":71,"displayorder":null,"regionid":3,"validfromdate":"2016-05-15Z","validtodate":"2016-06-14Z","validflag":1,"media":null,"shape_length":null,"shape_area":null,"graphicid":322,"regionname":"江干区","eventtypes":null,"otherrequest":null,"limitname":"上报区域71"}},{"type":"Feature","id":"jianfudan.318","geometry":{"type":"MultiPolygon","coordinates":[[[[30.26407600082185,120.19668600000001],[30.26407600082185,120.196434],[30.262875000821833,120.20785],[30.24708200082157,120.203896],[30.255150000821704,120.187164],[30.26407600082185,120.19668600000001]]]]},"geometry_name":"the_geom","properties":{"limitid":72,"displayorder":null,"regionid":3,"validfromdate":"2016-05-04Z","validtodate":"2016-06-03Z","validflag":1,"media":"http://172.18.6.197:8081/MediaRoot/null/20160505/72/84989ee1-9bab-4640-8f24-4a7381f1c4e8/机票预订.png","shape_length":null,"shape_area":null,"graphicid":318,"regionname":"江干区","eventtypes":"乱搭乱建,暴露垃圾,积存垃圾渣土,路面不洁,河道不洁(含沟渠、湖面)","otherrequest":"测试","limitname":"上报区域72"}}],"crs":{"type":"EPSG","properties":{"code":"4490"}}}

3.3.1.1点查询Filter

<Filterxmlns:ogc="http://www.opengis.net/ogc"xmlns:gml="http://www.opengis.net/gml"><Intersects><PropertyName>the_geom</PropertyName><gml:EnvelopesrsName="EPSG:4326"><gml:lowerCorner>120.15336460382575 30.2743621901609</gml:lowerCorner><gml:upperCorner>120.167097513982 30.28809510031715</gml:upperCorner></gml:Envelope></Intersects></Filter>

3.3.1.2自定义多边形查询Filter

<Filterxmlns:ogc="http://www.opengis.net/ogc"xmlns:gml="http://www.opengis.net/gml"><Intersects><PropertyName>the_geom</PropertyName><gml:MultiPolygonsrsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinatesxmlns:gml="http://www.opengis.net/gml"decimal="."cs=","ts="">120.15677,30.2557 120.15677,30.26351 120.16833,30.26351 120.16833,30.2557 120.15677,30.2557</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></Intersects></Filter>

3.3.2Post查询

因为GET请求的数据量大小在4kb以内,所以Post为更常用的方法。以下为一个具体的例子:

image

其中直接发送的为一个XML文件,其Filter中可以填写的内容和GET中的Filter一样。

具体内容如下:

<?xml version='1.0' encoding='GBK'?><wfs:GetFeatureservice='WFS'version='1.0.0'outputFormat='JSON'xmlns:wfs='http://www.opengis.net/wfs'xmlns:ogc='http://www.opengis.net/ogc'xmlns:gml='http://www.opengis.net/gml'xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'xsi:schemaLocation='http://www.opengis.net/wfs [http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd](http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd)'><wfs:QuerytypeName='cell'><wfs:PropertyName>the_geom</wfs:PropertyName><wfs:PropertyName>test1</wfs:PropertyName><ogc:Filter><Or><PropertyIsEqualTo><PropertyName>test1</PropertyName><Literal>valuetest1</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>test2</PropertyName><Literal>valuetest2</Literal></PropertyIsEqualTo></Or></ogc:Filter></wfs:Query></wfs:GetFeature>

3.4 Transaction(编辑要素)

该方法支持对要素的增删改。这里直接给出Post请求中发送的XML组织格式:

3.4.1添加要素

<wfs:Transactionservice="WFS"version="1.0.0"outputFormat="GML2"xmlns:opengis="[http://www.cetusOpengis.com](http://www.cetusopengis.com/)"xmlns:wfs="[http://www.opengis.net/wfs](http://www.opengis.net/wfs)"xmlns:ogc="[http://www.opengis.net/ogc](http://www.opengis.net/ogc)"xmlns:gml="[http://www.opengis.net/gml](http://www.opengis.net/gml)"xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)"xsi:schemaLocation="[http://www.opengis.net/wfs](http://www.opengis.net/wfs)  [http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd](http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd)"><wfs:Inserthandle="someprj1"><opengis:someprj><opengis:the_geom><gml:PointsrsName="[http://www.opengis.net/gml/srs/epsg.xml#3395](http://www.opengis.net/gml/srs/epsg.xml#3395)"><gml:coordinatesdecimal="."cs=","ts="">13404701.212,3850391.781</gml:coordinates></gml:Point></opengis:the_geom><opengis:ssds>13</opengis:ssds><opengis:qqybh>12</opengis:qqybh><opengis:status>0</opengis:status></opengis:someprj></wfs:Insert></wfs:Transaction>

3.4.2修改要素

<wfs:Transactionservice="WFS"version="1.0.0"outputFormat="GML2"xmlns:opengis="[http://www.cetusOpengis.com](http://www.cetusopengis.com/)"xmlns:wfs="[http://www.opengis.net/wfs](http://www.opengis.net/wfs)"xmlns:ogc="[http://www.opengis.net/ogc](http://www.opengis.net/ogc)"xmlns:gml="[http://www.opengis.net/gml](http://www.opengis.net/gml)"xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)"xsi:schemaLocation="[http://www.opengis.net/wfs](http://www.opengis.net/wfs)  [http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd](http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd)"><wfs:UpdatetypeName="opengis:qqyproject"><wfs:Property><wfs:Name>qqybh</wfs:Name><wfs:Value>12</wfs:Value></wfs:Property><ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>qqybh</ogc:PropertyName><ogc:Literal>0</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter></wfs:Update></wfs:Transaction>

3.4.3删除要素

<wfs:Transactionservice="WFS"version="1.0.0"outputFormat="GML2"xmlns:opengis="[http://www.cetusOpengis.com](http://www.cetusopengis.com/)"xmlns:wfs="[http://www.opengis.net/wfs](http://www.opengis.net/wfs)"xmlns:ogc="[http://www.opengis.net/ogc](http://www.opengis.net/ogc)"xmlns:gml="[http://www.opengis.net/gml](http://www.opengis.net/gml)"xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)"xsi:schemaLocation="[http://www.opengis.net/wfs](http://www.opengis.net/wfs)  [http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd](http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd)"><wfs:DeletetypeName="opengis:qqyproject"><ogc:Filter><ogc:PropertyIsLessThan><ogc:PropertyName>qqybh</ogc:PropertyName><ogc:Literal>12</ogc:Literal></ogc:PropertyIsLessThan><ogc:PropertyIsGreaterThan><ogc:PropertyName>qqybh</ogc:PropertyName><ogc:Literal>0</ogc:Literal></ogc:PropertyIsGreaterThan></ogc:Filter></wfs:Delete></wfs:Transaction>

4.总结

a.动态出图可以使用WMS中的GetMap请求。

b.矢量查询可以使用WFS中的GetFeature请求。

c.要素编辑可以使用WFS中的Transaction请求。

作者:绒羊

链接:https://www.jianshu.com/p/43ec1e9830f3

来源:简书

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,667评论 5 472
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,361评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,700评论 0 333
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,027评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,988评论 5 361
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,230评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,705评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,366评论 0 255
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,496评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,405评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,453评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,126评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,725评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,803评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,015评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,514评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,111评论 2 341

推荐阅读更多精彩内容