Coder Social home page Coder Social logo

sgbusdata's Introduction

SG Bus Data

Singapore Bus data

This is a data-only repository to complement BusRouter SG.

The data

It's in the /data folder.

Or, browse through them on the data server: https://data.busrouter.sg/

Terminologies

  • Stop - the bus stop itself
  • Service - the bus service, with numbers like 133 or 1N
  • Route - the route of a bus service, the lines connecting all the stops
  • Pattern - the patterns of a bus route, one of the lines connecting the stops
    • If the route is one-way (A->B), there's only one pattern
    • If the route is two-way (A->B, B->A), there're two patterns in a route
    • Each pattern usually pass through different stops, as they're usually on opposite sides of the road.

Scripts

npm run cleanup

Delete files in data/v1/raw/services/*, data/v1/patch/*.cm.json and data/v1/patch/*.om.json, before running the commands below.

npm run fetch

npm run datamall

โš ๏ธ This requires DatamallAccountKey environment variable. Make a copy of example.env file, rename to .env and put in your Datamall API key.

npm run patch

  • patch-missing-routes - Patch missing routes (failed requests from fetch-bus-services-route) by getting fresh route data from OneMap/Citymapper.
  • patch-multiline-routes - Patch multi-line routes (routes that has more than one line, we only need one line here, per pattern) by getting fresh route data from OneMap (again).
  • patch-bus-stop-names - Patch bus stop names (some of them are all-uppercase instead of titlecase) by double-checking them on https://www.transitlink.com.sg/eservice/eguide/bscode_idx.php

npm run generate

  • generate-data - Generate all the final clean data
  • generate-data-firstlast - Generate the first/last timing data

npm run build

Run all npm commands above.

sgbusdata's People

Contributors

cheeaun avatar slenplayz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sgbusdata's Issues

502 Bad Gateway error on npm run patch

Running npm run patch results in an error when getting a token or bus route data from developers.gov.sg. Any link in the website just leads to a 502 Gateway Error. This error was first seen on 17 Dec 23 and may have been occurring at most since 2nd Dec 23. I can't seem to find a new endpoint for the /publicapi/publicsessionid or /publicapi/busexp/getBusRoutes

Github Actions Logs:

(From npm run patch)

> [email protected] patch
> node scripts/patch-missing-routes && node scripts/patch-multiline-routes && node scripts/patch-bus-stop-names

๐Ÿ“– Read file: ./data/v1/raw/bus-services.json
๐Ÿ“– Read file: ./data/v1/patch/bus-services-routes.failures.json
๐Ÿ“– Read file: ./data/v1/raw/services/TRUNK/114A.json
๐Ÿ“– Read file: ./data/v1/raw/services/TRUNK/307.json
Missing pattern 2 for service 307
๐Ÿ“– Read file: ./data/v1/raw/services/TRUNK/60T.json
๐Ÿ“– Read file: ./data/v1/raw/services/TRUNK/812T.json
๐Ÿ“– Read file: ./data/v1/raw/services/TRUNK/83T.json
๐Ÿ“– Read file: ./data/v1/raw/services/TRUNK/859T.json
๐Ÿ“– Read file: ./data/v1/raw/services/TRUNK/860T.json
๐Ÿฅ https://developers.onemap.sg/publicapi/publicsessionid
๐Ÿšจ Retrying HTTPError: Response code 502 (Bad Gateway) time(s)
๐Ÿšจ Retrying HTTPError: Response code 502 (Bad Gateway) time(s)
๐Ÿšจ Retrying HTTPError: Response code 502 (Bad Gateway) time(s)
๐Ÿšจ Retrying HTTPError: Response code 502 (Bad Gateway) time(s)
๐Ÿšจ Retrying HTTPError: Response code 502 (Bad Gateway) time(s)
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

HTTPError: Response code 502 (Bad Gateway)
    at Request.<anonymous> (/home/runner/work/sgbusdata/sgbusdata/node_modules/got/dist/source/as-promise/index.js:117:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1704071523771,
    socket: 1704071523772,
    lookup: 1704071523783,
    connect: 1704071524023,
    secureConnect: 1704071524264,
    upload: 1704071524264,
    response: 1704071524547,
    end: 1704071524548,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 11,
      tcp: 240,
      tls: 241,
      request: 0,
      firstByte: 283,
      download: 1,
      total: 777
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.