Add getMetersPerUnit instance method to ol.Projection

This commit is contained in:
Bruno Binet
2013-03-06 10:27:50 +01:00
parent 59271ae2d8
commit 1803e7b28d

View File

@@ -33,6 +33,15 @@ 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 * 6378000 / 360;
ol.METERS_PER_UNIT[ol.ProjectionUnits.FEET] = 0.02540005080010160020;
ol.METERS_PER_UNIT[ol.ProjectionUnits.METERS] = 1;
/**
* @constructor
@@ -109,6 +118,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.
*/