Merge pull request #290 from bbinet/projection_stuff

Add a getMetersPerUnit instance method to ol.Projection class
This commit is contained in:
Bruno Binet
2013-03-06 08:50:47 -08:00
2 changed files with 27 additions and 1 deletions
+18
View File
@@ -33,6 +33,16 @@ ol.ProjectionUnits = {
};
/**
* @const {Object.<ol.ProjectionUnits, number>} Meters per unit lookup table.
*/
ol.METERS_PER_UNIT = {};
ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] =
2 * Math.PI * ol.sphere.NORMAL.radius / 360;
ol.METERS_PER_UNIT[ol.ProjectionUnits.FEET] = 0.3048;
ol.METERS_PER_UNIT[ol.ProjectionUnits.METERS] = 1;
/**
* @constructor
@@ -109,6 +119,14 @@ ol.Projection.prototype.getUnits = function() {
};
/**
* @return {number} Meters.
*/
ol.Projection.prototype.getMetersPerUnit = function() {
return ol.METERS_PER_UNIT[this.units_];
};
/**
* @return {string} Axis orientation.
*/