summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2014-09-27 15:55:12 +0100
committerChristopher Baines <cb15g11@soton.ac.uk>2014-09-27 15:55:12 +0100
commitbb828eb90b274d714f0a6e84a8dbb9ddd6c86689 (patch)
tree7b9072ea915412123049082bed0dbef73e1ffc43
parent77c38d655545ec3e23a786fb36271c2bd69b08f3 (diff)
downloadleaflet-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.
-rwxr-xr-xcreate-data.js48
-rw-r--r--src/leaflet-soton.js22
2 files changed, 56 insertions, 14 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];
diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js
index 0eb51be..ec86a7d 100644
--- a/src/leaflet-soton.js
+++ b/src/leaflet-soton.js
@@ -416,18 +416,10 @@ SELECT * WHERE {\
return; // No popup for corridors yet
}
- if( !('features' in feature.properties) ) { feature.properties.features=[]; }
- if( !('contents' in feature.properties) ) { feature.properties.contents=[]; }
- if( !('images' in feature.properties) ) { feature.properties.images=[]; }
+ if (feature.properties.buildingspart === "room" &&
+ !("uri" in feature.properties)) {
- if ('buildingpart' in feature.properties) {
- if (feature.properties.buildingpart === "room" &&
- feature.properties.features.length == 0 &&
- feature.properties.contents.length == 0 &&
- feature.properties.images.length == 0) {
-
- return false;
- }
+ return false;
}
return true;
@@ -1201,9 +1193,11 @@ SELECT * WHERE {\
function imageTemplate(properties, options, map, close) {
- if (properties.images.length == 0) {
+ if (!("images" in properties))
+ return false;
+
+ if (properties.images.length === 0)
return false;
- }
var imageWidth;
var imageHeight;
@@ -1276,7 +1270,7 @@ SELECT * WHERE {\
var room = LS.getFeatureByURI(uri);
if (room === null) {
- console.err("Unable to find room " + uri);
+ console.error("Unable to find room " + uri);
return;
}