summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2014-02-21 12:19:10 +0000
committerChristopher Baines <cb15g11@soton.ac.uk>2014-02-21 12:19:10 +0000
commit5addce86274887ea9549498f08929f7007244017 (patch)
tree7a905a7d327593987ec4058e75ef0f399a52fd7b
parente4d1c918444c15e2e1480ecb332e61ec8feb7629 (diff)
downloadleaflet-soton-5addce86274887ea9549498f08929f7007244017.tar
leaflet-soton-5addce86274887ea9549498f08929f7007244017.tar.gz
Add support for a building part to span mutiple levels
-rwxr-xr-xcreate-data.js18
-rw-r--r--src/leaflet-soton.js22
2 files changed, 31 insertions, 9 deletions
diff --git a/create-data.js b/create-data.js
index e236a99..1a9fa2e 100755
--- a/create-data.js
+++ b/create-data.js
@@ -309,12 +309,18 @@ function createRooms(buildings, workstations, callback) {
});
}, function(err) {
- osmIDToLevel = {};
+ osmIDToLevels = {};
async.each(levelRelations, function(level, callback) {
getBuildingPartMemberRefs(level, function(err, refs) {
for (var i=0; i<refs.length; i++) {
- osmIDToLevel[refs[i]] = parseInt(level.tags.level, 10);
+ var ref = refs[i];
+
+ if (!(ref in osmIDToLevels)) {
+ osmIDToLevels[ref] = [];
+ }
+
+ osmIDToLevels[refs[i]].push(parseInt(level.tags.level, 10));
}
callback();
});
@@ -322,8 +328,12 @@ function createRooms(buildings, workstations, callback) {
for (var i=0; i<buildingParts.length; i++) {
var part = buildingParts[i];
- if (part.id in osmIDToLevel) {
- part.properties.level = osmIDToLevel[part.id];
+ if (part.id in osmIDToLevels) {
+ part.properties.level = osmIDToLevels[part.id];
+
+ if (part.properties.level.length === 1) {
+ part.properties.level = part.properties.level[0];
+ }
} else {
console.log("unknown level");
console.log(JSON.stringify(part, null, 4));
diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js
index accd7f7..5851158 100644
--- a/src/leaflet-soton.js
+++ b/src/leaflet-soton.js
@@ -1677,13 +1677,25 @@ L.IndoorLayer = L.Class.extend({
return;
}
- if (level in layers) {
- layer = layers[level];
+ if (L.Util.isArray(level)) {
+ level.forEach(function(level) {
+ if (level in layers) {
+ layer = layers[level];
+ } else {
+ layer = layers[level] = L.geoJson({ type: "FeatureCollection", features: [] }, options);
+ }
+
+ layer.addData(part);
+ });
} else {
- layer = layers[level] = L.geoJson({ type: "FeatureCollection", features: [] }, options);
- }
+ if (level in layers) {
+ layer = layers[level];
+ } else {
+ layer = layers[level] = L.geoJson({ type: "FeatureCollection", features: [] }, options);
+ }
- layer.addData(part);
+ layer.addData(part);
+ }
});
},
getLevels: function() {