From 61f124f2144e0801278ae5bec44add2843a699cd Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 7 Feb 2008 21:06:08 +0000 Subject: [PATCH] Only write out min/max scale related properties if they are explicitly set on the layer. Thanks for slapping Safari around a bit with this on crschmidt. Works but still untested there. r=crschmidt (closes #1314) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6033 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/WMC/v1_1_0.js | 26 ++++++---- tests/Format/WMC/test_v1_1_0.html | 74 +++++++++++++++++++++++++++++ tests/list-tests.html | 1 + 3 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 tests/Format/WMC/test_v1_1_0.html diff --git a/lib/OpenLayers/Format/WMC/v1_1_0.js b/lib/OpenLayers/Format/WMC/v1_1_0.js index 0ba65b3fb5..17bd86c18d 100644 --- a/lib/OpenLayers/Format/WMC/v1_1_0.js +++ b/lib/OpenLayers/Format/WMC/v1_1_0.js @@ -89,17 +89,23 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class( ); // min/max scale denominator elements go before the 4th element in v1 - var minSD = this.createElementNS( - this.namespaces.sld, "sld:MinScaleDenominator" - ); - minSD.appendChild(this.createTextNode(layer.maxScale.toPrecision(10))); - node.insertBefore(minSD, node.childNodes[3]); + if(layer.options.resolutions || layer.options.scales || + layer.options.minResolution || layer.options.maxScale) { + var minSD = this.createElementNS( + this.namespaces.sld, "sld:MinScaleDenominator" + ); + minSD.appendChild(this.createTextNode(layer.maxScale.toPrecision(10))); + node.insertBefore(minSD, node.childNodes[3]); + } - var maxSD = this.createElementNS( - this.namespaces.sld, "sld:MaxScaleDenominator" - ); - maxSD.appendChild(this.createTextNode(layer.minScale.toPrecision(10))); - node.insertBefore(maxSD, node.childNodes[4]); + if(layer.options.resolutions || layer.options.scales || + layer.options.maxResolution || layer.options.minScale) { + var maxSD = this.createElementNS( + this.namespaces.sld, "sld:MaxScaleDenominator" + ); + maxSD.appendChild(this.createTextNode(layer.minScale.toPrecision(10))); + node.insertBefore(maxSD, node.childNodes[4]); + } return node; diff --git a/tests/Format/WMC/test_v1_1_0.html b/tests/Format/WMC/test_v1_1_0.html new file mode 100644 index 0000000000..8e43b99b85 --- /dev/null +++ b/tests/Format/WMC/test_v1_1_0.html @@ -0,0 +1,74 @@ + + + + + + +
+ + diff --git a/tests/list-tests.html b/tests/list-tests.html index bd942653f6..0495a619fa 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -31,6 +31,7 @@
  • Format/test_SLD.html
  • Format/test_WKT.html
  • Format/test_WMC.html
  • +
  • Format/WMC/test_v1_1_0.html
  • Format/test_XML.html
  • test_Icon.html
  • test_Marker.html