Generate projection transform function only when requested
This commit is contained in:
+21
-14
@@ -152,20 +152,6 @@ ol.proj.Projection = function(options) {
|
|||||||
if (options.units === undefined) {
|
if (options.units === undefined) {
|
||||||
this.units_ = def.units;
|
this.units_ = def.units;
|
||||||
}
|
}
|
||||||
var currentCode, currentDef, currentProj, proj4Transform;
|
|
||||||
for (currentCode in projections) {
|
|
||||||
currentDef = proj4js.defs(currentCode);
|
|
||||||
if (currentDef !== undefined) {
|
|
||||||
currentProj = ol.proj.get(currentCode);
|
|
||||||
if (currentDef === def) {
|
|
||||||
ol.proj.addEquivalentProjections([currentProj, this]);
|
|
||||||
} else {
|
|
||||||
proj4Transform = proj4js(currentCode, code);
|
|
||||||
ol.proj.addCoordinateTransforms(currentProj, this,
|
|
||||||
proj4Transform.forward, proj4Transform.inverse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -739,6 +725,27 @@ ol.proj.getTransformFromProjections = function(sourceProjection, destinationProj
|
|||||||
var transform;
|
var transform;
|
||||||
if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {
|
if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {
|
||||||
transform = transforms[sourceCode][destinationCode];
|
transform = transforms[sourceCode][destinationCode];
|
||||||
|
} else if (ol.ENABLE_PROJ4JS) {
|
||||||
|
var proj4js = ol.proj.proj4_ || window['proj4'];
|
||||||
|
if (typeof proj4js == 'function') {
|
||||||
|
var sourceDef = proj4js.defs(sourceCode);
|
||||||
|
var destinationDef = proj4js.defs(destinationCode);
|
||||||
|
|
||||||
|
if (sourceDef !== undefined && destinationDef !== undefined) {
|
||||||
|
if (sourceDef === destinationDef) {
|
||||||
|
ol.proj.addEquivalentProjections([destinationProjection, sourceProjection]);
|
||||||
|
} else {
|
||||||
|
var proj4Transform = proj4js(destinationCode, sourceCode);
|
||||||
|
ol.proj.addCoordinateTransforms(destinationProjection, sourceProjection,
|
||||||
|
proj4Transform.forward, proj4Transform.inverse);
|
||||||
|
}
|
||||||
|
if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {
|
||||||
|
transform = transforms[sourceCode][destinationCode];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
transform = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (transform === undefined) {
|
if (transform === undefined) {
|
||||||
ol.DEBUG && console.assert(transform !== undefined, 'transform should be defined');
|
ol.DEBUG && console.assert(transform !== undefined, 'transform should be defined');
|
||||||
|
|||||||
Reference in New Issue
Block a user