Add ol.TileCoord
This commit is contained in:
@@ -3,9 +3,6 @@ CLASS HIERARCHY
|
|||||||
|
|
||||||
```
|
```
|
||||||
goog.math.Coordinate // Simple 2D point
|
goog.math.Coordinate // Simple 2D point
|
||||||
|
|
||||||
|
|
||||||
goog.math.Coordinate3
|
|
||||||
|
|
|
|
||||||
+- TileCoord
|
+- TileCoord
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ goog.provide('ol');
|
|||||||
|
|
||||||
goog.require('ol.MVCObject');
|
goog.require('ol.MVCObject');
|
||||||
goog.require('ol.MVCArray');
|
goog.require('ol.MVCArray');
|
||||||
|
goog.require('ol.TileCoord');
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
goog.provide('ol.TileCoord');
|
||||||
|
|
||||||
|
goog.require('goog.math.Coordinate');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {goog.math.Coordinate}
|
||||||
|
* @param {number} z Z.
|
||||||
|
* @param {number} x X.
|
||||||
|
* @param {number} y Y.
|
||||||
|
*/
|
||||||
|
ol.TileCoord = function(z, x, y) {
|
||||||
|
|
||||||
|
goog.base(this, x, y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.z = z;
|
||||||
|
|
||||||
|
};
|
||||||
|
goog.inherits(ol.TileCoord, goog.math.Coordinate);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Hash.
|
||||||
|
*/
|
||||||
|
ol.TileCoord.prototype.hash = function() {
|
||||||
|
return (this.x << this.z) + this.y;
|
||||||
|
};
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
goog.require('goog.testing.jsunit');
|
||||||
|
goog.require('ol.TileCoord');
|
||||||
|
|
||||||
|
|
||||||
|
function testConstructorOrderZXY() {
|
||||||
|
var tc1 = new ol.TileCoord(1, 2, 3);
|
||||||
|
assertEquals(1, tc1.z);
|
||||||
|
assertEquals(2, tc1.x);
|
||||||
|
assertEquals(3, tc1.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testHashX() {
|
||||||
|
var tc1 = new ol.TileCoord(3, 2, 1);
|
||||||
|
var tc2 = new ol.TileCoord(3, 1, 1);
|
||||||
|
assertTrue(tc1.hash() != tc2.hash());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user