|
So you have just seen the WhereAreTrains? mashup and you would like to use it with different data on your own website. It could even not be a railway network: ferries, bus,... Good point: you are on the right page to learn how to do so :)
Prerequisites
This a list of what you need before going farther:
- real-time schedule boards of arrivals and departures (see this web site concerning trains in France),
- time profiles of routes (see this web site concerning trains in France),
- a Dapper account (sign up here),
- a Google Maps account (sign up here),
- a web site with PHP and Curl library (no need of MySQL),
- optionally a Google Analytics account (sign up here).
Procedure
Steps 1+2 produce an xml file like this one .
1- Network building
In this step, we build the network topology which is displayed as Gpolylines (lines) and GMarkers (stations).
- New Use one of my other mashup GMapsPolyTool to get all branchs of the network and encode them directly on the page.
- Copy-paste-process the content and add stations to get a file like this one. Note that <br> is the token manually inserted between levels and points and also at the end of points. Save as network.xml.
2- Time profile building
In this step, we build (time, position) couples of all possible routes
- Create an xml file like this one including only the segment block (route) you create the time profile for.
- Decompress this archive, add your google Maps key in _getSchedule.htm at line 8 and the route time profile at line 178, then upload the file on your web server. Call the html file. After more or less time, you should get a map displayed and a text line below.
- Create Profiles sections in your network.xml, Copy-paste-process text line for each profile (see previous step), add Destinations arrays where first item is name found on schedule boards and second item is time location "where" the moving entity enters the route.
- For each folder, add the codeMasterStation which identifies the station of which arrivals and departures are profiled. this Id is the argument of the Dapps (see step 3 below). You should now have a network.xml looking like this file. Upload it in the target folder on the server.
3- Schedule board scrapping
In the step, we produce a tool which answers our request with an rss feed including departure and arrival time of moving entities (trains, ferries, bus,...)
- Create a Dapp like this one for arriving entities. You should be able to call it with the codeMasterStation as argument (ex: http://www.dapper.net/RunDapp?dappName=mydap&v=1&variableArg_0=).
- Create a Dapp like this one for departing entities. You should be able to call it with the station code as argument.
4- Integration
In this step, we setup the mashup.
- Decompress this archive then add your google Maps key and Google Analytics key in index.htm, change TODO values in WhereAreTrains.overall.js and change TODO values in fetch_train_data.php.
- Upload everything in the target folder on the server.
- Use a Cron to process fetch_train_data.php every hour. Personally I use the WebCron.org service.
- Launch the mashup!!!
|