SLD maps minScaleDenominator and maxScaleDenominator to rule minScale and maxScale. r=tschaub (closes #1297)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@5964 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2008-02-01 21:17:12 +00:00
parent 9bb51fb088
commit 4fc4c6ce4b
6 changed files with 111 additions and 44 deletions

View File

@@ -15,7 +15,7 @@
}
function test_Style_create(t) {
t.plan(5);
t.plan(10);
var map = new OpenLayers.Map("map");
@@ -27,11 +27,21 @@
var style = new OpenLayers.Style(baseStyle);
var rule = new OpenLayers.Rule.FeatureId({
var rule1 = new OpenLayers.Rule.FeatureId({
fids: ["1"],
symbolizer: {"Point": {fillColor: "green"}},
maxScale: 2000000});
style.addRules([rule]);
maxScaleDenominator: 500000});
var rule2 = new OpenLayers.Rule.FeatureId({
fids: ["1"],
symbolizer: {"Point": {fillColor: "yellow"}},
minScaleDenominator: 500000,
maxScaleDenominator: 1000000});
var rule3 = new OpenLayers.Rule.FeatureId({
fids: ["1"],
symbolizer: {"Point": {fillColor: "red"}},
minScaleDenominator: 1000000,
maxScaleDenominator: 2500000});
style.addRules([rule1, rule2, rule3]);
var feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(3,5),
@@ -45,24 +55,37 @@
map.addLayer(layer);
map.setBaseLayer(layer);
map.setCenter(new OpenLayers.LonLat(3,5), 8);
// at this scale, the feature should be visible
map.setCenter(new OpenLayers.LonLat(3,5), 10);
// at this scale, the feature should be green
var createdStyle = style.createStyle(feature);
t.eq(createdStyle.externalGraphic, "barbar.png", "Calculated property style correctly.");
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
t.eq(createdStyle.fillColor, "green", "Point symbolizer from rule applied correctly.");
map.setCenter(new OpenLayers.LonLat(3,5), 9);
// at this scale, the feature should be red
createdStyle = style.createStyle(feature);
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
t.eq(createdStyle.fillColor, "yellow", "Point symbolizer from rule applied correctly.");
map.setCenter(new OpenLayers.LonLat(3,5), 8);
// at this scale, the feature should be yellow
createdStyle = style.createStyle(feature);
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
t.eq(createdStyle.fillColor, "red", "Point symbolizer from rule applied correctly.");
map.setCenter(new OpenLayers.LonLat(3,5), 7);
// at this scale, the feature should be invisible
createdStyle = style.createStyle(feature);
t.eq(createdStyle.display, "none", "Feature is invisible at scale "+map.getScale());
t.eq(createdStyle.fillColor, "green", "Point symbolizer from rule for fid=\"1\" applied correctly.");
t.eq(createdStyle.fillColor, baseStyle.fillColor, "Point symbolizer from base style applied correctly.");
feature.fid = "2";
// now the rule should not apply
createdStyle = style.createStyle(feature);
t.eq(createdStyle.fillColor, baseStyle.fillColor, "Correct style for rule that does not apply to fid=\"2\".");
}
function test_Style_destroy(t) {