1

I am trying to update feature information of wfs feature to geoserver using WFST in ol3. I am getting the below error in the response

<ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd">
 <ows:Exception exceptionCode="NoApplicableCode">
    <ows:ExceptionText>                               
  java.lang.RuntimeException: Parsing failed for pos: 
 java.lang.RuntimeException: Parsing failed for null: java.lang.NumberFormatException: For input string: "8682209.29541959,1159929.44262119"
 Parsing failed for pos: java.lang.RuntimeException: Parsing failed for null: java.lang.NumberFormatException: For input string: "8682209.29541959,1159929.44262119"
 Parsing failed for null: java.lang.NumberFormatException: For input string: "8682209.29541959,1159929.44262119"
 For input string: "8682209.29541959,1159929.44262119"</ows:ExceptionText>

The request is

<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
  <Update typeName="geowebmap_ws:tn_highways" xmlns:feature="http://localhost:8080/geoserver/web/geowebmap_ws">
    <Property>
      <Name>the_geom</Name>
      <Value>
        <Point xmlns="http://www.opengis.net/gml" srsName="EPSG:3857"> 
          <pos>8682209.29541959,1159929.44262119 undefined
          </pos>
        </Point>
      </Value>
    </Property>
    <Property>
      <Name>CATEGORY</Name>
        <Value>Automotive update test</Value>
    </Property>
    <Property>
      <Name>NAME</Name>
      <Value>Level crossing</Value>
    </Property>
    <Filter xmlns="http://www.opengis.net/ogc">
      <FeatureId fid="tn_poi.308"/>
    </Filter>
  </Update>
</Transaction>

I know there seems to some undefined null value in the request for pos but the object which i am sending to request doesnt has null value in it enter image description here

Where does this undefined value comes from below is my code

    var self.feat_att = $$hashKey: "object:722"
    geometry: Object
    coordinates: Array[2]
      0: 8682209.29541959
      1: 1159929.44262119
     length: 2
     type: "Point"
     geometry_name: "the_geom"
     id: "tn_poi.308"
     properties: Object
       CATEGORY: "Automotive update test"
       NAME: "Level crossing"
     type: "Feature"
for (var i in self.feat_att) {

            geomtype = self.feat_att[i].geometry.type;
            switch(geomtype) {
                case "Point":
                    geom = self.feat_att[i].geometry.coordinates;
                    feature =  new ol.geom.Point([geom]);
                    break;
                case "MultiPoint":
                     feature = new ol.geom.MultiPoint([geom]);
                     break;
                case "LineString":
                     feature = new ol.geom.LineString([geom]);
                     break;
                case "MultiLineString":
                     geom = self.feat_att[i].geometry.coordinates[0];
                     feature = new ol.geom.MultiLineString([geom]);
                     break;
                case "Polygon":
                     feature = new ol.geom.Polygon([geom]);
                     break;
                case "MultiPolygon":
                      geom = self.feat_att[i].geometry.coordinates;
                      feature = new ol.geom.MultiPolygon([geom]);
                      break;

            }
            var att_columns = self.feat_att[i].properties
            var featobj = {the_geom:feature}
            var attobj = $.extend(featobj, att_columns)
            var featurething = new ol.Feature(attobj)
            var featid = self.feat_att[i].id

            featurething.setId(featid)
            /*switch (p) {
                case 'update':
                    node =  formatWFS.writeTransaction(null, [featurething], null, formatGML);
                    break;
            }*/
            console.log(featurething);
            node =  formatWFS.writeTransaction(null, [featurething], null, formatGML);
            s =  new XMLSerializer();
            str = s.serializeToString(node);
            var feat_data=str.replace("feature:tn_poi",'geowebmap_ws:tn_highways');
            console.log(feat_data);
            $.ajax(base_URL+'geowebmap_ws/ows', {
                type: 'POST',
                dataType: 'xml',
                processData: false,
                contentType: 'text/xml',
                data: feat_data,
                error: function (xhr) {
                   var err = JSON.parse(xhr.responseText);
                   alert(err.message);
                }
            }).done();
0

The problem is your gml:pos element, instead of

<pos>8682209.29541959,1159929.44262119 undefined</pos>

it should be

<pos srsDimension="3">8682209.29541959 1159929.44262119 0</pos>

or

<pos srsDimension="2">8682209.29541959 1159929.44262119</pos>

From a quick look at the OL docs it looks like you need to specify

feature =  new ol.geom.Point([geom],'XY');

to prevent OL thinking you have a Z or M element in your array. I think the commas come from mixing GML 2 and GML3 but I can't see where you set up you formatGML object, but a WFS 1.1.0 will be expection GML2.

  • I am using var formatWFS = new ol.format.WFS(); var formatGML = new ol.format.GML2({ featureNS: base_URL+'web/geowebmap_ws', featureType: 'tn_poi', srsName: 'EPSG:3857' }); And feature = new ol.geom.Point([geom],'XY'); Still am getting the same error – User123 May 29 '18 at 8:03

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.