Remove static members from Units
This commit is contained in:
@@ -7,7 +7,7 @@ import {modulo} from './math.js';
|
||||
import {toEPSG4326, fromEPSG4326, PROJECTIONS as EPSG3857_PROJECTIONS} from './proj/epsg3857.js';
|
||||
import {PROJECTIONS as EPSG4326_PROJECTIONS} from './proj/epsg4326.js';
|
||||
import Projection from './proj/Projection.js';
|
||||
import Units from './proj/Units.js';
|
||||
import Units, {METERS_PER_UNIT} from './proj/Units.js';
|
||||
import * as projections from './proj/projections.js';
|
||||
import {add as addTransformFunc, clear as clearTransformFuncs, get as getTransformFunc} from './proj/transforms.js';
|
||||
|
||||
@@ -18,7 +18,7 @@ import {add as addTransformFunc, clear as clearTransformFuncs, get as getTransfo
|
||||
* @type {Object.<ol.proj.Units, number>}
|
||||
* @api
|
||||
*/
|
||||
export const METERS_PER_UNIT = Units.METERS_PER_UNIT;
|
||||
export {METERS_PER_UNIT};
|
||||
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ export function getPointResolution(projection, resolution, point, opt_units) {
|
||||
const height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));
|
||||
pointResolution = (width + height) / 2;
|
||||
const metersPerUnit = opt_units ?
|
||||
Units.METERS_PER_UNIT[opt_units] :
|
||||
METERS_PER_UNIT[opt_units] :
|
||||
projection.getMetersPerUnit();
|
||||
if (metersPerUnit !== undefined) {
|
||||
pointResolution /= metersPerUnit;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @module ol/proj/Projection
|
||||
*/
|
||||
import Units from '../proj/Units.js';
|
||||
import {METERS_PER_UNIT} from '../proj/Units.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -153,7 +153,7 @@ Projection.prototype.getUnits = function() {
|
||||
* @api
|
||||
*/
|
||||
Projection.prototype.getMetersPerUnit = function() {
|
||||
return this.metersPerUnit_ || Units.METERS_PER_UNIT[this.units_];
|
||||
return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @module ol/proj/Units
|
||||
*/
|
||||
|
||||
/**
|
||||
* Projection units: `'degrees'`, `'ft'`, `'m'`, `'pixels'`, `'tile-pixels'` or
|
||||
* `'us-ft'`.
|
||||
@@ -22,11 +23,11 @@ const Units = {
|
||||
* @type {Object.<ol.proj.Units, number>}
|
||||
* @api
|
||||
*/
|
||||
Units.METERS_PER_UNIT = {};
|
||||
export const METERS_PER_UNIT = {};
|
||||
// use the radius of the Normal sphere
|
||||
Units.METERS_PER_UNIT[Units.DEGREES] =
|
||||
2 * Math.PI * 6370997 / 360;
|
||||
Units.METERS_PER_UNIT[Units.FEET] = 0.3048;
|
||||
Units.METERS_PER_UNIT[Units.METERS] = 1;
|
||||
Units.METERS_PER_UNIT[Units.USFEET] = 1200 / 3937;
|
||||
METERS_PER_UNIT[Units.DEGREES] = 2 * Math.PI * 6370997 / 360;
|
||||
METERS_PER_UNIT[Units.FEET] = 0.3048;
|
||||
METERS_PER_UNIT[Units.METERS] = 1;
|
||||
METERS_PER_UNIT[Units.USFEET] = 1200 / 3937;
|
||||
|
||||
export default Units;
|
||||
|
||||
Reference in New Issue
Block a user