[OpenLayers-Dev] Adding Feature to WFS in Vector Layer / Copying Features

Fabian Patzke patzke at geoinformationsdienst.de
Mon Aug 10 06:41:16 EDT 2009


Hi,
i tried to find an answer in the ol.users list before [1], but didn't get
any. maybe some one here can give me some hint.

[1]
http://n2.nabble.com/Adding-Feature-to-WFS-in-Vector-Layer---Copying-Features-td3390769.html#a3390769

Old Message:
I try to build a copy function so that a user can select some features from
a
WFS and copy them to another.

My WFS are not normal WFS Layers they are build in Vector Layers

wfsLayer [layerArray[j].name] = new OpenLayers.Layer.Vector (
  ...
  {
    strategies: [
       new OpenLayers.Strategy.Fixed({preload:false}),
       new OpenLayers.Strategy.Save({
         ...
       ],
    projection: new OpenLayers.Projection("EPSG:31467"),
    protocol: new OpenLayers.Protocol.WFS({...})
  },
  ...
);

I made a function to select features from a WFS, these features are
temporarily
stored in a normal Vector layer ("select"). This function is build after:
http://www.openlayers.org/dev/examples/getfeature-wfs.html

Another function is called after the end of selecting features, the user has
to
end selecting manually. This should be the copy function. The function
should
take all features from the "select" layer and copy them over to the wfsLayer
from above.
That is all I have so far:

function copySelectedFeatures (wfsLayer){
  features = select.features;
  for (i=0;i<features.length;i++){
    var feature = features[i];
    layer.addFeatures([feature]);
    layer.strategies[1].save(feature);
  }
}

Is this the correct approach, I have included the line:
    layer.strategies[1].save(feature);
because I thought it would commit newly added features, but it wont work. No
feature is ever added.

Any help is welcome :)
Thanks in forward.

Greetings,
Fabian

My transaction is getting more and more
complete. But the Coordinates are still missing.
If anybody has an idea it would be great ;)

<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 http://www.FOO.BLA
http://FOO:8080/geoserver/wfs?Service=WFS&Request=DescribeFeatureType&
version=1.0.0&typename=foo:bla"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <wfs:Insert>
    <feature:bla
      xmlns:feature="http://FOO.BLA">
      <feature:the_geom>
        <gml:MultiPolygon
          xmlns:gml="http://www.opengis.net/gml"
          srsName="EPSG:31467"/>
      </feature:the_geom>
    </feature:bla>
  </wfs:Insert>
</wfs:Transaction>

Before I try to commit a newly added feature I print out FID an geometry of
the
last features of the layer I added to.
As you can see below, I get the last
feature that has been in the layer before the add (FID: bla.203) and the
newly
added (FID: null).
So I do not get the reason why no geometry is in the transaction.

FID: bla.203 #202: MULTIPOLYGON(((3440276.57 5791250.12,3440243.1
5791360.32,3440244.73 5791414.19,3440263.51 5791485.21,3440359.01
5791523.57,3440515.73 5791495.82,3440598.82 5791494.96,3440609.43
5791557.01,3440700.07 5791522.72,3440704.15 5791588.86,3440841.91
5791548.07,3440823.94 5791481.1,3440917.87 5791429.64,3440917.87
5791415.75,3440753.7 5791349.59,3440813.05 5791255.64,3440910.28
5791228.67,3440902.11 5791175.56,3440840.83 5791161.67,3440837.56
5791179.65,3440797.52 5791174.75,3440737.06 5791121.64,3440659.11
5791106.1,3440650.94 5791142.88,3440556.13 5791270.38,3440455.76
5791170.57,3440434.5 5791204.92,3440467.21 5791245.82,3440447.58
5791284.26,3440392.79 5791288.35,3440289.74 5791259.72,
3440276.57 5791250.12)))
FID: null #203: MULTIPOLYGON(((3302091.4993788 5913241.9002485,
3287274.8407132 5864558.5932041,3334547.0374084 5856797.486284,
3360652.578867 5906891.9036775,3302091.4993788 5913241.9002485)))

Any help would be nice.

Greetings,
Fabian


-- 
View this message in context: http://n2.nabble.com/Adding-Feature-to-WFS-in-Vector-Layer---Copying-Features-tp3416461p3416461.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.



More information about the Dev mailing list