From bb828eb90b274d714f0a6e84a8dbb9ddd6c86689 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 27 Sep 2014 15:55:12 +0100 Subject: Add rooms only found in OSM to the list of rooms in a building Previously, only the rooms in the University data was used, but this leaves a lot out. Also display popups for rooms if they have a URI, to allow the user to navigate to the uri. --- create-data.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'create-data.js') diff --git a/create-data.js b/create-data.js index 698c63e..1bdc294 100755 --- a/create-data.js +++ b/create-data.js @@ -452,6 +452,54 @@ SELECT DISTINCT * WHERE {\ } }); + buildingParts.forEach(function(room) { + if (room.properties.buildingpart !== "room") + return; + + if (room.properties.building in buildings) { + var buildingProperties = buildings[room.properties.building].properties; + + var uri; + + if ("uri" in room.properties) { + uri = room.properties.uri; + } else { + if (!("ref" in room.properties)) + return; + + uri = "http://id.southampton.ac.uk/room/" + buildingProperties.loc_ref + "-" + room.properties.ref; + + room.properties.uri = uri; + } + + if (!('rooms' in buildingProperties)) { + buildingProperties.rooms = {}; + } + + if ("level" in room.properties) { + var level = room.properties.level; + + if (!(level instanceof Array)) { + level = [ level ]; + } + + level.forEach(function(l) { + if (!(l in buildingProperties.rooms)) { + buildingProperties.rooms[l] = []; + } + + + + buildingProperties.rooms[l].push(uri); + }); + } else { + console.warn("no level for " + JSON.stringify(room, null, 4)); + } + } else { + addBuildingMessage(room.building, "errors", "location", "unknown (createBuildingParts)"); + } + }); + Object.keys(rooms).forEach(function(uri) { var room = rooms[uri]; -- cgit v1.2.3