From 53b9706ccbe5d08845728c367f76ad6756549b2b Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 4 Mar 2015 10:43:48 +0000 Subject: Patch data creation Do not fail if bus stop URI's are missing. --- create-data.js | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/create-data.js b/create-data.js index 4f224bf..d566704 100755 --- a/create-data.js +++ b/create-data.js @@ -817,18 +817,20 @@ function createBuildingParts(buildings, callback) { getDoors(buildingPart, function(err, doors) { buildingPart.properties.doors = []; - doors.forEach(function(door) { - if (!(door.id in doorsToRooms)) { - doorsToRooms[door.id] = [ buildingPart ]; - } else { - doorsToRooms[door.id].push(buildingPart); - } - doorsById[door.id] = door; - - buildingParts.push(door); - - buildingPart.properties.doors.push(door.id); - }); + if (typeof(doors) !== "undefined") { + doors.forEach(function(door) { + if (!(door.id in doorsToRooms)) { + doorsToRooms[door.id] = [ buildingPart ]; + } else { + doorsToRooms[door.id].push(buildingPart); + } + doorsById[door.id] = door; + + buildingParts.push(door); + + buildingPart.properties.doors.push(door.id); + }); + } callback(); }); @@ -1549,6 +1551,12 @@ function processRoute(route, routeMaster, stopAreaRoutes, callback) { var stopURIs = areas.map(function(area) { var uri = area.tags.uri; + if (uri == null) { + console.warn("null uri for area " + JSON.stringify(area)); + + return uri; + } + if (uri.indexOf("http://transport.data.gov.uk/id/stop-point/") === 0) { uri = "http://id.southampton.ac.uk/bus-stop/" + uri.slice(43); } else { @@ -1830,7 +1838,7 @@ function createBusStop(stopArea, routes, callback) { var uri = stopArea.tags.uri; - if (uri.indexOf("http://transport.data.gov.uk/id/stop-point/") === 0) { + if (uri != null && uri.indexOf("http://transport.data.gov.uk/id/stop-point/") === 0) { uri = "http://id.southampton.ac.uk/bus-stop/" + uri.slice(43); } else { console.warn("Unrecognised bus stop uri " + uri); -- cgit v1.2.3