diff options
author | Christopher Baines <cb15g11@soton.ac.uk> | 2014-09-27 15:55:12 +0100 |
---|---|---|
committer | Christopher Baines <cb15g11@soton.ac.uk> | 2014-09-27 15:55:12 +0100 |
commit | bb828eb90b274d714f0a6e84a8dbb9ddd6c86689 (patch) | |
tree | 7b9072ea915412123049082bed0dbef73e1ffc43 /create-data.js | |
parent | 77c38d655545ec3e23a786fb36271c2bd69b08f3 (diff) | |
download | leaflet-soton-bb828eb90b274d714f0a6e84a8dbb9ddd6c86689.tar leaflet-soton-bb828eb90b274d714f0a6e84a8dbb9ddd6c86689.tar.gz |
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.
Diffstat (limited to 'create-data.js')
-rwxr-xr-x | create-data.js | 48 |
1 files changed, 48 insertions, 0 deletions
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]; |