-A layer that contains multiple features
- I want to draw new features with new OpenLayers.Control.DrawFeature
and to add them to my layer.
var control = new OpenLayers.Control.DrawFeature(layer,OpenLayers.Handler.Polygon);
control.events.register('featureadded', control, function(f) {
f.feature.state = OpenLayers.State.INSERT;
f.feature.attributes.Geo_ID = 794;
saveStrategy.save();
});
When the feature is added, a xml file is sent to the geoserver with the following content:
<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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Insert>
<feature:Graeber xmlns:feature="myserver.de/Ahaus_neu">
<feature:the_geom>
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:31466">
<gml:exterior>
<gml:LinearRing>
<gml:posList>363183.0625 5770740.875 363192.0625 5770755.375 363177.5625 5770764.375 363168.5625 5770749.875 363183.0625 5770740.875</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</feature:the_geom>
<feature:Geo_ID>794</feature:Geo_ID>
</feature:Graeber>
</wfs:Insert>
</wfs:Transaction>
The coordinates are not saved in the geoserver, only the feature:Geo_ID
Element.
If I choose an existing Element to insert in the geoserver Database instead:
control.events.register('featureadded', control, function(f) {
layer.features[0].state = OpenLayers.State.INSERT;
f.feature.state = OpenLayers.State.INSERT;
f.feature.attributes.Geo_ID = 795;
saveStrategy.save();
});
I get the following XML in the Request:
<wfs:Insert>
<feature:Graeber xmlns:feature="myserver.de/Ahaus_neu" fid="Graeber.1">
<feature:the_geom>
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:31466">
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>363273.29099999997 5770863.855 363273.177000001 5770864.300999998 363274.1561700017 5770864.5512810005 363274.2701699999 5770864.105281 363273.29099999997 5770863.855</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</feature:the_geom>
<feature:Geo_ID>795</feature:Geo_ID>
</feature:Graeber>
</wfs:Insert>
And the coordinates DO get inserted in the geoserver DB.
I see one major difference between these two XMLs:
the insertion XML of an existing Element of the layer contains two more tags:
<gml:MultiSurface xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:31466">
and
<gml:surfaceMember>
How do I make the application know that the features added by drawing a polygon are to be treated the same way and put in the same format as the features that already exist in the Database?