Named exports from tilecoord
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import _ol_tilecoord_ from '../../../src/ol/tilecoord.js';
|
||||
import {
|
||||
quadKey,
|
||||
getKey,
|
||||
fromKey,
|
||||
hash,
|
||||
withinExtentAndZ
|
||||
} from '../../../src/ol/tilecoord.js';
|
||||
import TileGrid from '../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
|
||||
@@ -16,14 +22,14 @@ describe('ol.TileCoord', function() {
|
||||
describe('call quadKey', function() {
|
||||
it('returns expected string', function() {
|
||||
const tileCoord = [3, 3, 5];
|
||||
const s = _ol_tilecoord_.quadKey(tileCoord);
|
||||
const s = quadKey(tileCoord);
|
||||
expect(s).to.eql('213');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getKey()', function() {
|
||||
it('returns a key for a tile coord', function() {
|
||||
const key = _ol_tilecoord_.getKey([1, 2, 3]);
|
||||
const key = getKey([1, 2, 3]);
|
||||
expect(key).to.eql('1/2/3');
|
||||
});
|
||||
});
|
||||
@@ -31,9 +37,9 @@ describe('ol.TileCoord', function() {
|
||||
describe('fromKey()', function() {
|
||||
it('returns a tile coord given a key', function() {
|
||||
const tileCoord = [1, 2, 3];
|
||||
const key = _ol_tilecoord_.getKey(tileCoord);
|
||||
const key = getKey(tileCoord);
|
||||
|
||||
const returned = _ol_tilecoord_.fromKey(key);
|
||||
const returned = fromKey(key);
|
||||
expect(returned).to.eql(tileCoord);
|
||||
});
|
||||
});
|
||||
@@ -42,8 +48,8 @@ describe('ol.TileCoord', function() {
|
||||
it('produces different hashes for different tile coords', function() {
|
||||
const tileCoord1 = [3, 2, 1];
|
||||
const tileCoord2 = [3, 1, 1];
|
||||
expect(_ol_tilecoord_.hash(tileCoord1)).not.to.eql(
|
||||
_ol_tilecoord_.hash(tileCoord2));
|
||||
expect(hash(tileCoord1)).not.to.eql(
|
||||
hash(tileCoord2));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,9 +62,9 @@ describe('ol.TileCoord', function() {
|
||||
resolutions: [2, 1],
|
||||
minZoom: 1
|
||||
});
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([1, 0, -1], tileGrid)).to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([2, 0, -1], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([1, 0, -1], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([2, 0, -1], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('restricts by extent when extent defines tile ranges', function() {
|
||||
@@ -68,9 +74,9 @@ describe('ol.TileCoord', function() {
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
});
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 1, -2], tileGrid)).to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 2, -1], tileGrid)).to.be(false);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -3], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 1, -2], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, 2, -1], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, -3], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('restricts by extent when sizes define tile ranges', function() {
|
||||
@@ -80,12 +86,12 @@ describe('ol.TileCoord', function() {
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
});
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, -1, 0], tileGrid)).to.be(false);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 2, 2], tileGrid)).to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 3, 0], tileGrid)).to.be(false);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, 3], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, -1, 0], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 2, 2], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, 3, 0], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, 3], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('restricts by extent when sizes (neg y) define tile ranges', function() {
|
||||
@@ -95,12 +101,12 @@ describe('ol.TileCoord', function() {
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
});
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, -1, -1], tileGrid)).to.be(false);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 2, -3], tileGrid)).to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 3, -1], tileGrid)).to.be(false);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -4], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, -1, -1], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 2, -3], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, 3, -1], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, -4], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('does not restrict by extent with no extent or sizes', function() {
|
||||
@@ -109,13 +115,13 @@ describe('ol.TileCoord', function() {
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
});
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, Infinity, 0], tileGrid))
|
||||
expect(withinExtentAndZ([0, Infinity, 0], tileGrid))
|
||||
.to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, Infinity], tileGrid))
|
||||
expect(withinExtentAndZ([0, 0, Infinity], tileGrid))
|
||||
.to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, -Infinity, 0], tileGrid))
|
||||
expect(withinExtentAndZ([0, -Infinity, 0], tileGrid))
|
||||
.to.be(true);
|
||||
expect(_ol_tilecoord_.withinExtentAndZ([0, 0, Infinity], tileGrid))
|
||||
expect(withinExtentAndZ([0, 0, Infinity], tileGrid))
|
||||
.to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user