From 5964a8db60c12dfb7096cf814f17e64c75630365 Mon Sep 17 00:00:00 2001 From: bartvde Date: Fri, 7 Aug 2009 15:59:43 +0000 Subject: [PATCH] fix up sequence of elements in Web Map Context 1.1 Format when writing, thanks trondmm for the catch and initial patch, r=tschaub (closes #2174) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9614 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/WMC/v1.js | 9 ------- lib/OpenLayers/Format/WMC/v1_0_0.js | 25 +++++++++++++++++++ lib/OpenLayers/Format/WMC/v1_1_0.js | 13 ++++++++-- tests/Format/WMC/v1_1_0.html | 37 +++++++++++++++++------------ 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/lib/OpenLayers/Format/WMC/v1.js b/lib/OpenLayers/Format/WMC/v1.js index b172dbabe5..792389b070 100644 --- a/lib/OpenLayers/Format/WMC/v1.js +++ b/lib/OpenLayers/Format/WMC/v1.js @@ -641,15 +641,6 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { node.appendChild(this.write_wmc_MetadataURL(layer)); } - // optional FormatList element - node.appendChild(this.write_wmc_FormatList(layer)); - - // optional StyleList element - node.appendChild(this.write_wmc_StyleList(layer)); - - // OpenLayers specific properties go in an Extension element - node.appendChild(this.write_wmc_LayerExtension(layer)); - return node; }, diff --git a/lib/OpenLayers/Format/WMC/v1_0_0.js b/lib/OpenLayers/Format/WMC/v1_0_0.js index d0095c846d..d12f250092 100644 --- a/lib/OpenLayers/Format/WMC/v1_0_0.js +++ b/lib/OpenLayers/Format/WMC/v1_0_0.js @@ -44,6 +44,31 @@ OpenLayers.Format.WMC.v1_0_0 = OpenLayers.Class( ); }, + /** + * Method: write_wmc_Layer + * Create a Layer node given a layer object. + * + * Parameters: + * layer - {} Layer object. + * + * Returns: + * {Element} A WMC Layer element node. + */ + write_wmc_Layer: function(layer) { + var node = OpenLayers.Format.WMC.v1.prototype.write_wmc_Layer.apply( + this, [layer] + ); + + // optional FormatList element + node.appendChild(this.write_wmc_FormatList(layer)); + + // optional StyleList element + node.appendChild(this.write_wmc_StyleList(layer)); + + // OpenLayers specific properties go in an Extension element + node.appendChild(this.write_wmc_LayerExtension(layer)); + }, + CLASS_NAME: "OpenLayers.Format.WMC.v1_0_0" }); \ No newline at end of file diff --git a/lib/OpenLayers/Format/WMC/v1_1_0.js b/lib/OpenLayers/Format/WMC/v1_1_0.js index 17bd86c18d..53d244f374 100644 --- a/lib/OpenLayers/Format/WMC/v1_1_0.js +++ b/lib/OpenLayers/Format/WMC/v1_1_0.js @@ -95,7 +95,7 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class( this.namespaces.sld, "sld:MinScaleDenominator" ); minSD.appendChild(this.createTextNode(layer.maxScale.toPrecision(10))); - node.insertBefore(minSD, node.childNodes[3]); + node.appendChild(minSD); } if(layer.options.resolutions || layer.options.scales || @@ -104,8 +104,17 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class( this.namespaces.sld, "sld:MaxScaleDenominator" ); maxSD.appendChild(this.createTextNode(layer.minScale.toPrecision(10))); - node.insertBefore(maxSD, node.childNodes[4]); + node.appendChild(maxSD); } + + // optional FormatList element + node.appendChild(this.write_wmc_FormatList(layer)); + + // optional StyleList element + node.appendChild(this.write_wmc_StyleList(layer)); + + // OpenLayers specific properties go in an Extension element + node.appendChild(this.write_wmc_LayerExtension(layer)); return node; diff --git a/tests/Format/WMC/v1_1_0.html b/tests/Format/WMC/v1_1_0.html index 8e43b99b85..a9b3c5f832 100644 --- a/tests/Format/WMC/v1_1_0.html +++ b/tests/Format/WMC/v1_1_0.html @@ -1,20 +1,20 @@ - - - + + + - + layer.metadataURL = 'http://foo'; + node = wmc.write_wmc_Layer(layer); + t.eq(node.childNodes[3].localName || node.childNodes[3].nodeName.split(":").pop(), + 'MetadataURL', "MinScaleDenominator is written after MetadataURL, so third node should be MetadataURL"); + t.eq(node.childNodes[4].localName || node.childNodes[4].nodeName.split(":").pop(), + 'MinScaleDenominator', "MinScaleDenominator is written after MetadataURL, so fourth node should be MinScaleDenominator"); + + } + + + +
- - + +