Rename *AtPixel to *AtCoordinate if coordinate

This commit is contained in:
tsauerwein
2015-01-29 12:20:40 +01:00
parent 4d4bed454a
commit f4500c8f89
16 changed files with 56 additions and 55 deletions
+2 -2
View File
@@ -583,7 +583,7 @@ ol.Map.prototype.forEachFeatureAtPixel =
var layerFilter = goog.isDef(opt_layerFilter) ? var layerFilter = goog.isDef(opt_layerFilter) ?
opt_layerFilter : goog.functions.TRUE; opt_layerFilter : goog.functions.TRUE;
var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null; var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null;
return this.renderer_.forEachFeatureAtPixel( return this.renderer_.forEachFeatureAtCoordinate(
coordinate, this.frameState_, callback, thisArg, coordinate, this.frameState_, callback, thisArg,
layerFilter, thisArg2); layerFilter, thisArg2);
}; };
@@ -649,7 +649,7 @@ ol.Map.prototype.hasFeatureAtPixel =
var layerFilter = goog.isDef(opt_layerFilter) ? var layerFilter = goog.isDef(opt_layerFilter) ?
opt_layerFilter : goog.functions.TRUE; opt_layerFilter : goog.functions.TRUE;
var thisArg = goog.isDef(opt_this) ? opt_this : null; var thisArg = goog.isDef(opt_this) ? opt_this : null;
return this.renderer_.hasFeatureAtPixel( return this.renderer_.hasFeatureAtCoordinate(
coordinate, this.frameState_, layerFilter, thisArg); coordinate, this.frameState_, layerFilter, thisArg);
}; };
+1 -1
View File
@@ -1866,7 +1866,7 @@ ol.render.canvas.ReplayGroup.prototype.finish = function() {
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template T * @template T
*/ */
ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtPixel = function( ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
coordinate, resolution, rotation, skippedFeaturesHash, callback) { coordinate, resolution, rotation, skippedFeaturesHash, callback) {
var transform = this.hitDetectionTransform_; var transform = this.hitDetectionTransform_;
+3 -3
View File
@@ -1171,7 +1171,7 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context,
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template T * @template T
*/ */
ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtPixel = function( ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
coordinate, context, center, resolution, rotation, size, pixelRatio, coordinate, context, center, resolution, rotation, size, pixelRatio,
opacity, brightness, contrast, hue, saturation, skippedFeaturesHash, opacity, brightness, contrast, hue, saturation, skippedFeaturesHash,
callback) { callback) {
@@ -1228,9 +1228,9 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtPixel = function(
* @param {number} hue Global hue. * @param {number} hue Global hue.
* @param {number} saturation Global saturation. * @param {number} saturation Global saturation.
* @param {Object} skippedFeaturesHash Ids of features to skip. * @param {Object} skippedFeaturesHash Ids of features to skip.
* @return {boolean} Is there a feature at the given pixel? * @return {boolean} Is there a feature at the given coordinate?
*/ */
ol.render.webgl.ReplayGroup.prototype.hasFeatureAtPixel = function( ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function(
coordinate, context, center, resolution, rotation, size, pixelRatio, coordinate, context, center, resolution, rotation, size, pixelRatio,
opacity, brightness, contrast, hue, saturation, skippedFeaturesHash) { opacity, brightness, contrast, hue, saturation, skippedFeaturesHash) {
var gl = context.getGL(); var gl = context.getGL();
@@ -56,14 +56,14 @@ goog.inherits(ol.renderer.canvas.ImageLayer, ol.renderer.canvas.Layer);
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtPixel = ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
var layer = this.getLayer(); var layer = this.getLayer();
var source = layer.getSource(); var source = layer.getSource();
var resolution = frameState.viewState.resolution; var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation; var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids; var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel( return source.forEachFeatureAtCoordinate(
coordinate, resolution, rotation, skippedFeatureUids, coordinate, resolution, rotation, skippedFeatureUids,
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
@@ -88,7 +88,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
// for ImageVector sources use the original hit-detection logic, // for ImageVector sources use the original hit-detection logic,
// so that for example also transparent polygons are detected // so that for example also transparent polygons are detected
var coordinate = this.getMap().getCoordinateFromPixel(pixel); var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.forEachFeatureAtPixel( var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this); coordinate, frameState, goog.functions.TRUE, this);
if (hasFeature) { if (hasFeature) {
@@ -116,7 +116,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame =
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel = ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_)) { if (goog.isNull(this.replayGroup_)) {
return undefined; return undefined;
@@ -126,7 +126,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
var layer = this.getLayer(); var layer = this.getLayer();
/** @type {Object.<string, boolean>} */ /** @type {Object.<string, boolean>} */
var features = {}; var features = {};
return this.replayGroup_.forEachFeatureAtPixel(coordinate, return this.replayGroup_.forEachFeatureAtCoordinate(coordinate,
resolution, rotation, frameState.skippedFeatureUids, resolution, rotation, frameState.skippedFeatureUids,
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
+2 -2
View File
@@ -47,14 +47,14 @@ goog.inherits(ol.renderer.dom.ImageLayer, ol.renderer.dom.Layer);
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.dom.ImageLayer.prototype.forEachFeatureAtPixel = ol.renderer.dom.ImageLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
var layer = this.getLayer(); var layer = this.getLayer();
var source = layer.getSource(); var source = layer.getSource();
var resolution = frameState.viewState.resolution; var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation; var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids; var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel( return source.forEachFeatureAtCoordinate(
coordinate, resolution, rotation, skippedFeatureUids, coordinate, resolution, rotation, skippedFeatureUids,
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
@@ -176,7 +176,7 @@ ol.renderer.dom.VectorLayer.prototype.dispatchEvent_ =
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtPixel = ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_)) { if (goog.isNull(this.replayGroup_)) {
return undefined; return undefined;
@@ -186,7 +186,7 @@ ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtPixel =
var layer = this.getLayer(); var layer = this.getLayer();
/** @type {Object.<string, boolean>} */ /** @type {Object.<string, boolean>} */
var features = {}; var features = {};
return this.replayGroup_.forEachFeatureAtPixel(coordinate, return this.replayGroup_.forEachFeatureAtCoordinate(coordinate,
resolution, rotation, frameState.skippedFeatureUids, resolution, rotation, frameState.skippedFeatureUids,
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
+4 -4
View File
@@ -53,7 +53,7 @@ goog.inherits(ol.renderer.Layer, goog.Disposable);
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template S,T * @template S,T
*/ */
ol.renderer.Layer.prototype.forEachFeatureAtPixel = goog.nullFunction; ol.renderer.Layer.prototype.forEachFeatureAtCoordinate = goog.nullFunction;
/** /**
@@ -67,7 +67,7 @@ ol.renderer.Layer.prototype.forEachFeatureAtPixel = goog.nullFunction;
ol.renderer.Layer.prototype.forEachLayerAtPixel = ol.renderer.Layer.prototype.forEachLayerAtPixel =
function(pixel, frameState, callback, thisArg) { function(pixel, frameState, callback, thisArg) {
var coordinate = this.getMap().getCoordinateFromPixel(pixel); var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.forEachFeatureAtPixel( var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this); coordinate, frameState, goog.functions.TRUE, this);
if (hasFeature) { if (hasFeature) {
@@ -81,9 +81,9 @@ ol.renderer.Layer.prototype.forEachLayerAtPixel =
/** /**
* @param {ol.Coordinate} coordinate Coordinate. * @param {ol.Coordinate} coordinate Coordinate.
* @param {olx.FrameState} frameState Frame state. * @param {olx.FrameState} frameState Frame state.
* @return {boolean} Is there a feature at the given pixel? * @return {boolean} Is there a feature at the given coordinate?
*/ */
ol.renderer.Layer.prototype.hasFeatureAtPixel = goog.functions.FALSE; ol.renderer.Layer.prototype.hasFeatureAtCoordinate = goog.functions.FALSE;
/** /**
+7 -7
View File
@@ -121,7 +121,7 @@ ol.renderer.Map.expireIconCache_ = function(map, frameState) {
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template S,T,U * @template S,T,U
*/ */
ol.renderer.Map.prototype.forEachFeatureAtPixel = ol.renderer.Map.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg, function(coordinate, frameState, callback, thisArg,
layerFilter, thisArg2) { layerFilter, thisArg2) {
var result; var result;
@@ -131,7 +131,7 @@ ol.renderer.Map.prototype.forEachFeatureAtPixel =
if (!goog.isNull(this.replayGroup)) { if (!goog.isNull(this.replayGroup)) {
/** @type {Object.<string, boolean>} */ /** @type {Object.<string, boolean>} */
var features = {}; var features = {};
result = this.replayGroup.forEachFeatureAtPixel(coordinate, result = this.replayGroup.forEachFeatureAtCoordinate(coordinate,
viewResolution, viewRotation, {}, viewResolution, viewRotation, {},
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
@@ -158,7 +158,7 @@ ol.renderer.Map.prototype.forEachFeatureAtPixel =
if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) && if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) &&
layerFilter.call(thisArg2, layer)) { layerFilter.call(thisArg2, layer)) {
var layerRenderer = this.getLayerRenderer(layer); var layerRenderer = this.getLayerRenderer(layer);
result = layerRenderer.forEachFeatureAtPixel( result = layerRenderer.forEachFeatureAtCoordinate(
coordinate, frameState, callback, thisArg); coordinate, frameState, callback, thisArg);
if (result) { if (result) {
return result; return result;
@@ -193,7 +193,7 @@ ol.renderer.Map.prototype.forEachLayerAtPixel =
if (!goog.isNull(this.replayGroup)) { if (!goog.isNull(this.replayGroup)) {
var coordinate = this.getMap().getCoordinateFromPixel(pixel); var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.replayGroup.forEachFeatureAtPixel(coordinate, var hasFeature = this.replayGroup.forEachFeatureAtCoordinate(coordinate,
viewResolution, viewRotation, {}, goog.functions.TRUE); viewResolution, viewRotation, {}, goog.functions.TRUE);
if (hasFeature) { if (hasFeature) {
@@ -231,12 +231,12 @@ ol.renderer.Map.prototype.forEachLayerAtPixel =
* returns `true` will be tested for features. By default, all visible * returns `true` will be tested for features. By default, all visible
* layers will be tested. * layers will be tested.
* @param {U} thisArg Value to use as `this` when executing `layerFilter`. * @param {U} thisArg Value to use as `this` when executing `layerFilter`.
* @return {boolean} Is there a feature at the given pixel? * @return {boolean} Is there a feature at the given coordinate?
* @template U * @template U
*/ */
ol.renderer.Map.prototype.hasFeatureAtPixel = ol.renderer.Map.prototype.hasFeatureAtCoordinate =
function(coordinate, frameState, layerFilter, thisArg) { function(coordinate, frameState, layerFilter, thisArg) {
var hasFeature = this.forEachFeatureAtPixel( var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this, layerFilter, thisArg); coordinate, frameState, goog.functions.TRUE, this, layerFilter, thisArg);
return goog.isDef(hasFeature); return goog.isDef(hasFeature);
@@ -73,14 +73,14 @@ ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtPixel = ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
var layer = this.getLayer(); var layer = this.getLayer();
var source = layer.getSource(); var source = layer.getSource();
var resolution = frameState.viewState.resolution; var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation; var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids; var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel( return source.forEachFeatureAtCoordinate(
coordinate, resolution, rotation, skippedFeatureUids, coordinate, resolution, rotation, skippedFeatureUids,
/** /**
@@ -214,9 +214,9 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtPixel = ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtCoordinate =
function(coordinate, frameState) { function(coordinate, frameState) {
var hasFeature = this.forEachFeatureAtPixel( var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this); coordinate, frameState, goog.functions.TRUE, this);
return goog.isDef(hasFeature); return goog.isDef(hasFeature);
}; };
@@ -235,7 +235,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel =
// for ImageVector sources use the original hit-detection logic, // for ImageVector sources use the original hit-detection logic,
// so that for example also transparent polygons are detected // so that for example also transparent polygons are detected
var coordinate = this.getMap().getCoordinateFromPixel(pixel); var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.forEachFeatureAtPixel( var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this); coordinate, frameState, goog.functions.TRUE, this);
if (hasFeature) { if (hasFeature) {
+8 -7
View File
@@ -540,7 +540,7 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.webgl.Map.prototype.forEachFeatureAtPixel = ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg, function(coordinate, frameState, callback, thisArg,
layerFilter, thisArg2) { layerFilter, thisArg2) {
var result; var result;
@@ -560,7 +560,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtPixel =
// use default color values // use default color values
var d = ol.renderer.webgl.Map.DEFAULT_COLOR_VALUES_; var d = ol.renderer.webgl.Map.DEFAULT_COLOR_VALUES_;
result = this.replayGroup.forEachFeatureAtPixel(coordinate, result = this.replayGroup.forEachFeatureAtCoordinate(coordinate,
context, viewState.center, viewState.resolution, viewState.rotation, context, viewState.center, viewState.resolution, viewState.rotation,
frameState.size, frameState.pixelRatio, frameState.size, frameState.pixelRatio,
d.opacity, d.brightness, d.contrast, d.hue, d.saturation, {}, d.opacity, d.brightness, d.contrast, d.hue, d.saturation, {},
@@ -589,7 +589,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtPixel =
if (ol.layer.Layer.visibleAtResolution(layerState, viewState.resolution) && if (ol.layer.Layer.visibleAtResolution(layerState, viewState.resolution) &&
layerFilter.call(thisArg2, layer)) { layerFilter.call(thisArg2, layer)) {
var layerRenderer = this.getLayerRenderer(layer); var layerRenderer = this.getLayerRenderer(layer);
result = layerRenderer.forEachFeatureAtPixel( result = layerRenderer.forEachFeatureAtCoordinate(
coordinate, frameState, callback, thisArg); coordinate, frameState, callback, thisArg);
if (result) { if (result) {
return result; return result;
@@ -603,7 +603,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtPixel =
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.webgl.Map.prototype.hasFeatureAtPixel = ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate =
function(coordinate, frameState, layerFilter, thisArg) { function(coordinate, frameState, layerFilter, thisArg) {
var hasFeature = false; var hasFeature = false;
@@ -619,7 +619,7 @@ ol.renderer.webgl.Map.prototype.hasFeatureAtPixel =
// use default color values // use default color values
var d = ol.renderer.webgl.Map.DEFAULT_COLOR_VALUES_; var d = ol.renderer.webgl.Map.DEFAULT_COLOR_VALUES_;
hasFeature = this.replayGroup.hasFeatureAtPixel(coordinate, hasFeature = this.replayGroup.hasFeatureAtCoordinate(coordinate,
context, viewState.center, viewState.resolution, viewState.rotation, context, viewState.center, viewState.resolution, viewState.rotation,
frameState.size, frameState.pixelRatio, frameState.size, frameState.pixelRatio,
d.opacity, d.brightness, d.contrast, d.hue, d.saturation, {}); d.opacity, d.brightness, d.contrast, d.hue, d.saturation, {});
@@ -636,7 +636,8 @@ ol.renderer.webgl.Map.prototype.hasFeatureAtPixel =
if (ol.layer.Layer.visibleAtResolution(layerState, viewState.resolution) && if (ol.layer.Layer.visibleAtResolution(layerState, viewState.resolution) &&
layerFilter.call(thisArg, layer)) { layerFilter.call(thisArg, layer)) {
var layerRenderer = this.getLayerRenderer(layer); var layerRenderer = this.getLayerRenderer(layer);
hasFeature = layerRenderer.hasFeatureAtPixel(coordinate, frameState); hasFeature =
layerRenderer.hasFeatureAtCoordinate(coordinate, frameState);
if (hasFeature) { if (hasFeature) {
return true; return true;
} }
@@ -666,7 +667,7 @@ ol.renderer.webgl.Map.prototype.forEachLayerAtPixel =
var d = ol.renderer.webgl.Map.DEFAULT_COLOR_VALUES_; var d = ol.renderer.webgl.Map.DEFAULT_COLOR_VALUES_;
var coordinate = this.getMap().getCoordinateFromPixel(pixel); var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.replayGroup.hasFeatureAtPixel(coordinate, var hasFeature = this.replayGroup.hasFeatureAtCoordinate(coordinate,
context, viewState.center, viewState.resolution, viewState.rotation, context, viewState.center, viewState.resolution, viewState.rotation,
frameState.size, frameState.pixelRatio, frameState.size, frameState.pixelRatio,
d.opacity, d.brightness, d.contrast, d.hue, d.saturation, {}); d.opacity, d.brightness, d.contrast, d.hue, d.saturation, {});
@@ -106,7 +106,7 @@ ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() {
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtPixel = ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_) || goog.isNull(this.layerState_)) { if (goog.isNull(this.replayGroup_) || goog.isNull(this.layerState_)) {
return undefined; return undefined;
@@ -118,7 +118,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtPixel =
var layerState = this.layerState_; var layerState = this.layerState_;
/** @type {Object.<string, boolean>} */ /** @type {Object.<string, boolean>} */
var features = {}; var features = {};
return this.replayGroup_.forEachFeatureAtPixel(coordinate, return this.replayGroup_.forEachFeatureAtCoordinate(coordinate,
context, viewState.center, viewState.resolution, viewState.rotation, context, viewState.center, viewState.resolution, viewState.rotation,
frameState.size, frameState.pixelRatio, frameState.size, frameState.pixelRatio,
layerState.opacity, layerState.brightness, layerState.contrast, layerState.opacity, layerState.brightness, layerState.contrast,
@@ -142,8 +142,8 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtPixel =
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtPixel = ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate =
function(pixel, frameState) { function(coordinate, frameState) {
if (goog.isNull(this.replayGroup_) || goog.isNull(this.layerState_)) { if (goog.isNull(this.replayGroup_) || goog.isNull(this.layerState_)) {
return false; return false;
} else { } else {
@@ -151,8 +151,7 @@ ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtPixel =
var context = mapRenderer.getContext(); var context = mapRenderer.getContext();
var viewState = frameState.viewState; var viewState = frameState.viewState;
var layerState = this.layerState_; var layerState = this.layerState_;
var coordinate = this.getMap().getCoordinateFromPixel(pixel); return this.replayGroup_.hasFeatureAtCoordinate(coordinate,
return this.replayGroup_.hasFeatureAtPixel(coordinate,
context, viewState.center, viewState.resolution, viewState.rotation, context, viewState.center, viewState.resolution, viewState.rotation,
frameState.size, frameState.pixelRatio, frameState.size, frameState.pixelRatio,
layerState.opacity, layerState.brightness, layerState.contrast, layerState.opacity, layerState.brightness, layerState.contrast,
@@ -165,8 +164,9 @@ ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtPixel =
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.webgl.VectorLayer.prototype.forEachLayerAtPixel = ol.renderer.webgl.VectorLayer.prototype.forEachLayerAtPixel =
function(coordinate, frameState, callback, thisArg) { function(pixel, frameState, callback, thisArg) {
var hasFeature = this.hasFeatureAtPixel(coordinate, frameState); var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.hasFeatureAtCoordinate(coordinate, frameState);
if (hasFeature) { if (hasFeature) {
return callback.call(thisArg, this.getLayer()); return callback.call(thisArg, this.getLayer());
+2 -2
View File
@@ -152,14 +152,14 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ =
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.source.ImageVector.prototype.forEachFeatureAtPixel = function( ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
coordinate, resolution, rotation, skippedFeatureUids, callback) { coordinate, resolution, rotation, skippedFeatureUids, callback) {
if (goog.isNull(this.replayGroup_)) { if (goog.isNull(this.replayGroup_)) {
return undefined; return undefined;
} else { } else {
/** @type {Object.<string, boolean>} */ /** @type {Object.<string, boolean>} */
var features = {}; var features = {};
return this.replayGroup_.forEachFeatureAtPixel( return this.replayGroup_.forEachFeatureAtCoordinate(
coordinate, resolution, 0, skippedFeatureUids, coordinate, resolution, 0, skippedFeatureUids,
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
+1 -1
View File
@@ -85,7 +85,7 @@ goog.inherits(ol.source.Source, ol.Observable);
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template T * @template T
*/ */
ol.source.Source.prototype.forEachFeatureAtPixel = ol.source.Source.prototype.forEachFeatureAtCoordinate =
goog.nullFunction; goog.nullFunction;
+2 -2
View File
@@ -295,7 +295,7 @@ ol.source.Vector.prototype.forEachFeature = function(callback, opt_this) {
* @return {S|undefined} The return value from the last call to the callback. * @return {S|undefined} The return value from the last call to the callback.
* @template T,S * @template T,S
*/ */
ol.source.Vector.prototype.forEachFeatureAtCoordinate = ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect =
function(coordinate, callback, opt_this) { function(coordinate, callback, opt_this) {
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]]; var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
return this.forEachFeatureInExtent(extent, function(feature) { return this.forEachFeatureInExtent(extent, function(feature) {
@@ -409,7 +409,7 @@ ol.source.Vector.prototype.getFeatures = function() {
*/ */
ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) { ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) {
var features = []; var features = [];
this.forEachFeatureAtCoordinate(coordinate, function(feature) { this.forEachFeatureAtCoordinateDirect(coordinate, function(feature) {
features.push(feature); features.push(feature);
}); });
return features; return features;
@@ -58,7 +58,7 @@ describe('ol.renderer.canvas.VectorLayer', function() {
}); });
describe('#forEachFeatureAtPixel', function() { describe('#forEachFeatureAtCoordinate', function() {
var renderer; var renderer;
beforeEach(function() { beforeEach(function() {
@@ -70,8 +70,8 @@ describe('ol.renderer.canvas.VectorLayer', function() {
map.getRenderer(), layer); map.getRenderer(), layer);
var replayGroup = {}; var replayGroup = {};
renderer.replayGroup_ = replayGroup; renderer.replayGroup_ = replayGroup;
replayGroup.forEachFeatureAtPixel = function(resolution, replayGroup.forEachFeatureAtCoordinate = function(coordinate,
rotation, coordinate, skippedFeaturesUids, callback) { resolution, rotation, skippedFeaturesUids, callback) {
var geometry = new ol.geom.Point([0, 0]); var geometry = new ol.geom.Point([0, 0]);
var feature = new ol.Feature(); var feature = new ol.Feature();
callback(geometry, feature); callback(geometry, feature);
@@ -89,7 +89,7 @@ describe('ol.renderer.canvas.VectorLayer', function() {
rotation: 0 rotation: 0
} }
}; };
renderer.forEachFeatureAtPixel( renderer.forEachFeatureAtCoordinate(
coordinate, frameState, spy, undefined); coordinate, frameState, spy, undefined);
expect(spy.callCount).to.be(1); expect(spy.callCount).to.be(1);
}); });