Named exports from ol/proj
This commit is contained in:
committed by
Andreas Hocevar
parent
fab77e8d37
commit
6f72ffe498
@@ -1,4 +1,17 @@
|
||||
import _ol_proj_ from '../../../src/ol/proj.js';
|
||||
import {
|
||||
addCommon,
|
||||
setProj4,
|
||||
clearAllProjections,
|
||||
equivalent,
|
||||
get as getProjection,
|
||||
transform,
|
||||
transformExtent,
|
||||
fromLonLat,
|
||||
toLonLat,
|
||||
getTransform,
|
||||
getPointResolution,
|
||||
getTransformFromProjections
|
||||
} from '../../../src/ol/proj.js';
|
||||
import _ol_proj_EPSG3857_ from '../../../src/ol/proj/EPSG3857.js';
|
||||
import _ol_proj_EPSG4326_ from '../../../src/ol/proj/EPSG4326.js';
|
||||
import _ol_proj_Projection_ from '../../../src/ol/proj/Projection.js';
|
||||
@@ -7,8 +20,8 @@ import _ol_proj_Projection_ from '../../../src/ol/proj/Projection.js';
|
||||
describe('ol.proj', function() {
|
||||
|
||||
afterEach(function() {
|
||||
_ol_proj_.clearAllProjections();
|
||||
_ol_proj_.addCommon();
|
||||
clearAllProjections();
|
||||
addCommon();
|
||||
});
|
||||
|
||||
describe('toLonLat()', function() {
|
||||
@@ -28,7 +41,7 @@ describe('ol.proj', function() {
|
||||
|
||||
cases.forEach(function(c) {
|
||||
it('works for ' + c.from.join(', '), function() {
|
||||
var lonLat = _ol_proj_.toLonLat(c.from);
|
||||
var lonLat = toLonLat(c.from);
|
||||
expect(lonLat[0]).to.roughlyEqual(c.to[0], 1e-9);
|
||||
expect(lonLat[1]).to.roughlyEqual(c.to[1], 1e-9);
|
||||
});
|
||||
@@ -38,10 +51,10 @@ describe('ol.proj', function() {
|
||||
describe('projection equivalence', function() {
|
||||
|
||||
function _testAllEquivalent(codes) {
|
||||
var projections = codes.map(_ol_proj_.get);
|
||||
var projections = codes.map(getProjection);
|
||||
projections.forEach(function(source) {
|
||||
projections.forEach(function(destination) {
|
||||
expect(_ol_proj_.equivalent(source, destination)).to.be.ok();
|
||||
expect(equivalent(source, destination)).to.be.ok();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -66,7 +79,7 @@ describe('ol.proj', function() {
|
||||
code: code
|
||||
});
|
||||
|
||||
expect(_ol_proj_.equivalent(source, destination)).to.be.ok();
|
||||
expect(equivalent(source, destination)).to.be.ok();
|
||||
});
|
||||
|
||||
it('gives that default 3857 is equivalent to self', function() {
|
||||
@@ -96,7 +109,7 @@ describe('ol.proj', function() {
|
||||
code: 'EPSG:3857',
|
||||
units: 'tile-pixels'
|
||||
});
|
||||
expect(_ol_proj_.equivalent(proj1, proj2)).to.not.be.ok();
|
||||
expect(equivalent(proj1, proj2)).to.not.be.ok();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -104,10 +117,10 @@ describe('ol.proj', function() {
|
||||
describe('identify transform', function() {
|
||||
|
||||
it('returns a new object, with same coord values', function() {
|
||||
var epsg4326 = _ol_proj_.get('EPSG:4326');
|
||||
var epsg4326 = getProjection('EPSG:4326');
|
||||
var uniqueObject = {};
|
||||
var sourcePoint = [uniqueObject, uniqueObject];
|
||||
var destinationPoint = _ol_proj_.transform(
|
||||
var destinationPoint = transform(
|
||||
sourcePoint, epsg4326, epsg4326);
|
||||
expect(sourcePoint === destinationPoint).to.not.be();
|
||||
expect(destinationPoint[0] === sourcePoint[0]).to.be.ok();
|
||||
@@ -118,7 +131,7 @@ describe('ol.proj', function() {
|
||||
describe('transform 0,0 from 4326 to 3857', function() {
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = _ol_proj_.transform([0, 0], 'EPSG:4326', 'EPSG:3857');
|
||||
var point = transform([0, 0], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(point).not.to.be(undefined);
|
||||
expect(point).not.to.be(null);
|
||||
expect(point[1]).to.roughlyEqual(0, 1e-9);
|
||||
@@ -128,7 +141,7 @@ describe('ol.proj', function() {
|
||||
describe('transform 0,0 from 3857 to 4326', function() {
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = _ol_proj_.transform([0, 0], 'EPSG:3857', 'EPSG:4326');
|
||||
var point = transform([0, 0], 'EPSG:3857', 'EPSG:4326');
|
||||
expect(point).not.to.be(undefined);
|
||||
expect(point).not.to.be(null);
|
||||
expect(point[0]).to.eql(0);
|
||||
@@ -140,7 +153,7 @@ describe('ol.proj', function() {
|
||||
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
||||
|
||||
it('returns expected value using ol.proj.transform', function() {
|
||||
var point = _ol_proj_.transform(
|
||||
var point = transform(
|
||||
[-5.625, 52.4827802220782], 'EPSG:4326', 'EPSG:900913');
|
||||
expect(point).not.to.be(undefined);
|
||||
expect(point).not.to.be(null);
|
||||
@@ -149,7 +162,7 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('returns expected value using ol.proj.fromLonLat', function() {
|
||||
var point = _ol_proj_.fromLonLat([-5.625, 52.4827802220782]);
|
||||
var point = fromLonLat([-5.625, 52.4827802220782]);
|
||||
expect(point).not.to.be(undefined);
|
||||
expect(point).not.to.be(null);
|
||||
expect(point[0]).to.roughlyEqual(-626172.13571216376, 1e-9);
|
||||
@@ -161,7 +174,7 @@ describe('ol.proj', function() {
|
||||
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
||||
|
||||
it('returns expected value using ol.proj.transform', function() {
|
||||
var point = _ol_proj_.transform([-626172.13571216376, 6887893.4928337997],
|
||||
var point = transform([-626172.13571216376, 6887893.4928337997],
|
||||
'EPSG:900913', 'EPSG:4326');
|
||||
expect(point).not.to.be(undefined);
|
||||
expect(point).not.to.be(null);
|
||||
@@ -170,7 +183,7 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('returns expected value using ol.proj.toLonLat', function() {
|
||||
var point = _ol_proj_.toLonLat([-626172.13571216376, 6887893.4928337997]);
|
||||
var point = toLonLat([-626172.13571216376, 6887893.4928337997]);
|
||||
expect(point).not.to.be(undefined);
|
||||
expect(point).not.to.be(null);
|
||||
expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
|
||||
@@ -222,7 +235,7 @@ describe('ol.proj', function() {
|
||||
|
||||
it('transforms an extent given projection identifiers', function() {
|
||||
var sourceExtent = [-15, -30, 45, 60];
|
||||
var destinationExtent = _ol_proj_.transformExtent(
|
||||
var destinationExtent = transformExtent(
|
||||
sourceExtent, 'EPSG:4326', 'EPSG:3857');
|
||||
expect(destinationExtent).not.to.be(undefined);
|
||||
expect(destinationExtent).not.to.be(null);
|
||||
@@ -237,27 +250,27 @@ describe('ol.proj', function() {
|
||||
|
||||
describe('getPointResolution()', function() {
|
||||
it('returns the correct point resolution for EPSG:4326', function() {
|
||||
var pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, [0, 0]);
|
||||
var pointResolution = getPointResolution('EPSG:4326', 1, [0, 0]);
|
||||
expect (pointResolution).to.be(1);
|
||||
pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, [0, 52]);
|
||||
pointResolution = getPointResolution('EPSG:4326', 1, [0, 52]);
|
||||
expect (pointResolution).to.be(1);
|
||||
});
|
||||
it('returns the correct point resolution for EPSG:4326 with custom units', function() {
|
||||
var pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, [0, 0], 'm');
|
||||
var pointResolution = getPointResolution('EPSG:4326', 1, [0, 0], 'm');
|
||||
expect(pointResolution).to.roughlyEqual(111195.0802335329, 1e-5);
|
||||
pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, [0, 52], 'm');
|
||||
pointResolution = getPointResolution('EPSG:4326', 1, [0, 52], 'm');
|
||||
expect(pointResolution).to.roughlyEqual(89826.53390979706, 1e-5);
|
||||
});
|
||||
it('returns the correct point resolution for EPSG:3857', function() {
|
||||
var pointResolution = _ol_proj_.getPointResolution('EPSG:3857', 1, [0, 0]);
|
||||
var pointResolution = getPointResolution('EPSG:3857', 1, [0, 0]);
|
||||
expect(pointResolution).to.be(1);
|
||||
pointResolution = _ol_proj_.getPointResolution('EPSG:3857', 1, _ol_proj_.fromLonLat([0, 52]));
|
||||
pointResolution = getPointResolution('EPSG:3857', 1, fromLonLat([0, 52]));
|
||||
expect(pointResolution).to.roughlyEqual(0.615661, 1e-5);
|
||||
});
|
||||
it('returns the correct point resolution for EPSG:3857 with custom units', function() {
|
||||
var pointResolution = _ol_proj_.getPointResolution('EPSG:3857', 1, [0, 0], 'degrees');
|
||||
var pointResolution = getPointResolution('EPSG:3857', 1, [0, 0], 'degrees');
|
||||
expect(pointResolution).to.be(1);
|
||||
pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, _ol_proj_.fromLonLat([0, 52]), 'degrees');
|
||||
pointResolution = getPointResolution('EPSG:4326', 1, fromLonLat([0, 52]), 'degrees');
|
||||
expect(pointResolution).to.be(1);
|
||||
});
|
||||
});
|
||||
@@ -269,7 +282,7 @@ describe('ol.proj', function() {
|
||||
afterEach(function() {
|
||||
delete proj4.defs['EPSG:21781'];
|
||||
window.proj4 = proj4;
|
||||
_ol_proj_.setProj4(window.proj4);
|
||||
setProj4(window.proj4);
|
||||
});
|
||||
|
||||
it('creates ol.proj.Projection instance from EPSG:21781', function() {
|
||||
@@ -277,7 +290,7 @@ describe('ol.proj', function() {
|
||||
'+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');
|
||||
var proj = getProjection('EPSG:21781');
|
||||
expect(proj.getCode()).to.eql('EPSG:21781');
|
||||
expect(proj.getUnits()).to.eql('m');
|
||||
expect(proj.getMetersPerUnit()).to.eql(1);
|
||||
@@ -287,12 +300,12 @@ describe('ol.proj', function() {
|
||||
var proj4 = window.proj4;
|
||||
var proj4new = proj4;
|
||||
delete window.proj4;
|
||||
_ol_proj_.setProj4(proj4new);
|
||||
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');
|
||||
var proj = getProjection('EPSG:21781');
|
||||
expect(proj.getCode()).to.eql('EPSG:21781');
|
||||
expect(proj.getUnits()).to.eql('m');
|
||||
expect(proj.getMetersPerUnit()).to.eql(1);
|
||||
@@ -303,7 +316,7 @@ describe('ol.proj', function() {
|
||||
'+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 ' +
|
||||
'+x_0=800000.0000101599 +y_0=99999.99998983997 +ellps=GRS80 ' +
|
||||
'+towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs');
|
||||
var proj = _ol_proj_.get('EPSG:3739');
|
||||
var proj = getProjection('EPSG:3739');
|
||||
expect(proj.getCode()).to.eql('EPSG:3739');
|
||||
expect(proj.getUnits()).to.eql('us-ft');
|
||||
expect(proj.getMetersPerUnit()).to.eql(1200 / 3937);
|
||||
@@ -312,7 +325,7 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('allows Proj4js projections to be used transparently', function() {
|
||||
var point = _ol_proj_.transform(
|
||||
var point = transform(
|
||||
[-626172.13571216376, 6887893.4928337997], 'GOOGLE', 'WGS84');
|
||||
expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
|
||||
expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9);
|
||||
@@ -323,7 +336,7 @@ describe('ol.proj', function() {
|
||||
'+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 point = _ol_proj_.transform([7.439583333333333, 46.95240555555556],
|
||||
var point = transform([7.439583333333333, 46.95240555555556],
|
||||
'EPSG:4326', 'EPSG:21781');
|
||||
expect(point[0]).to.roughlyEqual(600072.300, 1);
|
||||
expect(point[1]).to.roughlyEqual(200146.976, 1);
|
||||
@@ -335,10 +348,10 @@ describe('ol.proj', function() {
|
||||
'+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 lonLat = [7.439583333333333, 46.95240555555556];
|
||||
var point = _ol_proj_.fromLonLat(lonLat, 'EPSG:21781');
|
||||
var point = fromLonLat(lonLat, 'EPSG:21781');
|
||||
expect(point[0]).to.roughlyEqual(600072.300, 1);
|
||||
expect(point[1]).to.roughlyEqual(200146.976, 1);
|
||||
point = _ol_proj_.toLonLat(point, 'EPSG:21781');
|
||||
point = toLonLat(point, 'EPSG:21781');
|
||||
expect(point[0]).to.roughlyEqual(lonLat[0], 1);
|
||||
expect(point[1]).to.roughlyEqual(lonLat[1], 1);
|
||||
});
|
||||
@@ -351,50 +364,50 @@ describe('ol.proj', function() {
|
||||
var code = 'urn:ogc:def:crs:EPSG:21781';
|
||||
var srsCode = 'EPSG:21781';
|
||||
proj4.defs(code, proj4.defs(srsCode));
|
||||
var proj = _ol_proj_.get(code);
|
||||
var proj2 = _ol_proj_.get(srsCode);
|
||||
expect(_ol_proj_.equivalent(proj2, proj)).to.be(true);
|
||||
var proj = getProjection(code);
|
||||
var proj2 = getProjection(srsCode);
|
||||
expect(equivalent(proj2, proj)).to.be(true);
|
||||
delete proj4.defs[code];
|
||||
});
|
||||
|
||||
it('numerically estimates point scale at the equator', function() {
|
||||
var googleProjection = _ol_proj_.get('GOOGLE');
|
||||
expect(_ol_proj_.getPointResolution(googleProjection, 1, [0, 0])).
|
||||
var googleProjection = getProjection('GOOGLE');
|
||||
expect(getPointResolution(googleProjection, 1, [0, 0])).
|
||||
to.roughlyEqual(1, 1e-1);
|
||||
});
|
||||
|
||||
it('numerically estimates point scale at various latitudes', function() {
|
||||
var epsg3857Projection = _ol_proj_.get('EPSG:3857');
|
||||
var googleProjection = _ol_proj_.get('GOOGLE');
|
||||
var epsg3857Projection = getProjection('EPSG:3857');
|
||||
var googleProjection = getProjection('GOOGLE');
|
||||
var point, y;
|
||||
for (y = -20; y <= 20; ++y) {
|
||||
point = [0, 1000000 * y];
|
||||
expect(_ol_proj_.getPointResolution(googleProjection, 1, point)).to.roughlyEqual(
|
||||
_ol_proj_.getPointResolution(epsg3857Projection, 1, point), 1e-1);
|
||||
expect(getPointResolution(googleProjection, 1, point)).to.roughlyEqual(
|
||||
getPointResolution(epsg3857Projection, 1, point), 1e-1);
|
||||
}
|
||||
});
|
||||
|
||||
it('numerically estimates point scale at various points', function() {
|
||||
var epsg3857Projection = _ol_proj_.get('EPSG:3857');
|
||||
var googleProjection = _ol_proj_.get('GOOGLE');
|
||||
var epsg3857Projection = getProjection('EPSG:3857');
|
||||
var googleProjection = getProjection('GOOGLE');
|
||||
var point, x, y;
|
||||
for (x = -20; x <= 20; x += 2) {
|
||||
for (y = -20; y <= 20; y += 2) {
|
||||
point = [1000000 * x, 1000000 * y];
|
||||
expect(_ol_proj_.getPointResolution(googleProjection, 1, point)).to.roughlyEqual(
|
||||
_ol_proj_.getPointResolution(epsg3857Projection, 1, point), 1e-1);
|
||||
expect(getPointResolution(googleProjection, 1, point)).to.roughlyEqual(
|
||||
getPointResolution(epsg3857Projection, 1, point), 1e-1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('does not overwrite existing projections in the registry', function() {
|
||||
var epsg4326 = _ol_proj_.get('EPSG:4326');
|
||||
var epsg4326 = getProjection('EPSG:4326');
|
||||
new _ol_proj_Projection_({
|
||||
code: 'EPSG:4326',
|
||||
units: 'degrees',
|
||||
extent: [-45, -45, 45, 45]
|
||||
});
|
||||
expect(_ol_proj_.get('EPSG:4326')).to.equal(epsg4326);
|
||||
expect(getProjection('EPSG:4326')).to.equal(epsg4326);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -402,8 +415,8 @@ describe('ol.proj', function() {
|
||||
describe('ol.proj.getTransformFromProjections()', function() {
|
||||
|
||||
it('returns a transform function', function() {
|
||||
var transform = _ol_proj_.getTransformFromProjections(_ol_proj_.get('GOOGLE'),
|
||||
_ol_proj_.get('EPSG:4326'));
|
||||
var transform = getTransformFromProjections(getProjection('GOOGLE'),
|
||||
getProjection('EPSG:4326'));
|
||||
expect(typeof transform).to.be('function');
|
||||
|
||||
var output = transform([-12000000, 5000000]);
|
||||
@@ -413,8 +426,8 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('works for longer arrays', function() {
|
||||
var transform = _ol_proj_.getTransformFromProjections(_ol_proj_.get('GOOGLE'),
|
||||
_ol_proj_.get('EPSG:4326'));
|
||||
var transform = getTransformFromProjections(getProjection('GOOGLE'),
|
||||
getProjection('EPSG:4326'));
|
||||
expect(typeof transform).to.be('function');
|
||||
|
||||
var output = transform([-12000000, 5000000, -12000000, 5000000]);
|
||||
@@ -430,12 +443,12 @@ describe('ol.proj', function() {
|
||||
describe('ol.proj.getTransform()', function() {
|
||||
|
||||
it('returns a function', function() {
|
||||
var transform = _ol_proj_.getTransform('GOOGLE', 'EPSG:4326');
|
||||
var transform = getTransform('GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).to.be('function');
|
||||
});
|
||||
|
||||
it('returns a transform function', function() {
|
||||
var transform = _ol_proj_.getTransform('GOOGLE', 'EPSG:4326');
|
||||
var transform = getTransform('GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).to.be('function');
|
||||
|
||||
var output = transform([-626172.13571216376, 6887893.4928337997]);
|
||||
@@ -446,7 +459,7 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('works for longer arrays of coordinate values', function() {
|
||||
var transform = _ol_proj_.getTransform('GOOGLE', 'EPSG:4326');
|
||||
var transform = getTransform('GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).to.be('function');
|
||||
|
||||
var output = transform([
|
||||
@@ -464,7 +477,7 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('accepts an optional destination array', function() {
|
||||
var transform = _ol_proj_.getTransform('EPSG:3857', 'EPSG:4326');
|
||||
var transform = getTransform('EPSG:3857', 'EPSG:4326');
|
||||
var input = [-12000000, 5000000];
|
||||
var output = [];
|
||||
|
||||
@@ -478,7 +491,7 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('accepts a dimension', function() {
|
||||
var transform = _ol_proj_.getTransform('GOOGLE', 'EPSG:4326');
|
||||
var transform = getTransform('GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).to.be('function');
|
||||
|
||||
var dimension = 3;
|
||||
@@ -503,14 +516,14 @@ describe('ol.proj', function() {
|
||||
describe('ol.proj.transform()', function() {
|
||||
|
||||
it('transforms a 2d coordinate', function() {
|
||||
var got = _ol_proj_.transform([-10, -20], 'EPSG:4326', 'EPSG:3857');
|
||||
var got = transform([-10, -20], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(got).to.have.length(2);
|
||||
expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3);
|
||||
expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3);
|
||||
});
|
||||
|
||||
it('transforms a 3d coordinate', function() {
|
||||
var got = _ol_proj_.transform([-10, -20, 3], 'EPSG:4326', 'EPSG:3857');
|
||||
var got = transform([-10, -20, 3], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(got).to.have.length(3);
|
||||
expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3);
|
||||
expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3);
|
||||
@@ -518,7 +531,7 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('transforms a 4d coordinate', function() {
|
||||
var got = _ol_proj_.transform([-10, -20, 3, 4], 'EPSG:4326', 'EPSG:3857');
|
||||
var got = transform([-10, -20, 3, 4], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(got).to.have.length(4);
|
||||
expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3);
|
||||
expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3);
|
||||
@@ -532,7 +545,7 @@ describe('ol.proj', function() {
|
||||
'+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 got = _ol_proj_.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[0]).to.roughlyEqual(-6601512.194209638, 1);
|
||||
expect(got[1]).to.roughlyEqual(6145843.802742112, 1);
|
||||
@@ -579,26 +592,26 @@ describe('ol.proj', function() {
|
||||
});
|
||||
|
||||
it('returns value in meters', function() {
|
||||
var epsg4326 = _ol_proj_.get('EPSG:4326');
|
||||
var epsg4326 = getProjection('EPSG:4326');
|
||||
expect(epsg4326.getMetersPerUnit()).to.eql(
|
||||
_ol_proj_EPSG4326_.METERS_PER_UNIT);
|
||||
});
|
||||
|
||||
it('works for proj4js projections without units', function() {
|
||||
var epsg26782 = _ol_proj_.get('EPSG:26782');
|
||||
var epsg26782 = getProjection('EPSG:26782');
|
||||
expect(epsg26782.getMetersPerUnit()).to.eql(0.3048006096012192);
|
||||
});
|
||||
|
||||
it('works for proj4js projections with units other than m', function() {
|
||||
var epsg3739 = _ol_proj_.get('EPSG:3739');
|
||||
var epsg3739 = getProjection('EPSG:3739');
|
||||
expect(epsg3739.getMetersPerUnit()).to.eql(1200 / 3937);
|
||||
});
|
||||
|
||||
it('works for proj4js OGC WKT GEOGCS projections', function() {
|
||||
var epsg4269 = _ol_proj_.get('EPSG:4269');
|
||||
var epsg4269 = getProjection('EPSG:4269');
|
||||
expect(epsg4269.getMetersPerUnit()).to.eql(
|
||||
6378137 * 0.01745329251994328);
|
||||
var epsg4279 = _ol_proj_.get('EPSG:4279');
|
||||
var epsg4279 = getProjection('EPSG:4279');
|
||||
expect(epsg4279.getMetersPerUnit()).to.eql(
|
||||
6377563.396 * 0.01745329251994328);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user