Remove usage of various goog.* functions

goog.isNull, goog.isDefAndNotNull and goog.array.*
This commit is contained in:
Petr Sloup
2015-10-14 11:06:19 +02:00
parent f3d5d16a82
commit 8fb1d1f244
7 changed files with 68 additions and 68 deletions

View File

@@ -43,8 +43,8 @@ ol.reproj.Image = function(sourceProj, targetProj,
this.maxSourceExtent_ = sourceProj.getExtent(); this.maxSourceExtent_ = sourceProj.getExtent();
var maxTargetExtent = targetProj.getExtent(); var maxTargetExtent = targetProj.getExtent();
var limitedTargetExtent = goog.isNull(maxTargetExtent) ? var limitedTargetExtent = maxTargetExtent ?
targetExtent : ol.extent.getIntersection(targetExtent, maxTargetExtent); ol.extent.getIntersection(targetExtent, maxTargetExtent) : targetExtent;
var targetCenter = ol.extent.getCenter(limitedTargetExtent); var targetCenter = ol.extent.getCenter(limitedTargetExtent);
var sourceResolution = ol.reproj.calculateSourceResolution( var sourceResolution = ol.reproj.calculateSourceResolution(
@@ -84,8 +84,7 @@ ol.reproj.Image = function(sourceProj, targetProj,
* @private * @private
* @type {number} * @type {number}
*/ */
this.srcPixelRatio_ = this.srcPixelRatio_ = this.srcImage_ ? this.srcImage_.getPixelRatio() : 1;
!goog.isNull(this.srcImage_) ? this.srcImage_.getPixelRatio() : 1;
/** /**
* @private * @private
@@ -103,7 +102,7 @@ ol.reproj.Image = function(sourceProj, targetProj,
var state = ol.ImageState.LOADED; var state = ol.ImageState.LOADED;
var attributions = []; var attributions = [];
if (!goog.isNull(this.srcImage_)) { if (this.srcImage_) {
state = ol.ImageState.IDLE; state = ol.ImageState.IDLE;
attributions = this.srcImage_.getAttributions(); attributions = this.srcImage_.getAttributions();
} }
@@ -195,7 +194,7 @@ ol.reproj.Image.prototype.load = function() {
* @private * @private
*/ */
ol.reproj.Image.prototype.unlistenSource_ = function() { ol.reproj.Image.prototype.unlistenSource_ = function() {
goog.asserts.assert(!goog.isNull(this.sourceListenerKey_), goog.asserts.assert(this.sourceListenerKey_,
'this.sourceListenerKey_ should not be null'); 'this.sourceListenerKey_ should not be null');
goog.events.unlistenByKey(this.sourceListenerKey_); goog.events.unlistenByKey(this.sourceListenerKey_);
this.sourceListenerKey_ = null; this.sourceListenerKey_ = null;

View File

@@ -1,6 +1,5 @@
goog.provide('ol.reproj'); goog.provide('ol.reproj');
goog.require('goog.array');
goog.require('goog.labs.userAgent.browser'); goog.require('goog.labs.userAgent.browser');
goog.require('goog.labs.userAgent.platform'); goog.require('goog.labs.userAgent.platform');
goog.require('goog.math'); goog.require('goog.math');
@@ -117,8 +116,7 @@ ol.reproj.render = function(width, height, pixelRatio,
context.scale(pixelRatio, pixelRatio); context.scale(pixelRatio, pixelRatio);
var wrapXShiftDistance = !goog.isNull(sourceExtent) ? var wrapXShiftDistance = sourceExtent ? ol.extent.getWidth(sourceExtent) : 0;
ol.extent.getWidth(sourceExtent) : 0;
var wrapXType = ol.reproj.WrapXRendering_.NONE; var wrapXType = ol.reproj.WrapXRendering_.NONE;
@@ -137,7 +135,7 @@ ol.reproj.render = function(width, height, pixelRatio,
} }
var srcDataExtent = ol.extent.createEmpty(); var srcDataExtent = ol.extent.createEmpty();
goog.array.forEach(sources, function(src, i, arr) { sources.forEach(function(src, i, arr) {
if (wrapXType == ol.reproj.WrapXRendering_.STITCH_SHIFT) { if (wrapXType == ol.reproj.WrapXRendering_.STITCH_SHIFT) {
var srcW = src.extent[2] - src.extent[0]; var srcW = src.extent[2] - src.extent[0];
var srcX = goog.math.modulo(src.extent[0], wrapXShiftDistance); var srcX = goog.math.modulo(src.extent[0], wrapXShiftDistance);
@@ -147,7 +145,7 @@ ol.reproj.render = function(width, height, pixelRatio,
ol.extent.extend(srcDataExtent, src.extent); ol.extent.extend(srcDataExtent, src.extent);
} }
}); });
if (!goog.isNull(sourceExtent)) { if (sourceExtent) {
if (wrapXType == ol.reproj.WrapXRendering_.NONE) { if (wrapXType == ol.reproj.WrapXRendering_.NONE) {
srcDataExtent[0] = ol.math.clamp( srcDataExtent[0] = ol.math.clamp(
srcDataExtent[0], sourceExtent[0], sourceExtent[2]); srcDataExtent[0], sourceExtent[0], sourceExtent[2]);
@@ -177,7 +175,7 @@ ol.reproj.render = function(width, height, pixelRatio,
pixelRatio / sourceResolution); pixelRatio / sourceResolution);
stitchContext.translate(-srcDataExtent[0], srcDataExtent[3]); stitchContext.translate(-srcDataExtent[0], srcDataExtent[3]);
goog.array.forEach(sources, function(src, i, arr) { sources.forEach(function(src, i, arr) {
var xPos = src.extent[0]; var xPos = src.extent[0];
var yPos = -src.extent[3]; var yPos = -src.extent[3];
var srcWidth = ol.extent.getWidth(src.extent); var srcWidth = ol.extent.getWidth(src.extent);
@@ -196,7 +194,7 @@ ol.reproj.render = function(width, height, pixelRatio,
var targetTL = ol.extent.getTopLeft(targetExtent); var targetTL = ol.extent.getTopLeft(targetExtent);
goog.array.forEach(triangulation.getTriangles(), function(tri, i, arr) { triangulation.getTriangles().forEach(function(tri, i, arr) {
context.save(); context.save();
/* Calculate affine transform (src -> dst) /* Calculate affine transform (src -> dst)
@@ -263,7 +261,7 @@ ol.reproj.render = function(width, height, pixelRatio,
[0, 0, x2, y2, v2 - v0] [0, 0, x2, y2, v2 - v0]
]; ];
var coefs = ol.math.solveLinearSystem(augmentedMatrix); var coefs = ol.math.solveLinearSystem(augmentedMatrix);
if (goog.isNull(coefs)) { if (!coefs) {
return; return;
} }
@@ -303,8 +301,7 @@ ol.reproj.render = function(width, height, pixelRatio,
context.strokeStyle = 'black'; context.strokeStyle = 'black';
context.lineWidth = 1; context.lineWidth = 1;
goog.array.forEach(triangulation.getTriangles(), function(tri, i, arr) { triangulation.getTriangles().forEach(function(tri, i, arr) {
var tgt = tri.target; var tgt = tri.target;
var u0 = (tgt[0][0] - targetTL[0]) / targetResolution, var u0 = (tgt[0][0] - targetTL[0]) / targetResolution,
v0 = -(tgt[0][1] - targetTL[1]) / targetResolution; v0 = -(tgt[0][1] - targetTL[1]) / targetResolution;

View File

@@ -1,6 +1,5 @@
goog.provide('ol.reproj.Tile'); goog.provide('ol.reproj.Tile');
goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
@@ -99,8 +98,8 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
var maxTargetExtent = this.targetTileGrid_.getExtent(); var maxTargetExtent = this.targetTileGrid_.getExtent();
var maxSourceExtent = this.sourceTileGrid_.getExtent(); var maxSourceExtent = this.sourceTileGrid_.getExtent();
var limitedTargetExtent = goog.isNull(maxTargetExtent) ? var limitedTargetExtent = maxTargetExtent ?
targetExtent : ol.extent.getIntersection(targetExtent, maxTargetExtent); ol.extent.getIntersection(targetExtent, maxTargetExtent) : targetExtent;
if (ol.extent.getArea(limitedTargetExtent) === 0) { if (ol.extent.getArea(limitedTargetExtent) === 0) {
// Tile is completely outside range -> EMPTY // Tile is completely outside range -> EMPTY
@@ -110,8 +109,8 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
} }
var sourceProjExtent = sourceProj.getExtent(); var sourceProjExtent = sourceProj.getExtent();
if (!goog.isNull(sourceProjExtent)) { if (sourceProjExtent) {
if (goog.isNull(maxSourceExtent)) { if (!maxSourceExtent) {
maxSourceExtent = sourceProjExtent; maxSourceExtent = sourceProjExtent;
} else { } else {
maxSourceExtent = ol.extent.getIntersection( maxSourceExtent = ol.extent.getIntersection(
@@ -152,7 +151,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
this.srcZ_ = sourceTileGrid.getZForResolution(sourceResolution); this.srcZ_ = sourceTileGrid.getZForResolution(sourceResolution);
var srcExtent = this.triangulation_.calculateSourceExtent(); var srcExtent = this.triangulation_.calculateSourceExtent();
if (!goog.isNull(maxSourceExtent) && if (maxSourceExtent &&
!this.triangulation_.getWrapsXInSource() && !this.triangulation_.getWrapsXInSource() &&
!ol.extent.intersects(maxSourceExtent, srcExtent)) { !ol.extent.intersects(maxSourceExtent, srcExtent)) {
this.state = ol.TileState.EMPTY; this.state = ol.TileState.EMPTY;
@@ -160,25 +159,31 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
var srcRange = sourceTileGrid.getTileRangeForExtentAndZ( var srcRange = sourceTileGrid.getTileRangeForExtentAndZ(
srcExtent, this.srcZ_); srcExtent, this.srcZ_);
var xRange; var xRange = [];
var srcFullRange = sourceTileGrid.getFullTileRange(this.srcZ_); var srcFullRange = sourceTileGrid.getFullTileRange(this.srcZ_);
if (!goog.isNull(srcFullRange)) { if (srcFullRange) {
srcRange.minY = Math.max(srcRange.minY, srcFullRange.minY); srcRange.minY = Math.max(srcRange.minY, srcFullRange.minY);
srcRange.maxY = Math.min(srcRange.maxY, srcFullRange.maxY); srcRange.maxY = Math.min(srcRange.maxY, srcFullRange.maxY);
if (srcRange.minX > srcRange.maxX) { if (srcRange.minX > srcRange.maxX) {
xRange = goog.array.concat( var i;
goog.array.range(srcRange.minX, srcFullRange.maxX + 1), for (i = srcRange.minX; i <= srcFullRange.maxX; i++) {
goog.array.range(srcFullRange.minX, srcRange.maxX + 1) xRange.push(i);
); }
} else { for (i = srcFullRange.minX; i <= srcRange.maxX; i++) {
xRange = goog.array.range( xRange.push(i);
Math.max(srcRange.minX, srcFullRange.minX),
Math.min(srcRange.maxX, srcFullRange.maxX) + 1
);
} }
} else { } else {
xRange = goog.array.range(srcRange.minX, srcRange.maxX + 1); var first = Math.max(srcRange.minX, srcFullRange.minX);
var last = Math.min(srcRange.maxX, srcFullRange.maxX);
for (var j = first; j <= last; j++) {
xRange.push(j);
}
}
} else {
for (var k = srcRange.minX; k <= srcRange.maxX; k++) {
xRange.push(k);
}
} }
var tilesRequired = xRange.length * srcRange.getHeight(); var tilesRequired = xRange.length * srcRange.getHeight();
@@ -187,7 +192,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
this.state = ol.TileState.ERROR; this.state = ol.TileState.ERROR;
return; return;
} }
goog.array.forEach(xRange, function(srcX, i, arr) { xRange.forEach(function(srcX, i, arr) {
for (var srcY = srcRange.minY; srcY <= srcRange.maxY; srcY++) { for (var srcY = srcRange.minY; srcY <= srcRange.maxY; srcY++) {
var tile = getTileFunction(this.srcZ_, srcX, srcY, pixelRatio); var tile = getTileFunction(this.srcZ_, srcX, srcY, pixelRatio);
if (tile) { if (tile) {
@@ -242,7 +247,7 @@ ol.reproj.Tile.prototype.getImage = function(opt_context) {
*/ */
ol.reproj.Tile.prototype.reproject_ = function() { ol.reproj.Tile.prototype.reproject_ = function() {
var sources = []; var sources = [];
goog.array.forEach(this.srcTiles_, function(tile, i, arr) { this.srcTiles_.forEach(function(tile, i, arr) {
if (tile && tile.getState() == ol.TileState.LOADED) { if (tile && tile.getState() == ol.TileState.LOADED) {
sources.push({ sources.push({
extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord), extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord),
@@ -280,11 +285,11 @@ ol.reproj.Tile.prototype.load = function() {
var leftToLoad = 0; var leftToLoad = 0;
goog.asserts.assert(goog.isNull(this.sourcesListenerKeys_), goog.asserts.assert(!this.sourcesListenerKeys_,
'this.sourcesListenerKeys_ should be null'); 'this.sourcesListenerKeys_ should be null');
this.sourcesListenerKeys_ = []; this.sourcesListenerKeys_ = [];
goog.array.forEach(this.srcTiles_, function(tile, i, arr) { this.srcTiles_.forEach(function(tile, i, arr) {
var state = tile.getState(); var state = tile.getState();
if (state == ol.TileState.IDLE || state == ol.TileState.LOADING) { if (state == ol.TileState.IDLE || state == ol.TileState.LOADING) {
leftToLoad++; leftToLoad++;
@@ -310,7 +315,7 @@ ol.reproj.Tile.prototype.load = function() {
} }
}, this); }, this);
goog.array.forEach(this.srcTiles_, function(tile, i, arr) { this.srcTiles_.forEach(function(tile, i, arr) {
var state = tile.getState(); var state = tile.getState();
if (state == ol.TileState.IDLE) { if (state == ol.TileState.IDLE) {
tile.load(); tile.load();
@@ -328,8 +333,8 @@ ol.reproj.Tile.prototype.load = function() {
* @private * @private
*/ */
ol.reproj.Tile.prototype.unlistenSources_ = function() { ol.reproj.Tile.prototype.unlistenSources_ = function() {
goog.asserts.assert(!goog.isNull(this.sourcesListenerKeys_), goog.asserts.assert(this.sourcesListenerKeys_,
'this.sourcesListenerKeys_ should not be null'); 'this.sourcesListenerKeys_ should not be null');
goog.array.forEach(this.sourcesListenerKeys_, goog.events.unlistenByKey); this.sourcesListenerKeys_.forEach(goog.events.unlistenByKey);
this.sourcesListenerKeys_ = null; this.sourcesListenerKeys_ = null;
}; };

View File

@@ -1,6 +1,5 @@
goog.provide('ol.reproj.Triangulation'); goog.provide('ol.reproj.Triangulation');
goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.math'); goog.require('goog.math');
goog.require('ol.extent'); goog.require('ol.extent');
@@ -96,8 +95,8 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent,
* @private * @private
*/ */
this.canWrapXInSource_ = this.sourceProj_.canWrapX() && this.canWrapXInSource_ = this.sourceProj_.canWrapX() &&
!goog.isNull(maxSourceExtent) && !!maxSourceExtent &&
!goog.isNull(this.sourceProj_.getExtent()) && !!this.sourceProj_.getExtent() &&
(ol.extent.getWidth(maxSourceExtent) == (ol.extent.getWidth(maxSourceExtent) ==
ol.extent.getWidth(this.sourceProj_.getExtent())); ol.extent.getWidth(this.sourceProj_.getExtent()));
@@ -105,14 +104,14 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent,
* @type {?number} * @type {?number}
* @private * @private
*/ */
this.sourceWorldWidth_ = !goog.isNull(this.sourceProj_.getExtent()) ? this.sourceWorldWidth_ = this.sourceProj_.getExtent() ?
ol.extent.getWidth(this.sourceProj_.getExtent()) : null; ol.extent.getWidth(this.sourceProj_.getExtent()) : null;
/** /**
* @type {?number} * @type {?number}
* @private * @private
*/ */
this.targetWorldWidth_ = !goog.isNull(this.targetProj_.getExtent()) ? this.targetWorldWidth_ = this.targetProj_.getExtent() ?
ol.extent.getWidth(this.targetProj_.getExtent()) : null; ol.extent.getWidth(this.targetProj_.getExtent()) : null;
var tlDst = ol.extent.getTopLeft(targetExtent); var tlDst = ol.extent.getTopLeft(targetExtent);
@@ -171,7 +170,7 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
aSrc, bSrc, cSrc, dSrc, maxSubdiv) { aSrc, bSrc, cSrc, dSrc, maxSubdiv) {
var srcQuadExtent = ol.extent.boundingExtent([aSrc, bSrc, cSrc, dSrc]); var srcQuadExtent = ol.extent.boundingExtent([aSrc, bSrc, cSrc, dSrc]);
var srcCoverageX = !goog.isNull(this.sourceWorldWidth_) ? var srcCoverageX = this.sourceWorldWidth_ ?
ol.extent.getWidth(srcQuadExtent) / this.sourceWorldWidth_ : null; ol.extent.getWidth(srcQuadExtent) / this.sourceWorldWidth_ : null;
// when the quad is wrapped in the source projection // when the quad is wrapped in the source projection
@@ -182,18 +181,18 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
var needsSubdivision = false; var needsSubdivision = false;
if (maxSubdiv > 0) { if (maxSubdiv > 0) {
if (this.targetProj_.isGlobal() && !goog.isNull(this.targetWorldWidth_)) { if (this.targetProj_.isGlobal() && this.targetWorldWidth_) {
var tgtQuadExtent = ol.extent.boundingExtent([a, b, c, d]); var tgtQuadExtent = ol.extent.boundingExtent([a, b, c, d]);
var tgtCoverageX = var tgtCoverageX =
ol.extent.getWidth(tgtQuadExtent) / this.targetWorldWidth_; ol.extent.getWidth(tgtQuadExtent) / this.targetWorldWidth_;
needsSubdivision |= tgtCoverageX > ol.RASTER_REPROJ_MAX_TRIANGLE_WIDTH; needsSubdivision |= tgtCoverageX > ol.RASTER_REPROJ_MAX_TRIANGLE_WIDTH;
} }
if (!wrapsX && this.sourceProj_.isGlobal() && !goog.isNull(srcCoverageX)) { if (!wrapsX && this.sourceProj_.isGlobal() && srcCoverageX) {
needsSubdivision |= srcCoverageX > ol.RASTER_REPROJ_MAX_TRIANGLE_WIDTH; needsSubdivision |= srcCoverageX > ol.RASTER_REPROJ_MAX_TRIANGLE_WIDTH;
} }
} }
if (!needsSubdivision && !goog.isNull(this.maxSourceExtent_)) { if (!needsSubdivision && this.maxSourceExtent_) {
if (!ol.extent.intersects(srcQuadExtent, this.maxSourceExtent_)) { if (!ol.extent.intersects(srcQuadExtent, this.maxSourceExtent_)) {
// whole quad outside source projection extent -> ignore // whole quad outside source projection extent -> ignore
return; return;
@@ -220,7 +219,7 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
var dx; var dx;
if (wrapsX) { if (wrapsX) {
goog.asserts.assert(!goog.isNull(this.sourceWorldWidth_)); goog.asserts.assert(this.sourceWorldWidth_);
var centerSrcEstimX = var centerSrcEstimX =
(goog.math.modulo(aSrc[0], this.sourceWorldWidth_) + (goog.math.modulo(aSrc[0], this.sourceWorldWidth_) +
goog.math.modulo(cSrc[0], this.sourceWorldWidth_)) / 2; goog.math.modulo(cSrc[0], this.sourceWorldWidth_)) / 2;
@@ -278,7 +277,7 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
* @return {ol.Extent} Calculated extent. * @return {ol.Extent} Calculated extent.
*/ */
ol.reproj.Triangulation.prototype.calculateSourceExtent = function() { ol.reproj.Triangulation.prototype.calculateSourceExtent = function() {
if (!goog.isNull(this.trianglesSourceExtent_)) { if (this.trianglesSourceExtent_) {
return this.trianglesSourceExtent_; return this.trianglesSourceExtent_;
} }
@@ -289,8 +288,8 @@ ol.reproj.Triangulation.prototype.calculateSourceExtent = function() {
// all coordinates need to be "shifted" to be positive // all coordinates need to be "shifted" to be positive
// to properly calculate the extent (and then possibly shifted back) // to properly calculate the extent (and then possibly shifted back)
goog.array.forEach(this.triangles_, function(triangle, i, arr) { this.triangles_.forEach(function(triangle, i, arr) {
goog.asserts.assert(!goog.isNull(this.sourceWorldWidth_)); goog.asserts.assert(this.sourceWorldWidth_);
var src = triangle.source; var src = triangle.source;
ol.extent.extendCoordinate(extent, ol.extent.extendCoordinate(extent,
[goog.math.modulo(src[0][0], this.sourceWorldWidth_), src[0][1]]); [goog.math.modulo(src[0][0], this.sourceWorldWidth_), src[0][1]]);
@@ -309,7 +308,7 @@ ol.reproj.Triangulation.prototype.calculateSourceExtent = function() {
extent[2] -= this.sourceWorldWidth_; extent[2] -= this.sourceWorldWidth_;
} }
} else { } else {
goog.array.forEach(this.triangles_, function(triangle, i, arr) { this.triangles_.forEach(function(triangle, i, arr) {
var src = triangle.source; var src = triangle.source;
ol.extent.extendCoordinate(extent, src[0]); ol.extent.extendCoordinate(extent, src[0]);
ol.extent.extendCoordinate(extent, src[1]); ol.extent.extendCoordinate(extent, src[1]);

View File

@@ -110,15 +110,15 @@ ol.source.Image.prototype.getImage =
function(extent, resolution, pixelRatio, projection) { function(extent, resolution, pixelRatio, projection) {
var sourceProjection = this.getProjection(); var sourceProjection = this.getProjection();
if (!ol.ENABLE_RASTER_REPROJECTION || if (!ol.ENABLE_RASTER_REPROJECTION ||
!goog.isDefAndNotNull(sourceProjection) || !sourceProjection ||
!goog.isDefAndNotNull(projection) || !projection ||
ol.proj.equivalent(sourceProjection, projection)) { ol.proj.equivalent(sourceProjection, projection)) {
if (!goog.isNull(sourceProjection)) { if (sourceProjection) {
projection = sourceProjection; projection = sourceProjection;
} }
return this.getImageInternal(extent, resolution, pixelRatio, projection); return this.getImageInternal(extent, resolution, pixelRatio, projection);
} else { } else {
if (!goog.isNull(this.reprojectedImage_)) { if (this.reprojectedImage_) {
if (this.reprojectedRevision_ == this.getRevision() && if (this.reprojectedRevision_ == this.getRevision() &&
ol.proj.equivalent( ol.proj.equivalent(
this.reprojectedImage_.getProjection(), projection) && this.reprojectedImage_.getProjection(), projection) &&

View File

@@ -152,8 +152,8 @@ ol.source.TileImage.prototype.getTileGridForProjection = function(projection) {
return goog.base(this, 'getTileGridForProjection', projection); return goog.base(this, 'getTileGridForProjection', projection);
} }
var thisProj = this.getProjection(); var thisProj = this.getProjection();
if (!goog.isNull(this.tileGrid) && if (this.tileGrid &&
(goog.isNull(thisProj) || ol.proj.equivalent(thisProj, projection))) { (!thisProj || ol.proj.equivalent(thisProj, projection))) {
return this.tileGrid; return this.tileGrid;
} else { } else {
var projKey = goog.getUid(projection).toString(); var projKey = goog.getUid(projection).toString();
@@ -174,7 +174,7 @@ ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) {
return goog.base(this, 'getTileCacheForProjection', projection); return goog.base(this, 'getTileCacheForProjection', projection);
} }
var thisProj = this.getProjection(); var thisProj = this.getProjection();
if (goog.isNull(thisProj) || ol.proj.equivalent(thisProj, projection)) { if (!thisProj || ol.proj.equivalent(thisProj, projection)) {
return this.tileCache; return this.tileCache;
} else { } else {
var projKey = goog.getUid(projection).toString(); var projKey = goog.getUid(projection).toString();
@@ -192,8 +192,8 @@ ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) {
ol.source.TileImage.prototype.getTile = ol.source.TileImage.prototype.getTile =
function(z, x, y, pixelRatio, projection) { function(z, x, y, pixelRatio, projection) {
if (!ol.ENABLE_RASTER_REPROJECTION || if (!ol.ENABLE_RASTER_REPROJECTION ||
!goog.isDefAndNotNull(this.getProjection()) || !this.getProjection() ||
!goog.isDefAndNotNull(projection) || !projection ||
ol.proj.equivalent(this.getProjection(), projection)) { ol.proj.equivalent(this.getProjection(), projection)) {
return this.getTileInternal(z, x, y, pixelRatio, projection); return this.getTileInternal(z, x, y, pixelRatio, projection);
} else { } else {
@@ -335,7 +335,7 @@ ol.source.TileImage.prototype.setTileGridForProjection =
function(projection, tilegrid) { function(projection, tilegrid) {
if (ol.ENABLE_RASTER_REPROJECTION) { if (ol.ENABLE_RASTER_REPROJECTION) {
var proj = ol.proj.get(projection); var proj = ol.proj.get(projection);
if (!goog.isNull(proj)) { if (proj) {
var projKey = goog.getUid(proj).toString(); var projKey = goog.getUid(proj).toString();
if (!(projKey in this.tileGridForProjection)) { if (!(projKey in this.tileGridForProjection)) {
this.tileGridForProjection[projKey] = tilegrid; this.tileGridForProjection[projKey] = tilegrid;
@@ -380,7 +380,7 @@ ol.source.TileImage.prototype.setTileUrlFunction = function(tileUrlFunction) {
ol.source.TileImage.prototype.useTile = function(z, x, y, projection) { ol.source.TileImage.prototype.useTile = function(z, x, y, projection) {
var tileCache = this.getTileCacheForProjection(projection); var tileCache = this.getTileCacheForProjection(projection);
var tileCoordKey = this.getKeyZXY(z, x, y); var tileCoordKey = this.getKeyZXY(z, x, y);
if (!goog.isNull(tileCache) && tileCache.containsKey(tileCoordKey)) { if (tileCache && tileCache.containsKey(tileCoordKey)) {
tileCache.get(tileCoordKey); tileCache.get(tileCoordKey);
} }
}; };

View File

@@ -103,7 +103,7 @@ ol.source.Tile.prototype.canExpireCache = function() {
*/ */
ol.source.Tile.prototype.expireCache = function(projection, usedTiles) { ol.source.Tile.prototype.expireCache = function(projection, usedTiles) {
var tileCache = this.getTileCacheForProjection(projection); var tileCache = this.getTileCacheForProjection(projection);
if (!goog.isNull(tileCache)) { if (tileCache) {
tileCache.expireCache(usedTiles); tileCache.expireCache(usedTiles);
} }
}; };
@@ -121,7 +121,7 @@ ol.source.Tile.prototype.expireCache = function(projection, usedTiles) {
ol.source.Tile.prototype.forEachLoadedTile = ol.source.Tile.prototype.forEachLoadedTile =
function(projection, z, tileRange, callback) { function(projection, z, tileRange, callback) {
var tileCache = this.getTileCacheForProjection(projection); var tileCache = this.getTileCacheForProjection(projection);
if (goog.isNull(tileCache)) { if (!tileCache) {
return false; return false;
} }
@@ -222,7 +222,7 @@ ol.source.Tile.prototype.getTileGridForProjection = function(projection) {
*/ */
ol.source.Tile.prototype.getTileCacheForProjection = function(projection) { ol.source.Tile.prototype.getTileCacheForProjection = function(projection) {
var thisProj = this.getProjection(); var thisProj = this.getProjection();
if (!goog.isNull(thisProj) && !ol.proj.equivalent(thisProj, projection)) { if (thisProj && !ol.proj.equivalent(thisProj, projection)) {
return null; return null;
} else { } else {
return this.tileCache; return this.tileCache;