Create ol.Coordinate around goog.math.Coordinate

This commit is contained in:
Tom Payne
2012-07-19 10:34:12 +02:00
parent d62ba69458
commit c547404615
22 changed files with 155 additions and 131 deletions
+11 -13
View File
@@ -2,8 +2,8 @@ goog.provide('ol.TileGrid');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.math.Coordinate');
goog.require('goog.math.Size');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.TileBounds');
goog.require('ol.TileCoord');
@@ -14,7 +14,7 @@ goog.require('ol.TileCoord');
* @constructor
* @param {!Array.<number>} resolutions Resolutions.
* @param {ol.Extent} extent Extent.
* @param {goog.math.Coordinate|!Array.<goog.math.Coordinate>} origin Origin.
* @param {ol.Coordinate|!Array.<ol.Coordinate>} origin Origin.
* @param {goog.math.Size=} opt_tileSize Tile size.
*/
ol.TileGrid = function(resolutions, extent, origin, opt_tileSize) {
@@ -42,17 +42,17 @@ ol.TileGrid = function(resolutions, extent, origin, opt_tileSize) {
/**
* @private
* @type {goog.math.Coordinate}
* @type {ol.Coordinate}
*/
this.origin_ = null;
/**
* @private
* @type {Array.<goog.math.Coordinate>}
* @type {Array.<ol.Coordinate>}
*/
this.origins_ = null;
if (origin instanceof goog.math.Coordinate) {
if (origin instanceof ol.Coordinate) {
this.origin_ = origin;
} else if (goog.isArray(origin)) {
goog.asserts.assert(origin.length == this.numResolutions_);
@@ -101,17 +101,15 @@ ol.TileGrid.prototype.getExtent = function() {
* @return {ol.TileBounds} Tile bounds.
*/
ol.TileGrid.prototype.getExtentTileBounds = function(z, extent) {
var min =
this.getTileCoord(z, new goog.math.Coordinate(extent.minX, extent.minY));
var max =
this.getTileCoord(z, new goog.math.Coordinate(extent.maxX, extent.maxY));
var min = this.getTileCoord(z, new ol.Coordinate(extent.minX, extent.minY));
var max = this.getTileCoord(z, new ol.Coordinate(extent.maxX, extent.maxY));
return new ol.TileBounds(min.x, min.y, max.x, max.y);
};
/**
* @param {number} z Z.
* @return {goog.math.Coordinate} Origin.
* @return {ol.Coordinate} Origin.
*/
ol.TileGrid.prototype.getOrigin = function(z) {
if (!goog.isNull(this.origin_)) {
@@ -144,7 +142,7 @@ ol.TileGrid.prototype.getResolutions = function() {
/**
* @param {number} z Z.
* @param {goog.math.Coordinate} coordinate Coordinate.
* @param {ol.Coordinate} coordinate Coordinate.
* @return {ol.TileCoord} Tile coordinate.
*/
ol.TileGrid.prototype.getTileCoord = function(z, coordinate) {
@@ -160,7 +158,7 @@ ol.TileGrid.prototype.getTileCoord = function(z, coordinate) {
/**
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @return {goog.math.Coordinate} Tile center.
* @return {ol.Coordinate} Tile center.
*/
ol.TileGrid.prototype.getTileCoordCenter = function(tileCoord) {
var origin = this.getOrigin(tileCoord.z);
@@ -168,7 +166,7 @@ ol.TileGrid.prototype.getTileCoordCenter = function(tileCoord) {
var tileSize = this.tileSize_;
var x = origin.x + (tileCoord.x + 0.5) * tileSize.width * resolution;
var y = origin.y + (tileCoord.y + 0.5) * tileSize.height * resolution;
return new goog.math.Coordinate(x, y);
return new ol.Coordinate(x, y);
};