Named exports for ol/proj/transforms

This commit is contained in:
Andreas Hocevar
2017-12-15 09:17:34 +01:00
parent 4fca41e83e
commit 345ce340e4
4 changed files with 29 additions and 41 deletions

View File

@@ -2,22 +2,21 @@
* @module ol/proj/transforms
*/
import _ol_obj_ from '../obj.js';
var _ol_proj_transforms_ = {};
/**
* @private
* @type {Object.<string, Object.<string, ol.TransformFunction>>}
*/
_ol_proj_transforms_.cache_ = {};
var transforms = {};
/**
* Clear the transform cache.
*/
_ol_proj_transforms_.clear = function() {
_ol_proj_transforms_.cache_ = {};
};
export function clear() {
transforms = {};
}
/**
@@ -28,15 +27,14 @@ _ol_proj_transforms_.clear = function() {
* @param {ol.proj.Projection} destination Destination.
* @param {ol.TransformFunction} transformFn Transform.
*/
_ol_proj_transforms_.add = function(source, destination, transformFn) {
export function add(source, destination, transformFn) {
var sourceCode = source.getCode();
var destinationCode = destination.getCode();
var transforms = _ol_proj_transforms_.cache_;
if (!(sourceCode in transforms)) {
transforms[sourceCode] = {};
}
transforms[sourceCode][destinationCode] = transformFn;
};
}
/**
@@ -48,17 +46,16 @@ _ol_proj_transforms_.add = function(source, destination, transformFn) {
* @param {ol.proj.Projection} destination Destination projection.
* @return {ol.TransformFunction} transformFn The unregistered transform.
*/
_ol_proj_transforms_.remove = function(source, destination) {
export function remove(source, destination) {
var sourceCode = source.getCode();
var destinationCode = destination.getCode();
var transforms = _ol_proj_transforms_.cache_;
var transform = transforms[sourceCode][destinationCode];
delete transforms[sourceCode][destinationCode];
if (_ol_obj_.isEmpty(transforms[sourceCode])) {
delete transforms[sourceCode];
}
return transform;
};
}
/**
@@ -67,12 +64,10 @@ _ol_proj_transforms_.remove = function(source, destination) {
* @param {string} destinationCode The code for the destination projection.
* @return {ol.TransformFunction|undefined} The transform function (if found).
*/
_ol_proj_transforms_.get = function(sourceCode, destinationCode) {
export function get(sourceCode, destinationCode) {
var transform;
var transforms = _ol_proj_transforms_.cache_;
if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {
transform = transforms[sourceCode][destinationCode];
}
return transform;
};
export default _ol_proj_transforms_;
}