diff options
author | Christopher Baines <cb15g11@soton.ac.uk> | 2014-07-05 20:20:31 +0100 |
---|---|---|
committer | Christopher Baines <cb15g11@soton.ac.uk> | 2014-07-05 20:20:31 +0100 |
commit | a236f4f4147caa9b06ed17baf625f26dde738679 (patch) | |
tree | 9558c1c05e388b44862b29d51cbf34bba2573de6 /create-data.js | |
parent | ed09134c1d99ea806cbdf9f8953493e7211b89d2 (diff) | |
download | leaflet-soton-a236f4f4147caa9b06ed17baf625f26dde738679.tar leaflet-soton-a236f4f4147caa9b06ed17baf625f26dde738679.tar.gz |
Include the library data in data.js
Instead of loading seperately
Diffstat (limited to 'create-data.js')
-rwxr-xr-x | create-data.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/create-data.js b/create-data.js index ed673f2..9097537 100755 --- a/create-data.js +++ b/create-data.js @@ -17,6 +17,8 @@ var yaml = require('js-yaml'); var config = require("./config.json"); +var library_data = require("./resources/hartley-library-map-data/data.json"); + try { var printers = yaml.safeLoad(fs.readFileSync('./resources/mfd-location/data.yaml', 'utf8')); } catch (e) { @@ -88,7 +90,11 @@ pgql.connect('tcp://' + config.user + ':' + } ], function(err) { getBuildingImages(buildings, function(err) { - callback(err, collections); + getLibraryData(library_data, function(err, features) { + collections.buildingParts.features.push.apply(collections.buildingParts.features, features); + + callback(err, collections); + }); }); }); }); @@ -118,6 +124,7 @@ pgql.connect('tcp://' + config.user + ':' + }); }); + // This code handles creating the basic collections, that is: // - buildings // - parking @@ -493,6 +500,28 @@ SELECT ?room ?type ?label ?building WHERE { }); } +function getLibraryData(library_data, callback) { + callback(null, library_data.features.map(function(feature) { + feature.properties.buildingpart = "room"; + feature.properties.name = feature.properties.label; + delete feature.properties.label; + + var points = feature.geometry.coordinates[0]; + + var lat = 0; + var lon = 0; + + points.forEach(function(point) { + lat += point[0]; + lon += point[1]; + }); + + feature.properties.center = [lon / points.length, lat / points.length]; + + return feature; + })); +} + function createBuildingParts(buildings, callback) { console.info("creating buildingParts collection"); |