From 263d3a1be102abe2765fd6ef76a5ce2613690a30 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Thu, 21 May 2020 01:38:30 +0200 Subject: [PATCH] fix error for bad binary data --- html/script.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/html/script.js b/html/script.js index 1fdb2ae..3486b32 100644 --- a/html/script.js +++ b/html/script.js @@ -4542,6 +4542,8 @@ function drawHeatmap() { if (heatmap.init) initHeatmap(); + console.log('drawHeat'); + let extent = OLMap.getView().calculateExtent(OLMap.getSize()); for (let i = 0; i < 16; i++) @@ -4555,13 +4557,14 @@ function drawHeatmap() { } let offsets = Array(heatChunks.length).fill(0); let done = false; + let iterations = 0; let indexes = Array(heatChunks.length).fill([]); for (let k = 0; k < heatChunks.length; k++) { if (heatPoints[k] != null) { true; // do nothing - } else if (heatChunks[k] != null) { + } else if (heatChunks[k] != null && heatChunks[k].byteLength % 16 == 0) { heatPoints[k] = new Int32Array(heatChunks[k]); } else { continue; @@ -4578,11 +4581,11 @@ function drawHeatmap() { index.sort((a, b) => (Math.random() - 0.5)); indexes[k] = index; } - while (pointCount < heatmap.max && !done) { + while (pointCount < heatmap.max && !done && iterations++ < 1000) { for (let k = 0; k < heatChunks.length; k++) { if (heatPoints[k] != null) { true; // do nothing - } else if (heatChunks[k] != null) { + } else if (heatChunks[k] != null && heatChunks[k].byteLength % 16 == 0) { heatPoints[k] = new Int32Array(heatChunks[k]); } else { continue; @@ -4642,6 +4645,8 @@ function drawHeatmap() { offsets[k] += 1; } } + if (iterations == 1000) + console.log("drawHeatmap: MAX_ITERATIONS!"); for (let i = 0; i < 16; i++) { //console.log(features.length); heatFeatures[i].addFeatures(features.splice(0, heatmap.max / 16));