From 56d96bdf4891cdaab839f7e975cbb823b434122a Mon Sep 17 00:00:00 2001 From: Robin Hawkes Date: Fri, 14 Feb 2014 23:15:38 +0000 Subject: [PATCH] Fixed bug in Web Worker that was preventing all features from being processed when using a single batch --- examples/index.html | 1 + src/client/data/Data.js | 2 +- src/client/data/DataOverpass.js | 2 +- src/client/objects/ObjectManager.js | 24 ++++++++++++++---------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/examples/index.html b/examples/index.html index c1b4268..bb3603f 100644 --- a/examples/index.html +++ b/examples/index.html @@ -30,6 +30,7 @@ var city = new VIZI.City(); city.init({ coords: [-0.01924, 51.50358] // Canary Wharf + // coords: [-0.1159894466, 51.5045487479] // London Eye // coords: [-73.984762, 40.7516199] // Empire State }); diff --git a/src/client/data/Data.js b/src/client/data/Data.js index dd5bc06..819dd77 100644 --- a/src/client/data/Data.js +++ b/src/client/data/Data.js @@ -81,7 +81,7 @@ // Skip duplicate features _.each(features, function(feature) { if (self.processedIds[feature.id]) { - VIZI.Log("Skipping duplicated feature"); + VIZI.Log("Skipping duplicated feature:", feature.id); return; } diff --git a/src/client/data/DataOverpass.js b/src/client/data/DataOverpass.js index d13fca6..a4df6fe 100644 --- a/src/client/data/DataOverpass.js +++ b/src/client/data/DataOverpass.js @@ -137,7 +137,7 @@ }); if (dupe) { - VIZI.Log("Skipping feature as it has duplicate coordinates", coordinates); + VIZI.Log("Skipping feature as it has duplicate coordinates", element.id, coordinates); return; } diff --git a/src/client/objects/ObjectManager.js b/src/client/objects/ObjectManager.js index 90304b1..3f4417f 100644 --- a/src/client/objects/ObjectManager.js +++ b/src/client/objects/ObjectManager.js @@ -196,21 +196,25 @@ // 4 batches or below seems to stop the model.faces typed array from converting to a normal array // Ideal 8 batches, if odd then subtract difference to make featuresPerBatch division clean // var batches = 8 - (features.length % 8); - - // Use one batch while testing tile-loading feature var batches = 1; - var featuresPerBatch = Math.ceil(features.length / batches); + + // Use all features while testing tile-loading + // var featuresPerBatch = Math.ceil(features.length / batches); + var batchPromises = []; - var i = batches; - while (i--) { - var startIndex = i * featuresPerBatch; - startIndex = (startIndex < 0) ? 0 : startIndex; + // var i = batches; + // while (i--) { + // var startIndex = i * featuresPerBatch; + // startIndex = (startIndex < 0) ? 0 : startIndex; - var featuresBatch = features.splice(startIndex, featuresPerBatch-1); + // var featuresBatch = features.splice(startIndex, featuresPerBatch-1); - batchPromises.push(this.workerPromise(worker, featuresBatch)); - } + // batchPromises.push(this.workerPromise(worker, featuresBatch)); + // } + + // Process all features in one go while testing tile-loading + batchPromises.push(this.workerPromise(worker, features)); var loader = new THREE.JSONLoader(); var material = new THREE.MeshLambertMaterial({vertexColors: THREE.VertexColors});