Use alphabetical order for canvas ReplayGroup methods
This commit is contained in:
@@ -1855,40 +1855,90 @@ ol.render.canvas.ReplayGroup = function(tolerance, maxExtent, resolution) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* FIXME empty description for jsdoc
|
||||||
* @param {CanvasRenderingContext2D} context Context.
|
*/
|
||||||
|
ol.render.canvas.ReplayGroup.prototype.finish = function() {
|
||||||
|
var zKey;
|
||||||
|
for (zKey in this.replaysByZIndex_) {
|
||||||
|
var replays = this.replaysByZIndex_[zKey];
|
||||||
|
var replayKey;
|
||||||
|
for (replayKey in replays) {
|
||||||
|
replays[replayKey].finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
* @param {number} resolution Resolution.
|
||||||
* @param {number} viewRotation View rotation.
|
* @param {number} rotation Rotation.
|
||||||
|
* @param {ol.Coordinate} coordinate Coordinate.
|
||||||
* @param {Object} skippedFeaturesHash Ids of features to skip
|
* @param {Object} skippedFeaturesHash Ids of features to skip
|
||||||
* @param {function(ol.geom.Geometry, Object): T} geometryCallback Geometry
|
* @param {function(ol.geom.Geometry, Object): T} callback Geometry callback.
|
||||||
* callback.
|
|
||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
|
ol.render.canvas.ReplayGroup.prototype.forEachGeometryAtPixel = function(
|
||||||
context, extent, transform, viewRotation, skippedFeaturesHash,
|
extent, resolution, rotation, coordinate,
|
||||||
geometryCallback) {
|
skippedFeaturesHash, callback) {
|
||||||
/** @type {Array.<number>} */
|
|
||||||
var zs = goog.array.map(goog.object.getKeys(this.replaysByZIndex_), Number);
|
|
||||||
goog.array.sort(zs, function(a, b) { return b - a; });
|
|
||||||
|
|
||||||
var i, ii, j, replays, replay, result;
|
var transform = this.hitDetectionTransform_;
|
||||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
ol.vec.Mat4.makeTransform2D(transform, 0.5, 0.5,
|
||||||
replays = this.replaysByZIndex_[zs[i].toString()];
|
1 / resolution, -1 / resolution, -rotation,
|
||||||
for (j = ol.render.REPLAY_ORDER.length - 1; j >= 0; --j) {
|
-coordinate[0], -coordinate[1]);
|
||||||
replay = replays[ol.render.REPLAY_ORDER[j]];
|
|
||||||
if (goog.isDef(replay) &&
|
var context = this.hitDetectionContext_;
|
||||||
ol.extent.intersects(extent, replay.getExtent())) {
|
context.clearRect(0, 0, 1, 1);
|
||||||
result = replay.replayHitDetection(context, transform, viewRotation,
|
|
||||||
skippedFeaturesHash, geometryCallback);
|
return this.replayHitDetection_(context, extent, transform,
|
||||||
if (result) {
|
rotation, skippedFeaturesHash,
|
||||||
return result;
|
/**
|
||||||
|
* @param {ol.geom.Geometry} geometry Geometry.
|
||||||
|
* @param {Object} data Opaque data object.
|
||||||
|
* @return {?} Callback result.
|
||||||
|
*/
|
||||||
|
function(geometry, data) {
|
||||||
|
var imageData = context.getImageData(0, 0, 1, 1).data;
|
||||||
|
if (imageData[3] > 0) {
|
||||||
|
var result = callback(geometry, data);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
context.clearRect(0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.canvas.ReplayGroup.prototype.getReplay =
|
||||||
|
function(zIndex, replayType) {
|
||||||
|
var zIndexKey = goog.isDef(zIndex) ? zIndex.toString() : '0';
|
||||||
|
var replays = this.replaysByZIndex_[zIndexKey];
|
||||||
|
if (!goog.isDef(replays)) {
|
||||||
|
replays = {};
|
||||||
|
this.replaysByZIndex_[zIndexKey] = replays;
|
||||||
}
|
}
|
||||||
return undefined;
|
var replay = replays[replayType];
|
||||||
|
if (!goog.isDef(replay)) {
|
||||||
|
var Constructor = ol.render.canvas.BATCH_CONSTRUCTORS_[replayType];
|
||||||
|
goog.asserts.assert(goog.isDef(Constructor));
|
||||||
|
replay = new Constructor(this.tolerance_, this.maxExtent_,
|
||||||
|
this.resolution_);
|
||||||
|
replays[replayType] = replay;
|
||||||
|
}
|
||||||
|
return replay;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.canvas.ReplayGroup.prototype.isEmpty = function() {
|
||||||
|
return goog.object.isEmpty(this.replaysByZIndex_);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1942,90 +1992,40 @@ ol.render.canvas.ReplayGroup.prototype.replay = function(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
|
* @param {CanvasRenderingContext2D} context Context.
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {number} resolution Resolution.
|
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||||
* @param {number} rotation Rotation.
|
* @param {number} viewRotation View rotation.
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
|
||||||
* @param {Object} skippedFeaturesHash Ids of features to skip
|
* @param {Object} skippedFeaturesHash Ids of features to skip
|
||||||
* @param {function(ol.geom.Geometry, Object): T} callback Geometry callback.
|
* @param {function(ol.geom.Geometry, Object): T} geometryCallback Geometry
|
||||||
|
* callback.
|
||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.canvas.ReplayGroup.prototype.forEachGeometryAtPixel = function(
|
ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
|
||||||
extent, resolution, rotation, coordinate,
|
context, extent, transform, viewRotation, skippedFeaturesHash,
|
||||||
skippedFeaturesHash, callback) {
|
geometryCallback) {
|
||||||
|
/** @type {Array.<number>} */
|
||||||
|
var zs = goog.array.map(goog.object.getKeys(this.replaysByZIndex_), Number);
|
||||||
|
goog.array.sort(zs, function(a, b) { return b - a; });
|
||||||
|
|
||||||
var transform = this.hitDetectionTransform_;
|
var i, ii, j, replays, replay, result;
|
||||||
ol.vec.Mat4.makeTransform2D(transform, 0.5, 0.5,
|
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||||
1 / resolution, -1 / resolution, -rotation,
|
replays = this.replaysByZIndex_[zs[i].toString()];
|
||||||
-coordinate[0], -coordinate[1]);
|
for (j = ol.render.REPLAY_ORDER.length - 1; j >= 0; --j) {
|
||||||
|
replay = replays[ol.render.REPLAY_ORDER[j]];
|
||||||
var context = this.hitDetectionContext_;
|
if (goog.isDef(replay) &&
|
||||||
context.clearRect(0, 0, 1, 1);
|
ol.extent.intersects(extent, replay.getExtent())) {
|
||||||
|
result = replay.replayHitDetection(context, transform, viewRotation,
|
||||||
return this.replayHitDetection_(context, extent, transform,
|
skippedFeaturesHash, geometryCallback);
|
||||||
rotation, skippedFeaturesHash,
|
if (result) {
|
||||||
/**
|
return result;
|
||||||
* @param {ol.geom.Geometry} geometry Geometry.
|
|
||||||
* @param {Object} data Opaque data object.
|
|
||||||
* @return {?} Callback result.
|
|
||||||
*/
|
|
||||||
function(geometry, data) {
|
|
||||||
var imageData = context.getImageData(0, 0, 1, 1).data;
|
|
||||||
if (imageData[3] > 0) {
|
|
||||||
var result = callback(geometry, data);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
context.clearRect(0, 0, 1, 1);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FIXME empty description for jsdoc
|
|
||||||
*/
|
|
||||||
ol.render.canvas.ReplayGroup.prototype.finish = function() {
|
|
||||||
var zKey;
|
|
||||||
for (zKey in this.replaysByZIndex_) {
|
|
||||||
var replays = this.replaysByZIndex_[zKey];
|
|
||||||
var replayKey;
|
|
||||||
for (replayKey in replays) {
|
|
||||||
replays[replayKey].finish();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
return undefined;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.render.canvas.ReplayGroup.prototype.getReplay =
|
|
||||||
function(zIndex, replayType) {
|
|
||||||
var zIndexKey = goog.isDef(zIndex) ? zIndex.toString() : '0';
|
|
||||||
var replays = this.replaysByZIndex_[zIndexKey];
|
|
||||||
if (!goog.isDef(replays)) {
|
|
||||||
replays = {};
|
|
||||||
this.replaysByZIndex_[zIndexKey] = replays;
|
|
||||||
}
|
|
||||||
var replay = replays[replayType];
|
|
||||||
if (!goog.isDef(replay)) {
|
|
||||||
var Constructor = ol.render.canvas.BATCH_CONSTRUCTORS_[replayType];
|
|
||||||
goog.asserts.assert(goog.isDef(Constructor));
|
|
||||||
replay = new Constructor(this.tolerance_, this.maxExtent_,
|
|
||||||
this.resolution_);
|
|
||||||
replays[replayType] = replay;
|
|
||||||
}
|
|
||||||
return replay;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.render.canvas.ReplayGroup.prototype.isEmpty = function() {
|
|
||||||
return goog.object.isEmpty(this.replaysByZIndex_);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user