Simplify hit detection code

This commit is contained in:
Éric Lemoine
2014-12-05 15:42:54 +01:00
parent 571cd1c57a
commit fdf52c1865
12 changed files with 142 additions and 158 deletions

View File

@@ -130,12 +130,10 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
return this.replayGroup_.forEachGeometryAtPixel(extent, resolution,
rotation, coordinate, frameState.skippedFeatureUids,
/**
* @param {ol.geom.Geometry} geometry Geometry.
* @param {Object} data Data.
* @param {ol.Feature} feature Feature.
* @return {?} Callback result.
*/
function(geometry, data) {
var feature = /** @type {ol.Feature} */ (data);
function(feature) {
goog.asserts.assert(goog.isDef(feature));
var key = goog.getUid(feature).toString();
if (!(key in features)) {
@@ -278,7 +276,7 @@ ol.renderer.canvas.VectorLayer.prototype.renderFeature =
loading = ol.renderer.vector.renderFeature(
replayGroup, feature, styles[i],
ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio),
feature, this.handleImageChange_, this) || loading;
this.handleImageChange_, this) || loading;
}
return loading;
};

View File

@@ -171,12 +171,10 @@ ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtPixel =
return this.replayGroup_.forEachGeometryAtPixel(extent, resolution,
rotation, coordinate, frameState.skippedFeatureUids,
/**
* @param {ol.geom.Geometry} geometry Geometry.
* @param {Object} data Data.
* @param {ol.Feature} feature Feature.
* @return {?} Callback result.
*/
function(geometry, data) {
var feature = /** @type {ol.Feature} */ (data);
function(feature) {
goog.asserts.assert(goog.isDef(feature));
var key = goog.getUid(feature).toString();
if (!(key in features)) {
@@ -319,7 +317,7 @@ ol.renderer.dom.VectorLayer.prototype.renderFeature =
loading = ol.renderer.vector.renderFeature(
replayGroup, feature, styles[i],
ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio),
feature, this.handleImageChange_, this) || loading;
this.handleImageChange_, this) || loading;
}
return loading;
};

View File

@@ -135,12 +135,10 @@ ol.renderer.Map.prototype.forEachFeatureAtPixel =
result = this.replayGroup.forEachGeometryAtPixel(extent, viewResolution,
viewRotation, coordinate, {},
/**
* @param {ol.geom.Geometry} geometry Geometry.
* @param {Object} data Data.
* @param {ol.Feature} feature Feature.
* @return {?} Callback result.
*/
function(geometry, data) {
var feature = /** @type {ol.Feature} */ (data);
function(feature) {
goog.asserts.assert(goog.isDef(feature));
var key = goog.getUid(feature).toString();
if (!(key in features)) {

View File

@@ -234,7 +234,7 @@ ol.renderer.webgl.VectorLayer.prototype.renderFeature =
loading = ol.renderer.vector.renderFeature(
replayGroup, feature, styles[i],
ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio),
feature, this.handleImageChange_, this) || loading;
this.handleImageChange_, this) || loading;
}
return loading;
};