Fix feature lookup after removal of alpha
This commit is contained in:
@@ -33,10 +33,10 @@ export function createHitDetectionImageData(size, transforms, features, styleFun
|
|||||||
const renderer = new CanvasImmediateRenderer(context, 0.5, extent, null, rotation);
|
const renderer = new CanvasImmediateRenderer(context, 0.5, extent, null, rotation);
|
||||||
const featureCount = features.length;
|
const featureCount = features.length;
|
||||||
// Stretch hit detection index to use the whole available color range
|
// Stretch hit detection index to use the whole available color range
|
||||||
const indexFactor = Math.ceil((256 * 256 * 256) / featureCount);
|
const indexFactor = Math.ceil((256 * 256 * 256 - 1) / featureCount);
|
||||||
const featuresByZIndex = {};
|
const featuresByZIndex = {};
|
||||||
for (let i = 0; i < featureCount; ++i) {
|
for (let i = 1; i <= featureCount; ++i) {
|
||||||
const feature = features[i];
|
const feature = features[i - 1];
|
||||||
const featureStyleFunction = feature.getStyleFunction() || styleFunction;
|
const featureStyleFunction = feature.getStyleFunction() || styleFunction;
|
||||||
if (!styleFunction) {
|
if (!styleFunction) {
|
||||||
continue;
|
continue;
|
||||||
@@ -141,9 +141,9 @@ export function hitDetect(pixel, features, imageData) {
|
|||||||
const g = imageData.data[index + 1];
|
const g = imageData.data[index + 1];
|
||||||
const b = imageData.data[index + 2];
|
const b = imageData.data[index + 2];
|
||||||
const i = b + (256 * (g + (256 * r)));
|
const i = b + (256 * (g + (256 * r)));
|
||||||
const indexFactor = Math.ceil((256 * 256 * 256) / features.length);
|
const indexFactor = Math.ceil((256 * 256 * 256 - 1) / features.length);
|
||||||
if (i % indexFactor === 0) {
|
if (i && i % indexFactor === 0) {
|
||||||
resultFeatures.push(features[i / indexFactor]);
|
resultFeatures.push(features[i / indexFactor - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultFeatures;
|
return resultFeatures;
|
||||||
|
|||||||
Reference in New Issue
Block a user