Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.
/ smart-bus Public archive

Open data for buses & data visulaization

Notifications You must be signed in to change notification settings

oursky/smart-bus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Background

KMB has a website and mobile application to track bus arrival time. We can improve it by digest such data and visualize it on a map, such that we can see the overall traffic status. Note that we shall not be bounded to KMB, the system should accept other data source as well, and we are not limited to show bus.

Goal

The goal of this project is to make a portal / platform which fetch data from KMB and process it such that we can estimate buses location and display on Google Map. The bus location should be update and it looks like real time traffic monitor. As there are about 3920 buses on KMB, we usually don’t display all buses at once (but it looks so fun), we shall provide a filter mechanic on the platform.

Servers

The platform consist of the follow servers, which can be installed on standalone machine or just colocated.

  1. MySQL
  2. Data Grabber and Processor
  3. Portal

Setup (MySQL)

  1. Install MySQL Server
> sudo apt-get install mysql-server
  1. Login mysql
mysql -u root -p
  1. Create database user
CREATE USER 'bususer'@'localhost' IDENTIFIED BY '1234';
CREATE USER 'bususer'@'%' IDENTIFIED BY '1234';
CREATE DATABASE busdb;
GRANT ALL ON busdb.* TO 'bususer'@'localhost'
GRANT ALL ON busdb.* TO 'bususer'@'%'
  1. Create Tables
Reference to database/create_table.txt
  1. Install store-procedures
Reference to database/sp_*.txt

Setup (Data Grabber)

  1. Install Node.JS 8
https://nodejs.org/en/download/package-manager/
  1. Install npm packages
> cd src
> npm install

Run Data Grabber

  1. Adjust config.json if needed
  2. Update bus stop information
> cd src
> nodejs kmb_updateroute.js 12A
  1. Update arrival estimation
> cd src
> nodejs kmb_updateeta.js 12A

PS. You might want to setup cron job for this

Setup (Portal Server)

  1. Install Node.JS 8
https://nodejs.org/en/download/package-manager/
  1. Install npm packages
> cd src
> npm install

Run Portal

NOTE: Adjust config.json if needed

> cd src
> nodejs portal.js

NOTE: As PoC the route is hardcoded on index.html