Ticket #1297: 1297-r5851-A0.patch
| File 1297-r5851-A0.patch, 3.7 kB (added by ahocevar, 11 months ago) |
|---|
-
lib/OpenLayers/Style.js
old new 113 113 } 114 114 var style = OpenLayers.Util.extend({}, baseStyle); 115 115 116 var draw = true;116 var draw = false; 117 117 118 var rule; 118 119 for (var i=0; i<this.rules.length; i++) { 120 rule = this.rules[i]; 119 121 // does the rule apply? 120 var applies = this.rules[i].evaluate(feature); 122 var applies = rule.evaluate(feature); 123 124 if (rule.minScale || rule.maxScale) { 125 var scale = feature.layer.map.getScale(); 126 } 127 128 // check if within minScale/maxScale bounds 129 if (rule.minScale) { 130 applies = scale >= OpenLayers.Style.createLiteral( 131 rule.minScale, feature); 132 } 133 if (applies && rule.maxScale) { 134 applies = scale < OpenLayers.Style.createLiteral( 135 rule.maxScale, feature); 136 } 137 121 138 if (applies) { 122 // check if within minScale/maxScale bounds 123 var scale = feature.layer.map.getScale(); 124 if (this.rules[i].minScale) { 125 draw = scale > OpenLayers.Style.createLiteral( 126 this.rules[i].minScale, feature); 127 } 128 if (draw && this.rules[i].maxScale) { 129 draw = scale < OpenLayers.Style.createLiteral( 130 this.rules[i].maxScale, feature); 131 } 132 139 draw = true; 140 133 141 // determine which symbolizer (Point, Line, Polygon) to use 134 142 var symbolizerPrefix = feature.geometry ? 135 143 this.getSymbolizerPrefix(feature.geometry) : … … 135 143 this.getSymbolizerPrefix(feature.geometry) : 136 144 OpenLayers.Style.SYMBOLIZER_PREFIXES[0]; 137 145 138 // nowmerge the style with the current style146 // merge the style with the current style 139 147 var symbolizer = this.rules[i].symbolizer[symbolizerPrefix]; 140 148 OpenLayers.Util.extend(style, symbolizer); 141 149 } -
tests/test_Style.html
old new 15 15 } 16 16 17 17 function test_Style_create(t) { 18 t.plan( 5);18 t.plan(6); 19 19 20 20 var map = new OpenLayers.Map("map"); 21 21 … … 50 50 var createdStyle = style.createStyle(feature); 51 51 t.eq(createdStyle.externalGraphic, "barbar.png", "Calculated property style correctly."); 52 52 t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale()); 53 t.eq(createdStyle.fillColor, "green", "Point symbolizer from rule applied correctly."); 53 54 54 55 map.setCenter(new OpenLayers.LonLat(3,5), 7); 55 56 // at this scale, the feature should be invisible … … 55 56 // at this scale, the feature should be invisible 56 57 createdStyle = style.createStyle(feature); 57 58 t.eq(createdStyle.display, "none", "Feature is invisible at scale "+map.getScale()); 58 t.eq(createdStyle.fillColor, "green", "Point symbolizer from rule for fid=\"1\"applied correctly.");59 t.eq(createdStyle.fillColor, baseStyle.fillColor, "Point symbolizer from base style applied correctly."); 59 60 60 61 feature.fid = "2"; 61 62 // now the rule should not apply
