From 2def6f632716ab03941dd8a05555f9e893db57aa Mon Sep 17 00:00:00 2001 From: euzuro Date: Wed, 19 Jul 2006 14:47:41 +0000 Subject: [PATCH] give Tile a unique id. add tests git-svn-id: http://svn.openlayers.org/trunk/openlayers@980 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Tile.js | 6 ++++++ tests/test_Tile.html | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Tile.js b/lib/OpenLayers/Tile.js index eca7c0bca1..d2754e1774 100644 --- a/lib/OpenLayers/Tile.js +++ b/lib/OpenLayers/Tile.js @@ -13,6 +13,9 @@ OpenLayers.Tile = Class.create(); OpenLayers.Tile.prototype = { + /** @type String */ + id: null, + /** @type OpenLayers.Layer */ layer: null, @@ -45,6 +48,9 @@ OpenLayers.Tile.prototype = { this.bounds = bounds; this.url = url; this.size = size; + + //give the tile a unique id based on its BBOX. + this.id = OpenLayers.Util.createUniqueID(bounds.toBBOX()); } }, diff --git a/tests/test_Tile.html b/tests/test_Tile.html index fe8dce1f55..ddea9016d8 100644 --- a/tests/test_Tile.html +++ b/tests/test_Tile.html @@ -5,7 +5,7 @@ var tile; function test_01_Tile_constructor (t) { - t.plan( 6 ); + t.plan( 8 ); var layer = new Object(); // bogus layer var position = new OpenLayers.Pixel(10,20); @@ -21,6 +21,9 @@ t.ok( tile.bounds.equals(bounds), "tile.bounds set correctly"); t.eq( tile.url, url, "tile.url set correctly"); t.ok( tile.size.equals(size), "tile.size is set correctly" ); + + t.ok( tile.id != null, "tile is given an id"); + t.ok( tile.id.startsWith(bounds.toBBOX()), "tile's id starts with bbox of bounds"); }