[OpenLayers-Users] WFS layer - commit works, save strategy from WFSProtocol does not work!!!! POST vs GET ?!?!

Tim Schaub tschaub at opengeo.org
Mon Mar 22 16:42:25 EDT 2010


paweluz wrote:
> Hi Tim!
> 
> Thanks a lot for your help! I am going to try it tomorrow at work, and see
> if it works... As far as I undestand the handlerOptions: {multi: true} tells
> if the data are saved as multi or not multi... am I right??
> Al this time I was thinking that WFS Web Servis version 1.1.0 is able to
> transform the geometry in the wright way (the way they are saved in the
> database). So now... for example if write some application and give it to
> the client. He will create his own new table in the database... I have to be
> careful and write 6 cases?
> - geometry Point multi
> - geometry Point
> - geometry Poligon multi
> - geometry Point
> - geometry Line multi
> - geometry Line
> I have to check what kind is used in the database (what type is the
> geometry, not only the point, poligon, or line but also multi or not) and
> use the correct one... I was making my application based on the
> wfs-protocol-transaction... but I actually did take much care on the Draw
> options... I was more carefull with the Protolcol definition (featureNS,
> src....), not so much on the draw options... 
> Thanks a lot for your help... I was warry that it may be a bug or
> something... 
> Wouldn't be easier it the strategy could 'tell' what type it should use...
> This would be hard to implememt??

The Save strategy doesn't get involved in feature schema validation (and 
isn't necessarily listening when you add features to your layer).  It 
just tells the protocol to commit.  The protocol just serializes the 
features it finds on the layer that are ready for insert or update.  If 
anything were to be enhanced to deal with feature schema, it would be 
the layer.

It would be nice eventually to be able to provide a layer with a schema 
for features.  On top of that, I can imagine optionally casting types 
when you added or modified features.

Until then, just don't add features to your layer that don't match your 
schema.  If your schema says multi-linestrings, don't add features with 
linestrings (or polygons, or points, etc.) to your layer.  You need to 
enforce this long before the save strategy is invoked.

Here's the ticket for putting the multi property on the DrawFeature control:

http://trac.openlayers.org/ticket/2542

Until that is closed, construct your DrawFeature control like this:

     var control = new OpenLayers.Control.DrawFeature(
         layer, OpenLayers.Handler.Path,
         {handlerOptions: {multi: true}}
     );

This casts geometries to multi-part types before features are added to 
the layer (not related to "save").

Tim

> 
> Poul
> 


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Users mailing list