I have published a WFS-T layer (using geoserver) and am able to add, edit and delete features using OpenLayers and it's Vector layer.
But, I don't know how can I populate additional attributes using OpenLayers and WFS-T. Any pointers?
Let's say I have database structure:
ARMY (
ID NUMBER PRIMARY KEY,
NAME VARCHAR2(200));
INVADED_AREA (
ID NUMBER PRIMARY KEY,
INVADED_BY_ARMY_ID NUMBER NOT NULL,
AREA_GEOMETRY SDO_GEOMETRY,
CONSTRAINT ia_fk FOREIGN KEY(INVADED_BY_ARMY_ID) REFERENCES ARMY(ID));
and I have a web application where you first select an army (with e.g. ID 42) and then start drawing geometries of invaded areas using OpenLayers. How do I get OpenLayers to put value 42 into INVADED_AREA.INVADED_BY_ARMY_ID column?
EDIT: I have found http://dev4.mapgears.com/bdga/bdgaWFS-T.html# which seems to do what I am looking for. Will update when I have investigated it more.
Also found bunch of related gis.stackexchange questions. I will look through them more carefully, at first glance none had an easy answer:
And from openlayers-dev: http://lists.osgeo.org/pipermail/openlayers-dev/2007-April/000520.html
Answer
Simply add the attribute to the feature before the wfs-commit:
// feat is the feature with the area the user drawn
feat.attributes.INVADED_BY_ARMY_ID = 42;
Of course, you should save somewhere the army id...
No comments:
Post a Comment