Rename ol.TileCoord.fromString to createFromString

This commit is contained in:
Tom Payne
2012-07-25 17:43:08 +02:00
parent 7902803063
commit 8d936e7865
3 changed files with 28 additions and 28 deletions

View File

@@ -145,7 +145,7 @@ ol.dom.TileLayerRenderer.prototype.removeInvisibleTiles_ = function(
tileBounds, z) {
var key, tileCoord, prune, tile;
for (key in this.renderedTiles_) {
tileCoord = ol.TileCoord.fromString(key);
tileCoord = ol.TileCoord.createFromString(key);
prune = z !== tileCoord.z ||
tileCoord.x < tileBounds.minX ||
tileCoord.x > tileBounds.maxX ||

View File

@@ -63,6 +63,19 @@ ol.TileCoord.createFromQuadKey = function(quadKey) {
};
/**
* @param {string} str String.
* @return {ol.TileCoord} Tile coord.
*/
ol.TileCoord.createFromString = function(str) {
var v = str.split('/');
v = goog.array.map(v, function(e, i, a) {
return parseInt(e, 10);
});
return new ol.TileCoord(v[0], v[1], v[2]);
};
/**
* @return {ol.TileCoord} Clone.
*/
@@ -107,16 +120,3 @@ ol.TileCoord.prototype.toQuadKey = function() {
ol.TileCoord.prototype.toString = function() {
return [this.z, this.x, this.y].join('/');
};
/**
* @param {string} str String.
* @return {ol.TileCoord} Tile coord.
*/
ol.TileCoord.fromString = function(str) {
var v = str.split('/');
v = goog.array.map(v, function(e, i, a) {
return parseInt(e, 10);
});
return new ol.TileCoord(v[0], v[1], v[2]);
};

View File

@@ -2,14 +2,6 @@ goog.require('goog.testing.jsunit');
goog.require('ol.TileCoord');
function testCreateFromQuadKey() {
var tileCoord = ol.TileCoord.createFromQuadKey('213');
assertEquals(3, tileCoord.z);
assertEquals(3, tileCoord.x);
assertEquals(5, tileCoord.y);
}
function testConstructorOrderZXY() {
var tc1 = new ol.TileCoord(1, 2, 3);
assertEquals(1, tc1.z);
@@ -18,16 +10,17 @@ function testConstructorOrderZXY() {
}
function testHashX() {
var tc1 = new ol.TileCoord(3, 2, 1);
var tc2 = new ol.TileCoord(3, 1, 1);
assertTrue(tc1.hash() != tc2.hash());
function testCreateFromQuadKey() {
var tileCoord = ol.TileCoord.createFromQuadKey('213');
assertEquals(3, tileCoord.z);
assertEquals(3, tileCoord.x);
assertEquals(5, tileCoord.y);
}
function testFromString() {
function testCreateFromString() {
var str = '1/2/3';
var tc = ol.TileCoord.fromString(str);
var tc = ol.TileCoord.createFromString(str);
assertEquals(1, tc.z);
assertEquals(2, tc.x);
assertEquals(3, tc.y);
@@ -37,3 +30,10 @@ function testFromString() {
function testToQuadKey() {
assertEquals('213', (new ol.TileCoord(3, 3, 5)).toQuadKey());
}
function testHash() {
var tc1 = new ol.TileCoord(3, 2, 1);
var tc2 = new ol.TileCoord(3, 1, 1);
assertTrue(tc1.hash() != tc2.hash());
}