Add getMetersPerUnit instance method to ol.Projection
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user