[OpenLayers-Dev] HTTP Protocols [Was: [OpenLayers-Users] GeoRSS and
Custom Icons]
Eric Lemoine
eric.c2c at gmail.com
Sun Jul 13 16:41:36 EDT 2008
On Sun, Jun 29, 2008 at 4:31 PM, Christopher Schmidt
<crschmidt at metacarta.com> wrote:
> On Sun, Jun 29, 2008 at 03:54:48PM +0200, Eric Lemoine wrote:
>> Current HTTP Protocol does CRUD through HTTP POST, GET, PUT, DELETE.
>> It should be generic enough for implementing Protocol.FeatureServer
>> and Protocol.OSM based upon it.
>
> Er, I don't think this is likely to be true.
>
> FeatureServer/MapFish use a protocol where you post an entire feature to
> the server, and it saves that feature.
>
> OSM uses a topological model, so editing is different: you don't edit
> linestrings, you edit individual nodes along them. So, although OSM is
> RESTful, the objects are lower level: a FeatureServer-friendly HTTP
> protocol and an OSM-friendly one would be significantly different.
>
> Maybe I don't know what I'm talking about, as per usual :) But it seems
> unlikely that OSM + FeatureServer protocols could share much code in
> terms of writing; only reading would be sanely sharable, I think.
Chris, let me go back to this. I went over the OSM Protocol
specifications and I don't see why we could not make use of
Protocol.HTTP for implementing Protocol.OSM. As I see it Protocol.OSM
would decorate Protocol.HTTP. Pseudo code:
-------------
class Protocol.OSM:
method initialize:
this.http = new Protocol.HTTP({format: new Format.OSM})
method read(options):
if options.filter is a featureid filter:
url = '/api/0.5/' + objtype + '/' + fid
else if options.filter is a box filter:
url = '/api/0.5/map?bbox=' + bbox
function callback(response):
// deal with response
// call user callback
this.http.read({url: url, callback: callback})
method create(features):
// creation is done with update on resource /api/0.5/<objtype>/create
url = '/api/0.5/' + objtype + '/create'
function callback(response):
// deal with response
// call user callback
this.http.update(features, {url: url, callback: callback})
method update(feature):
// update is done with update on resource /api/0.5/<objtype>/<id>
url = '/api/0.5/' + objtype + '/' feature.fid
function callback(response):
// deal with response
// call user callback
this.http.update(features, {url: url, callback: callback})
method delete(feature):
// delete is done with delete on resource /api/0.5/<objtype>/<id>
url = '/api/0.5/' + objtype + '/' feature.fid
function callback(response):
// deal with response
// call user callback
this.http.delete(features, {url: url, callback: callback})
-------------
I agree that the benefit over directly using Request (in place of
Protocol.HTTP) isn't that big; but still, I think that Protocol.HTTP
is generic enough for serving as a base for the implementation of
RESTFul protocols such as MapFish, FeatureServer and OSM.
Regards,
--
Eric
More information about the Dev
mailing list