From 5148ad038c58482d4eec83b8f925ad26bf7ffb5a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 19 Feb 2013 07:30:54 -0700 Subject: [PATCH] Sharing code with rectangle We cannot use the rectangle constructor here because a rectangle makes an assertion about min being less than max and a range may have equal min/max. --- src/ol/tilerange.js | 50 +++++---------------------------------------- 1 file changed, 5 insertions(+), 45 deletions(-) diff --git a/src/ol/tilerange.js b/src/ol/tilerange.js index 752716a4dc..76d3d7437c 100644 --- a/src/ol/tilerange.js +++ b/src/ol/tilerange.js @@ -1,7 +1,7 @@ goog.provide('ol.TileRange'); goog.require('goog.asserts'); -goog.require('ol.Size'); +goog.require('ol.Rectangle'); goog.require('ol.TileCoord'); @@ -11,6 +11,7 @@ goog.require('ol.TileCoord'); * by its min/max tile coordinates and is inclusive of coordinates. * * @constructor + * @extends {ol.Rectangle} * @param {number} minX Minimum X. * @param {number} minY Minimum Y. * @param {number} maxX Maximum X. @@ -39,6 +40,7 @@ ol.TileRange = function(minX, minY, maxX, maxY) { this.maxY = maxY; }; +goog.inherits(ol.TileRange, ol.Rectangle); /** @@ -83,28 +85,7 @@ ol.TileRange.prototype.containsTileRange = function(tileRange) { /** - * @param {ol.TileRange} range Other range. - * @return {boolean} The two ranges are equivalent. - */ -ol.TileRange.prototype.equals = function(range) { - return this.minX == range.minX && this.minY == range.minY && - this.maxX == range.maxX && this.maxY == range.maxY; -}; - - -/** - * Extend this range so it includes the other. - * @param {ol.TileRange} other Other range. - */ -ol.TileRange.prototype.extend = function(other) { - this.minX = Math.min(this.minX, other.minX); - this.minY = Math.min(this.minY, other.minY); - this.maxX = Math.max(this.maxX, other.maxX); - this.maxY = Math.max(this.maxY, other.maxY); -}; - - -/** + * @inheritDoc * @return {number} Height. */ ol.TileRange.prototype.getHeight = function() { @@ -113,30 +94,9 @@ ol.TileRange.prototype.getHeight = function() { /** - * @return {ol.Size} Size. - */ -ol.TileRange.prototype.getSize = function() { - return new ol.Size(this.getWidth(), this.getHeight()); -}; - - -/** + * @inheritDoc * @return {number} Width. */ ol.TileRange.prototype.getWidth = function() { return this.maxX - this.minX + 1; }; - - -/** - * Test for range intersection. - * @param {ol.TileRange} other Other range. - * @return {boolean} The two ranges intersect. - */ -ol.TileRange.prototype.intersects = function(other) { - return this.minX <= other.maxX && - this.maxX >= other.minX && - this.minY <= other.maxY && - this.maxY >= other.minY; -}; -