New wrapX functions for coordinate and extent
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {add as addCoordinate, scale as scaleCoordinate, rotate as rotateCoordinate, equals as coordinatesEqual, format as formatCoordinate, closestOnCircle, closestOnSegment, createStringXY, squaredDistanceToSegment, toStringXY, toStringHDMS} from '../../../src/ol/coordinate.js';
|
||||
import {add as addCoordinate, scale as scaleCoordinate, rotate as rotateCoordinate, equals as coordinatesEqual, format as formatCoordinate, closestOnCircle, closestOnSegment, createStringXY, squaredDistanceToSegment, toStringXY, toStringHDMS, wrapX} from '../../../src/ol/coordinate.js';
|
||||
import Circle from '../../../src/ol/geom/Circle.js';
|
||||
import {get} from '../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.coordinate', function() {
|
||||
@@ -235,4 +236,29 @@ describe('ol.coordinate', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('wrapX()', function() {
|
||||
const projection = get('EPSG:4326');
|
||||
|
||||
it('leaves real world coordinate untouched', function() {
|
||||
expect(wrapX([16, 48], projection)).to.eql([16, 48]);
|
||||
});
|
||||
|
||||
it('moves left world coordinate to real world', function() {
|
||||
expect(wrapX([-344, 48], projection)).to.eql([16, 48]);
|
||||
});
|
||||
|
||||
it('moves right world coordinate to real world', function() {
|
||||
expect(wrapX([376, 48], projection)).to.eql([16, 48]);
|
||||
});
|
||||
|
||||
it('moves far off left coordinate to real world', function() {
|
||||
expect(wrapX([-1064, 48], projection)).to.eql([16, 48]);
|
||||
});
|
||||
|
||||
it('moves far off right coordinate to real world', function() {
|
||||
expect(wrapX([1096, 48], projection)).to.eql([16, 48]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as _ol_extent_ from '../../../src/ol/extent.js';
|
||||
import {getTransform} from '../../../src/ol/proj.js';
|
||||
import {getTransform, get} from '../../../src/ol/proj.js';
|
||||
import {register} from '../../../src/ol/proj/proj4.js';
|
||||
|
||||
|
||||
@@ -818,4 +818,37 @@ describe('ol.extent', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('wrapX()', function() {
|
||||
const projection = get('EPSG:4326');
|
||||
|
||||
it('leaves real world extent untouched', function() {
|
||||
expect(_ol_extent_.wrapX([16, 48, 18, 49], projection)).to.eql([16, 48, 18, 49]);
|
||||
});
|
||||
|
||||
it('moves left world extent to real world', function() {
|
||||
expect(_ol_extent_.wrapX([-344, 48, -342, 49], projection)).to.eql([16, 48, 18, 49]);
|
||||
});
|
||||
|
||||
it('moves right world extent to real world', function() {
|
||||
expect(_ol_extent_.wrapX([376, 48, 378, 49], projection)).to.eql([16, 48, 18, 49]);
|
||||
});
|
||||
|
||||
it('moves far off left extent to real world', function() {
|
||||
expect(_ol_extent_.wrapX([-1064, 48, -1062, 49], projection)).to.eql([16, 48, 18, 49]);
|
||||
});
|
||||
|
||||
it('moves far off right extent to real world', function() {
|
||||
expect(_ol_extent_.wrapX([1096, 48, 1098, 49], projection)).to.eql([16, 48, 18, 49]);
|
||||
});
|
||||
|
||||
it('leaves -180 crossing extent with real world center untouched', function() {
|
||||
expect(_ol_extent_.wrapX([-184, 48, 16, 49], projection)).to.eql([-184, 48, 16, 49]);
|
||||
});
|
||||
|
||||
it('moves +180 crossing extent with off-world center to the real world', function() {
|
||||
expect(_ol_extent_.wrapX([300, 48, 376, 49], projection)).to.eql([-60, 48, 16, 49]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user