summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcreate-data.js31
1 files changed, 16 insertions, 15 deletions
diff --git a/create-data.js b/create-data.js
index 0c9a76f..2409855 100755
--- a/create-data.js
+++ b/create-data.js
@@ -1631,7 +1631,11 @@ function processRoute(route, routeMaster, stopAreaRoutes, callback) {
}
function loadBusData(collections, callback) {
- var stopAreaRoutes = {} // Mapping from id to stop area, also contains the route names for that stop area
+ var stopAreaRoutes = {}; // Mapping from id to stop area, also contains the route names for that stop area
+ var busRoutes = {
+ type: "FeatureCollection",
+ features: []
+ };
async.waterfall([
function(callback) {
@@ -1644,11 +1648,6 @@ function loadBusData(collections, callback) {
}, callback);
},
function(routeMasters, callback) {
- collections.busRoutes = {
- type: "FeatureCollection",
- features: []
- };
-
async.eachSeries(routeMasters, function(routeMaster, callback) {
async.eachSeries(routeMaster.members, function(member, callback) {
@@ -1657,7 +1656,7 @@ function loadBusData(collections, callback) {
if (err) callback(err);
processRoute(route, routeMaster, stopAreaRoutes, function(err, feature) {
- collections.busRoutes.features.push(feature);
+ busRoutes.features.push(feature);
callback(err);
});
@@ -1680,8 +1679,8 @@ function loadBusData(collections, callback) {
processRoute(route, null, stopAreaRoutes, function(err, feature) {
// Check if this route is a duplicate
- for (var i in collections.busRoutes.features) {
- var route = collections.busRoutes.features[i];
+ for (var i in busRoutes.features) {
+ var route = busRoutes.features[i];
if (route.properties.name === feature.properties.name) {
callback(err);
@@ -1689,7 +1688,7 @@ function loadBusData(collections, callback) {
}
}
- collections.busRoutes.features.push(feature);
+ busRoutes.features.push(feature);
callback(err);
});
@@ -1706,8 +1705,8 @@ function loadBusData(collections, callback) {
// Now remove all but the longest U1C route...
var longestRoute = 0;
- for (var i in collections.busRoutes.features) {
- var route = collections.busRoutes.features[i];
+ for (var i in busRoutes.features) {
+ var route = busRoutes.features[i];
if (route.properties.ref !== "U1C") {
continue;
@@ -1722,9 +1721,9 @@ function loadBusData(collections, callback) {
console.log("longest route " + longestRoute);
- i = collections.busRoutes.features.length;
+ i = busRoutes.features.length;
while (i--) {
- route = collections.busRoutes.features[i];
+ route = busRoutes.features[i];
if (route.properties.ref !== "U1C") {
continue;
@@ -1735,7 +1734,7 @@ function loadBusData(collections, callback) {
if (stops !== longestRoute) {
console.log("removing " + i);
- collections.busRoutes.features.splice(i, 1);
+ busRoutes.features.splice(i, 1);
}
}
@@ -1743,6 +1742,8 @@ function loadBusData(collections, callback) {
if (err)
console.error(err);
+ collections.busRoutes = busRoutes;
+
callback(err, collections);
});
}