2010年1月9日土曜日

OpenLayers 48a Filter Encoding1 - MapServer WFS Filter Encoding

MapServer の WFS Filter Encoding で使い方を試してみます。

MapServer の WFS Filter Encoding サイト
http://www.mapserver.org/ogc/filter_encoding.html

の Test を参考に WFS GetFeature を試します。
tokyo_pf_pgis.map の thirdsec レイヤの WFS データを OpenLayers41(SLD) で取得しました。

thirdsec.gml の内容

<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc"
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://mapserver.gis.umn.edu/mapserver http://192.168.1.6/cgi-bin/mapserv?map=/home/user/mapfile/tokyo_pf_pgis.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=thirdsec&OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:2456">
<gml:coordinates>139.403490,35.441650 140.038010,35.993800</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:thirdsec fid="thirdsec.819">
<gml:boundedBy>
<gml:Box srsName="EPSG:2456">
<gml:coordinates>139.641750,35.446240 139.643700,35.447350</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:LineString srsName="EPSG:2456">
<gml:coordinates>139.641750,35.447350 139.643700,35.446240 </gml:coordinates>
</gml:LineString>
</ms:msGeometry>
<ms:gid>819</ms:gid>
<ms:rac>12</ms:rac>
<ms:int>5</ms:int>
<ms:lin>みなとみらい21線</ms:lin>
<ms:opc>横浜高速鉄道</ms:opc>
</ms:thirdsec>
</gml:featureMember>
---


第3セクタ鉄道のうち、「ゆりかもめ」のデータだけを取得します。

wget -O thirdsec_yuri.gml "http://localhost/cgi-bin/mapserv?map=/home/user/mapfile/tokyo_pf_pgis.map&service=WFS&version=1.0.0&request=GetFeature&typename=thirdsec&Filter=<Filter><PropertyIsEqualTo><PropertyName>opc</PropertyName><Literal>ゆりかもめ</Literal></PropertyIsEqualTo></Filter>"

<Filter>: ルートエレメント
<PropertyIsEqualTo>: 条件に等しいデータを抽出
<PropertyName>: 参照エレメント
<Literal>: 抽出条件

詳しくは、
OpenGIS Filter Encoding
http://www.opengeospatial.org/standards/filter
の仕様書を参照してください。

thirdsec_yuri.gml の内容は「ゆりかもめ」の WFS データになります。

<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc"
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://mapserver.gis.umn.edu/mapserver http://192.168.1.6/cgi-bin/mapserv?map=/home/user/mapfile/tokyo_pf_pgis.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=thirdsec&OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>139.754930,35.616930 139.795830,35.666120</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:thirdsec fid="thirdsec.21673">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>139.773350,35.616930 139.779320,35.621290</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:LineString srsName="EPSG:4326">
<gml:coordinates>139.779320,35.617540 139.779250,35.617510 139.778280,35.617040 139.778150,35.616990 139.778010,35.616960 139.777830,35.616940 139.777660,35.616930 139.777480,35.616940 139.777320,35.616970 139.777200,35.616990 139.777030,35.617050 139.776890,35.617110 139.776720,35.617210 139.776610,35.617300 139.776500,35.617400 139.776350,35.617540 139.773380,35.621240 139.773350,35.621290 </gml:coordinates>
</gml:LineString>
</ms:msGeometry>
<ms:gid>21673</ms:gid>
<ms:rac>24</ms:rac>
<ms:int>5</ms:int>
<ms:lin>東京臨海新交通臨海線</ms:lin>
<ms:opc>ゆりかもめ</ms:opc>
</ms:thirdsec>
</gml:featureMember>
---

0 件のコメント: