Add and use new proj4.register function
This commit is contained in:
@@ -8,7 +8,6 @@ import EPSG3857 from './proj/EPSG3857.js';
|
||||
import EPSG4326 from './proj/EPSG4326.js';
|
||||
import Projection from './proj/Projection.js';
|
||||
import Units from './proj/Units.js';
|
||||
import _ol_proj_proj4_ from './proj/proj4.js';
|
||||
import _ol_proj_projections_ from './proj/projections.js';
|
||||
import {add as addTransformFunc, clear as clearTransformFuncs, get as getTransformFunc} from './proj/transforms.js';
|
||||
|
||||
@@ -29,23 +28,6 @@ export var METERS_PER_UNIT = Units.METERS_PER_UNIT;
|
||||
var SPHERE = new Sphere(Sphere.DEFAULT_RADIUS);
|
||||
|
||||
|
||||
/**
|
||||
* Register proj4. If not explicitly registered, it will be assumed that
|
||||
* proj4js will be loaded in the global namespace. For example in a
|
||||
* browserify ES6 environment you could use:
|
||||
*
|
||||
* import ol from 'openlayers';
|
||||
* import proj4 from 'proj4';
|
||||
* ol.proj.setProj4(proj4);
|
||||
*
|
||||
* @param {Proj4} proj4 Proj4.
|
||||
* @api
|
||||
*/
|
||||
export function setProj4(proj4) {
|
||||
_ol_proj_proj4_.set(proj4);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<number>} input Input coordinate array.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinate values.
|
||||
@@ -121,13 +103,6 @@ export function get(projectionLike) {
|
||||
} else if (typeof projectionLike === 'string') {
|
||||
var code = projectionLike;
|
||||
projection = _ol_proj_projections_.get(code);
|
||||
if (!projection) {
|
||||
var proj4js = _ol_proj_proj4_.get();
|
||||
if (typeof proj4js == 'function' && proj4js.defs(code) !== undefined) {
|
||||
projection = new Projection({code: code});
|
||||
addProjection(projection);
|
||||
}
|
||||
}
|
||||
}
|
||||
return projection;
|
||||
}
|
||||
@@ -390,24 +365,6 @@ export function equivalent(projection1, projection2) {
|
||||
export function getTransformFromProjections(sourceProjection, destinationProjection) {
|
||||
var sourceCode = sourceProjection.getCode();
|
||||
var destinationCode = destinationProjection.getCode();
|
||||
if (!transformFunc) {
|
||||
var proj4js = _ol_proj_proj4_.get();
|
||||
if (typeof proj4js == 'function') {
|
||||
var sourceDef = proj4js.defs(sourceCode);
|
||||
var destinationDef = proj4js.defs(destinationCode);
|
||||
|
||||
if (sourceDef !== undefined && destinationDef !== undefined) {
|
||||
if (sourceDef === destinationDef) {
|
||||
addEquivalentProjections([destinationProjection, sourceProjection]);
|
||||
} else {
|
||||
var proj4Transform = proj4js(destinationCode, sourceCode);
|
||||
addCoordinateTransforms(destinationProjection, sourceProjection,
|
||||
proj4Transform.forward, proj4Transform.inverse);
|
||||
}
|
||||
transformFunc = _ol_proj_transforms_.get(sourceCode, destinationCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
var transformFunc = getTransformFunc(sourceCode, destinationCode);
|
||||
if (!transformFunc) {
|
||||
transformFunc = identityTransform;
|
||||
|
||||
Reference in New Issue
Block a user