[mapserver-users] [TinyOWS] Inserting feature and XML schema validation

Тимур Галиаскарович Суфиев t.sufiev at acti.ru
Wed Nov 7 08:13:10 PST 2012


Hi!

This isn't the first question here about inserting features in TinyOWS, but I haven't found solution to my problem in archives.

The working environment is OpenLayers 2.13dev + TinyOWS from github + PostGIS 2.0 + PostgreSQL 9.2

Relevant js-code is:

    var POINT = 1;
    var save_objs_strategy = new OpenLayers.Strategy.Save(
    { "saves_what": "cities" });
    var cities = new OpenLayers.Layer.Vector(
    'Города', {
        strategies: [new OpenLayers.Strategy.BBOX(), 
             save_objs_strategy],
        protocol: new OpenLayers.Protocol.WFS(
        {
            version: "1.1.0",
            url: "http://localhost/mapserver/tinyows",
            featureType: "cities",
            featureNS: "http://www.tinyows.org",
            geometryName: "geom",
            outputFormat: "JSON",
            schema: "http://localhost/mapserver/tinyows?service=wfs&request=DescribeFeatureType&version=1.1.0&typename=tows:cities"
        })
    }
    );

    var draw = new OpenLayers.Control.DrawFeature(
    cities, OpenLayers.Handler.Point,
    {
            title: "Создание объектов",
            displayClass: "olControlDrawFeaturePoint"
    }
    );
    draw.events.on(
    {
        "featureadded": function(e) {
        var attrs = e.feature.attributes;
        attrs.pop_hk = 99;
        attrs.city_name = "Новый город";
        attrs.type_id = POINT;
        save_objs_strategy.save();
        }
    });

Adding a vector point feature (city) somewhere on the map creates the following XML request to tinyows:



<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs   http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.tinyows.org   http://localhost/mapserver/tinyows?service=wfs&request=DescribeFeatureType&version=1.1.0&typename=tows:cities" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


<wfs:Insert>


<feature:cities xmlns:feature="http://www.tinyows.org">


<feature:geom>


<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">


<gml:pos>37.962548828124 55.22265625</gml:pos>
</gml:Point>
</feature:geom>

<feature:pop_hk>99</feature:pop_hk>

<feature:city_name>Новый город</feature:city_name>

<feature:type_id>1</feature:type_id>
</feature:cities>
</wfs:Insert>
</wfs:Transaction>
The request fails with the following string in tinyows.log:

[Wed Nov  7 19:55:01 2012] [ERROR] Element '{http://www.tinyows.org}cities': This element is not expected. Expected is one of ( {http://www.opengis.net/gml}_Feature, {http://www.opengis.net/gml}FeatureCollection, {http://www.opengis.net/gml}MultiPointCoverage, {http://www.opengis.net/gml}MultiCurveCoverage, {http://www.opengis.net/gml}MultiSurfaceCoverage, {http://www.opengis.net/gml}MultiSolidCoverage, {http://www.opengis.net/gml}GridCoverage, {http://www.opengis.net/gml}RectifiedGridCoverage, {http://www.opengis.net/gml}Observation, {http://www.opengis.net/gml}DirectedObservation ).

This seems a little bit cryptic to me because the "schema" parameter in js-code (http://localhost/mapserver/tinyows?service=wfs&request=DescribeFeatureType&version=1.1.0&typename=tows:cities) returns the following xsd:

<xs:schema targetNamespace="http://www.tinyows.org/" elementFormDefault="qualified" version="1.1"><xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/><xs:element name="cities" type="tows:citiesType" substitutionGroup="gml:_Feature"/><xs:complexType name="citiesType"><xs:complexContent><xs:extension base="gml:AbstractFeatureType"><xs:sequence><xs:element name="pop_hk" type="int" nillable="true" minOccurs="0" maxOccurs="1"/><xs:element name="city_name" nillable="false" minOccurs="1" maxOccurs="1"><xs:simpleType><xs:restriction base="string"><xs:maxLength value="100"/></xs:restriction></xs:simpleType></xs:element><xs:element name="geom" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/><xs:element name="type_id" type="int" nillable="true" minOccurs="0" maxOccurs="1"/></xs:sequence></xs:extension></xs:complexContent></xs:complexType></xs:schema>

and this xsd should make tinyows use element '{http://www.tinyows.org}cities' like '{http://www.opengis.net/gml}_Feature'

Where am I wrong and what should be changed in my setup?

Best regards,
Timur Sufiev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20121107/92bf9ddc/attachment.htm>


More information about the MapServer-users mailing list