From 5a95d606f8f262dd857021e094fcc0d27e0faba9 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 24 Jun 2013 12:20:34 -0600 Subject: [PATCH 1/3] Override for clarity --- src/ol/proj/proj.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index d6fa643b4f..5622c30e95 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -143,15 +143,7 @@ ol.Projection.prototype.getUnits = function() { * @return {number} Meters. */ ol.Projection.prototype.getMetersPerUnit = function() { - var metersPerUnit; - if (!goog.isNull(this.units_)) { - metersPerUnit = ol.METERS_PER_UNIT[this.units_]; - } else { - if (this instanceof ol.Proj4jsProjection_) { - metersPerUnit = this.getProj4jsProj().to_meter; - } - } - return metersPerUnit; + return ol.METERS_PER_UNIT[this.units_]; }; @@ -231,6 +223,20 @@ ol.Proj4jsProjection_ = function(proj4jsProj, options) { goog.inherits(ol.Proj4jsProjection_, ol.Projection); +/** + * @inheritDoc + */ +ol.Proj4jsProjection_.prototype.getMetersPerUnit = function() { + var metersPerUnit; + if (!goog.isNull(this.units_)) { + metersPerUnit = ol.METERS_PER_UNIT[this.units_]; + } else { + metersPerUnit = this.getProj4jsProj().to_meter; + } + return metersPerUnit; +}; + + /** * @inheritDoc */ From 129e4d57041006f97a3c19c12c46dcef4eed0acb Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 24 Jun 2013 12:21:56 -0600 Subject: [PATCH 2/3] Fix doc bug --- src/ol/proj/proj.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 5622c30e95..7b1df3920a 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -139,8 +139,9 @@ ol.Projection.prototype.getUnits = function() { /** - * Get the amount of meters per unit of this projection. - * @return {number} Meters. + * Get the amount of meters per unit of this projection. If the projection is + * not configured with a units identifier, the return is `undefined`. + * @return {number|undefined} Meters. */ ol.Projection.prototype.getMetersPerUnit = function() { return ol.METERS_PER_UNIT[this.units_]; From bb915cbf3d34b2ec1d828a2e4f6a20445aeef32a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 24 Jun 2013 12:25:09 -0600 Subject: [PATCH 3/3] Less code Since out meters per unit conversion table is a bit spare, prefer the configured conversion. --- src/ol/proj/proj.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 7b1df3920a..a82f443bbf 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -228,11 +228,9 @@ goog.inherits(ol.Proj4jsProjection_, ol.Projection); * @inheritDoc */ ol.Proj4jsProjection_.prototype.getMetersPerUnit = function() { - var metersPerUnit; - if (!goog.isNull(this.units_)) { + var metersPerUnit = this.proj4jsProj_.to_meter; + if (!goog.isDef(metersPerUnit)) { metersPerUnit = ol.METERS_PER_UNIT[this.units_]; - } else { - metersPerUnit = this.getProj4jsProj().to_meter; } return metersPerUnit; };