From 89b10da8dbb80262d6c4cf063f8b3c33b541d8b6 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Thu, 31 Jul 2008 00:00:27 +0000 Subject: [PATCH] Fix for WMC does not read/write metadataURLs. This matches the style of other similar properties in the code, and has a negligable (<5%) impact on parsing speed in Firefox/Safari. patch from bartvde, (Closes #1452) git-svn-id: http://svn.openlayers.org/trunk/openlayers@7626 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/WMC/v1.js | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/OpenLayers/Format/WMC/v1.js b/lib/OpenLayers/Format/WMC/v1.js index 089965a7c4..ddd64c4323 100644 --- a/lib/OpenLayers/Format/WMC/v1.js +++ b/lib/OpenLayers/Format/WMC/v1.js @@ -375,6 +375,19 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { } }, + /** + * Method: read_wmc_MetadataURL + */ + read_wmc_MetadataURL: function(layerInfo, node) { + var metadataURL = {}; + var links = node.getElementsByTagName("OnlineResource"); + if(links.length > 0) { + this.read_wmc_OnlineResource(metadataURL, links[0]); + } + layerInfo.options.metadataURL = metadataURL.href; + + }, + /** * Method: read_wmc_Abstract */ @@ -620,6 +633,11 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { node.appendChild(this.createElementDefaultNS( "Title", layer.name )); + + // optional MetadataURL element + if (layer.metadataURL) { + node.appendChild(this.write_wmc_MetadataURL(layer)); + } // optional FormatList element node.appendChild(this.write_wmc_FormatList(layer)); @@ -726,6 +744,25 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { return node; }, + /** + * Method: write_wmc_MetadataURL + * Create a MetadataURL node given a layer object. + * + * Parameters: + * layer - {} Layer object. + * + * Returns: + * {Element} A WMC metadataURL element node. + */ + write_wmc_MetadataURL: function(layer) { + var node = this.createElementDefaultNS("MetadataURL"); + + // required OnlineResource element + node.appendChild(this.write_wmc_OnlineResource(layer.metadataURL)); + + return node; + }, + /** * Method: write_wmc_FormatList * Create a FormatList node given a layer.