From a28576d2b934cfa2027a859f89fd78fac16c35d2 Mon Sep 17 00:00:00 2001 From: oterral Date: Mon, 31 Oct 2016 11:35:31 +0100 Subject: [PATCH] Remove the use of ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_ when it's not wanted --- src/ol/format/kml.js | 12 ++---------- test/spec/ol/format/kml.test.js | 8 ++++---- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/ol/format/kml.js b/src/ol/format/kml.js index 0f38f6ecf2..5d00ab14ea 100644 --- a/src/ol/format/kml.js +++ b/src/ol/format/kml.js @@ -311,11 +311,8 @@ ol.format.KML.createNameStyleFunction_ = function(foundStyle, name) { if (imageSize === null) { imageSize = ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_; } - var imageScale = foundStyle.getImage().getScale(); - if (isNaN(imageScale)) { - imageScale = ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_; - } if (imageSize.length == 2) { + var imageScale = foundStyle.getImage().getScale(); // Offset the label to be centered to the right of the icon, if there is // one. textOffset[0] = imageScale * imageSize[0] / 2; @@ -621,11 +618,6 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { var scale = /** @type {number|undefined} */ (object['scale']); - if (isNaN(scale) || scale === undefined) { - scale = ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_; - } else { - scale = scale * ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_; - } if (drawIcon) { if (src == ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_) { @@ -2431,7 +2423,7 @@ ol.format.KML.writePolyStyle_ = function(node, style, objectStack) { ol.format.KML.writeScaleTextNode_ = function(node, scale) { // the Math is to remove any excess decimals created by float arithmetic ol.format.XSD.writeDecimalTextNode(node, - Math.round(scale * scale * 1e6) / 1e6); + Math.round(scale * 1e6) / 1e6); }; diff --git a/test/spec/ol/format/kml.test.js b/test/spec/ol/format/kml.test.js index 36f7a2aa2e..f03c22ceb9 100644 --- a/test/spec/ol/format/kml.test.js +++ b/test/spec/ol/format/kml.test.js @@ -1444,7 +1444,7 @@ describe('ol.format.KML', function() { expect(imageStyle.getOrigin()).to.be(null); expect(imageStyle.getRotation()).to.eql(0); expect(imageStyle.getSize()).to.be(null); - expect(imageStyle.getScale()).to.be(ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_); + expect(imageStyle.getScale()).to.be(1); expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -1489,7 +1489,7 @@ describe('ol.format.KML', function() { expect(imageStyle.getAnchor()).to.eql([24, 36]); expect(imageStyle.getOrigin()).to.eql([24, 108]); expect(imageStyle.getRotation()).to.eql(0); - expect(imageStyle.getScale()).to.eql(ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_ * 3.0); + expect(imageStyle.getScale()).to.eql(3.0); expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -1870,7 +1870,7 @@ describe('ol.format.KML', function() { ' ' + ' ' + ' ' +