Do not require an extent for global projections

This commit is contained in:
Andreas Hocevar
2015-04-21 08:47:36 +02:00
parent 4f8dca92ba
commit 40feabc3c8
5 changed files with 61 additions and 7 deletions

View File

@@ -120,9 +120,13 @@ ol.proj.Projection = function(options) {
* @type {boolean}
*/
this.global_ = goog.isDef(options.global) ? options.global : false;
if (this.global_) {
goog.asserts.assert(!goog.isNull(this.extent_));
}
/**
* @private
* @type {boolean}
*/
this.canWrapX_ = this.global_ && !goog.isNull(this.extent_);
/**
* @private
@@ -175,6 +179,14 @@ ol.proj.Projection = function(options) {
};
/**
* @return {boolean} The projection is suitable for wrapping the x-axis
*/
ol.proj.Projection.prototype.canWrapX = function() {
return this.canWrapX_;
};
/**
* Get the code for this projection, e.g. 'EPSG:4326'.
* @return {string} Code.
@@ -258,6 +270,7 @@ ol.proj.Projection.prototype.isGlobal = function() {
*/
ol.proj.Projection.prototype.setGlobal = function(global) {
this.global_ = global;
this.canWrapX_ = global && !goog.isNull(this.extent_);
};
@@ -284,6 +297,7 @@ ol.proj.Projection.prototype.setDefaultTileGrid = function(tileGrid) {
*/
ol.proj.Projection.prototype.setExtent = function(extent) {
this.extent_ = extent;
this.canWrapX_ = this.global_ && !goog.isNull(extent);
};