From 2a30747bd9f390fd060dc933923b11be5d89ec12 Mon Sep 17 00:00:00 2001 From: pgiraud Date: Thu, 15 Jul 2010 15:01:36 +0000 Subject: [PATCH] add support for the ol:tileSize layer property in WMC, p=fvanderbiest,r=me (Closes #2740) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10491 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/Context.js | 5 +++++ lib/OpenLayers/Format/WMC.js | 2 ++ lib/OpenLayers/Format/WMC/v1.js | 16 ++++++++++++++++ tests/Format/WMC.html | 10 +++++++--- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Format/Context.js b/lib/OpenLayers/Format/Context.js index 61dc920539..72002aee4b 100644 --- a/lib/OpenLayers/Format/Context.js +++ b/lib/OpenLayers/Format/Context.js @@ -128,6 +128,11 @@ OpenLayers.Format.Context = OpenLayers.Class({ opacity: layerContext.opacity, displayInLayerSwitcher: layerContext.displayInLayerSwitcher, singleTile: layerContext.singleTile, + tileSize: (layerContext.tileSize) ? + new OpenLayers.Size( + layerContext.tileSize.width, + layerContext.tileSize.height + ) : undefined, minScale: layerContext.minScale || layerContext.maxScaleDenominator, maxScale: layerContext.maxScale || layerContext.minScaleDenominator }; diff --git a/lib/OpenLayers/Format/WMC.js b/lib/OpenLayers/Format/WMC.js index 40722843b1..72733fdfbf 100644 --- a/lib/OpenLayers/Format/WMC.js +++ b/lib/OpenLayers/Format/WMC.js @@ -75,6 +75,8 @@ OpenLayers.Format.WMC = OpenLayers.Class(OpenLayers.Format.Context, { opacity: layer.opacity, displayInLayerSwitcher: layer.displayInLayerSwitcher, singleTile: layer.singleTile, + tileSize: (layer.singleTile || !layer.tileSize) ? + undefined : {width: layer.tileSize.w, height: layer.tileSize.h}, minScale : (layer.options.resolutions || layer.options.scales || layer.options.maxResolution || diff --git a/lib/OpenLayers/Format/WMC/v1.js b/lib/OpenLayers/Format/WMC/v1.js index edb346f88b..6ae657d31a 100644 --- a/lib/OpenLayers/Format/WMC/v1.js +++ b/lib/OpenLayers/Format/WMC/v1.js @@ -231,6 +231,14 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { layerContext.singleTile = (this.getChildValue(node) == "true"); }, + /** + * Method: read_ol_tileSize + */ + read_ol_tileSize: function(layerContext, node) { + var obj = {"width": node.getAttribute("width"), "height": node.getAttribute("height")}; + layerContext.tileSize = obj; + }, + /** * Method: read_ol_isBaseLayer */ @@ -618,6 +626,14 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { }); node.appendChild(maxExtent); + if (context.tileSize && !context.singleTile) { + var size = this.createElementNS( + this.namespaces.ol, "ol:tileSize" + ); + this.setAttributes(size, context.tileSize); + node.appendChild(size); + } + var properties = [ "transparent", "numZoomLevels", "units", "isBaseLayer", "opacity", "displayInLayerSwitcher", "singleTile" diff --git a/tests/Format/WMC.html b/tests/Format/WMC.html index 52e4f662bc..218d9f6508 100644 --- a/tests/Format/WMC.html +++ b/tests/Format/WMC.html @@ -3,11 +3,11 @@