OpenLayers OpenLayers

Changeset 6127

Show
Ignore:
Timestamp:
02/08/08 14:41:49 (1 year ago)
Author:
euzuro
Message:

merging bits from trunk into sandbox

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/euzuro/pop/doc/authors.txt

    r6105 r6127  
    3535Some portions of OpenLayers are used under the MIT license, availabie in  
    3636doc/licenses/MIT-LICENSE.txt. 
     37 
     38Some portions of OpenLayers are Copyright 2001 Robert Penner, and are used  
     39under the BSD license, available in doc/licenses/BSD-LICENSE.txt 
  • sandbox/euzuro/pop/lib/OpenLayers/Control.js

    r5910 r6127  
    140140            this.handler = null; 
    141141        } 
     142        if(this.handlers) { 
     143            for(var key in this.handlers) { 
     144                if(this.handlers.hasOwnProperty(key) && 
     145                   typeof this.handlers[key].destroy == "function") { 
     146                    this.handlers[key].destroy(); 
     147                } 
     148            } 
     149            this.handlers = null; 
     150        } 
    142151        if (this.map) { 
    143152            this.map.removeControl(this); 
  • sandbox/euzuro/pop/lib/OpenLayers/Control/DragFeature.js

    r5614 r6127  
    7878 
    7979    /** 
    80      * Property: dragHandler 
    81      * {<OpenLayers.Handler.Drag>} 
    82      */ 
    83     dragHandler: null, 
    84  
    85     /** 
    8680     * Property: dragCallbacks 
    8781     * {Object} The functions that are sent to the drag handler for callback. 
    8882     */ 
    8983    dragCallbacks: {}, 
    90  
    91     /** 
    92      * Property: featureHandler 
    93      * {<OpenLayers.Handler.Feature>} 
    94      */ 
    95     featureHandler: null, 
    9684 
    9785    /** 
     
    120108        OpenLayers.Control.prototype.initialize.apply(this, [options]); 
    121109        this.layer = layer; 
    122         this.dragCallbacks = OpenLayers.Util.extend({down: this.downFeature, 
    123                                                      move: this.moveFeature, 
    124                                                      up: this.upFeature, 
    125                                                      out: this.cancel, 
    126                                                      done: this.doneDragging 
    127                                                     }, this.dragCallbacks); 
    128         this.dragHandler = new OpenLayers.Handler.Drag(this, this.dragCallbacks); 
    129         this.featureCallbacks = OpenLayers.Util.extend({over: this.overFeature, 
    130                                                         out: this.outFeature 
    131                                                        }, this.featureCallbacks); 
    132         var handlerOptions = {geometryTypes: this.geometryTypes}; 
    133         this.featureHandler = new OpenLayers.Handler.Feature(this, this.layer, 
    134                                                         this.featureCallbacks, 
    135                                                         handlerOptions); 
     110        this.handlers = { 
     111            drag: new OpenLayers.Handler.Drag( 
     112                this, OpenLayers.Util.extend({ 
     113                    down: this.downFeature, 
     114                    move: this.moveFeature, 
     115                    up: this.upFeature, 
     116                    out: this.cancel, 
     117                    done: this.doneDragging 
     118                }, this.dragCallbacks) 
     119            ), 
     120            feature: new OpenLayers.Handler.Feature( 
     121                this, this.layer, OpenLayers.Util.extend({ 
     122                    over: this.overFeature, 
     123                    out: this.outFeature 
     124                }, this.featureCallbacks), 
     125                {geometryTypes: this.geometryTypes} 
     126            ) 
     127        }; 
    136128    }, 
    137129     
     
    142134    destroy: function() { 
    143135        this.layer = null; 
    144         this.dragHandler.destroy(); 
    145         this.featureHandler.destroy(); 
    146136        OpenLayers.Control.prototype.destroy.apply(this, []); 
    147137    }, 
     
    155145     */ 
    156146    activate: function() { 
    157         return (this.featureHandler.activate() && 
     147        return (this.handlers.feature.activate() && 
    158148                OpenLayers.Control.prototype.activate.apply(this, arguments)); 
    159149    }, 
     
    168158    deactivate: function() { 
    169159        // the return from the handlers is unimportant in this case 
    170         this.dragHandler.deactivate(); 
    171         this.featureHandler.deactivate(); 
     160        this.handlers.drag.deactivate(); 
     161        this.handlers.feature.deactivate(); 
    172162        this.feature = null; 
    173163        this.dragging = false; 
     
    185175     */ 
    186176    overFeature: function(feature) { 
    187         if(!this.dragHandler.dragging) { 
     177        if(!this.handlers.drag.dragging) { 
    188178            this.feature = feature; 
    189             this.dragHandler.activate(); 
     179            this.handlers.drag.activate(); 
    190180            this.over = true; 
    191181            // TBD replace with CSS classes 
     
    239229    upFeature: function(pixel) { 
    240230        if(!this.over) { 
    241             this.dragHandler.deactivate(); 
     231            this.handlers.drag.deactivate(); 
    242232            this.feature = null; 
    243233            // TBD replace with CSS classes 
     
    266256     */ 
    267257    outFeature: function(feature) { 
    268         if(!this.dragHandler.dragging) { 
     258        if(!this.handlers.drag.dragging) { 
    269259            this.over = false; 
    270             this.dragHandler.deactivate(); 
     260            this.handlers.drag.deactivate(); 
    271261            // TBD replace with CSS classes 
    272262            this.map.div.style.cursor = "default"; 
     
    284274     */ 
    285275    cancel: function() { 
    286         this.dragHandler.deactivate(); 
     276        this.handlers.drag.deactivate(); 
    287277        this.over = false; 
    288278    }, 
     
    296286     */ 
    297287    setMap: function(map) { 
    298         this.dragHandler.setMap(map); 
    299         this.featureHandler.setMap(map); 
     288        this.handlers.drag.setMap(map); 
     289        this.handlers.feature.setMap(map); 
    300290        OpenLayers.Control.prototype.setMap.apply(this, arguments); 
    301291    }, 
  • sandbox/euzuro/pop/lib/OpenLayers/Control/ModifyFeature.js

    r5974 r6127  
    8484     
    8585    /** 
    86      * Property: keyboardHandler 
    87      * {<OpenLayers.Handler.Keyboard>
    88      */ 
    89     keyboardHandler: null, 
     86     * Property: handlers 
     87     * {Object
     88     */ 
     89    handlers: null, 
    9090     
    9191    /** 
     
    217217            keypress: this.handleKeypress 
    218218        }; 
    219         this.keyboardHandler = new OpenLayers.Handler.Keyboard( 
    220             this, keyboardOptions 
    221         )
     219        this.handlers = { 
     220            keyboard: new OpenLayers.Handler.Keyboard(this, keyboardOptions) 
     221        }
    222222    }, 
    223223 
     
    230230        this.selectControl.destroy(); 
    231231        this.dragControl.destroy(); 
    232         this.keyboardHandler.destroy(); 
    233232        OpenLayers.Control.prototype.destroy.apply(this, []); 
    234233    }, 
     
    243242    activate: function() { 
    244243        return (this.selectControl.activate() && 
    245                 this.keyboardHandler.activate() && 
     244                this.handlers.keyboard.activate() && 
    246245                OpenLayers.Control.prototype.activate.apply(this, arguments)); 
    247246    }, 
     
    267266            } 
    268267            this.selectControl.deactivate(); 
    269             this.keyboardHandler.deactivate(); 
     268            this.handlers.keyboard.deactivate(); 
    270269            deactivated = true; 
    271270        } 
     
    353352                                                   [feature]); 
    354353                this.dragControl.lastPixel = pixel; 
    355                 this.dragControl.dragHandler.started = true; 
    356                 this.dragControl.dragHandler.start = pixel; 
    357                 this.dragControl.dragHandler.last = pixel; 
     354                this.dragControl.handlers.drag.started = true; 
     355                this.dragControl.handlers.drag.start = pixel; 
     356                this.dragControl.handlers.drag.last = pixel; 
    358357            } 
    359358        } 
     
    487486            if(vertex && 
    488487               OpenLayers.Util.indexOf(this.vertices, vertex) != -1 && 
    489                !this.dragControl.dragHandler.dragging && 
     488               !this.dragControl.handlers.drag.dragging && 
    490489               vertex.geometry.parent) { 
    491490                // remove the vertex 
  • sandbox/euzuro/pop/lib/OpenLayers/Control/Navigation.js

    r5990 r6127  
    3737    zoomBox: null, 
    3838 
    39     /**  
    40      * Property: wheelHandler 
    41      * {<OpenLayers.Handler.MouseWheel>} 
    42      */ 
    43     wheelHandler: null, 
    44  
    4539    /** 
    4640     * Constructor: OpenLayers.Control.Navigation 
     
    5246     */ 
    5347    initialize: function(options) { 
     48        this.handlers = {}; 
    5449        OpenLayers.Control.prototype.initialize.apply(this, arguments); 
    5550    }, 
     
    6257     */ 
    6358    destroy: function() { 
    64         OpenLayers.Control.prototype.destroy.apply(this,arguments); 
    65  
    6659        this.deactivate(); 
    6760 
     
    7164        this.dragPan = null; 
    7265 
    73         if (this.wheelHandler) { 
    74             this.wheelHandler.destroy(); 
    75         } 
    76         this.wheelHandler = null; 
    77  
    78         if (this.clickHandler) { 
    79             this.clickHandler.destroy(); 
    80         } 
    81         this.clickHandler = null; 
    82          
    8366        if (this.zoomBox) { 
    8467            this.zoomBox.destroy(); 
    8568        } 
    8669        this.zoomBox = null; 
     70        OpenLayers.Control.prototype.destroy.apply(this,arguments); 
    8771    }, 
    8872     
     
    9276    activate: function() { 
    9377        this.dragPan.activate(); 
    94         this.wheelHandler.activate(); 
    95         this.clickHandler.activate(); 
     78        this.handlers.wheel.activate(); 
     79        this.handlers.click.activate(); 
    9680        this.zoomBox.activate(); 
    9781        return OpenLayers.Control.prototype.activate.apply(this,arguments); 
     
    10488        this.zoomBox.deactivate(); 
    10589        this.dragPan.deactivate(); 
    106         this.clickHandler.deactivate(); 
    107         this.wheelHandler.deactivate(); 
     90        this.handlers.click.deactivate(); 
     91        this.handlers.wheel.deactivate(); 
    10892        return OpenLayers.Control.prototype.deactivate.apply(this,arguments); 
    10993    }, 
     
    11397     */ 
    11498    draw: function() { 
    115         this.clickHandler = new OpenLayers.Handler.Click(this,  
     99        this.handlers.click = new OpenLayers.Handler.Click(this,  
    116100                                        { 'dblclick': this.defaultDblClick }, 
    117101                                        { 
     
    124108        this.dragPan.draw(); 
    125109        this.zoomBox.draw(); 
    126         this.wheelHandler = new OpenLayers.Handler.MouseWheel( 
     110        this.handlers.wheel = new OpenLayers.Handler.MouseWheel( 
    127111                                    this, {"up"  : this.wheelUp, 
    128112                                           "down": this.wheelDown} ); 
  • sandbox/euzuro/pop/lib/OpenLayers/Control/OverviewMap.js

    r6083 r6127  
    9999     
    100100    /** 
    101      * Property: dragHandler 
    102      * {<OpenLayers.Handler.Drag>} A handler for dragging the extent rectangle. 
    103      */ 
    104     dragHandler: null, 
     101     * Property: handlers 
     102     * {Object} 
     103     */ 
     104    handlers: null, 
    105105 
    106106    /** 
     
    115115    initialize: function(options) { 
    116116        this.layers = []; 
     117        this.handlers = {}; 
    117118        OpenLayers.Control.prototype.initialize.apply(this, [options]); 
    118119    }, 
     
    126127            return; 
    127128        } 
    128         this.dragHandler.destroy(); 
    129         this.clickHandler.destroy(); 
     129        this.handlers.click.destroy(); 
    130130 
    131131        this.mapDiv.removeChild(this.extentRectangle); 
     
    281281     */ 
    282282    rectDrag: function(px) { 
    283         var deltaX = this.dragHandler.last.x - px.x; 
    284         var deltaY = this.dragHandler.last.y - px.y; 
     283        var deltaX = this.handlers.drag.last.x - px.x; 
     284        var deltaY = this.handlers.drag.last.y - px.y; 
    285285        if(deltaX != 0 || deltaY != 0) { 
    286286            var rectTop = this.rectPxBounds.top; 
     
    457457        this.hComp = (this.hComp) ? this.hComp : 2; 
    458458 
    459         this.dragHandler = new OpenLayers.Handler.Drag( 
     459        this.handlers.drag = new OpenLayers.Handler.Drag( 
    460460            this, {move: this.rectDrag, done: this.updateMapToRect}, 
    461461            {map: this.ovmap} 
    462462        ); 
    463         this.clickHandler = new OpenLayers.Handler.Click( 
     463        this.handlers.click = new OpenLayers.Handler.Click( 
    464464            this, { 
    465465                "click": this.mapDivClick 
     
    471471            } 
    472472        ); 
    473         this.clickHandler.activate(); 
     473        this.handlers.click.activate(); 
    474474         
    475475        this.rectEvents = new OpenLayers.Events(this, this.extentRectangle, 
    476476                                                null, true); 
    477477        this.rectEvents.register("mouseover", this, function(e) { 
    478             if(!this.dragHandler.active && !this.map.dragging) { 
    479                 this.dragHandler.activate(); 
     478            if(!this.handlers.drag.active && !this.map.dragging) { 
     479                this.handlers.drag.activate(); 
    480480            } 
    481481        }); 
    482482        this.rectEvents.register("mouseout", this, function(e) { 
    483             if(!this.dragHandler.dragging) { 
    484                 this.dragHandler.deactivate(); 
     483            if(!this.handlers.drag.dragging) { 
     484                this.handlers.drag.deactivate(); 
    485485            } 
    486486        }); 
     
    512512    updateMapToRect: function() { 
    513513        var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds); 
    514         this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom); 
     514        this.map.panTo(lonLatBounds.getCenterLonLat()); 
    515515    }, 
    516516 
  • sandbox/euzuro/pop/lib/OpenLayers/Format/SLD.js

    r5978 r6127  
    344344            for (var i=0; i<filters.length; i++) { 
    345345                if (filters[i].nodeType == 1) { 
    346                     rule.children.push(this.parseFilter(filters[i])); 
     346                    rule.rules.push(this.parseFilter(filters[i])); 
    347347                } 
    348348            } 
     
    358358            for (var i=0; i<filters.length; i++) { 
    359359                if (filters[i].nodeType == 1) { 
    360                     rule.children.push(this.parseFilter(filters[i])); 
     360                    rule.rules.push(this.parseFilter(filters[i])); 
    361361                } 
    362362            } 
     
    369369            var rule = new OpenLayers.Rule.Logical( 
    370370                    {type: OpenLayers.Rule.Logical.NOT}); 
    371             rule.children.push(this.parseFilter(filter[0])); 
     371            rule.rules.push(this.parseFilter(filter[0])); 
    372372            return rule; 
    373373        } 
  • sandbox/euzuro/pop/lib/OpenLayers/Map.js

    r6104 r6127  
    374374            //  Note that this is ok, as updateSize() does nothing if the  
    375375            //  map's size has not actually changed. 
     376            this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize,  
     377                this); 
    376378            OpenLayers.Event.observe(window, 'resize', 
    377                             OpenLayers.Function.bind(this.updateSize, this)); 
     379                            this.updateSizeDestroy); 
    378380        } 
    379381         
     
    435437     */ 
    436438    unloadDestroy: null, 
     439     
     440    /** 
     441     * Method: updateSizeDestroy 
     442     * When the map is destroyed, we need to stop listening to updateSize 
     443     *    events: this method stores the function we need to unregister in  
     444     *    non-IE browsers. 
     445     */ 
     446    updateSizeDestroy: null, 
    437447 
    438448    /** 
     
    449459        OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy); 
    450460        this.unloadDestroy = null; 
     461 
     462        if (this.updateSizeDestroy) { 
     463            OpenLayers.Event.stopObserving(window, 'resize',  
     464                                           this.updateSizeDestroy); 
     465        } else { 
     466            this.events.unregister("resize", this, this.updateSize); 
     467        }     
    451468 
    452469        if (this.layers != null) { 
     
    12301247     * dx - {Integer} 
    12311248     * dy - {Integer} 
    1232      */ 
    1233     pan: function(dx, dy) { 
    1234  
     1249     * options - {Object} Only one at this time: "animate", which uses 
     1250     *    panTo instead of setCenter. Default is true. 
     1251     */ 
     1252    pan: function(dx, dy, options) { 
     1253         
     1254        if (!options) { 
     1255            options = {} 
     1256        }     
    12351257        // getCenter 
    12361258        var centerPx = this.getViewPortPxFromLonLat(this.getCenter()); 
     
    12421264        if (!newCenterPx.equals(centerPx)) { 
    12431265            var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx); 
    1244             this.setCenter(newCenterLonLat); 
     1266            if (options.animate) { 
     1267                this.panTo(newCenterLonLat); 
     1268            } else { 
     1269                this.setCenter(newCenterLonLat); 
     1270            }     
    12451271        } 
    12461272 
    12471273   }, 
     1274    
     1275   /**  
     1276     * APIMethod: panTo 
     1277     * Allows user to pan to a new lonlat 
     1278     * If the new lonlat is in the current extent the map will slide smoothly 
     1279     *  
     1280     * Parameters: 
     1281     * lonlat - {<OpenLayers.Lonlat>} 
     1282     */ 
     1283    panTo: function(lonlat) { 
     1284        if (this.getExtent().containsLonLat(lonlat)) { 
     1285            if (!this.panTween) { 
     1286                this.panTween = new OpenLayers.Tween(OpenLayers.Easing.Expo.easeOut); 
     1287            } 
     1288            var center = this.getCenter(); 
     1289            var from = { 
     1290                lon: center.lon, 
     1291                lat: center.lat 
     1292            }; 
     1293            var to = { 
     1294                lon: lonlat.lon, 
     1295                lat: lonlat.lat 
     1296            }; 
     1297            this.panTween.start(from, to, 50, { 
     1298                callbacks: { 
     1299                    start: OpenLayers.Function.bind(function(lonlat) { 
     1300                        this.events.triggerEvent("movestart"); 
     1301                    }, this), 
     1302                    eachStep: OpenLayers.Function.bind(function(lonlat) { 
     1303                        var lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat); 
     1304                        this.moveTo(lonlat, this.zoom, true); 
     1305                    }, this), 
     1306                    done: OpenLayers.Function.bind(function(lonlat) { 
     1307                        this.events.triggerEvent("moveend"); 
     1308                    }, this) 
     1309                } 
     1310            }); 
     1311        } else { 
     1312            this.setCenter(lonlat); 
     1313        } 
     1314    }, 
    12481315 
    12491316    /** 
     
    12861353        // noEvent is false by default 
    12871354        var noEvent = options.noEvent; 
     1355 
     1356        if (this.panTween && options.caller == "setCenter") { 
     1357            this.panTween.stop(); 
     1358        }     
    12881359              
    12891360        if (!this.center && !this.isValidLonLat(lonlat)) { 
  • sandbox/euzuro/pop/lib/OpenLayers/Rule.js

    r5978 r6127  
    2020     */ 
    2121    name: 'default', 
     22     
     23    /** 
     24     * Property: context 
     25     * {Object} An optional object with properties that the rule and its 
     26     * symbolizers' property values should be evaluatad against. If no 
     27     * context is specified, feature.attributes will be used 
     28     */ 
     29    context: null, 
    2230 
    2331    /** 
     
    94102     */ 
    95103    evaluate: function(feature) { 
    96         // Default rule always applies. Subclasses will want to override this. 
    97         return true; 
     104        var context = this.getContext(feature); 
     105        var applies = true; 
     106 
     107        if (this.minScaleDenominator || this.maxScaleDenominator) { 
     108            var scale = feature.layer.map.getScale(); 
     109        } 
     110         
     111        // check if within minScale/maxScale bounds 
     112        if (this.minScaleDenominator) { 
     113            applies = scale >= OpenLayers.Style.createLiteral( 
     114                    this.minScaleDenominator, context); 
     115        } 
     116        if (applies && this.maxScaleDenominator) { 
     117            applies = scale < OpenLayers.Style.createLiteral( 
     118                    this.maxScaleDenominator, context); 
     119        } 
     120 
     121        return applies; 
    98122    }, 
    99123     
     124    /** 
     125     * Method: getContext 
     126     * Gets the context for evaluating this rule 
     127     *  
     128     * Paramters: 
     129     * feature - {<OpenLayers.Feature>} feature to take the context from if 
     130     *           none is specified. 
     131     */ 
     132    getContext: function(feature) { 
     133        var context = this.context; 
     134        if (!context) { 
     135            context = feature.attributes || feature.data; 
     136        } 
     137        return context; 
     138    }, 
     139         
    100140    CLASS_NAME: "OpenLayers.Rule" 
    101141}); 
  • sandbox/euzuro/pop/lib/OpenLayers/Rule/Comparison.js

    r5614 r6127  
    3434     * APIProperty: property 
    3535     * {String} 
    36      * name of the feature attribute to compare 
     36     * name of the context property to compare 
    3737     */ 
    3838    property: null, 
     
    8585    /** 
    8686     * APIMethod: evaluate 
    87      * evaluates this rule for a specific feature 
    88      *  
    89      * Parameters: 
    90      * feature - {<OpenLayers.Feature>} feature to apply the rule to. 
     87     * evaluates this rule for a specific context 
     88     *  
     89     * Parameters: 
     90     * context - {Object} context to apply the rule to. 
    9191     *  
    9292     * Returns: 
     
    9494     */ 
    9595    evaluate: function(feature) { 
    96         var attributes = feature.attributes || feature.data; 
     96        if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) { 
     97            return false; 
     98        } 
     99        var context = this.getContext(feature); 
    97100        switch(this.type) { 
    98101            case OpenLayers.Rule.Comparison.EQUAL_TO: 
     
    101104            case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO: 
    102105            case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO: 
    103                 return this.binaryCompare(feature, this.property, this.value); 
     106                return this.binaryCompare(context, this.property, this.value); 
    104107             
    105108            case OpenLayers.Rule.Comparison.BETWEEN: 
    106109                var result = 
    107                         attributes[this.property] > this.lowerBoundary; 
     110                        context[this.property] > this.lowerBoundary; 
    108111                result = result && 
    109                         attributes[this.property] < this.upperBoundary; 
     112                        context[this.property] < this.upperBoundary; 
    110113                return result; 
    111114            case OpenLayers.Rule.Comparison.LIKE: 
    112115                var regexp = new RegExp(this.value, 
    113116                                "gi"); 
    114                 return regexp.test(attributes[this.property]);  
     117                return regexp.test(context[this.property]);  
    115118        } 
    116119    }, 
     
    166169     *  
    167170     * Parameters: 
    168      * feature  - {<OpenLayers.Feature>
     171     * context  - {Object
    169172     * property - {String} or {Number} 
    170173     * value    - {String} or {Number}, same as property 
     
    173176     * {boolean} 
    174177     */ 
    175     binaryCompare: function(feature, property, value) { 
    176         var attributes = feature.attributes || feature.data; 
     178    binaryCompare: function(context, property, value) { 
    177179        switch (this.type) { 
    178180            case OpenLayers.Rule.Comparison.EQUAL_TO: 
    179                 return attributes[property] == value; 
     181                return context[property] == value; 
    180182            case OpenLayers.Rule.Comparison.NOT_EQUAL_TO: 
    181                 return attributes[property] != value; 
     183                return context[property] != value; 
    182184            case OpenLayers.Rule.Comparison.LESS_THAN: 
    183                 return attributes[property] < value; 
     185                return context[property] < value; 
    184186            case OpenLayers.Rule.Comparison.GREATER_THAN: 
    185                 return attributes[property] > value; 
     187                return context[property] > value; 
    186188            case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO: 
    187                 return attributes[property] <= value; 
     189                return context[property] <= value; 
    188190            case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO: 
    189                 return attributes[property] >= value; 
     191                return context[property] >= value; 
    190192        }       
    191193    }, 
  • sandbox/euzuro/pop/lib/OpenLayers/Rule/FeatureId.js

    r5614 r6127  
    5454     */ 
    5555    evaluate: function(feature) { 
     56        if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) { 
     57            return false; 
     58        } 
    5659        for (var i=0; i<this.fids.length; i++) { 
    5760            var fid = feature.fid || feature.id; 
  • sandbox/euzuro/pop/lib/OpenLayers/Rule/Logical.js

    r5614 r6127  
    2121     * {Array(<OpenLayers.Rule>)} child rules for this rule 
    2222     */ 
    23     children: null,  
     23    rules: null,  
    2424      
    2525    /** 
     
    4444     */ 
    4545    initialize: function(options) { 
    46         this.children = []; 
     46        this.rules = []; 
    4747        OpenLayers.Rule.prototype.initialize.apply(this, [options]); 
    4848    }, 
     
    5353     */ 
    5454    destroy: function() { 
    55         for (var i=0; i<this.children.length; i++) { 
    56             this.children[i].destroy(); 
     55        for (var i=0; i<this.rules.length; i++) { 
     56            this.rules[i].destroy(); 
    5757        } 
    58         this.children = null; 
     58        this.rules = null; 
    5959        OpenLayers.Rule.prototype.destroy.apply(this, arguments); 
    6060    }, 
     
    7171     */ 
    7272    evaluate: function(feature) { 
     73        if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) { 
     74            return false; 
     75        } 
    7376        switch(this.type) { 
    7477            case OpenLayers.Rule.Logical.AND: 
    75                 for (var i=0; i<this.children.length; i++) { 
    76                     if (this.children[i].evaluate(feature) == false) { 
     78                for (var i=0; i<this.rules.length; i++) { 
     79                    if (this.rules[i].evaluate(feature) == false) { 
    7780                        return false; 
    7881                    } 
     
    8184                 
    8285            case OpenLayers.Rule.Logical.OR: 
    83                 for (var i=0; i<this.children.length; i++) { 
    84                     if (this.children[i].evaluate(feature) == true) { 
     86                for (var i=0; i<this.rules.length; i++) { 
     87                    if (this.rules[i].evaluate(feature) == true) { 
    8588                        return true; 
    8689                    } 
     
    8992             
    9093            case OpenLayers.Rule.Logical.NOT: 
    91                 return (!this.children[0].evaluate(feature)); 
     94                return (!this.rules[0].evaluate(feature)); 
    9295        } 
    9396    }, 
  • sandbox/euzuro/pop/lib/OpenLayers/Style.js

    r5978 r6127  
    113113        var rules = this.rules; 
    114114 
    115         var rule
     115        var rule, context
    116116        var elseRules = []; 
    117117        var appliedRules = false; 
    118118        for(var i=0; i<rules.length; i++) { 
    119119            rule = rules[i]; 
     120            context = rule.context; 
     121            if (!context) { 
     122                context = feature.attributes || feature.data; 
     123            } 
    120124            // does the rule apply? 
    121125            var applies = rule.evaluate(feature); 
    122126             
    123             if (rule.minScaleDenominator || rule.maxScaleDenominator) { 
    124                 var scale = feature.layer.map.getScale(); 
    125             } 
    126              
    127             // check if within minScale/maxScale bounds 
    128             if (rule.minScaleDenominator) { 
    129                 applies = scale >= OpenLayers.Style.createLiteral( 
    130                         rule.minScaleDenominator, feature); 
    131             } 
    132             if (applies && rule.maxScaleDenominator) { 
    133                 applies = scale < OpenLayers.Style.createLiteral( 
    134                         rule.maxScaleDenominator, feature); 
    135             } 
    136  
    137127            if(applies) { 
    138128                if(rule instanceof OpenLayers.Rule && rule.elseFilter) { 
     
    140130                } else { 
    141131                    appliedRules = true; 
    142                     this.applySymbolizer(rule, style, feature); 
     132                    this.applySymbolizer(rule, style, feature, context); 
    143133                } 
    144134            } 
     
    149139            appliedRules = true; 
    150140            for(var i=0; i<elseRules.length; i++) { 
    151                 this.applySymbolizer(elseRules[i], style, feature); 
    152             } 
    153         } 
    154  
    155         // calculate literals for all styles in the propertyStyles cache 
    156         this.createLiterals(style, feature); 
     141                this.applySymbolizer(elseRules[i], style, feature, context); 
     142            } 
     143        } 
    157144 
    158145        // don't display if there were rules but none applied 
     
    173160     * style - {Object} 
    174161     * feature - {<OpenLayer.Feature.Vector>} 
     162     * context - {Object} 
    175163     * 
    176164     * Returns: 
    177165     * {Object} A style with new symbolizer applied. 
    178166     */ 
    179     applySymbolizer: function(rule, style, feature) { 
     167    applySymbolizer: function(rule, style, feature, context) { 
    180168        var symbolizerPrefix = feature.geometry ? 
    181169                this.getSymbolizerPrefix(feature.geometry) : 
    182170                OpenLayers.Style.SYMBOLIZER_PREFIXES[0]; 
    183171 
     172        var symbolizer = rule.symbolizer[symbolizerPrefix]; 
     173 
    184174        // merge the style with the current style 
    185         var symbolizer = rule.symbolizer[symbolizerPrefix]; 
    186         return OpenLayers.Util.extend(style, symbolizer); 
     175        return this.createLiterals( 
     176                OpenLayers.Util.extend(style, symbolizer), context); 
    187177    }, 
    188178     
     
    195185     * style   - {Object} style to create literals for. Will be modified 
    196186     *           inline. 
    197      * feature - {<OpenLayers.Feature.Vector>} feature to take properties from 
     187     * context - {Object} context to take property values from. Defaults to 
     188     *           feature.attributes (or feature.data, if attributes are not