0

I'm developing an application using OpenLayers-3.8.2 and geoserver-2.7.2. I defined a wfs layer as follow:

var url = "http://localhost:8084/geoserver/wfs?&service=WFS&" +
           "version=1.1.0&request=GetFeature&typeName=Calk:Point&" + 
           "outputFormate=application/json";

var format = new ol.format.WFS();
source = new ol.source.Vector({
    url: 'proxy.cgi?url=' + encodeURIComponent(u),
    format: format
});

layer = new ol.layer.Vector({
    title: 'Iran bound',
    source: source
});
map.addLayer(layer);

The above code makes a WFS version 1.1.0 request. With this version it works fine, but when I change it to 1.0.0 or 2.0.0 it does not work. Server response for various versions are as follows:

Version: 1.0.0:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" 
                xmlns:wfs="http://www.opengis.net/wfs" xmlns:Calk="http://itsme.calk.ir" 
                xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:schemaLocation="http://www.opengis.net/wfs http://localhost:8084/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd 
                http://itsme.calk.ir http://localhost:8084/geoserver/wfs?service=WFS&amp;version=1.0.0&amp;request=DescribeFeatureType&amp;typeName=Calk%3APoint">
    <gml:boundedBy>
        <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
            <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">27.195,28.9653 53.4167,60.8482</gml:coordinates>
        </gml:Box>
    </gml:boundedBy>
    <gml:featureMember>
        <Calk:Point fid="Point.1">
            <gml:boundedBy>
                <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
                    <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">28.4101,41.5723 28.4101,41.5723</gml:coordinates>
                </gml:Box>
            </gml:boundedBy>
            <Calk:the_geom>
                <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
                    <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">28.4101,41.5723</gml:coordinates>
                </gml:Point>
            </Calk:the_geom>
            <Calk:AREA>0.0</Calk:AREA>
            <Calk:PERIMETER>0.0</Calk:PERIMETER>
            <Calk:IR_CEN_>1</Calk:IR_CEN_>
            <Calk:IR_CEN_ID>9</Calk:IR_CEN_ID>
            <Calk:X_COORD>45.08176</Calk:X_COORD>
            <Calk:Y_COORD>37.57299</Calk:Y_COORD>
            <Calk:NAME>ORUMIEH-iran</Calk:NAME>
        </Calk:Point>
    </gml:featureMember>
    ...
</wfs:FeatureCollection>

Version 1.1.0:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:Calk="http://itsme.calk.ir" 
                       xmlns:world="http://itsme.world.ir" xmlns:wfs="http://www.opengis.net/wfs" 
                       xmlns:gml="http://www.opengis.net/gml" xmlns:iran="http://itsme.iran.ir" 
                       xmlns:ogc="http://www.opengis.net/ogc" xmlns:ows="http://www.opengis.net/ows" 
                       xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                       numberOfFeatures="25" timeStamp="2015-08-08T12:02:52.752Z" 
                       xsi:schemaLocation="http://www.opengis.net/wfs 
                        http://localhost:8084/geoserver/schemas/wfs/1.1.0/wfs.xsd 
                        http://itsme.calk.ir http://localhost:8084/geoserver/wfs?service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;typeName=Calk%3APoint">
    <gml:boundedBy>
        <gml:Envelope srsDimension="2" srsName="urn:x-ogc:def:crs:EPSG:4326">
            <gml:lowerCorner>28.96533966064453 27.195</gml:lowerCorner>
            <gml:upperCorner>60.8482 53.41667175292969</gml:upperCorner>
        </gml:Envelope>
    </gml:boundedBy>
    <gml:featureMembers>
        <Calk:Point gml:id="Point.1">
            <gml:boundedBy>
                <gml:Envelope srsName="urn:x-ogc:def:crs:EPSG:4326" srsDimension="2">
                    <gml:lowerCorner>41.5723 28.4101</gml:lowerCorner>
                    <gml:upperCorner>41.5723 28.4101</gml:upperCorner>
                </gml:Envelope>
            </gml:boundedBy>
            <Calk:the_geom>
                <gml:Point srsName="urn:x-ogc:def:crs:EPSG:4326" srsDimension="2">
                    <gml:pos>41.5723 28.4101</gml:pos>
                </gml:Point>
            </Calk:the_geom>
            <Calk:AREA>0.0</Calk:AREA>
            <Calk:PERIMETER>0.0</Calk:PERIMETER>
            <Calk:IR_CEN_>1</Calk:IR_CEN_>
            <Calk:IR_CEN_ID>9</Calk:IR_CEN_ID>
            <Calk:X_COORD>45.08176</Calk:X_COORD>
            <Calk:Y_COORD>37.57299</Calk:Y_COORD>
            <Calk:NAME>ORUMIEH-iran</Calk:NAME>
        </Calk:Point>
        ...
    </gml:featureMembers>
</wfs:FeatureCollection>

Version 2.0.0:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:Calk="http://itsme.calk.ir" xmlns:wfs="http://www.opengis.net/wfs/2.0" 
    xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    numberMatched="25" numberReturned="25" timeStamp="2015-08-08T12:03:28.744Z" 
    xsi:schemaLocation="http://www.opengis.net/wfs/2.0 
        http://localhost:8084/geoserver/schemas/wfs/2.0/wfs.xsd 
        http://itsme.calk.ir http://localhost:8084/geoserver/wfs?service=WFS&amp;version=2.0.0&amp;request=DescribeFeatureType&amp;typeName=Calk%3APoint 
        http://www.opengis.net/gml/3.2 http://localhost:8084/geoserver/schemas/gml/3.2.1/gml.xsd">
    <wfs:boundedBy>
        <gml:Envelope>
            <gml:lowerCorner>28.96533966064453 27.195</gml:lowerCorner>
            <gml:upperCorner>60.8482 53.41667175292969</gml:upperCorner>
        </gml:Envelope>
    </wfs:boundedBy>
    <wfs:member>
        <Calk:Point gml:id="Point.1">
            <gml:boundedBy>
                <gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326" srsDimension="2">
                    <gml:lowerCorner>41.572266 28.410145</gml:lowerCorner>
                    <gml:upperCorner>41.572266 28.410145</gml:upperCorner>
                </gml:Envelope>
            </gml:boundedBy>
            <Calk:the_geom>
                <gml:Point srsName="urn:ogc:def:crs:EPSG::4326" srsDimension="2">
                    <gml:pos>41.572266 28.410145</gml:pos>
                </gml:Point>
            </Calk:the_geom>
            <Calk:AREA>0.0</Calk:AREA>
            <Calk:PERIMETER>0.0</Calk:PERIMETER>
            <Calk:IR_CEN_>1</Calk:IR_CEN_>
            <Calk:IR_CEN_ID>9</Calk:IR_CEN_ID>
            <Calk:X_COORD>45.08176</Calk:X_COORD>
            <Calk:Y_COORD>37.57299</Calk:Y_COORD>
            <Calk:NAME>ORUMIEH-iran</Calk:NAME>
        </Calk:Point>
        ...
    </wfs:member>
</wfs:FeatureCollection>

Where is the problem?

Is it OpenLayers bug?

How do I fix it?

A another thing is that when I use wfs in version 1.1.0 and I modify some features, I save layer according to this tutorial, And in geoserver the points coordinates are displaced (mypoint.x in client side save as y in server side and vice versa). But when I create a new feature, It save correctly. It's astounding and I'm confused. What do I do?

  • It seems you get a good response each time what is your question? – Ian Turton Aug 8 '15 at 15:25
  • But in version 1.0.0 and 2.0.0 does not show anything. – Morteza Malvandi Aug 8 '15 at 17:30
  • note you have spelt "outputFormate=application/json"; wrong which is why you get GML back – Ian Turton Aug 9 '15 at 11:21
  • Not because it is not – Morteza Malvandi Aug 9 '15 at 11:27
  • You can use WFS 1.0.0 by defining a GML2 parser in the ol.format.WFS instance. var format = new ol.format.WFS({gmlFormat: new ol.format.GML2()}); You can't use WFS 2.0.0 though. – Gabor Farkas Aug 9 '15 at 14:15
2

OL3.8.2 only supports WFS 1.1.0. See docs:

ol.format.WFS Feature format for reading and writing data in the WFS format. By default, supports WFS version 1.1.0. You can pass a GML format as option if you want to read a WFS that contains GML2 (WFS 1.0.0). Also see ol.format.GMLBase which is used by this format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.