[OpenLayers-Users] Help with Strategy.save and protocol.http

Frank Broniewski brfr at metrico.lu
Thu May 20 04:02:30 EDT 2010


Hello Eric, all,

> The save strategy just calls protocol.commit(). See
> <http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Strategy/Save.js#L178>.
>
> The protocol's commit method looks at the states of the features and
> calls the appropriate method (update/create/delete). See
> <http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js#L519>.

If it "just" calls protocol.commit(), what's the reason for having a 
save-strategy? Is it to have some kind of user - frontend to the 
protocols methods? If I don't use the save-strategies autosave feature, 
there's for me no difference wether I call protocol.commit() or 
strategy.save(). Or is there something more to using strategy.save() or 
strategies in general? Something like: "Don't use protocols directly, it 
is preferred to use them through strategies.", thus a design decision?

 From looking at the code ;-) I see that there is a projection check and 
an optional transformation to the remote projection, so that would be 
the "only" difference before protocol.commit(), right? I presume, the 
transformation is mostly there for the google projection (900913) to 
wgs84 transformation, or does OpenLayers have already some kind of proj 
support built in?



> I'm far from an expert, but I know that it's possible to edit features on the
> map and save those changes externally (eg to a database) without these
> strategies or protocols. I write them directly to feature attributes and
> send the data to a db with AJAX.

Well, obvious I am also far from being an expert, but I like to 
understand how things work together and from my standpoint I don't see 
the reason to wrap up my own communication protocol when I can use a 
built-in one, especially when I use GeoJSON as a transport format and I 
just need to specify that in my layer definition. This feels very 
snappy, it fits nicely together, simply using the protocol and strategy 
with my layer. No need to reenvent the wheel a second time ...


Well, thanks for the clarification so far. This should get me going with 
my project


Frank


-- 
Frank BRONIEWSKI

METRICO s.à r.l.
géomètres
technologies d'information géographique
rue des Romains 36
L-5433 NIEDERDONVEN

tél.: +352 26 74 94 - 28
fax.: +352 26 74 94 99
http://www.metrico.lu



More information about the Users mailing list