Skip to content

Commit

Permalink
Huge update:
Browse files Browse the repository at this point in the history
- Migrate to Google Maps instead of Gothere, because there're bus stops in Johor
- Relayout everything
- Minified scripts
- Shows all routes passing through one bus stop
- Show bus stops on when zoomed further in
- Places search
  • Loading branch information
cheeaun committed Jan 31, 2012
1 parent 4d50d4b commit 6fae653
Show file tree
Hide file tree
Showing 10 changed files with 673 additions and 157 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ Here's how to get the data, assuming that you have `node` and checked out this r
cd data cd data
./get-bus-services.js ./get-bus-services.js
./get-bus-routes-stops.js ./get-bus-routes-stops.js
./get-bus-stops-services.js


Then, load `index.html` in the browser. The map is powered by [Gothere Maps API](http://gothere.sg/api). Even the color scheme is inspired by Gothere. Tested to work great on latest Firefox and Chrome browsers. The data you'll get are:

- `bus-services.json` - Lists all bus services with the bus numbers and `dir` (number of routes where 2 means two routes, usually in opposite direction).
- `bus-stops.json` - Lists all bus stops with coordinates and names.
- `bus-stops-services.json` - List all bus stops with the bus numbers/services that stops there.
- `services/{number}.json` - List two routes with all (polyline) coordinates and bus stops for each route. If the bus service doesn't have a second route, the second route data will be empty.

The map is powered by [Google Maps JavaScript API](http://code.google.com/apis/maps/documentation/javascript/). The color scheme and markers are *inspired* by [Gothere.sg](http://gothere.sg/). Tested to work great on latest Firefox and Chrome browsers.


If you have any feedback, tweet me at [@cheeaun](http://twitter.com/cheeaun). If you have any feedback, tweet me at [@cheeaun](http://twitter.com/cheeaun).
13 changes: 8 additions & 5 deletions assets/director.js
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,8 @@



// //
// Generated on Tue Dec 06 2011 04:47:21 GMT-0500 (EST) by Nodejitsu, Inc (Using Codesurgeon). // Generated on Tue Jan 31 2012 02:13:32 GMT+0000 (MPST) by Nodejitsu, Inc (Using Codesurgeon).
// Version 1.0.7 // Version 1.0.9
// //


(function (exports) { (function (exports) {
Expand Down Expand Up @@ -302,7 +303,7 @@ function paramifyString(str, params, mod) {
} }
} }
} }
return mod === str ? "([a-zA-Z0-9-]+)" : mod; return mod === str ? "([._a-zA-Z0-9-]+)" : mod;
} }


function regifyString(str, params) { function regifyString(str, params) {
Expand Down Expand Up @@ -403,8 +404,10 @@ Router.prototype.dispatch = function(method, path, callback) {
Router.prototype.invoke = function(fns, thisArg, callback) { Router.prototype.invoke = function(fns, thisArg, callback) {
var self = this; var self = this;
if (this.async) { if (this.async) {
_asyncEverySeries(fns, function(fn, next) { _asyncEverySeries(fns, function apply(fn, next) {
if (typeof fn == "function") { if (Array.isArray(fn)) {
return _asyncEverySeries(fn, apply, next);
} else if (typeof fn == "function") {
fn.apply(thisArg, fns.captures.concat(next)); fn.apply(thisArg, fns.captures.concat(next));
} }
}, function() { }, function() {
Expand Down
Binary file added assets/dot-blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added assets/dot-red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/bus-stops-services.json

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions data/get-bus-stops-services.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env node

var fs = require('fs');

var json = fs.readFileSync('bus-services.json', 'ascii');
if (!json) console.log('bus-services.json not found');

var stops = {};

var data = JSON.parse(json);
for (var type in data){
var services = data[type];
services.forEach(function(service){
var no = service.no;
var json = fs.readFileSync('bus-services/' + no + '.json', 'ascii');
var d = JSON.parse(json);
var stops1 = d[1].stops;
stops1.forEach(function(stop){
if (stops[stop]){
if (stops[stop].indexOf(no) == -1) stops[stop].push(no);
} else {
stops[stop] = [no];
}
});
if (d[2] && d[2].stops && d[2].stops.length){
var stops2 = d[2].stops;
stops2.forEach(function(stop){
if (stops[stop]){
if (stops[stop].indexOf(no) == -1) stops[stop].push(no);
} else {
stops[stop] = [no];
}
});
}
});
}

fs.writeFile('bus-stops-services.json', JSON.stringify(stops), function(){
console.log('bus-stops-services.json created.');
});
Loading

0 comments on commit 6fae653

Please sign in to comment.