diff options
author | Christopher Baines <cb15g11@soton.ac.uk> | 2014-07-19 14:21:12 +0100 |
---|---|---|
committer | Christopher Baines <cb15g11@soton.ac.uk> | 2014-07-19 14:21:12 +0100 |
commit | 9e9db3e84038a638b9a1caa793b693f32544a904 (patch) | |
tree | b73c8fdb6ff7b372bcc4f3e479e043064cc930e4 | |
parent | a236f4f4147caa9b06ed17baf625f26dde738679 (diff) | |
download | leaflet-soton-9e9db3e84038a638b9a1caa793b693f32544a904.tar leaflet-soton-9e9db3e84038a638b9a1caa793b693f32544a904.tar.gz |
Split the printers and vending machines
Also try to prevent the caching of data.json
-rwxr-xr-x | create-data.js | 46 | ||||
-rw-r--r-- | src/leaflet-soton.js | 19 |
2 files changed, 27 insertions, 38 deletions
diff --git a/create-data.js b/create-data.js index 9097537..75fe2b5 100755 --- a/create-data.js +++ b/create-data.js @@ -55,7 +55,6 @@ pgql.connect('tcp://' + config.user + ':' + // - busStops // - busRoutes // - buildingParts - // - buildingFeatures // - workstations // // Extracting the data for these is a bit harder than the simpler @@ -77,14 +76,28 @@ pgql.connect('tcp://' + config.user + ':' + async.parallel([ function(callback) { - getBuildingFeatures(buildings, function(err, buildingFeatures) { - collections.buildingFeatures = buildingFeatures; - callback(err); + getPrinters(buildings, function(err, features) { + collections.multiFunctionDevices = { + type: "FeatureCollection", + features: features + }; + + callback(); + }); + }, + function(callback) { + getVendingMachines(buildings, function(err, features) { + collections.vendingMachines = { + type: "FeatureCollection", + features: features + }; + callback(); }); }, function(callback) { getUniWorkstations(workstations, function(err, workstations) { collections.workstations = workstations; + callback(err); }); } @@ -238,29 +251,6 @@ function createCollection(name, query, callback) { }); } -// buildingFeatures - -function getBuildingFeatures(buildings, callback) { - async.parallel([ - function(callback) { - getPrinters(buildings, callback); - }, - function(callback) { - getVendingMachines(buildings, callback); - } - ], function(err, results) { - var features = [] - features = features.concat.apply(features, results); - - var buildingFeatures = { - type: "FeatureCollection", - features: features - }; - - callback(err, buildingFeatures); - }); -} - function getBuildingImages(buildings, callback) { console.info("getting building images"); async.each(Object.keys(buildings), function(uri, callback) { @@ -891,8 +881,6 @@ SELECT * WHERE {\ }); } -// buildingFeatures - function getPrinters(buildings, callback) { console.info("begining create printers"); diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js index d134ff4..81aad08 100644 --- a/src/leaflet-soton.js +++ b/src/leaflet-soton.js @@ -18,7 +18,7 @@ if (!this._dataFetchInProgress) { this._dataFetchInProgress = true; - getJSON({url: LS.dataPath} , function(data) { + getJSON({url: LS.dataPath, cache: false} , function(data) { LS.data = data; LS._dataFetchInProgress = false; @@ -96,13 +96,7 @@ return null; }, getVendingMachinesLayer: function() { - var features = []; - - this.data.buildingFeatures.features.forEach(function(feature) { - if ("vending" in feature.properties) { - features.push(feature); - } - }); + var features = this.data.vendingMachines.features; var layer = new L.GeoJSON(features, { pointToLayer: vendingPointToLayer, @@ -641,7 +635,8 @@ SELECT * WHERE {\ } }); - map.indoorLayer.addData(data.buildingFeatures); + map.indoorLayer.addData(data.vendingMachines); + map.indoorLayer.addData(data.multiFunctionDevices); map.levelControl = L.Control.level({ levels: map.indoorLayer.getLevels(), @@ -1551,6 +1546,12 @@ SELECT * WHERE {\ options.data = options.data || null; + var url = options.url + + if ("cache" in options && options.cache == false) { + url += "?" + new Date().getTime(); + } + xhttp.open('GET', options.url, true); xhttp.setRequestHeader('Accept', 'application/json'); |