Add and use new proj4.register function

This commit is contained in:
Andreas Hocevar
2017-12-15 18:47:51 +01:00
parent 345ce340e4
commit 9f1ebbb852
20 changed files with 195 additions and 138 deletions

View File

@@ -1,5 +1,36 @@
## Upgrade notes ## Upgrade notes
### Next release
#### Changes in proj4 integration
Because relying on a globally available proj4 is not practical with ES modules, we have made a change to the way we integrate proj4:
* The `setProj4()` function from the `ol/proj` module was removed.
* A new `ol/proj/proj4` module with a `register()` function was added. Regardless of whether the application imports `proj4` or uses a global `proj4`, this function needs to be called with the proj4 instance as argument whenever projection definitions were added to proj4's registry with (`proj4.defs`).
It is also recommended to no longer use a global `proj4`. Instead,
npm install proj4
and import it:
```js
import proj4 from 'proj4';
```
Applications can be updated by importing the `register` function from the `ol/proj/proj4` module
```js
import {register} from 'ol/proj/proj4'
```
and calling it before using projections, and any time the proj4 registry was changed by `proj4.defs()` calls:
```js
register(proj4);
```
### v4.6.0 ### v4.6.0
#### Renamed `exceedLength` option of `ol.style.Text` to `overflow` #### Renamed `exceedLength` option of `ol.style.Text` to `overflow`

View File

@@ -3,6 +3,7 @@ import _ol_View_ from '../src/ol/View.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import {get as getProjection, getTransform} from '../src/ol/proj.js'; import {get as getProjection, getTransform} from '../src/ol/proj.js';
import {register} from '../src/ol/proj/proj4.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_TileImage_ from '../src/ol/source/TileImage.js'; import _ol_source_TileImage_ from '../src/ol/source/TileImage.js';
@@ -42,6 +43,7 @@ function setProjection(code, name, proj4def, bbox) {
var newProjCode = 'EPSG:' + code; var newProjCode = 'EPSG:' + code;
proj4.defs(newProjCode, proj4def); proj4.defs(newProjCode, proj4def);
register(proj4);
var newProj = getProjection(newProjCode); var newProj = getProjection(newProjCode);
var fromLonLat = getTransform('EPSG:4326', newProj); var fromLonLat = getTransform('EPSG:4326', newProj);

View File

@@ -5,7 +5,5 @@ shortdesc: Demonstrates client-side reprojection of single image source.
docs: > docs: >
This example shows client-side reprojection of single image source. This example shows client-side reprojection of single image source.
tags: "reprojection, projection, proj4js, image, imagestatic" tags: "reprojection, projection, proj4js, image, imagestatic"
resources:
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js
--- ---
<div id="map" class="map"></div> <div id="map" class="map"></div>

View File

@@ -6,12 +6,15 @@ import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import {transform} from '../src/ol/proj.js'; import {transform} from '../src/ol/proj.js';
import _ol_source_ImageStatic_ from '../src/ol/source/ImageStatic.js'; import _ol_source_ImageStatic_ from '../src/ol/source/ImageStatic.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import {register} from '../src/ol/proj/proj4.js';
import proj4 from 'proj4';
proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' + proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' +
'+x_0=400000 +y_0=-100000 +ellps=airy ' + '+x_0=400000 +y_0=-100000 +ellps=airy ' +
'+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' + '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
'+units=m +no_defs'); '+units=m +no_defs');
register(proj4);
var imageExtent = [0, 0, 700000, 1300000]; var imageExtent = [0, 0, 700000, 1300000];
var map = new _ol_Map_({ var map = new _ol_Map_({

View File

@@ -4,6 +4,7 @@ import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js'; import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import {get as getProjection} from '../src/ol/proj.js'; import {get as getProjection} from '../src/ol/proj.js';
import {register} from '../src/ol/proj/proj4.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_TileImage_ from '../src/ol/source/TileImage.js'; import _ol_source_TileImage_ from '../src/ol/source/TileImage.js';
import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js';
@@ -16,38 +17,40 @@ proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' +
'+x_0=400000 +y_0=-100000 +ellps=airy ' + '+x_0=400000 +y_0=-100000 +ellps=airy ' +
'+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' + '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
'+units=m +no_defs'); '+units=m +no_defs');
var proj27700 = getProjection('EPSG:27700');
proj27700.setExtent([0, 0, 700000, 1300000]);
proj4.defs('EPSG:23032', '+proj=utm +zone=32 +ellps=intl ' + proj4.defs('EPSG:23032', '+proj=utm +zone=32 +ellps=intl ' +
'+towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs'); '+towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs');
var proj23032 = getProjection('EPSG:23032');
proj23032.setExtent([-1206118.71, 4021309.92, 1295389.00, 8051813.28]);
proj4.defs('EPSG:5479', '+proj=lcc +lat_1=-76.66666666666667 +lat_2=' + proj4.defs('EPSG:5479', '+proj=lcc +lat_1=-76.66666666666667 +lat_2=' +
'-79.33333333333333 +lat_0=-78 +lon_0=163 +x_0=7000000 +y_0=5000000 ' + '-79.33333333333333 +lat_0=-78 +lon_0=163 +x_0=7000000 +y_0=5000000 ' +
'+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'); '+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
var proj5479 = getProjection('EPSG:5479');
proj5479.setExtent([6825737.53, 4189159.80, 9633741.96, 5782472.71]);
proj4.defs('EPSG:21781', '+proj=somerc +lat_0=46.95240555555556 ' + proj4.defs('EPSG:21781', '+proj=somerc +lat_0=46.95240555555556 ' +
'+lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs'); '+towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs');
proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 ' +
'+x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
proj4.defs('EPSG:2163', '+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 ' +
'+a=6370997 +b=6370997 +units=m +no_defs');
proj4.defs('ESRI:54009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 ' +
'+units=m +no_defs');
register(proj4);
var proj27700 = getProjection('EPSG:27700');
proj27700.setExtent([0, 0, 700000, 1300000]);
var proj23032 = getProjection('EPSG:23032');
proj23032.setExtent([-1206118.71, 4021309.92, 1295389.00, 8051813.28]);
var proj5479 = getProjection('EPSG:5479');
proj5479.setExtent([6825737.53, 4189159.80, 9633741.96, 5782472.71]);
var proj21781 = getProjection('EPSG:21781'); var proj21781 = getProjection('EPSG:21781');
proj21781.setExtent([485071.54, 75346.36, 828515.78, 299941.84]); proj21781.setExtent([485071.54, 75346.36, 828515.78, 299941.84]);
proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 ' +
'+x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
var proj3413 = getProjection('EPSG:3413'); var proj3413 = getProjection('EPSG:3413');
proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]); proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]);
proj4.defs('EPSG:2163', '+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 ' +
'+a=6370997 +b=6370997 +units=m +no_defs');
var proj2163 = getProjection('EPSG:2163'); var proj2163 = getProjection('EPSG:2163');
proj2163.setExtent([-8040784.5135, -2577524.9210, 3668901.4484, 4785105.1096]); proj2163.setExtent([-8040784.5135, -2577524.9210, 3668901.4484, 4785105.1096]);
proj4.defs('ESRI:54009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 ' +
'+units=m +no_defs');
var proj54009 = getProjection('ESRI:54009'); var proj54009 = getProjection('ESRI:54009');
proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]); proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]);

View File

@@ -3,6 +3,7 @@ import _ol_View_ from '../src/ol/View.js';
import ScaleLine from '../src/ol/control/ScaleLine.js'; import ScaleLine from '../src/ol/control/ScaleLine.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import {fromLonLat, transformExtent} from '../src/ol/proj.js'; import {fromLonLat, transformExtent} from '../src/ol/proj.js';
import {register} from '../src/ol/proj/proj4.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' + proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' +
@@ -14,6 +15,7 @@ proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' +
'PARAMETER["central_meridian",-85.66666666666670],' + 'PARAMETER["central_meridian",-85.66666666666670],' +
'PARAMETER["latitude_of_origin",37.50000000000000],' + 'PARAMETER["latitude_of_origin",37.50000000000000],' +
'UNIT["Foot_US",0.30480060960122]]'); 'UNIT["Foot_US",0.30480060960122]]');
register(proj4);
var map = new _ol_Map_({ var map = new _ol_Map_({
layers: [ layers: [

View File

@@ -5,10 +5,12 @@ import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import {register} from '../src/ol/proj/proj4.js';
proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' + proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' +
'+b=6371000 +units=m +no_defs'); '+b=6371000 +units=m +no_defs');
register(proj4);
// Configure the Sphere Mollweide projection object with an extent, // Configure the Sphere Mollweide projection object with an extent,
// and a world extent. These are required for the Graticule. // and a world extent. These are required for the Graticule.

View File

@@ -141,7 +141,15 @@ ExampleBuilder.prototype.render = async function(dir, chunk) {
// add in script tag // add in script tag
const jsName = `${name}.js`; const jsName = `${name}.js`;
let jsSource = chunk.modules[0].source; const jsPath = path.join(dir, jsName);
let jsSource;
for (let i = 0, ii = chunk.modules.length; i < ii; ++i) {
const module = chunk.modules[i];
if (module.identifier == jsPath) {
jsSource = module.source;
break;
}
}
if (data.cloak) { if (data.cloak) {
for (const key in data.cloak) { for (const key in data.cloak) {
jsSource = jsSource.replace(new RegExp(key, 'g'), data.cloak[key]); jsSource = jsSource.replace(new RegExp(key, 'g'), data.cloak[key]);

View File

@@ -6,6 +6,7 @@ import _ol_layer_Image_ from '../src/ol/layer/Image.js';
import {fromLonLat} from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js'; import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
import {register} from '../src/ol/proj/proj4.js';
// Transparent Proj4js support: // Transparent Proj4js support:
@@ -23,6 +24,8 @@ import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
// create an ol.proj.Projection instance. ol.proj.get() will take care of it // create an ol.proj.Projection instance. ol.proj.get() will take care of it
// internally. // internally.
register(proj4);
var projection = new _ol_proj_Projection_({ var projection = new _ol_proj_Projection_({
code: 'EPSG:21781', code: 'EPSG:21781',
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864] extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]

View File

@@ -8,7 +8,6 @@ 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_proj4_ from './proj/proj4.js';
import _ol_proj_projections_ from './proj/projections.js'; import _ol_proj_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';
@@ -29,23 +28,6 @@ export var METERS_PER_UNIT = Units.METERS_PER_UNIT;
var SPHERE = new Sphere(Sphere.DEFAULT_RADIUS); 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>} input Input coordinate array.
* @param {Array.<number>=} opt_output Output array of coordinate values. * @param {Array.<number>=} opt_output Output array of coordinate values.
@@ -121,13 +103,6 @@ export function get(projectionLike) {
} else if (typeof projectionLike === 'string') { } else if (typeof projectionLike === 'string') {
var code = projectionLike; var code = projectionLike;
projection = _ol_proj_projections_.get(code); 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; return projection;
} }
@@ -390,24 +365,6 @@ export function equivalent(projection1, projection2) {
export function getTransformFromProjections(sourceProjection, destinationProjection) { export function getTransformFromProjections(sourceProjection, destinationProjection) {
var sourceCode = sourceProjection.getCode(); var sourceCode = sourceProjection.getCode();
var destinationCode = destinationProjection.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); var transformFunc = getTransformFunc(sourceCode, destinationCode);
if (!transformFunc) { if (!transformFunc) {
transformFunc = identityTransform; transformFunc = identityTransform;

View File

@@ -2,7 +2,6 @@
* @module ol/proj/Projection * @module ol/proj/Projection
*/ */
import _ol_proj_Units_ from '../proj/Units.js'; import _ol_proj_Units_ from '../proj/Units.js';
import _ol_proj_proj4_ from '../proj/proj4.js';
/** /**
* @classdesc * @classdesc
@@ -105,23 +104,6 @@ var _ol_proj_Projection_ = function(options) {
* @type {number|undefined} * @type {number|undefined}
*/ */
this.metersPerUnit_ = options.metersPerUnit; this.metersPerUnit_ = options.metersPerUnit;
var code = options.code;
var proj4js = _ol_proj_proj4_.get();
if (typeof proj4js == 'function') {
var def = proj4js.defs(code);
if (def !== undefined) {
if (def.axis !== undefined && options.axisOrientation === undefined) {
this.axisOrientation_ = def.axis;
}
if (options.metersPerUnit === undefined) {
this.metersPerUnit_ = def.to_meter;
}
if (options.units === undefined) {
this.units_ = def.units;
}
}
}
}; };

View File

@@ -21,15 +21,14 @@
* for the required projections. These definitions can be obtained from * for the required projections. These definitions can be obtained from
* {@link https://epsg.io/}, and are a JS function, so can be loaded in a script * {@link https://epsg.io/}, and are a JS function, so can be loaded in a script
* tag (as in the examples) or pasted into your application. * tag (as in the examples) or pasted into your application.
* The first time there is a request for a projection, either with a *
* {@link ol.proj.projectionLike} or directly with {@link ol.proj.get}, the * After all required projection definitions are added to proj4's registry (by
* code will check if the Proj4js library and the necessary definition are * using `proj4.defs()`), simply call `register(proj4)` from the `ol/proj/proj4`
* loaded; if so, it will register the appropriate {@link ol.proj.Projection} * package. Existing transforms are not changed by this function. See
* object and add transform functions between the new projection and all the * examples/wms-image-custom-proj for an example of this.
* existing ones. See examples/wms-image-custom-proj for an example of this. *
* Because the check for presence of the Proj4js library and the definition only * Additional projection definitions can be registered with `proj4.defs()` any
* takes place on the first request for them, this means they can be loaded * time. Just make sure to call `register(proj4)` again; for example, with user-supplied data where you don't
* dynamically as needed; for example, with user-supplied data where you don't
* know in advance what projections are needed, you can initially load minimal * know in advance what projections are needed, you can initially load minimal
* support and then load whichever are requested. * support and then load whichever are requested.
* *

View File

@@ -1,30 +1,51 @@
/** /**
* @module ol/proj/proj4 * @module ol/proj/proj4
*/ */
var _ol_proj_proj4_ = {}; import {addCoordinateTransforms, addProjection, addEquivalentProjections, get} from '../proj.js';
import {get as getTransform} from './transforms.js';
import Projection from './Projection.js';
/** /**
* @private * Make projections defined in proj4 (with `proj4.defs()`) available in
* @type {Proj4} * OpenLayers.
*
* This function should be called whenever changes are made to the proj4
* registry, e.g. after calling `proj4.defs()`. Existing transforms will not be
* modified by this function.
*
* @param {?} proj4 Proj4.
* @api
*/ */
_ol_proj_proj4_.cache_ = null; export function register(proj4) {
var projCodes = Object.keys(proj4.defs);
var len = projCodes.length;
/** var i, j;
* Store the proj4 function. for (i = 0; i < len; ++i) {
* @param {Proj4} proj4 The proj4 function. var code = projCodes[i];
*/ if (!get(code)) {
_ol_proj_proj4_.set = function(proj4) { var def = proj4.defs(code);
_ol_proj_proj4_.cache_ = proj4; addProjection(new Projection({
}; code: code,
axisOrientation: def.axis,
metersPerUnit: def.to_meter,
/** units: def.units
* Get proj4. }));
* @return {Proj4} The proj4 function set above or available globally. }
*/ }
_ol_proj_proj4_.get = function() { for (i = 0; i < len; ++i) {
return _ol_proj_proj4_.cache_ || window['proj4']; var code1 = projCodes[i];
}; var proj1 = get(code1);
export default _ol_proj_proj4_; for (j = 0; j < len; ++j) {
var code2 = projCodes[j];
var proj2 = get(code2);
if (!getTransform(code1, code2)) {
if (proj4.defs[code1] === proj4.defs[code2]) {
addEquivalentProjections([proj1, proj2]);
} else {
var transform = proj4(code1, code2);
addCoordinateTransforms(proj1, proj2, transform.forward, transform.inverse);
}
}
}
}
}

View File

@@ -4,6 +4,7 @@ import {get as getProjection} from '../../../../src/ol/proj.js';
import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js';
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
import {register} from '../../../../src/ol/proj/proj4.js';
describe('ol.rendering.reproj.Tile', function() { describe('ol.rendering.reproj.Tile', function() {
@@ -58,6 +59,7 @@ describe('ol.rendering.reproj.Tile', function() {
proj4.defs('EPSG:5070', proj4.defs('EPSG:5070',
'+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 ' + '+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 ' +
'+y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'); '+y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
register(proj4);
var proj5070 = getProjection('EPSG:5070'); var proj5070 = getProjection('EPSG:5070');
proj5070.setExtent([-6e6, 0, 4e6, 6e6]); proj5070.setExtent([-6e6, 0, 4e6, 6e6]);
@@ -69,6 +71,7 @@ describe('ol.rendering.reproj.Tile', function() {
it('to ESRI:54009', function(done) { it('to ESRI:54009', function(done) {
proj4.defs('ESRI:54009', proj4.defs('ESRI:54009',
'+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
register(proj4);
var proj54009 = getProjection('ESRI:54009'); var proj54009 = getProjection('ESRI:54009');
proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]); proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]);
@@ -96,6 +99,7 @@ describe('ol.rendering.reproj.Tile', function() {
proj4.defs('EPSG:3740', proj4.defs('EPSG:3740',
'+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 ' + '+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 ' +
'+units=m +no_defs'); '+units=m +no_defs');
register(proj4);
var proj3740 = getProjection('EPSG:3740'); var proj3740 = getProjection('EPSG:3740');
proj3740.setExtent([318499.05, 2700792.39, 4359164.89, 7149336.98]); proj3740.setExtent([318499.05, 2700792.39, 4359164.89, 7149336.98]);
@@ -158,6 +162,7 @@ describe('ol.rendering.reproj.Tile', function() {
it('wraps X when prime meridian is shifted', function(done) { it('wraps X when prime meridian is shifted', function(done) {
proj4.defs('merc_180', '+proj=merc +lon_0=180 +units=m +no_defs'); proj4.defs('merc_180', '+proj=merc +lon_0=180 +units=m +no_defs');
register(proj4);
var proj_ = getProjection('merc_180'); var proj_ = getProjection('merc_180');
proj_.setExtent([-20026376.39, -20048966.10, 20026376.39, 20048966.10]); proj_.setExtent([-20026376.39, -20048966.10, 20026376.39, 20048966.10]);
@@ -169,6 +174,7 @@ describe('ol.rendering.reproj.Tile', function() {
it('displays north pole correctly (EPSG:3413)', function(done) { it('displays north pole correctly (EPSG:3413)', function(done) {
proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 ' + proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 ' +
'+k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); '+k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
register(proj4);
var proj3413 = getProjection('EPSG:3413'); var proj3413 = getProjection('EPSG:3413');
proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]); proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]);

View File

@@ -7,7 +7,8 @@ import MultiLineString from '../../../../src/ol/geom/MultiLineString.js';
import MultiPoint from '../../../../src/ol/geom/MultiPoint.js'; import MultiPoint from '../../../../src/ol/geom/MultiPoint.js';
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js'; import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
import Polygon from '../../../../src/ol/geom/Polygon.js'; import Polygon from '../../../../src/ol/geom/Polygon.js';
import {transform} from '../../../../src/ol/proj.js'; import {addCommon, clearAllProjections, transform} from '../../../../src/ol/proj.js';
import {register} from '../../../../src/ol/proj/proj4.js';
import _ol_xml_ from '../../../../src/ol/xml.js'; import _ol_xml_ from '../../../../src/ol/xml.js';
describe('ol.format.WFS', function() { describe('ol.format.WFS', function() {
@@ -36,6 +37,7 @@ describe('ol.format.WFS', function() {
before(function(done) { before(function(done) {
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326')); proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'));
register(proj4);
afterLoadText('spec/ol/format/wfs/topp-states-wfs.xml', function(data) { afterLoadText('spec/ol/format/wfs/topp-states-wfs.xml', function(data) {
try { try {
xml = data; xml = data;
@@ -47,6 +49,12 @@ describe('ol.format.WFS', function() {
}); });
}); });
after(function() {
delete proj4.defs['urn:x-ogc:def:crs:EPSG:4326'];
clearAllProjections();
addCommon();
});
it('creates 3 features', function() { it('creates 3 features', function() {
expect(features).to.have.length(3); expect(features).to.have.length(3);
}); });
@@ -85,6 +93,7 @@ describe('ol.format.WFS', function() {
before(function(done) { before(function(done) {
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326')); proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'));
register(proj4);
afterLoadText('spec/ol/format/wfs/polygonv2.xml', function(data) { afterLoadText('spec/ol/format/wfs/polygonv2.xml', function(data) {
try { try {
xml = data; xml = data;
@@ -96,6 +105,12 @@ describe('ol.format.WFS', function() {
}); });
}); });
after(function() {
delete proj4.defs['urn:x-ogc:def:crs:EPSG:4326'];
clearAllProjections();
addCommon();
});
it('creates 3 features', function() { it('creates 3 features', function() {
expect(features).to.have.length(3); expect(features).to.have.length(3);
}); });
@@ -153,6 +168,7 @@ describe('ol.format.WFS', function() {
'+lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 ' + '+lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 ' +
'+ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,' + '+ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,' +
'-1.8774,4.0725 +units=m +no_defs'); '-1.8774,4.0725 +units=m +no_defs');
register(proj4);
afterLoadText('spec/ol/format/wfs/boundedBy.xml', afterLoadText('spec/ol/format/wfs/boundedBy.xml',
function(xml) { function(xml) {
try { try {

View File

@@ -1,4 +1,6 @@
import _ol_format_WMSGetFeatureInfo_ from '../../../../src/ol/format/WMSGetFeatureInfo.js'; import _ol_format_WMSGetFeatureInfo_ from '../../../../src/ol/format/WMSGetFeatureInfo.js';
import {addCommon, clearAllProjections} from '../../../../src/ol/proj.js';
import {register} from '../../../../src/ol/proj/proj4.js';
describe('ol.format.WMSGetFeatureInfo', function() { describe('ol.format.WMSGetFeatureInfo', function() {
@@ -27,6 +29,7 @@ describe('ol.format.WMSGetFeatureInfo', function() {
before(function(done) { before(function(done) {
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326')); proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'));
register(proj4);
afterLoadText('spec/ol/format/wms/getfeatureinfo.xml', function(data) { afterLoadText('spec/ol/format/wms/getfeatureinfo.xml', function(data) {
try { try {
features = new _ol_format_WMSGetFeatureInfo_().readFeatures(data); features = new _ol_format_WMSGetFeatureInfo_().readFeatures(data);
@@ -38,7 +41,9 @@ describe('ol.format.WMSGetFeatureInfo', function() {
}); });
after(function() { after(function() {
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', undefined); delete proj4.defs['urn:x-ogc:def:crs:EPSG:4326'];
clearAllProjections();
addCommon();
}); });
it('creates 3 features', function() { it('creates 3 features', function() {

View File

@@ -1,6 +1,5 @@
import { import {
addCommon, addCommon,
setProj4,
clearAllProjections, clearAllProjections,
equivalent, equivalent,
get as getProjection, get as getProjection,
@@ -12,6 +11,7 @@ import {
getPointResolution, getPointResolution,
getTransformFromProjections getTransformFromProjections
} from '../../../src/ol/proj.js'; } from '../../../src/ol/proj.js';
import {register} from '../../../src/ol/proj/proj4.js';
import _ol_proj_EPSG3857_ from '../../../src/ol/proj/EPSG3857.js'; import _ol_proj_EPSG3857_ from '../../../src/ol/proj/EPSG3857.js';
import _ol_proj_EPSG4326_ from '../../../src/ol/proj/EPSG4326.js'; import _ol_proj_EPSG4326_ from '../../../src/ol/proj/EPSG4326.js';
import _ol_proj_Projection_ from '../../../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../../../src/ol/proj/Projection.js';
@@ -277,12 +277,10 @@ describe('ol.proj', function() {
describe('Proj4js integration', function() { describe('Proj4js integration', function() {
var proj4 = window.proj4;
afterEach(function() { afterEach(function() {
delete proj4.defs['EPSG:21781']; delete proj4.defs['EPSG:21781'];
window.proj4 = proj4; clearAllProjections();
setProj4(window.proj4); addCommon();
}); });
it('creates ol.proj.Projection instance from EPSG:21781', function() { it('creates ol.proj.Projection instance from EPSG:21781', function() {
@@ -290,21 +288,7 @@ describe('ol.proj', function() {
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs');
var proj = getProjection('EPSG:21781'); register(proj4);
expect(proj.getCode()).to.eql('EPSG:21781');
expect(proj.getUnits()).to.eql('m');
expect(proj.getMetersPerUnit()).to.eql(1);
});
it('can use an alternative namespace for proj4', function() {
var proj4 = window.proj4;
var proj4new = proj4;
delete window.proj4;
setProj4(proj4new);
proj4new.defs('EPSG:21781',
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs');
var proj = getProjection('EPSG:21781'); var proj = getProjection('EPSG:21781');
expect(proj.getCode()).to.eql('EPSG:21781'); expect(proj.getCode()).to.eql('EPSG:21781');
expect(proj.getUnits()).to.eql('m'); expect(proj.getUnits()).to.eql('m');
@@ -316,6 +300,7 @@ describe('ol.proj', function() {
'+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 ' + '+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 ' +
'+x_0=800000.0000101599 +y_0=99999.99998983997 +ellps=GRS80 ' + '+x_0=800000.0000101599 +y_0=99999.99998983997 +ellps=GRS80 ' +
'+towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs'); '+towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs');
register(proj4);
var proj = getProjection('EPSG:3739'); var proj = getProjection('EPSG:3739');
expect(proj.getCode()).to.eql('EPSG:3739'); expect(proj.getCode()).to.eql('EPSG:3739');
expect(proj.getUnits()).to.eql('us-ft'); expect(proj.getUnits()).to.eql('us-ft');
@@ -325,6 +310,7 @@ describe('ol.proj', function() {
}); });
it('allows Proj4js projections to be used transparently', function() { it('allows Proj4js projections to be used transparently', function() {
register(proj4);
var point = transform( var point = transform(
[-626172.13571216376, 6887893.4928337997], 'GOOGLE', 'WGS84'); [-626172.13571216376, 6887893.4928337997], 'GOOGLE', 'WGS84');
expect(point[0]).to.roughlyEqual(-5.625, 1e-9); expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
@@ -336,6 +322,7 @@ describe('ol.proj', function() {
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs');
register(proj4);
var point = transform([7.439583333333333, 46.95240555555556], var point = transform([7.439583333333333, 46.95240555555556],
'EPSG:4326', 'EPSG:21781'); 'EPSG:4326', 'EPSG:21781');
expect(point[0]).to.roughlyEqual(600072.300, 1); expect(point[0]).to.roughlyEqual(600072.300, 1);
@@ -347,6 +334,7 @@ describe('ol.proj', function() {
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs');
register(proj4);
var lonLat = [7.439583333333333, 46.95240555555556]; var lonLat = [7.439583333333333, 46.95240555555556];
var point = fromLonLat(lonLat, 'EPSG:21781'); var point = fromLonLat(lonLat, 'EPSG:21781');
expect(point[0]).to.roughlyEqual(600072.300, 1); expect(point[0]).to.roughlyEqual(600072.300, 1);
@@ -364,6 +352,7 @@ describe('ol.proj', function() {
var code = 'urn:ogc:def:crs:EPSG:21781'; var code = 'urn:ogc:def:crs:EPSG:21781';
var srsCode = 'EPSG:21781'; var srsCode = 'EPSG:21781';
proj4.defs(code, proj4.defs(srsCode)); proj4.defs(code, proj4.defs(srsCode));
register(proj4);
var proj = getProjection(code); var proj = getProjection(code);
var proj2 = getProjection(srsCode); var proj2 = getProjection(srsCode);
expect(equivalent(proj2, proj)).to.be(true); expect(equivalent(proj2, proj)).to.be(true);
@@ -371,12 +360,14 @@ describe('ol.proj', function() {
}); });
it('numerically estimates point scale at the equator', function() { it('numerically estimates point scale at the equator', function() {
register(proj4);
var googleProjection = getProjection('GOOGLE'); var googleProjection = getProjection('GOOGLE');
expect(getPointResolution(googleProjection, 1, [0, 0])). expect(getPointResolution(googleProjection, 1, [0, 0])).
to.roughlyEqual(1, 1e-1); to.roughlyEqual(1, 1e-1);
}); });
it('numerically estimates point scale at various latitudes', function() { it('numerically estimates point scale at various latitudes', function() {
register(proj4);
var epsg3857Projection = getProjection('EPSG:3857'); var epsg3857Projection = getProjection('EPSG:3857');
var googleProjection = getProjection('GOOGLE'); var googleProjection = getProjection('GOOGLE');
var point, y; var point, y;
@@ -388,6 +379,7 @@ describe('ol.proj', function() {
}); });
it('numerically estimates point scale at various points', function() { it('numerically estimates point scale at various points', function() {
register(proj4);
var epsg3857Projection = getProjection('EPSG:3857'); var epsg3857Projection = getProjection('EPSG:3857');
var googleProjection = getProjection('GOOGLE'); var googleProjection = getProjection('GOOGLE');
var point, x, y; var point, x, y;
@@ -401,6 +393,7 @@ describe('ol.proj', function() {
}); });
it('does not overwrite existing projections in the registry', function() { it('does not overwrite existing projections in the registry', function() {
register(proj4);
var epsg4326 = getProjection('EPSG:4326'); var epsg4326 = getProjection('EPSG:4326');
new _ol_proj_Projection_({ new _ol_proj_Projection_({
code: 'EPSG:4326', code: 'EPSG:4326',
@@ -414,6 +407,10 @@ describe('ol.proj', function() {
describe('ol.proj.getTransformFromProjections()', function() { describe('ol.proj.getTransformFromProjections()', function() {
beforeEach(function() {
register(proj4);
});
it('returns a transform function', function() { it('returns a transform function', function() {
var transform = getTransformFromProjections(getProjection('GOOGLE'), var transform = getTransformFromProjections(getProjection('GOOGLE'),
getProjection('EPSG:4326')); getProjection('EPSG:4326'));
@@ -442,6 +439,10 @@ describe('ol.proj', function() {
describe('ol.proj.getTransform()', function() { describe('ol.proj.getTransform()', function() {
beforeEach(function() {
register(proj4);
});
it('returns a function', function() { it('returns a function', function() {
var transform = getTransform('GOOGLE', 'EPSG:4326'); var transform = getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).to.be('function'); expect(typeof transform).to.be('function');
@@ -544,6 +545,7 @@ describe('ol.proj', function() {
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs');
register(proj4);
var got = transform([-111, 45.5, 123], 'EPSG:4326', 'custom'); var got = transform([-111, 45.5, 123], 'EPSG:4326', 'custom');
expect(got).to.have.length(3); expect(got).to.have.length(3);
@@ -552,6 +554,8 @@ describe('ol.proj', function() {
expect(got[2]).to.be(123); expect(got[2]).to.be(123);
delete proj4.defs.custom; delete proj4.defs.custom;
clearAllProjections();
addCommon();
}); });
}); });
@@ -582,6 +586,7 @@ describe('ol.proj', function() {
'PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],' + 'PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],' +
'UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],' + 'UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],' +
'AUTHORITY["EPSG","4279"]]'); 'AUTHORITY["EPSG","4279"]]');
register(proj4);
}); });
afterEach(function() { afterEach(function() {
@@ -589,6 +594,8 @@ describe('ol.proj', function() {
delete proj4.defs['EPSG:3739']; delete proj4.defs['EPSG:3739'];
delete proj4.defs['EPSG:4269']; delete proj4.defs['EPSG:4269'];
delete proj4.defs['EPSG:4279']; delete proj4.defs['EPSG:4279'];
clearAllProjections();
addCommon();
}); });
it('returns value in meters', function() { it('returns value in meters', function() {

View File

@@ -1,6 +1,7 @@
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js';
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
import {get as getProjection} from '../../../../src/ol/proj.js'; import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js';
import {register} from '../../../../src/ol/proj/proj4.js';
import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
@@ -11,12 +12,15 @@ describe('ol.reproj.Tile', function() {
'+k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy ' + '+k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy ' +
'+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' + '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
'+units=m +no_defs'); '+units=m +no_defs');
register(proj4);
var proj27700 = getProjection('EPSG:27700'); var proj27700 = getProjection('EPSG:27700');
proj27700.setExtent([0, 0, 700000, 1300000]); proj27700.setExtent([0, 0, 700000, 1300000]);
}); });
afterEach(function() { afterEach(function() {
delete proj4.defs['EPSG:27700']; delete proj4.defs['EPSG:27700'];
clearAllProjections();
addCommon();
}); });

View File

@@ -1,4 +1,5 @@
import {get as getProjection} from '../../../../src/ol/proj.js'; import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js';
import {register} from '../../../../src/ol/proj/proj4.js';
import _ol_reproj_Triangulation_ from '../../../../src/ol/reproj/Triangulation.js'; import _ol_reproj_Triangulation_ from '../../../../src/ol/reproj/Triangulation.js';
@@ -8,12 +9,15 @@ describe('ol.reproj.Triangulation', function() {
'+k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy ' + '+k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy ' +
'+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' + '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
'+units=m +no_defs'); '+units=m +no_defs');
register(proj4);
var proj27700 = getProjection('EPSG:27700'); var proj27700 = getProjection('EPSG:27700');
proj27700.setExtent([0, 0, 700000, 1300000]); proj27700.setExtent([0, 0, 700000, 1300000]);
}); });
afterEach(function() { afterEach(function() {
delete proj4.defs['EPSG:27700']; delete proj4.defs['EPSG:27700'];
clearAllProjections();
addCommon();
}); });
describe('constructor', function() { describe('constructor', function() {

View File

@@ -2,7 +2,8 @@ import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js';
import _ol_TileState_ from '../../../../src/ol/TileState.js'; import _ol_TileState_ from '../../../../src/ol/TileState.js';
import _ol_TileUrlFunction_ from '../../../../src/ol/TileUrlFunction.js'; import _ol_TileUrlFunction_ from '../../../../src/ol/TileUrlFunction.js';
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
import {get as getProjection} from '../../../../src/ol/proj.js'; import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js';
import {register} from '../../../../src/ol/proj/proj4.js';
import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js'; import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js';
@@ -131,10 +132,13 @@ describe('ol.source.TileImage', function() {
beforeEach(function() { beforeEach(function() {
proj4.defs('4326_noextentnounits', '+proj=longlat +datum=WGS84 +no_defs'); proj4.defs('4326_noextentnounits', '+proj=longlat +datum=WGS84 +no_defs');
register(proj4);
}); });
afterEach(function() { afterEach(function() {
delete proj4.defs['4326_noextentnounits']; delete proj4.defs['4326_noextentnounits'];
clearAllProjections();
addCommon();
}); });
it('can handle source projection without extent and units', function(done) { it('can handle source projection without extent and units', function(done) {