Allow Proj4js to be non-global and cache test result
This commit is contained in:
+8
-10
@@ -15,6 +15,12 @@ goog.require('ol.TransformFunction');
|
|||||||
ol.ENABLE_PROJ4JS = true;
|
ol.ENABLE_PROJ4JS = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const {boolean} Have Proj4js.
|
||||||
|
*/
|
||||||
|
ol.HAVE_PROJ4JS = ol.ENABLE_PROJ4JS && typeof Proj4js == 'object';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
@@ -253,7 +259,7 @@ ol.Projection.addTransform = function(source, destination, transformFn) {
|
|||||||
*/
|
*/
|
||||||
ol.Projection.getFromCode = function(code) {
|
ol.Projection.getFromCode = function(code) {
|
||||||
var projection = ol.Projection.projections_[code];
|
var projection = ol.Projection.projections_[code];
|
||||||
if (ol.Projection.isProj4jsSupported() && !goog.isDef(projection)) {
|
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
|
||||||
projection = ol.Projection.getProj4jsProjectionFromCode_(code);
|
projection = ol.Projection.getProj4jsProjectionFromCode_(code);
|
||||||
}
|
}
|
||||||
if (!goog.isDef(projection)) {
|
if (!goog.isDef(projection)) {
|
||||||
@@ -319,7 +325,7 @@ ol.Projection.getTransform = function(source, destination) {
|
|||||||
goog.object.containsKey(transforms[sourceCode], destinationCode)) {
|
goog.object.containsKey(transforms[sourceCode], destinationCode)) {
|
||||||
transform = transforms[sourceCode][destinationCode];
|
transform = transforms[sourceCode][destinationCode];
|
||||||
}
|
}
|
||||||
if (ol.Projection.isProj4jsSupported() && !goog.isDef(transform)) {
|
if (ol.HAVE_PROJ4JS && !goog.isDef(transform)) {
|
||||||
var proj4jsSource;
|
var proj4jsSource;
|
||||||
if (source instanceof ol.Proj4jsProjection) {
|
if (source instanceof ol.Proj4jsProjection) {
|
||||||
proj4jsSource = source;
|
proj4jsSource = source;
|
||||||
@@ -373,14 +379,6 @@ ol.Projection.getTransformFromCodes = function(sourceCode, destinationCode) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean} True if Proj4js is available and enabled.
|
|
||||||
*/
|
|
||||||
ol.Projection.isProj4jsSupported = function() {
|
|
||||||
return ol.ENABLE_PROJ4JS && 'Proj4js' in goog.global;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate} point Point.
|
* @param {ol.Coordinate} point Point.
|
||||||
* @return {ol.Coordinate} Unaltered point (same reference).
|
* @return {ol.Coordinate} Unaltered point (same reference).
|
||||||
|
|||||||
Reference in New Issue
Block a user