[OpenLayers-Dev] Bug? Adding Multipolygons to Multipolygon Layer not working was: [Re: Adding Feature to WFS in Vector Layer / Copying Features]

Fabian Patzke patzke at geoinformationsdienst.de
Thu Aug 13 03:08:32 EDT 2009


I made progress and now I'm able to copy between, but there is some strange
behavior. See below ...

Fabian Patzke wrote:
> 
> 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({...})
>   },
>   ...
> );
> [...]
> 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);
>   }
> }
> 
i changed the copy action:

function copySelectedFeatures (layer){
  features = select.features;
  layerFeatures = layer.features;
  var layerFeaturesLengthBegin = layerFeatures.length;      
  for (i=0;i<features.length;i++){
    var geometry;
    //check whether its multi or normal geom and copy the inner one
    if (features[i].geometry.components != null){
      geometry = features[i].geometry.components[0].clone();
    } else {
      geometry = features[i].geometry.clone();
    }
    var feature = new OpenLayers.Feature.Vector(geometry);
    layer.addFeatures([feature]);
    //this is a specific draw control for this layer
    controls["draw_"+layer.name].featureAdded(feature);
  }
}

this works well and i can copy all my geometries to another
vector(wfs)layer. The problem was that if my destination layer was one that
had a multigeom i tried to add a multigeom to it. For me that sounded to be
the right approach, but when I did so, the transaction only hat an empty
geometry.
Then i tried to copy a non multigeom to the corresponding multigeom
destination layer and it worked my transaction was complete with a full
geometry and I got the added feature in my destination layer.

For me this sounds a bit weird that I am not able to copy i.e. a
multipolygon to a multipolygon layer. Maybe my approach is in some way
wrong, but maybe it's a bug?

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



More information about the Dev mailing list