diff options
-rwxr-xr-x | create-data.js | 48 | ||||
-rw-r--r-- | src/leaflet-soton.js | 22 |
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; } |