[OpenLayers-Dev] vector behavior
Tim Schaub
tschaub at openplans.org
Tue Apr 15 08:37:07 EDT 2008
In case it helps in understanding the design, I'll include a little
detail on a very simple example here.
http://dev.openlayers.org/sandbox/topp/almanac/examples/v2-fixed-http-gml.html
That example does about the same thing that the gml-layer.html example
does. Except it is more verbose.
Instead of creating a layer like:
var layer = new OpenLayers.Layer.GML("GML", "gml/polygon.xml");
The vector behavior example (v2-fixed-http-gml.html) does the following:
var layer = new OpenLayers.Layer.Vector2("GML", {
strategy: new OpenLayers.Strategy.Fixed(),
protocol: new OpenLayers.Protocol.HTTP({
url: "gml/polygon.xml"
}),
format: new OpenLayers.Format.GML()
});
Looks horrible, right? And the example name is so long and tedious as well.
The point is that the existing GML layer wraps up a bunch (well, a bit)
of vector behavior into a single class. The GML layer requests all data
once (that's a strategy), it uses HTTP (that's a protocol), and it
parses responses as GML (that's a format).
The new design separates strategy, protocol, and format. A strategy is
tied to a layer (it has a reference to a layer and can only be used with
a layer). A protocol is tied to a format (it has a reference to a
format). You can swap out the format for a protocol (in theory) and you
can use a protocol in the absence of a layer.
The result is that we can use these parts elsewhere. People can mix and
match as they like. We can develop new strategies, protocols, and
formats independently - assumptions about how they are integrated
doesn't need to be tied up in a layer.
Then, of course, we can make things convenient again. The GML layer (if
there is demand for one) can use a Fixed strategy, an HTTP protocol, and
a GML format. The WFS layer can use a BBOX strategy, a WFS protocol,
and a GML format. Etc.
Tim
Tim Schaub wrote:
> Hey-
>
> Some may have already seen the proposal for new vector layer behavior.
> http://trac.openlayers.org/wiki/Proposal/VectorBehavior
>
> This week, I'll be working on implementing a bit of this new design.
> I'm focussed on an AtomPub protocol, an Atom format, and a somewhat
> smartish BBOX strategy.
>
> I've started putting stuff up in an "almanac" sandbox. The one example
> that shows it wired together is not that impressive - but it represents
> a new design for giving vector layers behavior.
>
> http://dev.openlayers.org/sandbox/topp/almanac/examples/vector2.html
>
> I appreciate any ideas on the work. I've got a deadline to get this
> working by next Monday - so it will be hasty work for a while.
>
> http://trac.openlayers.org/log/sandbox/topp/almanac/
>
> I've also refactored the WFS stuff into a WFS protocol. This is
> completely untested and expected not to work currently. If anybody is
> interested in picking that up, sbenthall will be working on it this week
> as well.
>
> Tim
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
> !DSPAM:4033,4803ed6625911804284693!
>
More information about the Dev
mailing list