[TinyOWS-users] Problem inserting new features

Gissur Þórhallsson gissur at loftmyndir.is
Mon Dec 5 07:31:11 EST 2011


Yeah - I've had this problem too.

Reordering the attribute fields in postgis has thus far been the only
reliable way of ensuring that this does not occur.
( I could never get that OpenLayers strategy to work for my use-case, but
so it goes).

Regrettably, postgres does not support column
re-ordering<http://wiki.postgresql.org/wiki/Alter_column_position> ,
so the only way is to do it via dropping/recreating columns or tables.

Kind regards,
Gissur

On Sat, Dec 3, 2011 at 12:42 PM, Rahkonen Jukka
<Jukka.Rahkonen at mmmtike.fi>wrote:

> Hi,
>
> Yes, order of attributes does matter in WFS. Here is a part of a
> FeatureType schema that comes with DescribeFeatureType request
>
> <xs:complexType name="osm_pointType">
> <xs:complexContent><xs:extension base="gml:AbstractFeatureType">
> <xs:sequence>
> <xs:element name="osm_id" type="int" nillable="true" minOccurs="0"
> maxOccurs="1"/>
> <xs:element name="note" type="string" nillable="true" minOccurs="0"
> maxOccurs="1"/>
> ...
>
> List of properities is defined to be "xs:sequence" which means that they
> must appear in correct order if they are used in the requests which contain
> XML. The only reliable way for knowing the correct order is to make the
> client to do DescribeFeatureType and read it from the service.
>
> GET requests without any XML do not care about the propertyname order and
> both following requests work.
>
>
> http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=sahko,the_geom&maxfeatures=1
>
> http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=the_geom,sahko&maxfeatures=1
>
> However, if the latter is send as http POST it will probably lead to an
> error because "the_geom" should come after "sahko".
>
> -Jukka Rahkonen-
>
> ________________________________
> Nicolás Ardissono wrote:
>
> I had the same problem, and you have two options to solve it. Because is a
> field order problem.
> Check with pgadmin how your fields are orderer, you have first name and
> then the_geom, so tinyows doesn't except anything after the_geom. What you
> have to do is delete the name field and create it again so it will be after
> the_geom, with that it works for me.
>
> Or you can try this script, but not always work:
>
> /**
>  * @requires OpenLayers/Strategy.js
>  */
>
> /**
>  * Allow to force the ordering of attributes before saving
>  *
>  * @class
>  */
> OpenLayers.Strategy.SaveAttrOrder =
>  OpenLayers.Class(OpenLayers.Strategy,
> {
>
>  /**
>   * Order of attributes to save.
>   *
>   * Only the attributes listed here will be saved!
>   *
>   * @type {Array.<string>}
>   */
>  order: [],
>
>  /**
>   * Strategy to communicate with for save operation
>   *
>   * @type {OpenLayers.Strategy.Save}
>   */
>  saveStrategy: null,
>
>  /**
>   * APIMethod: activate
>   * Activate the strategy.  Register any listeners, do appropriate setup.
>   *
>   * Returns:
>   * {Boolean} The strategy was successfully activated.
>   */
>  activate: function() {
>    var activated = OpenLayers.Strategy.prototype.activate.call(this);
>    if (activated) {
>      this.saveStrategy.events.on({
>          start: this.beforeSave,
>          scope: this
>      });
>    }
>    return activated;
>  },
>
>  /**
>   * APIMethod: deactivate
>   * Deactivate the strategy.  Unregister any listeners, do appropriate
>   *     tear-down.
>   *
>   * Returns:
>   * {Boolean} The strategy was successfully deactivated.
>   */
>  deactivate: function() {
>    var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);
>    if(deactivated) {
>      this.saveStrategy.events.un({
>          start: this.beforeSave,
>          scope: this
>      });
>    }
>    return deactivated;
>  },
>
>  beforeSave: function(event) {
>    var features = event.features;
>    features.forEach(dojo.hitch(this, 'reorderFeature'));
>  },
>
>  reorderFeature: function(feature) {
>    var obj = {};
>    this.order.forEach(
>        function(attr) {
>          if (feature.attributes.hasOwnProperty(attr)) {
>            obj[attr] = feature.attributes[attr];
>          }
>        });
>    feature.attributes = obj;
>  }
>
>
>
> Hope this help
>
> ________________________________
> De: Jessica Lapointe <jlapointe at mapgears.com>
> Para: tinyows-users at lists.maptools.org
> Enviado: viernes, 2 de diciembre de 2011 16:41
> Asunto: [TinyOWS-users] Problem inserting new features
>
> Hello,
> I'm having trouble in inserting new features in my db. In fact I have
> the same problem as described in there:
> http://lists.maptools.org/pipermail/tinyows-users/2010-November/000230.html
> I use openlayers 2.11 and tinyows trunk revision 615.
>
> I'm able to update and delete data with no problem. If I insert simple
> features containing only geometry it also works. But if my new feature
> has data, my xml response in firebug will be "XML request isn't
> valid". Tinyows' log says :
>
> [Fri Dec  2 14:30:11 2011] [ERROR] Element '{http://127.0.0.1/}name':
> This element is not expected.
>
> [Fri Dec  2 14:30:11 2011] [ERROR] XML request isn't valid
>
> The xml sent to tinyows is the following:
>
> <wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
> version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs
> http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <wfs:Insert>
> <feature:popplace xmlns:feature="http://127.0.0.1/">
> <feature:the_geom>
> <gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
> <gml:coordinates decimal="." cs="," ts="
> ">-45.925780534744,-11.97656750679</gml:coordinates>
> </gml:Point>
> </feature:the_geom>
> <feature:name>test</feature:name>
> </feature:popplace>
> </wfs:Insert>
> </wfs:Transaction>
>
> Any help would be appreciated.
> _______________________________________________
> TinyOWS-users mailing list
> TinyOWS-users at lists.maptools.org<mailto:TinyOWS-users at lists.maptools.org>
> http://lists.maptools.org/mailman/listinfo/tinyows-users
>
>
> _______________________________________________
> TinyOWS-users mailing list
> TinyOWS-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/tinyows-users
>



-- 
Gissur Þórhallsson

Loftmyndir ehf.
Laugavegur 13
IS 101 Reykjavík - Iceland
sími (tel): (+354) 540 2500
tölvupóstur (email): gissur at loftmyndir.is
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/tinyows-users/attachments/20111205/973e177c/attachment.htm 


More information about the TinyOWS-users mailing list