Skip to content

chronakis/speed-monitor-bot

Repository files navigation

speed-monitor-bot

** The project is moving towards here api v7 and this informatin is outdated **

A set of tools to help process HERE Maps and google distance matrix data written in node js. The twitter bot was inspired by the original speederbot. It does not depend to any third party service and you can run it from your computer or your Rasberry PI or whatever device you can put node in.

There are four tools in this project:

  1. The monitoring-bot: This is used to collect traffic flow data for a set of road sections in a CSV file.
  2. The gmonitoring-bot: A google version that uses the distance matrix to collect journey times in a CSV file.
  3. The speeder-bot: A javascript bot that reports on twitter when the flow data indicate average speeds above a given limit.
  4. The Flow data explorer: A web tool for identifying the road sections in HERE maps and previewing live data. It is live at speedbot.bikesnbytes.net, no need to build it. Use this to get your configuration parameters.

Quick start

I. Pre-requisites

You will need.

  • A HERE Maps developer account an the API KEY
    • Go here, get started for free and create a "Freemium" account and API key. This is instant.
  • node js installed. You can do this either globally (with an installer) or inside the folder folder (with a zip). The installer will take care of everything. If you do the manual way, just don't for get to make sure the PATH is updated for node and npm. Node Js can be found here.
  • If you want to use the google monitoring bot, you will need a google developer account with a distance matrix API KEY. Whilst this API is not free, you can get a lot of credits to run some free tests. Starting point: developers.google.com/maps

If you want to tweet (optional)

You will need a twitter developer account. Go here and apply for a hobbyist account. It takes a few ours to get it approved, but you run the bot in "dry run" mode and print the twitter status, so don't wait for it.

If you want to run the explorer on your own (not recommended)

A simple http-server. I am suggesting the node module http-server to keep things tidy. To install it, type in the console npm install http-server -g. Again, you can choose to install this in your project folder in which case you probably know what you are doing.

II. Configuration

  1. auth-config.js:
    1. Copy the file auth-config.js.template into auth-config.js
    2. Edit auth-config.js and replace your api keys and secrets. You can leave twitter empty, if you don't use it.
  2. bot-config.js:
  3. Copy the file bot-config.js.template into bot-config.js
  4. Go to speedbot.bikesnbytes.net to get your location data. You will need bbox (area to query), LI and PC (road section identifier).
  5. Set a bbox from the explorer (alternative way at here maps)
  6. monitoring-bot:
    1. Set one or more road setions in the sections array. The bot will log data from all those.
  7. Set logInterval to the number of seconds between runs. null to use in run once mode.
  8. speeder-bot:
    1. Use tweet: false for a dry run to preview what the tweet will look like.
  9. Set tweetInterval to the number of seconds between runs. null to use in run once mode. 2. Set the LI_filter and PC_filter 3. Set your speed limits ( limitKm or limitMi)
  • Note: The bot supports multiple configurations. See run section below
  • Note2: I don't have documentation yet for the google distance matrix but the config files should give enough information.

III. Run the bot(s)

For the monitoring bot:

node monitoring-bot.js

For the speeder bot:

node speeder-bot.js

If you set the interval, the bot will run forever until killed.

On a un*x You can use somethign like nohup, daemon, daemonize, at etc. Ir you can just run it with screen. Or you can put it in init if you are crazy enough :)

On windows you can use the task scheduler to run it in the background (remember if you set an interval to run it once). Lots of options on how long to run etc.

IV. Multiple configurations

Pass a configurtion directory from the command line

node monitoring-bot.js config-directory
  • config-directory
    • auth-config.js
    • bot-config.js

If you want to use a single auth-config.js and multiple bot configurations, keep the auth-config.js in the same directory as the bot and only add bot-config in the cirectories, e.g.:

  • monitoring-bot.js
  • auth-config.js
  • config-dir-1
    • bot-config.js
  • config-dir-2
    • bot-config.js

The future

Unfortunatly, when I started this project I did not know that HERE Maps did not report data for Regent's Park, London that I was interested in. I found out after I wrote the first draft of the exlorer. I finished this project only because I got it started and it was interesting playing with map and traffic data, something I haven't done before. I don't have any personal use so I am not that motivated. I am however open to suggestions.

The next things I may implement are:

  1. Get the bounding box from the current map view. The HERE Maps page is herendous. DONe
  2. A speed-audit-bot that will monitor some given roads and create a database of recorded average speeds for analysis.. DON
  3. A version of the traffic monitoring bot that uses the google distance matrix

Thanks & Credits

Thanks to the original speederbot - @BerkshireCar that kickstarted this work.

Sources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors