From ab0ebc8eb5e9fd2e70c9685d710b148686dceb6c Mon Sep 17 00:00:00 2001 From: IanMJB Date: Fri, 12 Sep 2014 15:59:44 +0100 Subject: Magic with recommended entrances. --- create-data.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'create-data.js') diff --git a/create-data.js b/create-data.js index 2cd3353..6ba0408 100755 --- a/create-data.js +++ b/create-data.js @@ -320,6 +320,9 @@ function processBuildingParts(buildingParts, callback) { function(callback) { findRoomContents(part, workstations, callback); }, + function(callback) { + getRecommendedEntrances(part, callback); + }, function(callback) { findRoomImages(part, callback); }], @@ -1130,6 +1133,43 @@ SELECT * WHERE {\ }); } +function getRecommendedEntrances(part, callback) { + var query = "PREFIX rdfs: \ + PREFIX portals: \ + PREFIX geo: \ + SELECT ?portal WHERE {\ + ?uri portals:recommendedBuildingEntrance ?portal\ + FILTER (\ + ?uri = \ + )\ + }"; + + query = query.replace("URI", part.properties.uri); + + sparqlQuery(query, function(err, data) { + if (err) { + console.error("error in getRecommended Entrance"); + console.error("query " + query); + console.error(err); + } + + part.properties.recommendedEntrances = portals = []; + + data.results.bindings.forEach(function(portal) { + if ('error-message' in portal) { + console.error("error in portals"); + console.error(JSON.stringify(feature)); + console.error("query:\n" + query); + return; + } + + portals.push(portal.portal.value); + }); + + callback(null, portals); + }); +} + // workstations function getUniWorkstations(workstations, callback) { -- cgit v1.2.3