OpenLayers OpenLayers

Changeset 5429

Show
Ignore:
Timestamp:
12/15/07 11:17:50 (9 months ago)
Author:
crschmidt
Message:

Add support for the extremely awesomely super-comprehensive rule based styling
that Andreas has been working so hard on. I think this is the single most
awesome commit I've ever had the pleasure of committing. The results of this
commit are described on http://trac.openlayers.org/wiki/Styles: essentially,
this makes it possible to style features in all kinds of fun ways based on
rules, and will also form the underlying basis for #533. Things this patch
adds:

  • OL.Rule classes. These classes allow you to do tests against the propertie
    of a feature, and set a style based on these properties -- so you can
    compare the 'speedlimit' property of a line, and test if it is > 60, and if
    it is greater than 60, render it in a different color. You can also test
    combinations of rules using the OL.Rule.Logical class, and test featureids
    with the FeatureID class.
  • OL.Style class: The OL.Style class lets you wrap up Rules into styles that
    can be used with drawFeature to draw the feature in the selected style.
  • OL.Layer.Vector.drawFeature will check if the given style is an OL.Style
    object, and if so, it will draw the feature accordingly.

examples/georss-flickr.html shows usage of these classes.

Many, many thanks go to Andreas for all his hard work on this: this code really
is very pretty, and includes unit tests for all the classes (and we know that I
am a big fan of tests.)

Three cheers for Andreas: Hip hip, hooray! hip hip, hooray! hip hip, hooray!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers.js

    r5412 r5429  
    165165            "OpenLayers/Layer/Vector.js", 
    166166            "OpenLayers/Layer/GML.js", 
     167            "OpenLayers/Style.js", 
     168            "OpenLayers/Rule.js", 
     169            "OpenLayers/Rule/FeatureId.js", 
     170            "OpenLayers/Rule/Logical.js", 
     171            "OpenLayers/Rule/Comparison.js", 
    167172            "OpenLayers/Format.js", 
    168173            "OpenLayers/Format/XML.js", 
  • trunk/openlayers/lib/OpenLayers/Layer/Vector.js

    r5330 r5429  
    351351            } 
    352352        } 
     353 
     354        if (style && style.CLASS_NAME &&  
     355            style.CLASS_NAME == "OpenLayers.Style") { 
     356            style = style.createStyle(feature); 
     357        }     
     358         
    353359        this.renderer.drawFeature(feature, style); 
    354360    }, 
  • trunk/openlayers/tests/list-tests.html

    r5415 r5429  
    3636    <li>test_Feature.html</li> 
    3737    <li>Feature/test_Vector.html</li> 
     38    <li>test_Style.html</li> 
     39    <li>test_Rule.html</li> 
     40    <li>Rule/test_FeatureId.html</li> 
     41    <li>Rule/test_Logical.html</li> 
     42    <li>Rule/test_Comparison.html</li> 
    3843    <li>test_Events.html</li> 
    3944    <li>test_Util.html</li>