Add ol.proj.setProj4 function

This commit is contained in:
Bart van den Eijnden
2016-01-04 14:51:19 +01:00
parent 65b90df4b8
commit cdf9a8e84d
4 changed files with 112 additions and 38 deletions

View File

@@ -221,6 +221,25 @@ describe('ol.proj', function() {
delete proj4.defs['EPSG:21781'];
});
it('can use an alternative namespace for proj4', function() {
var proj4 = window.proj4;
var proj4new = proj4;
delete window.proj4;
ol.proj.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 = ol.proj.get('EPSG:21781');
expect(proj.getCode()).to.eql('EPSG:21781');
expect(proj.getUnits()).to.eql('m');
expect(proj.getMetersPerUnit()).to.eql(1);
delete proj4new.defs['EPSG:21781'];
window.proj4 = proj4;
ol.proj.setProj4(window.proj4);
});
it('creates ol.proj.Projection instance from EPSG:3739', function() {
proj4.defs('EPSG:3739',
'+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 ' +