Named exports from ol/proj/projections
This commit is contained in:
@@ -8,7 +8,7 @@ import EPSG3857 from './proj/EPSG3857.js';
|
|||||||
import EPSG4326 from './proj/EPSG4326.js';
|
import EPSG4326 from './proj/EPSG4326.js';
|
||||||
import Projection from './proj/Projection.js';
|
import Projection from './proj/Projection.js';
|
||||||
import Units from './proj/Units.js';
|
import Units from './proj/Units.js';
|
||||||
import _ol_proj_projections_ from './proj/projections.js';
|
import * as projections from './proj/projections.js';
|
||||||
import {add as addTransformFunc, clear as clearTransformFuncs, get as getTransformFunc} from './proj/transforms.js';
|
import {add as addTransformFunc, clear as clearTransformFuncs, get as getTransformFunc} from './proj/transforms.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ export function identityTransform(input, opt_output, opt_dimension) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
export function addProjection(projection) {
|
export function addProjection(projection) {
|
||||||
_ol_proj_projections_.add(projection.getCode(), projection);
|
projections.add(projection.getCode(), projection);
|
||||||
addTransformFunc(projection, projection, cloneTransform);
|
addTransformFunc(projection, projection, cloneTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ export function get(projectionLike) {
|
|||||||
projection = projectionLike;
|
projection = projectionLike;
|
||||||
} else if (typeof projectionLike === 'string') {
|
} else if (typeof projectionLike === 'string') {
|
||||||
const code = projectionLike;
|
const code = projectionLike;
|
||||||
projection = _ol_proj_projections_.get(code);
|
projection = projections.get(code);
|
||||||
}
|
}
|
||||||
return projection;
|
return projection;
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ export function addEquivalentTransforms(projections1, projections2, forwardTrans
|
|||||||
* Clear all cached projections and transforms.
|
* Clear all cached projections and transforms.
|
||||||
*/
|
*/
|
||||||
export function clearAllProjections() {
|
export function clearAllProjections() {
|
||||||
_ol_proj_projections_.clear();
|
projections.clear();
|
||||||
clearTransformFuncs();
|
clearTransformFuncs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,8 +377,7 @@ export function getTransformFromProjections(sourceProjection, destinationProject
|
|||||||
export function getTransform(source, destination) {
|
export function getTransform(source, destination) {
|
||||||
const sourceProjection = get(source);
|
const sourceProjection = get(source);
|
||||||
const destinationProjection = get(destination);
|
const destinationProjection = get(destination);
|
||||||
return getTransformFromProjections(
|
return getTransformFromProjections(sourceProjection, destinationProjection);
|
||||||
sourceProjection, destinationProjection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -427,8 +426,7 @@ export function transformExtent(extent, source, destination) {
|
|||||||
* @return {ol.Coordinate} Point.
|
* @return {ol.Coordinate} Point.
|
||||||
*/
|
*/
|
||||||
export function transformWithProjections(point, sourceProjection, destinationProjection) {
|
export function transformWithProjections(point, sourceProjection, destinationProjection) {
|
||||||
const transformFunc = getTransformFromProjections(
|
const transformFunc = getTransformFromProjections(sourceProjection, destinationProjection);
|
||||||
sourceProjection, destinationProjection);
|
|
||||||
return transformFunc(point);
|
return transformFunc(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/proj/projections
|
* @module ol/proj/projections
|
||||||
*/
|
*/
|
||||||
const _ol_proj_projections_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
|
||||||
* @type {Object.<string, ol.proj.Projection>}
|
* @type {Object.<string, ol.proj.Projection>}
|
||||||
*/
|
*/
|
||||||
_ol_proj_projections_.cache_ = {};
|
let cache = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the projections cache.
|
* Clear the projections cache.
|
||||||
*/
|
*/
|
||||||
_ol_proj_projections_.clear = function() {
|
export function clear() {
|
||||||
_ol_proj_projections_.cache_ = {};
|
cache = {};
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,10 +22,9 @@ _ol_proj_projections_.clear = function() {
|
|||||||
* @param {string} code The code for the projection.
|
* @param {string} code The code for the projection.
|
||||||
* @return {ol.proj.Projection} The projection (if cached).
|
* @return {ol.proj.Projection} The projection (if cached).
|
||||||
*/
|
*/
|
||||||
_ol_proj_projections_.get = function(code) {
|
export function get(code) {
|
||||||
const projections = _ol_proj_projections_.cache_;
|
return cache[code] || null;
|
||||||
return projections[code] || null;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,8 +32,6 @@ _ol_proj_projections_.get = function(code) {
|
|||||||
* @param {string} code The projection code.
|
* @param {string} code The projection code.
|
||||||
* @param {ol.proj.Projection} projection The projection to cache.
|
* @param {ol.proj.Projection} projection The projection to cache.
|
||||||
*/
|
*/
|
||||||
_ol_proj_projections_.add = function(code, projection) {
|
export function add(code, projection) {
|
||||||
const projections = _ol_proj_projections_.cache_;
|
cache[code] = projection;
|
||||||
projections[code] = projection;
|
}
|
||||||
};
|
|
||||||
export default _ol_proj_projections_;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user