Change ol.TileCoord to an Array

This commit is contained in:
Éric Lemoine
2014-08-15 23:33:22 +02:00
parent 0d20b337a0
commit ba035abb1f
29 changed files with 318 additions and 323 deletions

View File

@@ -4,47 +4,49 @@ describe('ol.TileCoord', function() {
describe('create', function() {
it('sets x y z properties as expected', function() {
var tc = new ol.TileCoord(1, 2, 3);
expect(tc.z).to.eql(1);
expect(tc.x).to.eql(2);
expect(tc.y).to.eql(3);
var tileCoord = [1, 2, 3];
expect(tileCoord[0]).to.eql(1);
expect(tileCoord[1]).to.eql(2);
expect(tileCoord[2]).to.eql(3);
});
});
describe('create from quad key', function() {
it('sets x y z properties as expected', function() {
var tc = ol.TileCoord.createFromQuadKey('213');
expect(tc.z).to.eql(3);
expect(tc.x).to.eql(3);
expect(tc.y).to.eql(5);
var tileCoord = ol.tilecoord.createFromQuadKey('213');
expect(tileCoord[0]).to.eql(3);
expect(tileCoord[1]).to.eql(3);
expect(tileCoord[2]).to.eql(5);
});
});
describe('create from string', function() {
it('sets x y z properties as expected', function() {
var str = '1/2/3';
var tc = ol.TileCoord.createFromString(str);
expect(tc.z).to.eql(1);
expect(tc.x).to.eql(2);
expect(tc.y).to.eql(3);
var tileCoord = ol.tilecoord.createFromString(str);
expect(tileCoord[0]).to.eql(1);
expect(tileCoord[1]).to.eql(2);
expect(tileCoord[2]).to.eql(3);
});
});
describe('call quadKey', function() {
it('returns expected string', function() {
var tc = new ol.TileCoord(3, 3, 5);
var s = tc.quadKey();
var tileCoord = [3, 3, 5];
var s = ol.tilecoord.quadKey(tileCoord);
expect(s).to.eql('213');
});
});
describe('hash', function() {
it('produces different hashes for different tile coords', function() {
var tc1 = new ol.TileCoord(3, 2, 1);
var tc2 = new ol.TileCoord(3, 1, 1);
expect(tc1.hash()).not.to.eql(tc2.hash());
var tileCoord1 = [3, 2, 1];
var tileCoord2 = [3, 1, 1];
expect(ol.tilecoord.hash(tileCoord1)).not.to.eql(
ol.tilecoord.hash(tileCoord2));
});
});
});
goog.require('ol.TileCoord');
goog.require('ol.tilecoord');