From 79aad5a1b4de17eed2eb2c353d2d49b94cbf20bb Mon Sep 17 00:00:00 2001 From: bartvde Date: Mon, 5 Oct 2009 14:30:00 +0000 Subject: [PATCH] When writing a WMC, bounds should not be rounded to a predefined precision, original patch by bbinet, r=me (closes #2242) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9703 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/WMC/v1.js | 24 ++++++++++++------------ lib/OpenLayers/Format/WMC/v1_1_0.js | 6 +++--- tests/Format/WMC/v1_1_0.html | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/OpenLayers/Format/WMC/v1.js b/lib/OpenLayers/Format/WMC/v1.js index 792389b070..550a550c5c 100644 --- a/lib/OpenLayers/Format/WMC/v1.js +++ b/lib/OpenLayers/Format/WMC/v1.js @@ -539,10 +539,10 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { node.appendChild(this.createElementDefaultNS( "BoundingBox", null, { - minx: bounds.left.toPrecision(10), - miny: bounds.bottom.toPrecision(10), - maxx: bounds.right.toPrecision(10), - maxy: bounds.top.toPrecision(10), + minx: bounds.left.toPrecision(18), + miny: bounds.bottom.toPrecision(18), + maxx: bounds.right.toPrecision(18), + maxy: bounds.top.toPrecision(18), SRS: context.projection } )); @@ -570,10 +570,10 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { this.namespaces.ol, "ol:maxExtent" ); this.setAttributes(maxExtent, { - minx: bounds.left.toPrecision(10), - miny: bounds.bottom.toPrecision(10), - maxx: bounds.right.toPrecision(10), - maxy: bounds.top.toPrecision(10) + minx: bounds.left.toPrecision(18), + miny: bounds.bottom.toPrecision(18), + maxx: bounds.right.toPrecision(18), + maxy: bounds.top.toPrecision(18) }); node.appendChild(maxExtent); } @@ -662,10 +662,10 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { this.namespaces.ol, "ol:maxExtent" ); this.setAttributes(maxExtent, { - minx: bounds.left.toPrecision(10), - miny: bounds.bottom.toPrecision(10), - maxx: bounds.right.toPrecision(10), - maxy: bounds.top.toPrecision(10) + minx: bounds.left.toPrecision(18), + miny: bounds.bottom.toPrecision(18), + maxx: bounds.right.toPrecision(18), + maxy: bounds.top.toPrecision(18) }); node.appendChild(maxExtent); diff --git a/lib/OpenLayers/Format/WMC/v1_1_0.js b/lib/OpenLayers/Format/WMC/v1_1_0.js index 53d244f374..a7dc3b28cc 100644 --- a/lib/OpenLayers/Format/WMC/v1_1_0.js +++ b/lib/OpenLayers/Format/WMC/v1_1_0.js @@ -94,7 +94,7 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class( var minSD = this.createElementNS( this.namespaces.sld, "sld:MinScaleDenominator" ); - minSD.appendChild(this.createTextNode(layer.maxScale.toPrecision(10))); + minSD.appendChild(this.createTextNode(layer.maxScale.toPrecision(16))); node.appendChild(minSD); } @@ -103,7 +103,7 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class( var maxSD = this.createElementNS( this.namespaces.sld, "sld:MaxScaleDenominator" ); - maxSD.appendChild(this.createTextNode(layer.minScale.toPrecision(10))); + maxSD.appendChild(this.createTextNode(layer.minScale.toPrecision(16))); node.appendChild(maxSD); } @@ -122,4 +122,4 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class( CLASS_NAME: "OpenLayers.Format.WMC.v1_1_0" -}); \ No newline at end of file +}); diff --git a/tests/Format/WMC/v1_1_0.html b/tests/Format/WMC/v1_1_0.html index a9b3c5f832..edc3eccf12 100644 --- a/tests/Format/WMC/v1_1_0.html +++ b/tests/Format/WMC/v1_1_0.html @@ -39,11 +39,11 @@ node = wmc.write_wmc_Layer(layer); minList = wmc.getElementsByTagNameNS(node, sldNS, "MinScaleDenominator"); t.eq(minList.length, 1, "(resolutions) node written with MinScaleDenominator"); - t.eq(layer.maxScale.toPrecision(10), wmc.getChildValue(minList[0]), + t.eq(layer.maxScale.toPrecision(16), wmc.getChildValue(minList[0]), "(resolutions) node written with correct MinScaleDenominator value"); maxList = wmc.getElementsByTagNameNS(node, sldNS, "MaxScaleDenominator"); t.eq(maxList.length, 1, "(resolutions) node written with MaxScaleDenominator"); - t.eq(layer.minScale.toPrecision(10), wmc.getChildValue(maxList[0]), + t.eq(layer.minScale.toPrecision(16), wmc.getChildValue(maxList[0]), "(resolutions) node written with correct MaxScaleDenominator value"); layer = new OpenLayers.Layer.WMS( @@ -56,11 +56,11 @@ minList = wmc.getElementsByTagNameNS(node, sldNS, "MinScaleDenominator"); var f = new OpenLayers.Format.XML(); t.eq(minList.length, 1, "(scales) node written with MinScaleDenominator"); - t.eq(layer.maxScale.toPrecision(10), wmc.getChildValue(minList[0]), + t.eq(layer.maxScale.toPrecision(16), wmc.getChildValue(minList[0]), "(scales) node written with correct MinScaleDenominator value"); maxList = wmc.getElementsByTagNameNS(node, sldNS, "MaxScaleDenominator"); t.eq(maxList.length, 1, "(scales) node written with MaxScaleDenominator"); - t.eq(layer.minScale.toPrecision(10), wmc.getChildValue(maxList[0]), + t.eq(layer.minScale.toPrecision(16), wmc.getChildValue(maxList[0]), "(scales) node written with correct MaxScaleDenominator value"); layer.metadataURL = 'http://foo';