[OpenLayers-Dev] Code Sprint: SLD

Andreas Hocevar andreas.hocevar at gmail.com
Tue Oct 2 03:12:39 EDT 2007


Hi,

after discussing the pro and cons of evaluating rules by a
pre-compiled string and eval() vs. an object-based representation of
the ogc rules with Chris and Tim at the FOSS4G code sprint, I have to
admit that avoiding eval() has several advantages:

- rules can be easily created independently from the sld parser (eg
through a sld editor), and written out with a write() method, like
with other formats.
- better security
- (maybe also) better performance

I finally figured out a way to build an object tree with rules,
including all requirements like recursively stacking logical
operators.

For this, I had to create a new class OpenLayers.Rule, with subclasses
for the main types of rules, similar to those in the OGC filter spec
sld. This class replaces the OpenLayers.Style.Rule hash we had before,
and instances of this class (or its subclasses) are held in the rules
array of an OpenLayers.Style instance. This Rule class has a method
evaluate(feature), which is different for all rule types and returns
true or false.

I also rewrote parts of the SLD parser itself (OpenLayers.Format.SLD)
for better readability of the code, by adding convenience methods and
taking care of the length of code lines.

I hope the progress I made will make it easier for you to move this
sld thing into trunk.

Regards,
Andreas.

On 10/1/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> Andreas Hocevar and Pierre Giraud sat down on Friday at the code sprint
> and got working on SLD rendering.
>
> The results of that are available at:
>
> http://dev.openlayers.org/sandbox/ahocevar/sldRenderer/examples/gml-layer-sld.html
>
> This small example demonstrates significant support for SLD parameters
> and filters, parsing (as I understand it) a lot of the contents of the
> file at:
>
> http://dev.openlayers.org/sandbox/ahocevar/sldRenderer/examples/xml/sld.xml
>
> Very cool work, and I'm looking forward to helping move the work back to
> trunk!
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>



More information about the Dev mailing list