summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2014-09-10 21:08:36 +0100
committerChristopher Baines <cb15g11@soton.ac.uk>2014-09-10 21:08:36 +0100
commit25046fb610d1198c8c1fbc511e6538c4af48ba42 (patch)
treead57c7ddaa3b34394e7885938a0886389394cacd
parent47f0d35c5d1e7b210fce4928d62cdfe0ae5b5961 (diff)
downloadleaflet-soton-25046fb610d1198c8c1fbc511e6538c4af48ba42.tar
leaflet-soton-25046fb610d1198c8c1fbc511e6538c4af48ba42.tar.gz
Improve portal/door handling
-rwxr-xr-xcreate-data.js44
-rw-r--r--examples/doors.html47
2 files changed, 54 insertions, 37 deletions
diff --git a/create-data.js b/create-data.js
index 60947d2..2cd3353 100755
--- a/create-data.js
+++ b/create-data.js
@@ -660,17 +660,23 @@ function createBuildingParts(buildings, callback) {
portal.buildingpart = "entrance";
- buildingParts.push({
+ var portalObj = {
type: "Feature",
- geometry: {
+
+ properties: portal
+ };
+
+ if ("lat" in portal && "lon" in portal) {
+ portalObj.geometry = {
type: "Point",
coordinates: [
parseFloat(portal.lon, 10),
parseFloat(portal.lat, 10)
]
- },
- properties: portal
- });
+ };
+ }
+
+ buildingParts.push(portalObj);
buildingProperties = building.properties;
if (!("entrances" in buildingProperties)) {
@@ -1066,11 +1072,11 @@ PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\
SELECT * WHERE {\
?portal a portals:BuildingEntrance;\
portals:connectsBuilding ?building;\
- rdfs:comment ?comment;\
- rdfs:label ?label;\
- geo:lat ?lat;\
- geo:long ?long;\
OPTIONAL {\
+ ?portal rdfs:comment ?comment .\
+ ?portal rdfs:label ?label .\
+ ?portal geo:lat ?lat .\
+ ?portal geo:long ?long .\
?portal portals:connectsFloor ?floor\
}\
}"
@@ -1095,16 +1101,28 @@ SELECT * WHERE {\
var obj = {
uri: portal.portal.value,
building: portal.building.value,
- label: portal.label.value,
- comment: portal.comment.value,
- lat: portal.lat.value,
- lon: portal.long.value
}
if ("floor" in portal) {
obj.floor = portal.floor.value;
}
+ if ("label" in portal) {
+ obj.label = portal.label.value;
+ }
+
+ if ("comment" in portal) {
+ obj.comment = portal.comment.value;
+ }
+
+ if ("lat" in portal) {
+ obj.lat = portal.lat.value;
+ }
+
+ if ("long" in portal) {
+ obj.lon = portal.long.value;
+ }
+
portals.push(obj);
});
diff --git a/examples/doors.html b/examples/doors.html
index 3c29b11..4957a41 100644
--- a/examples/doors.html
+++ b/examples/doors.html
@@ -114,6 +114,7 @@
}
var entrance = entrances[entrance_id];
+ console.log(entrance);
if ("geometry" in entrance) {
return L.GeoJSON.coordsToLatLng(entrance.geometry.coordinates);
} else {
@@ -194,30 +195,28 @@
}
addToTable(comment);
- var a = document.createElement("a");
- a.textContent = "Show";
- a.href = "#";
-
- // when the entrance is clicked
- a.onclick = function() {
- var coordinates = entranceLocations[index];
-
- if (coordinates === null) {
- return;
- }
-
- // pan to the entrance
- map.panTo(coordinates);
-
- if ("level" in entrance.properties) {
- // display the relevant level
- map.setLevel(entrance.properties.level);
- }
-
- return false;
- };
-
- addToTable(a);
+ var coordinates = entranceLocations[index];
+ if (coordinates === null) {
+ addToTable(document.createTextNode("No Location"));
+ } else {
+ var a = document.createElement("a");
+ a.textContent = "Show";
+ a.href = "#";
+
+ // when the entrance is clicked
+ a.onclick = function() {
+ // pan to the entrance
+ map.panTo(coordinates);
+
+ if ("level" in entrance.properties) {
+ // display the relevant level
+ map.setLevel(entrance.properties.level);
+ }
+
+ return false;
+ };
+ addToTable(a);
+ }
tbody.appendChild(tr);
});