summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2014-04-04 22:40:15 +0100
committerChristopher Baines <cb15g11@soton.ac.uk>2014-04-04 22:40:15 +0100
commit860ca767c8ba0d5d33befc233f1a8047b36eef37 (patch)
tree759b84570822ac206e2aa9bc1b65af560cf0b131
parent18c5740c3aa4d4f89c8cb5fef1111016b130ad37 (diff)
downloadleaflet-soton-860ca767c8ba0d5d33befc233f1a8047b36eef37.tar
leaflet-soton-860ca767c8ba0d5d33befc233f1a8047b36eef37.tar.gz
Better display of vertical passageways
-rwxr-xr-xcreate-data.js6
-rw-r--r--src/leaflet-soton.js46
2 files changed, 50 insertions, 2 deletions
diff --git a/create-data.js b/create-data.js
index 0d2fcb1..149a5b4 100755
--- a/create-data.js
+++ b/create-data.js
@@ -325,12 +325,16 @@ function createRooms(buildings, workstations, callback) {
callback();
});
}, function(err) {
+ // Assign levels to parts
+
for (var i=0; i<buildingParts.length; i++) {
var part = buildingParts[i];
if (part.id in osmIDToLevels) {
part.properties.level = osmIDToLevels[part.id];
+ part.properties.level.sort(function(a,b){return a-b});
+
if (part.properties.level.length === 1) {
part.properties.level = part.properties.level[0];
}
@@ -466,7 +470,7 @@ function getBuildingPartMemberRefs(levelRelation, callback) {
}
function getBuildingParts(callback) {
- var query = "select ST_AsGeoJSON(ST_Transform(way, 4326), 10) as polygon,ST_AsText(ST_Transform(ST_Centroid(way), 4326)) as center,osm_id,name,buildingpart,ref,uri,amenity,unisex,male,female from planet_osm_polygon where buildingpart is not null";
+ var query = "select ST_AsGeoJSON(ST_Transform(way, 4326), 10) as polygon,ST_AsText(ST_Transform(ST_Centroid(way), 4326)) as center,osm_id,name,buildingpart,\"buildingpart:verticalpassage\",ref,uri,amenity,unisex,male,female from planet_osm_polygon where buildingpart is not null";
pg.query(query, function(err, results) {
if (err) {
diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js
index c70a12a..f6ce069 100644
--- a/src/leaflet-soton.js
+++ b/src/leaflet-soton.js
@@ -426,6 +426,8 @@ SELECT * WHERE {\
var fill = 'white';
if (feature.properties.buildingpart === 'corridor') {
fill = '#169EC6';
+ } else if (feature.properties.buildingpart === 'verticalpassage') {
+ fill = '#0A485B';
}
return {
@@ -529,13 +531,21 @@ SELECT * WHERE {\
}
},
onEachFeature: function(feature, layer) {
+ if (feature.properties.buildingpart === "corridor") {
+ return; // No popup for corridors yet
+ }
+
layer.on('click', function(e) {
var content;
var popupOptions = {};
// When the feature is clicked on
if ("buildingpart" in feature.properties) {
- content = roomPopupTemplate(feature.properties);
+ if (feature.properties.buildingpart === "room") {
+ content = roomPopupTemplate(feature.properties);
+ } else if (feature.properties.buildingpart === "verticalpassage") {
+ content = verticalPassagePopupTemplate(feature.properties);
+ }
} else { // Assume that it is a printer
// TODO: Use different icons where appropriate
popupOptions.offset = icons.vendingHotDrinks.options.popupAnchor;
@@ -843,6 +853,40 @@ SELECT * WHERE {\
});
}
+ function verticalPassagePopupTemplate(properties) {
+ properties = L.extend({}, properties);
+
+ if (!("name" in properties)) {
+ if (properties["buildingpart:verticalpassage"] === "stairway") {
+ properties.name = "Stairway";
+ } else {
+ properties.name = "Vertical Passage";
+ }
+
+ if ("ref" in properties) {
+ properties.name += properties.ref;
+ }
+ }
+
+ return getTemplateWrapper(properties, function(content) {
+
+ if ("level" in properties) {
+ content.appendChild(document.createTextNode("Levels:"));
+
+ var levelList = document.createElement("ul");
+
+ properties.level.forEach(function(level) {
+ var levelLi = document.createElement("li");
+ levelLi.textContent = level;
+
+ levelList.appendChild(levelLi);
+ });
+
+ content.appendChild(levelList);
+ }
+ });
+ }
+
function printerPopupTemplate(properties) {
properties.name = "Printer";