Reduce work for hitdetection

Skip cloning of style if geometry is not in extent.
This commit is contained in:
Maximilian Krög
2021-02-10 21:26:53 +01:00
parent 99564671c1
commit dde6d6559c

View File

@@ -69,6 +69,10 @@ export function createHitDetectionImageData(
const color = '#' + ('000000' + index.toString(16)).slice(-6);
for (let j = 0, jj = styles.length; j < jj; ++j) {
const originalStyle = styles[j];
const geometry = originalStyle.getGeometryFunction()(feature);
if (!geometry || !intersects(extent, geometry.getExtent())) {
continue;
}
const style = originalStyle.clone();
const fill = style.getFill();
if (fill) {
@@ -119,13 +123,10 @@ export function createHitDetectionImageData(
byGeometryType[GeometryType.LINE_STRING] = [];
byGeometryType[GeometryType.POINT] = [];
}
const geometry = style.getGeometryFunction()(feature);
if (geometry && intersects(extent, geometry.getExtent())) {
byGeometryType[geometry.getType().replace('Multi', '')].push(
geometry,
style
);
}
byGeometryType[geometry.getType().replace('Multi', '')].push(
geometry,
style
);
}
}