2014年3月31日月曜日

40 - TinyOWS 4 - TinyOWS と OpenLayers を使った WFS-T

40-4 TinyOWS と OpenLayers を使った WFS-T「Sample: WFS-T with TinyOWS and OpenLayers(http://mapserver.org/trunk/tinyows/openlayershowto.html)」
ここでは、「35 - WFS-T(WFS Transaction) 4 - Point, Line, Polygon レイヤを設定」で使った「ol016-nippon_bmi_akiruno_pgis.html」を修正して TinyOWS で WFS-T を試してみます。GeoServer のレイヤは MapServer に修正します。
最初に、tinyOWS を作成します。

user@debian7-vmw:~$ cd tinyows-1.1.0/demo
user@debian7-vmw:~/tinyows-1.1.0/demo$ ls
ABOUT       france.shp  install.sh     tinyows.xml     world.dbf  world.shx
france.dbf  france.shx  install.sh.in  tinyows.xml.in  world.shp
user@debian7-vmw:~/tinyows-1.1.0/demo$ cp tinyows.xml tinyows.xml_org
user@debian7-vmw:~/tinyows-1.1.0/demo$ vim tinyows.xml
<tinyows online_resource="http://127.0.0.1/cgi-bin/tinyows"
         schema_dir="/usr/local/share/tinyows/schema/">

  <pg host="127.0.0.1" user="user" password="password" dbname="nippon_bmi" port="5432" />

  <metadata name="TinyOWS Server"
            title="TinyOWS Server - Akiruno Service" />


  <contact name="Akiruno Server"
         site="http://www.debian7-vmw/"
         email="user@debian7-vmw" />

  <layer retrievable="1"
         writable="1"
         ns_prefix="npn"
         ns_uri="http://www.myhome.net/"
         name="akiruno_point"
         title="Akiruno Point" />

  <layer retrievable="1"
         writable="1"
         ns_prefix="npn"
         ns_uri="http://www.myhome.net/"
         name="akiruno_line"
         title="Akiruno Line" />

  <layer retrievable="1"
         writable="1"
         ns_prefix="npn"
         ns_uri="http://www.myhome.net/"
         name="akiruno_polygon"
         title="Akiruno Polygon" />

</tinyows>

user@debian7-vmw:~/tinyows-1.1.0/demo$ su
パスワード:
root@debian7-vmw:/home/user/tinyows-1.1.0/demo# cp tinyows.xml /etc
root@debian7-vmw:/home/user/tinyows-1.1.0/demo#
root@debian7-vmw:/home/user/tinyows-1.1.0/demo# exit
exit
user@debian7-vmw:~/tinyows-1.1.0/demo$ cd ../
user@debian7-vmw:~/tinyows-1.1.0$ ./tinyows --check
TinyOWS version:   1.1.0
FCGI support:      No
Config File Path:  /etc/tinyows.xml (TinyOWS XML)
PostGIS Version:   1.5.3
PostGIS dsn:       host=127.0.0.1 user=user password=password dbname=nippon_bmi port=5432 
Output Encoding:   UTF-8
Database Encoding: UTF8
Schema dir:        /usr/local/share/tinyows/schema/
Display bbox:      Yes
Estimated extent:  No
Check schema:      Yes
Check valid geoms: Yes
Available layers:
 - public.akiruno_point (2451) -> npn:akiruno_point [RW]
 - public.akiruno_line (2451) -> npn:akiruno_line [RW]
 - public.akiruno_polygon (2451) -> npn:akiruno_polygon [RW]

「ol020-nippon_bmi_akiruno_pgis.html」
---
<title>WMS Example BMI Akiruno PGIS2 TinyOWS</title>
---
  akirunoPoint = new OpenLayers.Layer.Vector("Akiruno Point", {
   strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy[0]],
   projection: new OpenLayers.Projection("EPSG:2451"),
   protocol: new OpenLayers.Protocol.WFS({
    version: "1.0.0",
    srsName: "EPSG:2451",
    url: "http://127.0.0.1/cgi-bin/tinyows",
    featureNS :  "http://www.myhome.net/",
    featureType: "akiruno_point",
    geometryName: "the_geom",
    schema: "http://127.0.0.1/cgi-bin/tinyows?request=DescribeFeatureType&service=wfs&version=1.0.0&typename=npn:akiruno_point"
    })
   });
  akirunoLine = new OpenLayers.Layer.Vector("Akiruno Line", {
   strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy[1]],
   projection: new OpenLayers.Projection("EPSG:2451"),
   protocol: new OpenLayers.Protocol.WFS({
    version: "1.0.0",
    srsName: "EPSG:2451",
    url: "http://127.0.0.1/cgi-bin/tinyows",
    featureNS :  "http://www.myhome.net/",
    featureType: "akiruno_line",
    geometryName: "the_geom",
    schema: "http://127.0.0.1/cgi-bin/tinyows?request=DescribeFeatureType&service=wfs&version=1.0.0&typename=npn:akiruno_line"
    })
   });
  akirunoPolygon = new OpenLayers.Layer.Vector("Akiruno Polygon", {
   strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy[2]],
   projection: new OpenLayers.Projection("EPSG:2451"),
   protocol: new OpenLayers.Protocol.WFS({
    version: "1.0.0",
    srsName: "EPSG:2451",
    url: "http://127.0.0.1/cgi-bin/tinyows",
    featureNS :  "http://www.myhome.net/",
    featureType: "akiruno_polygon",
    geometryName: "the_geom",
    schema: "http://127.0.0.1/cgi-bin/tinyows?request=DescribeFeatureType&service=wfs&version=1.0.0&typename=npn:akiruno_polygon"
    })
   });
---


「version=1.0.0」にします。
「version=1.1.0」にすると、フィーチャが表示できなくなりました。Firbug の「コンソール」->「All」の「POST」のメッセージに

<?xml version='1.0' encoding='UTF-8'?>
<ows:ExceptionReport
 xmlns='http://www.opengis.net/ows'
 xmlns:ows='http://www.opengis.net/ows'
 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
 xsi:schemaLocation='http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsExceptionReport.xsd'
 version='1.1.0' language='en'>
 <ows:Exception exceptionCode='InvalidParameterValue' locator='request'>
  <ows:ExceptionText>XML request isn't valid</ows:ExceptionText>
 </ows:Exception>
</ows:ExceptionReport>

と表示されました。これは、理由はわかりませんが、GML3 がサポートされないためだとおもわれます。
参考:「Working Around the LibXML2 XSD Schema GML Bug(http://mapserver.org/tinyows/libxmlschemagmlbug.html)」

0 件のコメント: