Transformed
This commit is contained in:
+44
-42
@@ -1,14 +1,14 @@
|
||||
goog.provide('ol.reproj.Image');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.ImageBase');
|
||||
goog.require('ol.ImageState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.reproj');
|
||||
goog.require('ol.reproj.Triangulation');
|
||||
|
||||
/**
|
||||
* @module ol/reproj/Image
|
||||
*/
|
||||
import _ol_ from '../index.js';
|
||||
import _ol_ImageBase_ from '../ImageBase.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import _ol_events_EventType_ from '../events/EventType.js';
|
||||
import _ol_extent_ from '../extent.js';
|
||||
import _ol_reproj_ from '../reproj.js';
|
||||
import _ol_reproj_Triangulation_ from '../reproj/Triangulation.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -25,7 +25,7 @@ goog.require('ol.reproj.Triangulation');
|
||||
* @param {ol.ReprojImageFunctionType} getImageFunction
|
||||
* Function returning source images (extent, resolution, pixelRatio).
|
||||
*/
|
||||
ol.reproj.Image = function(sourceProj, targetProj,
|
||||
var _ol_reproj_Image_ = function(sourceProj, targetProj,
|
||||
targetExtent, targetResolution, pixelRatio, getImageFunction) {
|
||||
|
||||
/**
|
||||
@@ -42,19 +42,19 @@ ol.reproj.Image = function(sourceProj, targetProj,
|
||||
var maxTargetExtent = targetProj.getExtent();
|
||||
|
||||
var limitedTargetExtent = maxTargetExtent ?
|
||||
ol.extent.getIntersection(targetExtent, maxTargetExtent) : targetExtent;
|
||||
_ol_extent_.getIntersection(targetExtent, maxTargetExtent) : targetExtent;
|
||||
|
||||
var targetCenter = ol.extent.getCenter(limitedTargetExtent);
|
||||
var sourceResolution = ol.reproj.calculateSourceResolution(
|
||||
var targetCenter = _ol_extent_.getCenter(limitedTargetExtent);
|
||||
var sourceResolution = _ol_reproj_.calculateSourceResolution(
|
||||
sourceProj, targetProj, targetCenter, targetResolution);
|
||||
|
||||
var errorThresholdInPixels = ol.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD;
|
||||
var errorThresholdInPixels = _ol_.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!ol.reproj.Triangulation}
|
||||
*/
|
||||
this.triangulation_ = new ol.reproj.Triangulation(
|
||||
this.triangulation_ = new _ol_reproj_Triangulation_(
|
||||
sourceProj, targetProj, limitedTargetExtent, this.maxSourceExtent_,
|
||||
sourceResolution * errorThresholdInPixels);
|
||||
|
||||
@@ -99,32 +99,33 @@ ol.reproj.Image = function(sourceProj, targetProj,
|
||||
this.sourceListenerKey_ = null;
|
||||
|
||||
|
||||
var state = ol.ImageState.LOADED;
|
||||
var state = _ol_ImageState_.LOADED;
|
||||
|
||||
if (this.sourceImage_) {
|
||||
state = ol.ImageState.IDLE;
|
||||
state = _ol_ImageState_.IDLE;
|
||||
}
|
||||
|
||||
ol.ImageBase.call(this, targetExtent, targetResolution, this.sourcePixelRatio_, state);
|
||||
_ol_ImageBase_.call(this, targetExtent, targetResolution, this.sourcePixelRatio_, state);
|
||||
};
|
||||
ol.inherits(ol.reproj.Image, ol.ImageBase);
|
||||
|
||||
_ol_.inherits(_ol_reproj_Image_, _ol_ImageBase_);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.reproj.Image.prototype.disposeInternal = function() {
|
||||
if (this.state == ol.ImageState.LOADING) {
|
||||
_ol_reproj_Image_.prototype.disposeInternal = function() {
|
||||
if (this.state == _ol_ImageState_.LOADING) {
|
||||
this.unlistenSource_();
|
||||
}
|
||||
ol.ImageBase.prototype.disposeInternal.call(this);
|
||||
_ol_ImageBase_.prototype.disposeInternal.call(this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.reproj.Image.prototype.getImage = function() {
|
||||
_ol_reproj_Image_.prototype.getImage = function() {
|
||||
return this.canvas_;
|
||||
};
|
||||
|
||||
@@ -132,7 +133,7 @@ ol.reproj.Image.prototype.getImage = function() {
|
||||
/**
|
||||
* @return {ol.proj.Projection} Projection.
|
||||
*/
|
||||
ol.reproj.Image.prototype.getProjection = function() {
|
||||
_ol_reproj_Image_.prototype.getProjection = function() {
|
||||
return this.targetProj_;
|
||||
};
|
||||
|
||||
@@ -140,14 +141,14 @@ ol.reproj.Image.prototype.getProjection = function() {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.reproj.Image.prototype.reproject_ = function() {
|
||||
_ol_reproj_Image_.prototype.reproject_ = function() {
|
||||
var sourceState = this.sourceImage_.getState();
|
||||
if (sourceState == ol.ImageState.LOADED) {
|
||||
var width = ol.extent.getWidth(this.targetExtent_) / this.targetResolution_;
|
||||
if (sourceState == _ol_ImageState_.LOADED) {
|
||||
var width = _ol_extent_.getWidth(this.targetExtent_) / this.targetResolution_;
|
||||
var height =
|
||||
ol.extent.getHeight(this.targetExtent_) / this.targetResolution_;
|
||||
_ol_extent_.getHeight(this.targetExtent_) / this.targetResolution_;
|
||||
|
||||
this.canvas_ = ol.reproj.render(width, height, this.sourcePixelRatio_,
|
||||
this.canvas_ = _ol_reproj_.render(width, height, this.sourcePixelRatio_,
|
||||
this.sourceImage_.getResolution(), this.maxSourceExtent_,
|
||||
this.targetResolution_, this.targetExtent_, this.triangulation_, [{
|
||||
extent: this.sourceImage_.getExtent(),
|
||||
@@ -162,21 +163,21 @@ ol.reproj.Image.prototype.reproject_ = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.reproj.Image.prototype.load = function() {
|
||||
if (this.state == ol.ImageState.IDLE) {
|
||||
this.state = ol.ImageState.LOADING;
|
||||
_ol_reproj_Image_.prototype.load = function() {
|
||||
if (this.state == _ol_ImageState_.IDLE) {
|
||||
this.state = _ol_ImageState_.LOADING;
|
||||
this.changed();
|
||||
|
||||
var sourceState = this.sourceImage_.getState();
|
||||
if (sourceState == ol.ImageState.LOADED ||
|
||||
sourceState == ol.ImageState.ERROR) {
|
||||
if (sourceState == _ol_ImageState_.LOADED ||
|
||||
sourceState == _ol_ImageState_.ERROR) {
|
||||
this.reproject_();
|
||||
} else {
|
||||
this.sourceListenerKey_ = ol.events.listen(this.sourceImage_,
|
||||
ol.events.EventType.CHANGE, function(e) {
|
||||
this.sourceListenerKey_ = _ol_events_.listen(this.sourceImage_,
|
||||
_ol_events_EventType_.CHANGE, function(e) {
|
||||
var sourceState = this.sourceImage_.getState();
|
||||
if (sourceState == ol.ImageState.LOADED ||
|
||||
sourceState == ol.ImageState.ERROR) {
|
||||
if (sourceState == _ol_ImageState_.LOADED ||
|
||||
sourceState == _ol_ImageState_.ERROR) {
|
||||
this.unlistenSource_();
|
||||
this.reproject_();
|
||||
}
|
||||
@@ -190,7 +191,8 @@ ol.reproj.Image.prototype.load = function() {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.reproj.Image.prototype.unlistenSource_ = function() {
|
||||
ol.events.unlistenByKey(/** @type {!ol.EventsKey} */ (this.sourceListenerKey_));
|
||||
_ol_reproj_Image_.prototype.unlistenSource_ = function() {
|
||||
_ol_events_.unlistenByKey(/** @type {!ol.EventsKey} */ (this.sourceListenerKey_));
|
||||
this.sourceListenerKey_ = null;
|
||||
};
|
||||
export default _ol_reproj_Image_;
|
||||
|
||||
+54
-52
@@ -1,15 +1,15 @@
|
||||
goog.provide('ol.reproj.Tile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.math');
|
||||
goog.require('ol.reproj');
|
||||
goog.require('ol.reproj.Triangulation');
|
||||
|
||||
/**
|
||||
* @module ol/reproj/Tile
|
||||
*/
|
||||
import _ol_ from '../index.js';
|
||||
import _ol_Tile_ from '../Tile.js';
|
||||
import _ol_TileState_ from '../TileState.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import _ol_events_EventType_ from '../events/EventType.js';
|
||||
import _ol_extent_ from '../extent.js';
|
||||
import _ol_math_ from '../math.js';
|
||||
import _ol_reproj_ from '../reproj.js';
|
||||
import _ol_reproj_Triangulation_ from '../reproj/Triangulation.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -31,11 +31,11 @@ goog.require('ol.reproj.Triangulation');
|
||||
* @param {number=} opt_errorThreshold Acceptable reprojection error (in px).
|
||||
* @param {boolean=} opt_renderEdges Render reprojection edges.
|
||||
*/
|
||||
ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid,
|
||||
targetProj, targetTileGrid, tileCoord, wrappedTileCoord,
|
||||
pixelRatio, gutter, getTileFunction,
|
||||
opt_errorThreshold, opt_renderEdges) {
|
||||
ol.Tile.call(this, tileCoord, ol.TileState.IDLE);
|
||||
_ol_Tile_.call(this, tileCoord, _ol_TileState_.IDLE);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -102,12 +102,12 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
var maxSourceExtent = this.sourceTileGrid_.getExtent();
|
||||
|
||||
var limitedTargetExtent = maxTargetExtent ?
|
||||
ol.extent.getIntersection(targetExtent, maxTargetExtent) : targetExtent;
|
||||
_ol_extent_.getIntersection(targetExtent, maxTargetExtent) : targetExtent;
|
||||
|
||||
if (ol.extent.getArea(limitedTargetExtent) === 0) {
|
||||
if (_ol_extent_.getArea(limitedTargetExtent) === 0) {
|
||||
// Tile is completely outside range -> EMPTY
|
||||
// TODO: is it actually correct that the source even creates the tile ?
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.state = _ol_TileState_.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
if (!maxSourceExtent) {
|
||||
maxSourceExtent = sourceProjExtent;
|
||||
} else {
|
||||
maxSourceExtent = ol.extent.getIntersection(
|
||||
maxSourceExtent = _ol_extent_.getIntersection(
|
||||
maxSourceExtent, sourceProjExtent);
|
||||
}
|
||||
}
|
||||
@@ -124,31 +124,31 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
var targetResolution = targetTileGrid.getResolution(
|
||||
this.wrappedTileCoord_[0]);
|
||||
|
||||
var targetCenter = ol.extent.getCenter(limitedTargetExtent);
|
||||
var sourceResolution = ol.reproj.calculateSourceResolution(
|
||||
var targetCenter = _ol_extent_.getCenter(limitedTargetExtent);
|
||||
var sourceResolution = _ol_reproj_.calculateSourceResolution(
|
||||
sourceProj, targetProj, targetCenter, targetResolution);
|
||||
|
||||
if (!isFinite(sourceResolution) || sourceResolution <= 0) {
|
||||
// invalid sourceResolution -> EMPTY
|
||||
// probably edges of the projections when no extent is defined
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.state = _ol_TileState_.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
var errorThresholdInPixels = opt_errorThreshold !== undefined ?
|
||||
opt_errorThreshold : ol.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD;
|
||||
opt_errorThreshold : _ol_.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!ol.reproj.Triangulation}
|
||||
*/
|
||||
this.triangulation_ = new ol.reproj.Triangulation(
|
||||
this.triangulation_ = new _ol_reproj_Triangulation_(
|
||||
sourceProj, targetProj, limitedTargetExtent, maxSourceExtent,
|
||||
sourceResolution * errorThresholdInPixels);
|
||||
|
||||
if (this.triangulation_.getTriangles().length === 0) {
|
||||
// no valid triangles -> EMPTY
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.state = _ol_TileState_.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,17 +157,17 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
|
||||
if (maxSourceExtent) {
|
||||
if (sourceProj.canWrapX()) {
|
||||
sourceExtent[1] = ol.math.clamp(
|
||||
sourceExtent[1] = _ol_math_.clamp(
|
||||
sourceExtent[1], maxSourceExtent[1], maxSourceExtent[3]);
|
||||
sourceExtent[3] = ol.math.clamp(
|
||||
sourceExtent[3] = _ol_math_.clamp(
|
||||
sourceExtent[3], maxSourceExtent[1], maxSourceExtent[3]);
|
||||
} else {
|
||||
sourceExtent = ol.extent.getIntersection(sourceExtent, maxSourceExtent);
|
||||
sourceExtent = _ol_extent_.getIntersection(sourceExtent, maxSourceExtent);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ol.extent.getArea(sourceExtent)) {
|
||||
this.state = ol.TileState.EMPTY;
|
||||
if (!_ol_extent_.getArea(sourceExtent)) {
|
||||
this.state = _ol_TileState_.EMPTY;
|
||||
} else {
|
||||
var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ(
|
||||
sourceExtent, this.sourceZ_);
|
||||
@@ -182,21 +182,22 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
}
|
||||
|
||||
if (this.sourceTiles_.length === 0) {
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.state = _ol_TileState_.EMPTY;
|
||||
}
|
||||
}
|
||||
};
|
||||
ol.inherits(ol.reproj.Tile, ol.Tile);
|
||||
|
||||
_ol_.inherits(_ol_reproj_Tile_, _ol_Tile_);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.reproj.Tile.prototype.disposeInternal = function() {
|
||||
if (this.state == ol.TileState.LOADING) {
|
||||
_ol_reproj_Tile_.prototype.disposeInternal = function() {
|
||||
if (this.state == _ol_TileState_.LOADING) {
|
||||
this.unlistenSources_();
|
||||
}
|
||||
ol.Tile.prototype.disposeInternal.call(this);
|
||||
_ol_Tile_.prototype.disposeInternal.call(this);
|
||||
};
|
||||
|
||||
|
||||
@@ -204,7 +205,7 @@ ol.reproj.Tile.prototype.disposeInternal = function() {
|
||||
* Get the HTML Canvas element for this tile.
|
||||
* @return {HTMLCanvasElement} Canvas.
|
||||
*/
|
||||
ol.reproj.Tile.prototype.getImage = function() {
|
||||
_ol_reproj_Tile_.prototype.getImage = function() {
|
||||
return this.canvas_;
|
||||
};
|
||||
|
||||
@@ -212,10 +213,10 @@ ol.reproj.Tile.prototype.getImage = function() {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
_ol_reproj_Tile_.prototype.reproject_ = function() {
|
||||
var sources = [];
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
if (tile && tile.getState() == ol.TileState.LOADED) {
|
||||
if (tile && tile.getState() == _ol_TileState_.LOADED) {
|
||||
sources.push({
|
||||
extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord),
|
||||
image: tile.getImage()
|
||||
@@ -225,7 +226,7 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
this.sourceTiles_.length = 0;
|
||||
|
||||
if (sources.length === 0) {
|
||||
this.state = ol.TileState.ERROR;
|
||||
this.state = _ol_TileState_.ERROR;
|
||||
} else {
|
||||
var z = this.wrappedTileCoord_[0];
|
||||
var size = this.targetTileGrid_.getTileSize(z);
|
||||
@@ -236,12 +237,12 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
|
||||
var targetExtent = this.targetTileGrid_.getTileCoordExtent(
|
||||
this.wrappedTileCoord_);
|
||||
this.canvas_ = ol.reproj.render(width, height, this.pixelRatio_,
|
||||
this.canvas_ = _ol_reproj_.render(width, height, this.pixelRatio_,
|
||||
sourceResolution, this.sourceTileGrid_.getExtent(),
|
||||
targetResolution, targetExtent, this.triangulation_, sources,
|
||||
this.gutter_, this.renderEdges_);
|
||||
|
||||
this.state = ol.TileState.LOADED;
|
||||
this.state = _ol_TileState_.LOADED;
|
||||
}
|
||||
this.changed();
|
||||
};
|
||||
@@ -250,9 +251,9 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.reproj.Tile.prototype.load = function() {
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
_ol_reproj_Tile_.prototype.load = function() {
|
||||
if (this.state == _ol_TileState_.IDLE) {
|
||||
this.state = _ol_TileState_.LOADING;
|
||||
this.changed();
|
||||
|
||||
var leftToLoad = 0;
|
||||
@@ -260,17 +261,17 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
this.sourcesListenerKeys_ = [];
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.IDLE || state == ol.TileState.LOADING) {
|
||||
if (state == _ol_TileState_.IDLE || state == _ol_TileState_.LOADING) {
|
||||
leftToLoad++;
|
||||
|
||||
var sourceListenKey;
|
||||
sourceListenKey = ol.events.listen(tile, ol.events.EventType.CHANGE,
|
||||
sourceListenKey = _ol_events_.listen(tile, _ol_events_EventType_.CHANGE,
|
||||
function(e) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.LOADED ||
|
||||
state == ol.TileState.ERROR ||
|
||||
state == ol.TileState.EMPTY) {
|
||||
ol.events.unlistenByKey(sourceListenKey);
|
||||
if (state == _ol_TileState_.LOADED ||
|
||||
state == _ol_TileState_.ERROR ||
|
||||
state == _ol_TileState_.EMPTY) {
|
||||
_ol_events_.unlistenByKey(sourceListenKey);
|
||||
leftToLoad--;
|
||||
if (leftToLoad === 0) {
|
||||
this.unlistenSources_();
|
||||
@@ -284,7 +285,7 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.IDLE) {
|
||||
if (state == _ol_TileState_.IDLE) {
|
||||
tile.load();
|
||||
}
|
||||
});
|
||||
@@ -299,7 +300,8 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.reproj.Tile.prototype.unlistenSources_ = function() {
|
||||
this.sourcesListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||
_ol_reproj_Tile_.prototype.unlistenSources_ = function() {
|
||||
this.sourcesListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.sourcesListenerKeys_ = null;
|
||||
};
|
||||
export default _ol_reproj_Tile_;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
goog.provide('ol.reproj.Triangulation');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.math');
|
||||
goog.require('ol.proj');
|
||||
|
||||
/**
|
||||
* @module ol/reproj/Triangulation
|
||||
*/
|
||||
import _ol_ from '../index.js';
|
||||
import _ol_extent_ from '../extent.js';
|
||||
import _ol_math_ from '../math.js';
|
||||
import _ol_proj_ from '../proj.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -18,7 +18,7 @@ goog.require('ol.proj');
|
||||
* @param {number} errorThreshold Acceptable error (in source units).
|
||||
* @constructor
|
||||
*/
|
||||
ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent,
|
||||
var _ol_reproj_Triangulation_ = function(sourceProj, targetProj, targetExtent,
|
||||
maxSourceExtent, errorThreshold) {
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent,
|
||||
|
||||
/** @type {!Object.<string, ol.Coordinate>} */
|
||||
var transformInvCache = {};
|
||||
var transformInv = ol.proj.getTransform(this.targetProj_, this.sourceProj_);
|
||||
var transformInv = _ol_proj_.getTransform(this.targetProj_, this.sourceProj_);
|
||||
|
||||
/**
|
||||
* @param {ol.Coordinate} c A coordinate.
|
||||
@@ -82,27 +82,27 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent,
|
||||
this.canWrapXInSource_ = this.sourceProj_.canWrapX() &&
|
||||
!!maxSourceExtent &&
|
||||
!!this.sourceProj_.getExtent() &&
|
||||
(ol.extent.getWidth(maxSourceExtent) ==
|
||||
ol.extent.getWidth(this.sourceProj_.getExtent()));
|
||||
(_ol_extent_.getWidth(maxSourceExtent) ==
|
||||
_ol_extent_.getWidth(this.sourceProj_.getExtent()));
|
||||
|
||||
/**
|
||||
* @type {?number}
|
||||
* @private
|
||||
*/
|
||||
this.sourceWorldWidth_ = this.sourceProj_.getExtent() ?
|
||||
ol.extent.getWidth(this.sourceProj_.getExtent()) : null;
|
||||
_ol_extent_.getWidth(this.sourceProj_.getExtent()) : null;
|
||||
|
||||
/**
|
||||
* @type {?number}
|
||||
* @private
|
||||
*/
|
||||
this.targetWorldWidth_ = this.targetProj_.getExtent() ?
|
||||
ol.extent.getWidth(this.targetProj_.getExtent()) : null;
|
||||
_ol_extent_.getWidth(this.targetProj_.getExtent()) : null;
|
||||
|
||||
var destinationTopLeft = ol.extent.getTopLeft(targetExtent);
|
||||
var destinationTopRight = ol.extent.getTopRight(targetExtent);
|
||||
var destinationBottomRight = ol.extent.getBottomRight(targetExtent);
|
||||
var destinationBottomLeft = ol.extent.getBottomLeft(targetExtent);
|
||||
var destinationTopLeft = _ol_extent_.getTopLeft(targetExtent);
|
||||
var destinationTopRight = _ol_extent_.getTopRight(targetExtent);
|
||||
var destinationBottomRight = _ol_extent_.getBottomRight(targetExtent);
|
||||
var destinationBottomLeft = _ol_extent_.getBottomLeft(targetExtent);
|
||||
var sourceTopLeft = this.transformInv_(destinationTopLeft);
|
||||
var sourceTopRight = this.transformInv_(destinationTopRight);
|
||||
var sourceBottomRight = this.transformInv_(destinationBottomRight);
|
||||
@@ -112,7 +112,7 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent,
|
||||
destinationTopLeft, destinationTopRight,
|
||||
destinationBottomRight, destinationBottomLeft,
|
||||
sourceTopLeft, sourceTopRight, sourceBottomRight, sourceBottomLeft,
|
||||
ol.RASTER_REPROJECTION_MAX_SUBDIVISION);
|
||||
_ol_.RASTER_REPROJECTION_MAX_SUBDIVISION);
|
||||
|
||||
if (this.wrapsXInSource_) {
|
||||
var leftBound = Infinity;
|
||||
@@ -167,7 +167,7 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent,
|
||||
* @param {ol.Coordinate} cSrc The source c coordinate.
|
||||
* @private
|
||||
*/
|
||||
ol.reproj.Triangulation.prototype.addTriangle_ = function(a, b, c,
|
||||
_ol_reproj_Triangulation_.prototype.addTriangle_ = function(a, b, c,
|
||||
aSrc, bSrc, cSrc) {
|
||||
this.triangles_.push({
|
||||
source: [aSrc, bSrc, cSrc],
|
||||
@@ -192,12 +192,12 @@ ol.reproj.Triangulation.prototype.addTriangle_ = function(a, b, c,
|
||||
* @param {number} maxSubdivision Maximal allowed subdivision of the quad.
|
||||
* @private
|
||||
*/
|
||||
ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
|
||||
_ol_reproj_Triangulation_.prototype.addQuad_ = function(a, b, c, d,
|
||||
aSrc, bSrc, cSrc, dSrc, maxSubdivision) {
|
||||
|
||||
var sourceQuadExtent = ol.extent.boundingExtent([aSrc, bSrc, cSrc, dSrc]);
|
||||
var sourceQuadExtent = _ol_extent_.boundingExtent([aSrc, bSrc, cSrc, dSrc]);
|
||||
var sourceCoverageX = this.sourceWorldWidth_ ?
|
||||
ol.extent.getWidth(sourceQuadExtent) / this.sourceWorldWidth_ : null;
|
||||
_ol_extent_.getWidth(sourceQuadExtent) / this.sourceWorldWidth_ : null;
|
||||
var sourceWorldWidth = /** @type {number} */ (this.sourceWorldWidth_);
|
||||
|
||||
// when the quad is wrapped in the source projection
|
||||
@@ -209,20 +209,20 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
|
||||
|
||||
if (maxSubdivision > 0) {
|
||||
if (this.targetProj_.isGlobal() && this.targetWorldWidth_) {
|
||||
var targetQuadExtent = ol.extent.boundingExtent([a, b, c, d]);
|
||||
var targetQuadExtent = _ol_extent_.boundingExtent([a, b, c, d]);
|
||||
var targetCoverageX =
|
||||
ol.extent.getWidth(targetQuadExtent) / this.targetWorldWidth_;
|
||||
_ol_extent_.getWidth(targetQuadExtent) / this.targetWorldWidth_;
|
||||
needsSubdivision |=
|
||||
targetCoverageX > ol.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH;
|
||||
targetCoverageX > _ol_.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH;
|
||||
}
|
||||
if (!wrapsX && this.sourceProj_.isGlobal() && sourceCoverageX) {
|
||||
needsSubdivision |=
|
||||
sourceCoverageX > ol.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH;
|
||||
sourceCoverageX > _ol_.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
if (!needsSubdivision && this.maxSourceExtent_) {
|
||||
if (!ol.extent.intersects(sourceQuadExtent, this.maxSourceExtent_)) {
|
||||
if (!_ol_extent_.intersects(sourceQuadExtent, this.maxSourceExtent_)) {
|
||||
// whole quad outside source projection extent -> ignore
|
||||
return;
|
||||
}
|
||||
@@ -249,10 +249,10 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
|
||||
var dx;
|
||||
if (wrapsX) {
|
||||
var centerSrcEstimX =
|
||||
(ol.math.modulo(aSrc[0], sourceWorldWidth) +
|
||||
ol.math.modulo(cSrc[0], sourceWorldWidth)) / 2;
|
||||
(_ol_math_.modulo(aSrc[0], sourceWorldWidth) +
|
||||
_ol_math_.modulo(cSrc[0], sourceWorldWidth)) / 2;
|
||||
dx = centerSrcEstimX -
|
||||
ol.math.modulo(centerSrc[0], sourceWorldWidth);
|
||||
_ol_math_.modulo(centerSrc[0], sourceWorldWidth);
|
||||
} else {
|
||||
dx = (aSrc[0] + cSrc[0]) / 2 - centerSrc[0];
|
||||
}
|
||||
@@ -305,14 +305,14 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d,
|
||||
*
|
||||
* @return {ol.Extent} Calculated extent.
|
||||
*/
|
||||
ol.reproj.Triangulation.prototype.calculateSourceExtent = function() {
|
||||
var extent = ol.extent.createEmpty();
|
||||
_ol_reproj_Triangulation_.prototype.calculateSourceExtent = function() {
|
||||
var extent = _ol_extent_.createEmpty();
|
||||
|
||||
this.triangles_.forEach(function(triangle, i, arr) {
|
||||
var src = triangle.source;
|
||||
ol.extent.extendCoordinate(extent, src[0]);
|
||||
ol.extent.extendCoordinate(extent, src[1]);
|
||||
ol.extent.extendCoordinate(extent, src[2]);
|
||||
_ol_extent_.extendCoordinate(extent, src[0]);
|
||||
_ol_extent_.extendCoordinate(extent, src[1]);
|
||||
_ol_extent_.extendCoordinate(extent, src[2]);
|
||||
});
|
||||
|
||||
return extent;
|
||||
@@ -322,6 +322,7 @@ ol.reproj.Triangulation.prototype.calculateSourceExtent = function() {
|
||||
/**
|
||||
* @return {Array.<ol.ReprojTriangle>} Array of the calculated triangles.
|
||||
*/
|
||||
ol.reproj.Triangulation.prototype.getTriangles = function() {
|
||||
_ol_reproj_Triangulation_.prototype.getTriangles = function() {
|
||||
return this.triangles_;
|
||||
};
|
||||
export default _ol_reproj_Triangulation_;
|
||||
|
||||
Reference in New Issue
Block a user