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

View File

@@ -583,7 +583,7 @@ ol.Map.prototype.forEachFeatureAtPixel =
var layerFilter = goog.isDef(opt_layerFilter) ?
opt_layerFilter : goog.functions.TRUE;
var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null;
return this.renderer_.forEachFeatureAtPixel(
return this.renderer_.forEachFeatureAtCoordinate(
coordinate, this.frameState_, callback, thisArg,
layerFilter, thisArg2);
};
@@ -649,7 +649,7 @@ ol.Map.prototype.hasFeatureAtPixel =
var layerFilter = goog.isDef(opt_layerFilter) ?
opt_layerFilter : goog.functions.TRUE;
var thisArg = goog.isDef(opt_this) ? opt_this : null;
return this.renderer_.hasFeatureAtPixel(
return this.renderer_.hasFeatureAtCoordinate(
coordinate, this.frameState_, layerFilter, thisArg);
};

View File

@@ -1866,7 +1866,7 @@ ol.render.canvas.ReplayGroup.prototype.finish = function() {
* @return {T|undefined} Callback result.
* @template T
*/
ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtPixel = function(
ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
coordinate, resolution, rotation, skippedFeaturesHash, callback) {
var transform = this.hitDetectionTransform_;

View File

@@ -1171,7 +1171,7 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context,
* @return {T|undefined} Callback result.
* @template T
*/
ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtPixel = function(
ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
coordinate, context, center, resolution, rotation, size, pixelRatio,
opacity, brightness, contrast, hue, saturation, skippedFeaturesHash,
callback) {
@@ -1228,9 +1228,9 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtPixel = function(
* @param {number} hue Global hue.
* @param {number} saturation Global saturation.
* @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,
opacity, brightness, contrast, hue, saturation, skippedFeaturesHash) {
var gl = context.getGL();

View File

@@ -56,14 +56,14 @@ goog.inherits(ol.renderer.canvas.ImageLayer, ol.renderer.canvas.Layer);
/**
* @inheritDoc
*/
ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtPixel =
ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) {
var layer = this.getLayer();
var source = layer.getSource();
var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel(
return source.forEachFeatureAtCoordinate(
coordinate, resolution, rotation, skippedFeatureUids,
/**
* @param {ol.Feature} feature Feature.
@@ -88,7 +88,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
// for ImageVector sources use the original hit-detection logic,
// so that for example also transparent polygons are detected
var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.forEachFeatureAtPixel(
var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this);
if (hasFeature) {

View File

@@ -116,7 +116,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame =
/**
* @inheritDoc
*/
ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_)) {
return undefined;
@@ -126,7 +126,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
var layer = this.getLayer();
/** @type {Object.<string, boolean>} */
var features = {};
return this.replayGroup_.forEachFeatureAtPixel(coordinate,
return this.replayGroup_.forEachFeatureAtCoordinate(coordinate,
resolution, rotation, frameState.skippedFeatureUids,
/**
* @param {ol.Feature} feature Feature.

View File

@@ -47,14 +47,14 @@ goog.inherits(ol.renderer.dom.ImageLayer, ol.renderer.dom.Layer);
/**
* @inheritDoc
*/
ol.renderer.dom.ImageLayer.prototype.forEachFeatureAtPixel =
ol.renderer.dom.ImageLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) {
var layer = this.getLayer();
var source = layer.getSource();
var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel(
return source.forEachFeatureAtCoordinate(
coordinate, resolution, rotation, skippedFeatureUids,
/**
* @param {ol.Feature} feature Feature.

View File

@@ -176,7 +176,7 @@ ol.renderer.dom.VectorLayer.prototype.dispatchEvent_ =
/**
* @inheritDoc
*/
ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtPixel =
ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_)) {
return undefined;
@@ -186,7 +186,7 @@ ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtPixel =
var layer = this.getLayer();
/** @type {Object.<string, boolean>} */
var features = {};
return this.replayGroup_.forEachFeatureAtPixel(coordinate,
return this.replayGroup_.forEachFeatureAtCoordinate(coordinate,
resolution, rotation, frameState.skippedFeatureUids,
/**
* @param {ol.Feature} feature Feature.

View File

@@ -53,7 +53,7 @@ goog.inherits(ol.renderer.Layer, goog.Disposable);
* @return {T|undefined} Callback result.
* @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 =
function(pixel, frameState, callback, thisArg) {
var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.forEachFeatureAtPixel(
var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this);
if (hasFeature) {
@@ -81,9 +81,9 @@ ol.renderer.Layer.prototype.forEachLayerAtPixel =
/**
* @param {ol.Coordinate} coordinate Coordinate.
* @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;
/**

View File

@@ -121,7 +121,7 @@ ol.renderer.Map.expireIconCache_ = function(map, frameState) {
* @return {T|undefined} Callback result.
* @template S,T,U
*/
ol.renderer.Map.prototype.forEachFeatureAtPixel =
ol.renderer.Map.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg,
layerFilter, thisArg2) {
var result;
@@ -131,7 +131,7 @@ ol.renderer.Map.prototype.forEachFeatureAtPixel =
if (!goog.isNull(this.replayGroup)) {
/** @type {Object.<string, boolean>} */
var features = {};
result = this.replayGroup.forEachFeatureAtPixel(coordinate,
result = this.replayGroup.forEachFeatureAtCoordinate(coordinate,
viewResolution, viewRotation, {},
/**
* @param {ol.Feature} feature Feature.
@@ -158,7 +158,7 @@ ol.renderer.Map.prototype.forEachFeatureAtPixel =
if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) &&
layerFilter.call(thisArg2, layer)) {
var layerRenderer = this.getLayerRenderer(layer);
result = layerRenderer.forEachFeatureAtPixel(
result = layerRenderer.forEachFeatureAtCoordinate(
coordinate, frameState, callback, thisArg);
if (result) {
return result;
@@ -193,7 +193,7 @@ ol.renderer.Map.prototype.forEachLayerAtPixel =
if (!goog.isNull(this.replayGroup)) {
var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.replayGroup.forEachFeatureAtPixel(coordinate,
var hasFeature = this.replayGroup.forEachFeatureAtCoordinate(coordinate,
viewResolution, viewRotation, {}, goog.functions.TRUE);
if (hasFeature) {
@@ -231,12 +231,12 @@ ol.renderer.Map.prototype.forEachLayerAtPixel =
* returns `true` will be tested for features. By default, all visible
* layers will be tested.
* @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
*/
ol.renderer.Map.prototype.hasFeatureAtPixel =
ol.renderer.Map.prototype.hasFeatureAtCoordinate =
function(coordinate, frameState, layerFilter, thisArg) {
var hasFeature = this.forEachFeatureAtPixel(
var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this, layerFilter, thisArg);
return goog.isDef(hasFeature);

View File

@@ -73,14 +73,14 @@ ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) {
/**
* @inheritDoc
*/
ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtPixel =
ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) {
var layer = this.getLayer();
var source = layer.getSource();
var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel(
return source.forEachFeatureAtCoordinate(
coordinate, resolution, rotation, skippedFeatureUids,
/**
@@ -214,9 +214,9 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
/**
* @inheritDoc
*/
ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtPixel =
ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtCoordinate =
function(coordinate, frameState) {
var hasFeature = this.forEachFeatureAtPixel(
var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this);
return goog.isDef(hasFeature);
};
@@ -235,7 +235,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel =
// for ImageVector sources use the original hit-detection logic,
// so that for example also transparent polygons are detected
var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.forEachFeatureAtPixel(
var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this);
if (hasFeature) {

View File

@@ -540,7 +540,7 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
/**
* @inheritDoc
*/
ol.renderer.webgl.Map.prototype.forEachFeatureAtPixel =
ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg,
layerFilter, thisArg2) {
var result;
@@ -560,7 +560,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtPixel =
// use 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,
frameState.size, frameState.pixelRatio,
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) &&
layerFilter.call(thisArg2, layer)) {
var layerRenderer = this.getLayerRenderer(layer);
result = layerRenderer.forEachFeatureAtPixel(
result = layerRenderer.forEachFeatureAtCoordinate(
coordinate, frameState, callback, thisArg);
if (result) {
return result;
@@ -603,7 +603,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtPixel =
/**
* @inheritDoc
*/
ol.renderer.webgl.Map.prototype.hasFeatureAtPixel =
ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate =
function(coordinate, frameState, layerFilter, thisArg) {
var hasFeature = false;
@@ -619,7 +619,7 @@ ol.renderer.webgl.Map.prototype.hasFeatureAtPixel =
// use 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,
frameState.size, frameState.pixelRatio,
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) &&
layerFilter.call(thisArg, layer)) {
var layerRenderer = this.getLayerRenderer(layer);
hasFeature = layerRenderer.hasFeatureAtPixel(coordinate, frameState);
hasFeature =
layerRenderer.hasFeatureAtCoordinate(coordinate, frameState);
if (hasFeature) {
return true;
}
@@ -666,7 +667,7 @@ ol.renderer.webgl.Map.prototype.forEachLayerAtPixel =
var d = ol.renderer.webgl.Map.DEFAULT_COLOR_VALUES_;
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,
frameState.size, frameState.pixelRatio,
d.opacity, d.brightness, d.contrast, d.hue, d.saturation, {});

View File

@@ -106,7 +106,7 @@ ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() {
/**
* @inheritDoc
*/
ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtPixel =
ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_) || goog.isNull(this.layerState_)) {
return undefined;
@@ -118,7 +118,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtPixel =
var layerState = this.layerState_;
/** @type {Object.<string, boolean>} */
var features = {};
return this.replayGroup_.forEachFeatureAtPixel(coordinate,
return this.replayGroup_.forEachFeatureAtCoordinate(coordinate,
context, viewState.center, viewState.resolution, viewState.rotation,
frameState.size, frameState.pixelRatio,
layerState.opacity, layerState.brightness, layerState.contrast,
@@ -142,8 +142,8 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtPixel =
/**
* @inheritDoc
*/
ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtPixel =
function(pixel, frameState) {
ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate =
function(coordinate, frameState) {
if (goog.isNull(this.replayGroup_) || goog.isNull(this.layerState_)) {
return false;
} else {
@@ -151,8 +151,7 @@ ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtPixel =
var context = mapRenderer.getContext();
var viewState = frameState.viewState;
var layerState = this.layerState_;
var coordinate = this.getMap().getCoordinateFromPixel(pixel);
return this.replayGroup_.hasFeatureAtPixel(coordinate,
return this.replayGroup_.hasFeatureAtCoordinate(coordinate,
context, viewState.center, viewState.resolution, viewState.rotation,
frameState.size, frameState.pixelRatio,
layerState.opacity, layerState.brightness, layerState.contrast,
@@ -165,8 +164,9 @@ ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtPixel =
* @inheritDoc
*/
ol.renderer.webgl.VectorLayer.prototype.forEachLayerAtPixel =
function(coordinate, frameState, callback, thisArg) {
var hasFeature = this.hasFeatureAtPixel(coordinate, frameState);
function(pixel, frameState, callback, thisArg) {
var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var hasFeature = this.hasFeatureAtCoordinate(coordinate, frameState);
if (hasFeature) {
return callback.call(thisArg, this.getLayer());

View File

@@ -152,14 +152,14 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ =
/**
* @inheritDoc
*/
ol.source.ImageVector.prototype.forEachFeatureAtPixel = function(
ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
coordinate, resolution, rotation, skippedFeatureUids, callback) {
if (goog.isNull(this.replayGroup_)) {
return undefined;
} else {
/** @type {Object.<string, boolean>} */
var features = {};
return this.replayGroup_.forEachFeatureAtPixel(
return this.replayGroup_.forEachFeatureAtCoordinate(
coordinate, resolution, 0, skippedFeatureUids,
/**
* @param {ol.Feature} feature Feature.

View File

@@ -85,7 +85,7 @@ goog.inherits(ol.source.Source, ol.Observable);
* @return {T|undefined} Callback result.
* @template T
*/
ol.source.Source.prototype.forEachFeatureAtPixel =
ol.source.Source.prototype.forEachFeatureAtCoordinate =
goog.nullFunction;

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.
* @template T,S
*/
ol.source.Vector.prototype.forEachFeatureAtCoordinate =
ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect =
function(coordinate, callback, opt_this) {
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
return this.forEachFeatureInExtent(extent, function(feature) {
@@ -409,7 +409,7 @@ ol.source.Vector.prototype.getFeatures = function() {
*/
ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) {
var features = [];
this.forEachFeatureAtCoordinate(coordinate, function(feature) {
this.forEachFeatureAtCoordinateDirect(coordinate, function(feature) {
features.push(feature);
});
return features;

View File

@@ -58,7 +58,7 @@ describe('ol.renderer.canvas.VectorLayer', function() {
});
describe('#forEachFeatureAtPixel', function() {
describe('#forEachFeatureAtCoordinate', function() {
var renderer;
beforeEach(function() {
@@ -70,8 +70,8 @@ describe('ol.renderer.canvas.VectorLayer', function() {
map.getRenderer(), layer);
var replayGroup = {};
renderer.replayGroup_ = replayGroup;
replayGroup.forEachFeatureAtPixel = function(resolution,
rotation, coordinate, skippedFeaturesUids, callback) {
replayGroup.forEachFeatureAtCoordinate = function(coordinate,
resolution, rotation, skippedFeaturesUids, callback) {
var geometry = new ol.geom.Point([0, 0]);
var feature = new ol.Feature();
callback(geometry, feature);
@@ -89,7 +89,7 @@ describe('ol.renderer.canvas.VectorLayer', function() {
rotation: 0
}
};
renderer.forEachFeatureAtPixel(
renderer.forEachFeatureAtCoordinate(
coordinate, frameState, spy, undefined);
expect(spy.callCount).to.be(1);
});