Add between stops to feed YAML
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
-maxious-canberra-transit-feed/output/
+maxious-canberra-transit-feed/source-html
+origin-src
--- a/betweenpoint.php
+++ b/betweenpoint.php
@@ -7,71 +7,65 @@
function init()
{
- // create the ol map object
- var map = new OpenLayers.Map('map');
+ // create the ol map object
+ var map = new OpenLayers.Map('map');
- var osmtiles = new OpenLayers.Layer.OSM("local", "http://127.0.0.1/Maps/OSM/${z}/${x}/${y}.png")
+ var osmtiles = new OpenLayers.Layer.OSM("local", "http://127.0.0.1/Maps/OSM/${z}/${x}/${y}.png")
// use http://open.atlas.free.fr/GMapsTransparenciesImgOver.php and http://code.google.com/p/googletilecutter/ to make tiles
- markers = new OpenLayers.Layer.Markers("Between Stop Markers");
+ markers = new OpenLayers.Layer.Markers("Between Stop Markers");
<?php
-$conn = pg_connect("dbname=bus user=postgres password=snmc");
-if (!$conn) {
- echo "An error occured.\n";
- exit;
-}
-$result_stops = pg_query($conn, "Select * FROM stops");
-
-while ($stop = pg_fetch_assoc($result_stops)) {
-echo 'marker = new OpenLayers.Marker(new OpenLayers.LonLat('.($stop['lng']/10000000).",".($stop['lat']/10000000).')
+ $conn = pg_connect("dbname=bus user=postgres password=snmc");
+ if (!$conn) {
+ echo "An error occured.\n";
+ exit;
+ }
+ $result_stops = pg_query($conn, "Select * FROM stops");
+
+ while ($stop = pg_fetch_assoc($result_stops)) {
+ echo 'marker = new OpenLayers.Marker(new OpenLayers.LonLat(' . ($stop['lng'] / 10000000) . "," . ($stop['lat'] / 10000000) . ')
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection
));';
-
-echo '
- marker.id="'.$stop['geohash'].'";
+
+ echo '
+ marker.id="' . $stop['geohash'] . '";
markers.addMarker(marker);
marker.events.register("mousedown", marker, function() {
document.getElementById("between_points").innerHTML += this.id+";";
});
';
-}
+ }
?>
var timeicon = new OpenLayers.Icon("http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png",new OpenLayers.Size(32,32));
var timepoints = new OpenLayers.Layer.GeoRSS("Timing Points", "displaytimepoints.georss.php", { icon: timeicon });
map.addLayers([osmtiles, markers,timepoints]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
- map.zoomToExtent(markers.getDataExtent());
+ map.zoomToExtent(markers.getDataExtent());
}
+ </script>
+ <script type="text/javascript">
+function submitBetween () {
+ $.post("betweenpoint.submit.php", $("#inputform").serialize(), function(html){
+ $("#response").html(html);
+ //clearForms();
+ return false;
+ });
+};
- function submit(){
- $.ajax({
- type: "POST",
- url: "betweenpoint.submit.php",
- data: "reverse=" + document.getElementById("reverse").value +
- "&from=" + document.getElementById("from").value +
- "&to=" + document.getElementById("to").value +
- "&routes=" + document.getElementById("routes").value +
- "&between_points=" + document.getElementById("between_points").value,
- success: function(html){
- $("#response").html(html);
- clearForms();
- }
- });
-
- }
-<!--
function OnChange(dropdown)
{
var myindex = dropdown.selectedIndex
- var selValue = dropdown.options[myindex].value
-alert(selValue);
+ var selValue = dropdown.options[myindex].value;
+ $("#routes").val(selValue.split(":",2)[0]);
+ fromto = selValue.split(":",2)[1];
+ $("#from").val(fromto.split("->",2)[0]);
+ $("#to").val(fromto.split("->",2)[1]);
return true;
}
-//-->
// function will clear input elements on each form
function clearForms(){
@@ -96,7 +90,7 @@
break;
case "radio":
case "checkbox":
- document.forms[x].elements[y].checked = "";
+ document.forms[x].elements[y].checked = true;
break;
case "select-one":
document.forms[x].elements[y].options[0].selected = true;
@@ -118,72 +112,69 @@
<select name=selectPair onchange='OnChange(this.form.selectPair);'>
<option>Select a from/to pair...</option>
<?php
-include('spyc/spyc.php');
-//$timetable = Spyc::YAMLLoad('../spyc.yaml');
-$path = "maxious-canberra-transit-feed/output/";
-$dhandle = opendir("maxious-canberra-transit-feed/output/");
-// define an array to hold the files
-$files = array();
-$paths = array();
+ include('spyc/spyc.php');
+ //$timetable = Spyc::YAMLLoad('../spyc.yaml');
+ $path = "maxious-canberra-transit-feed/output/";
+ $dhandle = opendir("maxious-canberra-transit-feed/output/");
+ // define an array to hold the files
+ $files = array();
+ $paths = array();
+
+ if ($dhandle) {
+ // loop through all of the files
+ while (false !== ($fname = readdir($dhandle))) {
+ if (($fname != '.') && ($fname != '..')) {
+ $timetable = Spyc::YAMLLoad("maxious-canberra-transit-feed/output/" . $fname);
+ // Strip off individual platforms because it usually doesn't matter for routes
+ $timetable["time_points"] = preg_replace("/-.* Platform.*/","",$timetable["time_points"]);
+ for ($i = 0; $i < sizeof($timetable["time_points"]) - 1; $i++) {
+ @$paths[trim($timetable["time_points"][$i]) . "->" . trim($timetable["time_points"][$i + 1])] .= $timetable["short_name"] . ";";
+ }
+ }
+ }
+ }
+ ksort($paths);
+
+ $completedPaths = array();
+ $result_betweenstops = pg_query($conn, "Select * FROM between_stops");
+ while ($path = pg_fetch_assoc($result_betweenstops)) {
+ $completedPaths[trim($path['fromlocation']) . "->" . trim($path['tolocation'])] .= trim($path['routes']);
+ }
+
+ foreach ($paths as $path => $routes) {
+ if (!in_array($path, array_keys($completedPaths))) {
+ echo "<option value=\"$routes:$path\">" . sizeof(explode(";", $routes)) . " $path</option>\n";
+ } else {
+ $completedRoutes = explode(";", $completedPaths[$path]);
+ $incompleteRoutes = "";
+ foreach (explode(";", $routes) as $route) {
-if ($dhandle) {
- // loop through all of the files
- while (false !== ($fname = readdir($dhandle))) {
- if (($fname != '.') && ($fname != '..')) {
- $timetable = Spyc::YAMLLoad("maxious-canberra-transit-feed/output/".$fname);
- for ($i = 0; $i < sizeof($timetable["time_points"]) -1 ; $i++)
- {
- @$paths[$timetable["time_points"][$i]."->".$timetable["time_points"][$i+1]] .= $timetable["short_name"].";";
- }
+ if (!in_array($route,$completedRoutes)) {
+ $incompleteRoutes .= $route.';';
+ }
+
}
- }
-}
-$completedPaths = Array("Cameron Ave Bus Station->Lathlain St Bus Station",
-"Lathlain St Bus Station->Cohen St Bus Station",
-"Cohen St Bus Station->Lathlain St Bus Station",
-"Lathlain St Bus Station->Cameron Ave Bus Station",
-"Lathlain St Bus Station - Platform 1->Cameron Ave Bus Station - Platform 1",
-"Lathlain St Bus Station - Platform 2->Cameron Ave Bus Station - Platform 1",
-"Lathlain St Bus Station - Platform 2->Cameron Ave Bus Station - Platform 2",
-"Lathlain St Bus Station - Platform 3->Cameron Ave Bus Station - Platform 2",
-"Lathlain St Bus Station - Platform 3->Cameron Ave Bus Station - Platform 3",
-"Lathlain St Bus Station - Platform 4->Cohen St Bus Station - Platform 4",
-"Lathlain St Bus Station - Platform 4->Cohen St Bus Station - Platform 6",
-"Lathlain St Bus Station - Platform 5->Cohen St Bus Station - Platform 5",
-"Lathlain St Bus Station - Platform 6->Cohen St Bus Station - Platform 5",
-"Cohen St Bus Station - Platform 1->Lathlain St Bus Station - Platform 2",
-"Cohen St Bus Station - Platform 1->Lathlain St Bus Station - Platform 3",
-"Cohen St Bus Station - Platform 2->Lathlain St Bus Station - Platform 1",
-"Cohen St Bus Station - Platform 2->Lathlain St Bus Station - Platform 2",
-"Cohen St Bus Station - Platform 2->Lathlain St Bus Station - Platform 3",
-"Cohen St Bus Station - Platform 3->Lathlain St Bus Station - Platform 1",
-"Cameron Ave Bus Station - Platform 4->Lathlain St Bus Station - Platform 4",
-"Cameron Ave Bus Station - Platform 5->Lathlain St Bus Station - Platform 5",
-"Cameron Ave Bus Station - Platform 5->Lathlain St Bus Station - Platform 6"
-);
-ksort($paths);
-foreach ($paths as $path => $routes)
-{
- if (!in_array($path,$completedPaths)) echo "<option value=\"$routes:$path\">".sizeof(explode(";",$routes))." $path</option>\n";
-}
+ if ($incompleteRoutes != "") echo "<option value=\"$incompleteRoutes:$path\">" . sizeof(explode(";", $incompleteRoutes)) . " $path</option>\n";
+ }
+
+ }
?>
</select>
- from <input type="text" id="from"/>
- to <input type="text" id="to"/>
+ from <input type="text" name="from" id="from"/>
+ to <input type="text" name="to" id="to"/>
<br>
- on routes <input type="text" id="routes"/>
-Reverse? <input type="checkbox" name="reverse" id="reverse" value="true"/>
-<input type="button" onclick="javascript:submit()" name="mysubmit" value="Submit!">
+ on routes <input type="text" name="routes" id="routes"/>
+Reverse? <input type="checkbox" name="reverse" id="reverse" checked="true"/>
+<input type="button" onclick="javascript:submitBetween()" value="Submit!">
<input type="button" value="Clear" onclick="javascript:clearForms()" title="Start clearForms() JavaScript function">
<br>
-<textarea id="between_points" rows="1" cols="120"></textarea>
+<textarea name="between_points" id="between_points" rows="1" cols="120"></textarea>
</form>
-<br><div id="response">
- <!-- Our message will be echoed out here -->
- </div>
+<div id="response">
+ <!-- Our message will be echoed out here -->
+ </div>
</div>
<div id="map" width="100%" height="100%"></div>
</body>
</html>
-
--- a/betweenpoint.submit.php
+++ b/betweenpoint.submit.php
@@ -1,76 +1,29 @@
<?php
-/*
- * GeoPo Encode in PHP
- * @author : Shintaro Inagaki
- * @param $location (Array)
- * @return $geopo (String)
- */
-function geopoEncode($lat, $lng) {
- // 64characters (number + big and small letter + hyphen + underscore)
- $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
-
- $geopo = "";
- $scale = 7;
-
- // Change a degree measure to a decimal number
- $lat = ($lat + 90) / 180 * pow(8, 10);
- $lng = ($lng + 180) / 360 * pow(8, 10);
- // Compute a GeoPo code from head and concatenate
- for($i = 0; $i < $scale; $i++) {
- $geopo .= substr($chars, floor($lat / pow(8, 9 - $i) % 8) + floor($lng / pow(8, 9 - $i) % 8) * 8, 1);
- }
- return $geopo;
-}
-
-/*
- * GeoPo Decode in PHP
- * @author : Shintaro Inagaki
- * @param $geopo (String)
- * @return $location (Array)
- */
-function geopoDecode($geopo) {
- // 64characters (number + big and small letter + hyphen + underscore)
- $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
- // Array for geolocation
- $location = array ();
-
- for ($i = 0; $i < strlen($geopo); $i++) {
- // What number of character that equal to a GeoPo code (0-63)
- $order = strpos($chars, substr($geopo, $i, 1));
- // Lat/Lng plus geolocation value of scale
- $location['lat'] = $location['lat'] + floor($order % 8) * pow(8, 9 - $i);
- $location['lng'] = $location['lng'] + floor($order / 8) * pow(8, 9 - $i);
- }
-
- // Change a decimal number to a degree measure, and plus revised value that shift center of area
- $location['lat'] = $location['lat'] * 180 / pow(8, 10) + 180 / pow(8, strlen($geopo)) / 2 - 90;
- $location['lng'] = $location['lng'] * 360 / pow(8, 10) + 360 / pow(8, strlen($geopo)) / 2 - 180;
- $location['scale'] = strlen($geopo);
-
- return $location;
-}
-
$conn = pg_connect("dbname=bus user=postgres password=snmc");
if (!$conn) {
echo "An error occured.\n";
exit;
}
-$xml = simplexml_load_file("04-locatebetweenpoints.osm");
-
-/* Access the <rating> nodes of the first movie.
- * Output the rating scale, too. */
-foreach ($xml->node as $node) {
- $geoPo = geopoEncode((float)$node['lat'],(float)$node['lon']);
- $node['lat'] = (int) ((float)$node['lat']*10000000);
- $node['lon'] = (int) ((float)$node['lon']*10000000);
- echo($node['lat'].",".$node['lon']."=$geoPo<br>");
- $sql = "INSERT INTO stops (geohash, lat, lng) VALUES('$geoPo','{$node['lat']}','{$node['lon']}')";
+print_r($_REQUEST);
+$reverse=$_REQUEST["reverse"];
+$from=$_REQUEST["from"];
+$to=$_REQUEST["to"];
+$routes=$_REQUEST["routes"] ;
+$points=$_REQUEST["between_points"];
+ $sql = "INSERT INTO between_stops (fromLocation, toLocation, points, routes) VALUES('$from','$to','$points','$routes')";
$result = pg_query($conn, $sql);
if (!$result) {
echo("Error in SQL query: " . pg_last_error() ."<br>\n");
}
+ if ($reverse === "on") {
+ $points = implode(";",array_reverse(explode(";",$points)));
+$sql = "INSERT INTO between_stops ( toLocation, fromLocation, points, routes) VALUES('$from','$to','$points','$routes')";
+$result = pg_query($conn, $sql);
+ if (!$result) {
+ echo("Error in SQL query: " . pg_last_error() ."<br>\n");
+ }
+ }
flush();
-}
?>
--- a/busui/common.inc.php
+++ b/busui/common.inc.php
@@ -1,6 +1,7 @@
<?php
date_default_timezone_set('Australia/ACT');
$APIurl = "http://localhost:8765";
+error_reporting(E_ALL ^ E_NOTICE);
function isDebug()
{
--- a/maxious-canberra-transit-feed/02-tidytimepoints.rb
+++ b/maxious-canberra-transit-feed/02-tidytimepoints.rb
@@ -38,7 +38,7 @@
"Lathlain St Station - Platform 5" => "Lathlain St Bus Station - Platform 5",
"Lathlain St Station - Platform 6" => "Lathlain St Bus Station - Platform 6",
"Flemington Rd, Sandford St" => "Flemington Rd/Sandford St",
- "Erindale Centre / - Sternberg Crescent" => "Erindale Drive/Sternberg",
+ "Erindale Centre /Sternberg Crescent" => "Erindale Drive/Sternberg",
"Canberra Hospita" => "Canberra Hospital",
"Cohen Str Station - Platform 1" => "Cohen St Bus Station - Platform 1",
"Cohen Street Station" => "Cohen St Bus Station",
--- a/maxious-canberra-transit-feed/04-generateymlinclude.rb
+++ b/maxious-canberra-transit-feed/04-generateymlinclude.rb
@@ -1,10 +1,10 @@
#!/usr/bin/ruby
-require 'postgres'
require 'highline.rb'
include HighLine
require 'rubygems'
+require 'postgres'
require 'json'
require 'yaml'
require 'pp'
@@ -19,7 +19,7 @@
f2.puts header
f2.puts "stops:\n";
begin
- time_points = connbus.exec("SELECT * from timing_point")
+ time_points = connbus.exec("SELECT * from timing_point ORDER BY name")
rescue PGError => e
puts "Error reading from DB #{e}"
#conn.close() if conn
@@ -30,7 +30,22 @@
# 1 = lat*100000
# 2 = lng*100000
+ #pp time_point[0]
f2.puts " - { name: #{time_point[0]},stop_code: #{time_point[0]}, lat: #{Float(time_point[1])/10000000}, lng: #{Float(time_point[2])/10000000}}"
+ end
+ begin
+ stops = connbus.exec("SELECT * from stops")
+ rescue PGError => e
+ puts "Error reading from DB #{e}"
+ #conn.close() if conn
+ end
+ stops.each do |stop|
+ #pp stop
+ # 0 = geoPo
+ # 1 = lat*100000
+ # 2 = lng*100000
+ #pp time_point[0]
+ f2.puts " - { name: #{stop[0]},stop_code: #{stop[0]}, lat: #{Float(stop[1])/10000000}, lng: #{Float(stop[2])/10000000}}"
end
f2.puts "routes:\n";
end
--- /dev/null
+++ b/maxious-canberra-transit-feed/05-addbetweenpointstotimetables.rb
@@ -1,1 +1,50 @@
+require 'rubygems'
+require 'postgres'
+require 'pp'
+require 'yaml'
+class String
+ def escape_single_quotes
+ self.gsub(/'/, "''")
+ end
+end
+class Array
+ def to_yaml_style
+ :inline
+ end
+end
+Dir.chdir("output")
+connbus = PGconn.connect("localhost", 5432, '', '', "bus", "postgres", "snmc")
+
+Dir.glob("*.yml") { |file|
+ timetable = YAML::load_file(file)
+ if timetable
+ route_name = timetable["short_name"]
+ timetable["between_stops"] = {}
+ for i in 0..timetable["time_points"].length-2
+ begin
+ searchFrom = timetable["time_points"][i].escape_single_quotes.split("-")[0].strip
+ searchTo = timetable["time_points"][i+1].escape_single_quotes.split("-")[0].strip
+
+ between_points = connbus.exec("SELECT * from between_stops
+ WHERE fromlocation = '#{searchFrom}'
+ AND tolocation = '#{searchTo}' AND routes LIKE '%#{route_name};%'")
+ rescue PGError => e
+ puts "Error selecting matching between points from DB #{e}"
+ #conn.close() if conn
+ end
+ between_points.each do |between_point_row|
+ timetable["between_stops"][timetable["time_points"][i] + '-' +timetable["time_points"][i+1]] \
+ = between_point_row['points'].split(";");
+ end
+ end
+ #pp timetable["between_stops"]
+ File.open(file, "w") do |f|
+ f.write timetable.to_yaml
+ end
+
+ else
+ print "error, #{file} empty\n"
+ end
+}
+
--- a/maxious-canberra-transit-feed/05-generateymlinclude.rb
+++ /dev/null
@@ -1,53 +1,1 @@
-#!/usr/bin/ruby
-require 'postgres'
-require 'highline.rb'
-include HighLine
-
-require 'rubygems'
-require 'json'
-require 'yaml'
-require 'pp'
-# make - { name: Civic Interchange Platform 1,stop_code: civic_platform_1, lat: -35.2794347, lng: 149.130588}
-connbus = PGconn.connect("localhost", 5432, '', '', "bus", "postgres", "snmc")
-
-f = File.open('cbrtable.yml.in.in')
-header = f.readlines
-f.close
-
-File.open('cbrtable.yml.in', 'w') do |f2|
- f2.puts header
- f2.puts "stops:\n";
- begin
- time_points = connbus.exec("SELECT * from timing_point ORDER BY name")
- rescue PGError => e
- puts "Error reading from DB #{e}"
- #conn.close() if conn
- end
- time_points.each do |time_point|
- #pp time_point
- # 0 = name
-
- # 1 = lat*100000
- # 2 = lng*100000
- #pp time_point[0]
- f2.puts " - { name: #{time_point[0]},stop_code: #{time_point[0]}, lat: #{Float(time_point[1])/10000000}, lng: #{Float(time_point[2])/10000000}}"
- end
- begin
- stops = connbus.exec("SELECT * from stops")
- rescue PGError => e
- puts "Error reading from DB #{e}"
- #conn.close() if conn
- end
- stops.each do |stop|
- #pp stop
- # 0 = geoPo
- # 1 = lat*100000
- # 2 = lng*100000
- #pp time_point[0]
- f2.puts " - { name: #{stop[0]},stop_code: #{stop[0]}, lat: #{Float(stop[1])/10000000}, lng: #{Float(stop[2])/10000000}}"
- end
- f2.puts "routes:\n";
-end
-
-
--- a/maxious-canberra-transit-feed/900-intertown.yml
+++ b/maxious-canberra-transit-feed/900-intertown.yml
@@ -1,7 +1,9 @@
short_name: 900
long_name: Intertown
time_points: [ civic_platform_6, 3042, 4531, 4929, civic_platform_1, civic_platform_5 ]
-between_stops: [ ]
+between_stops: [
+civic_platform_6-3042: [ADFA]
+]
stop_times: [
[ 632a, 642a, 657a, 708a, 715a, 727a],
[ 702a, 712a, 727a, 738a, 745a, 757a],
--- a/maxious-canberra-transit-feed/Makefile
+++ b/maxious-canberra-transit-feed/Makefile
@@ -1,19 +1,21 @@
default: cbrfeed.zip
cbrfeed.zip: cbrtable.yml createfeed.py
+ sh 06-cleanupyaml.sh
./createfeed.py --input=cbrtable.yml --output=cbrfeed.zip
cbrtable.yml: cbrtable.yml.in indent-route.pl
cp cbrtable.yml.in cbrtable.yml
@$(foreach ROUTE_FILE, $(wildcard output/*), \
echo "Parsing $(ROUTE_FILE)"; \
- echo "TODO: replace friendly timing spot names with OSM node IDs or geohash in $(ROUTE_FILE)"; \
- echo "TODO: add inbetween stops in $(ROUTE_FILE)"; \
- ./indent-route.pl < $(ROUTE_FILE) >> cbrtable.yml;)
+ ./indent-route.pl < "$(ROUTE_FILE)" >> cbrtable.yml;)
cbrtable.yml.in: cbrtable.yml.in.in
- ruby 04-generateymlinclude.rb
+ ruby 01-extracttimes.rb
+ ruby 02-tidytimepoints.rb
+ ruby 04-generateymlinclude.rb
+ ruby 05-addbetweenpointstotimetables.rb
clean:
- rm -f cbrtable.yml cbrtable.yml.in cbrfeed.zip *~
+ rm -f cbrtable.yml cbrtable.yml.in cbrfeed.zip *~ output/*
--- a/maxious-canberra-transit-feed/README
+++ b/maxious-canberra-transit-feed/README
@@ -1,10 +1,9 @@
=== Introduction ===
This distribution contains everything required to build a basic google transit
-feed for Halifax Metro Transit, Nova Scotia, Canada. Note that it is woefully
-incomplete at the moment.
+feed for Canberra, Australia. Note that it is woefully incomplete at the moment.
-Requirements: GNU Make, Perl, Python 2.5.
+Requirements: GNU Make, Perl, Python 2.5, PHP, Ruby, libpq (postgres-devel package on Fedora), postgres,json gem for Ruby, libyaml and pyyaml for Python
=== Usage ===
@@ -21,7 +20,7 @@
Then just type "make" to build the feed. The output at the end is "feed.zip".
For fun, you can view this feed using the snazzy transit feed view application:
-$HOME/src/transitfeed-1.1.7/python/schedule_viewer.py --feed=hfxfeed.zip
+$HOME/src/transitfeed-1.1.7/python/schedule_viewer.py --feed=cbrfeed.zip
=== Copyright ===
@@ -29,7 +28,7 @@
License, please consider all software tools in distribution to be in the public
domain. Use them for what you will.
-I believe the Metro Transit route data is considered factual information
-which can not be copyrighted. Note, however, that Metro Transit and/or
-the city of Halifax may have claim over its own name and other trademarks.
+I believe the ACTION busses route data is considered factual information
+which can not be copyrighted. Note, however, that ACTION busses and/or
+the ACT Government may have claim over its own name and other trademarks.
--- a/maxious-canberra-transit-feed/add-between-times.pl
+++ /dev/null
@@ -1,104 +1,1 @@
-#!/usr/bin/perl
-use strict;
-
-sub parse_time {
- my ($time) = @_;
-
- my ($hour, $minute);
-
- if ($time =~ /a\Z/) {
- $time =~ m/([0-9]+)([0-9][0-9])a/;
- ($hour, $minute) = ($1, $2);
- } elsif ($time =~ /p\Z/) {
- $time =~ m/([0-9]+)([0-9][0-9])p/;
- ($hour, $minute) = ($1, $2);
- if ($hour < 12) {
- $hour += 12;
- }
- } elsif ($time =~ /x\Z/) {
- $time =~ m/([0-9]+)([0-9][0-9])x/;
- ($hour, $minute) = ($1, $2);
- if ($hour == 12) {
- $hour += 12;
- } else {
- $hour += 24;
- }
- } elsif ($time =~ /^\ *-\Z/) {
- ($hour, $minute) = (0, 0);
- # no stop at this time
- } else {
- print "Should not happen! Time ('$time') misformed.\n";
- exit;
- }
-
- return ($hour, $minute);
-}
-
-my $num_intervals = $ARGV[0] or die "No num intervals given!";
-my $interval = $ARGV[1] or die "No interval given!";
-
-my @times;
-
-$_ = <STDIN>;
-print $_;
-
-if ($_ !~ /^\#/) {
- my @timestrs;
- if ($_ =~ m/\[(.*)\]/) {
- my $inner = $1;
- @timestrs = split (/\,/, $inner);
-
- } else {
- @timestrs = split /\ /;
- }
-
- foreach (@timestrs) {
- my ($hour, $minute) = parse_time($_);
- push @times, [ $hour, $minute ];
- }
-}
-
-for (my $i=1; $i<($num_intervals+1); $i++) {
- my $first = 1;
- foreach (@times) {
- my $mytime = $_;
- my ($hour, $minute) = (@$mytime[0], @$mytime[1]);
- if ($hour > 0 || $minute > 0) {
- $minute += $interval * $i;
- if ($minute > 59) {
- $hour += int($minute / 60);
- $minute = $minute % 60;
- if ($minute < 10) {
- $minute = "0" . $minute;
- }
- }
- }
-
- sub print_time {
- my ($hour, $minute) = @_;
- if ($hour == 0 && $minute == 0) {
- print "-";
- } else {
- if ($hour < 12) {
- print "$hour$minute" . "a";
- } else {
- if ($hour > 12) {
- $hour -= 12;
- }
- print "$hour$minute" . "p";
- }
- }
- }
-
- if (!$first) {
- print " ";
- print_time($hour, $minute);
- } else {
- $first = 0;
- print_time($hour, $minute);
- }
- }
-print "\n";
-}
-
--- a/maxious-canberra-transit-feed/cbrtable.yml
+++ b/maxious-canberra-transit-feed/cbrtable.yml
@@ -238,20777 +238,3401 @@
- { name: Woden Interchange - Platform 9,stop_code: Woden Interchange - Platform 9, lat: -35.3442083, lng: 149.0877771}
- { name: Woodcock/Clare Dennis,stop_code: Woodcock/Clare Dennis, lat: -35.4422566, lng: 149.0854375}
- { name: Yarralumla Shops,stop_code: Yarralumla Shops, lat: -35.30725, lng: 149.0972}
+ - { name: Wjz2mTK,stop_code: Wjz2mTK, lat: -35.3815863, lng: 149.0936139}
+ - { name: Wjz6kCT,stop_code: Wjz6kCT, lat: -35.217402, lng: 149.0910262}
+ - { name: Wjz6keB,stop_code: Wjz6keB, lat: -35.2175697, lng: 149.0866478}
+ - { name: Wjr-TRM,stop_code: Wjr-TRM, lat: -35.2021703, lng: 149.0498418}
+ - { name: Wjr_MMi,stop_code: Wjr_MMi, lat: -35.200018, lng: 149.0491234}
+ - { name: Wjr_Mxy,stop_code: Wjr_Mxy, lat: -35.1992913, lng: 149.0468658}
+ - { name: Wjr-IeY,stop_code: Wjr-IeY, lat: -35.2176259, lng: 149.032238}
+ - { name: Wjr-J8t,stop_code: Wjr-J8t, lat: -35.2161747, lng: 149.0315719}
+ - { name: Wjr-InZ,stop_code: Wjr-InZ, lat: -35.2169003, lng: 149.0335258}
+ - { name: Wjr-Jm9,stop_code: Wjr-Jm9, lat: -35.2124379, lng: 149.0325045}
+ - { name: Wjr-J44,stop_code: Wjr-J44, lat: -35.2135626, lng: 149.0296181}
+ - { name: Wjr-BB3,stop_code: Wjr-BB3, lat: -35.2129096, lng: 149.0241561}
+ - { name: Wjr-Alc,stop_code: Wjr-Alc, lat: -35.2183514, lng: 149.021625}
+ - { name: Wjr-AY4,stop_code: Wjr-AY4, lat: -35.2190044, lng: 149.0282415}
+ - { name: Wjr-I4P,stop_code: Wjr-I4P, lat: -35.2191133, lng: 149.0306838}
+ - { name: Wjr-IcO,stop_code: Wjr-IcO, lat: -35.2191858, lng: 149.0319716}
+ - { name: Wjr-IqS,stop_code: Wjr-IqS, lat: -35.2202741, lng: 149.034858}
+ - { name: Wjr-IGJ,stop_code: Wjr-IGJ, lat: -35.2203467, lng: 149.0373003}
+ - { name: Wjr-IMR,stop_code: Wjr-IMR, lat: -35.2216889, lng: 149.0389433}
+ - { name: Wjr-H-a,stop_code: Wjr-H-a, lat: -35.2232851, lng: 149.039343}
+ - { name: Wjr-Q4G,stop_code: Wjr-Q4G, lat: -35.2192221, lng: 149.0415189}
+ - { name: Wjz6zth,stop_code: Wjz6zth, lat: -35.2241129, lng: 149.1109391}
+ - { name: Wjz6zon,stop_code: Wjz6zon, lat: -35.2269858, lng: 149.1109391}
+ - { name: Wjz6ytu,stop_code: Wjz6ytu, lat: -35.2291622, lng: 149.1110812}
+ - { name: Wjz6yir,stop_code: Wjz6yir, lat: -35.2314837, lng: 149.1098378}
+ - { name: Wjz5mpm,stop_code: Wjz5mpm, lat: -35.2538531, lng: 149.0889493}
+ - { name: Wjz5mxf,stop_code: Wjz5mxf, lat: -35.2538241, lng: 149.0902637}
+ - { name: Wjzd0oD,stop_code: Wjzd0oD, lat: -35.2874406, lng: 149.1552177}
+ - { name: Wjr-MNh,stop_code: Wjr-MNh, lat: -35.2433401, lng: 149.0492618}
+ - { name: Wjr-Mqd,stop_code: Wjr-Mqd, lat: -35.2422956, lng: 149.0448568}
+ - { name: Wjr-N9a,stop_code: Wjr-N9a, lat: -35.2377693, lng: 149.0421213}
+ - { name: Wjr-EYe,stop_code: Wjr-EYe, lat: -35.2408449, lng: 149.0394925}
+ - { name: Wjr-EA_,stop_code: Wjr-EA_, lat: -35.2407288, lng: 149.0362953}
+ - { name: Wjr-EuB,stop_code: Wjr-EuB, lat: -35.2395683, lng: 149.034448}
+ - { name: Wjr-Fw4,stop_code: Wjr-Fw4, lat: -35.2382916, lng: 149.035194}
+ - { name: Wjr-VdI,stop_code: Wjr-VdI, lat: -35.2348097, lng: 149.0539156}
+ - { name: Wjr-Vnf,stop_code: Wjr-Vnf, lat: -35.2331848, lng: 149.054555}
+ - { name: Wjr-Ws2,stop_code: Wjr-Ws2, lat: -35.230167, lng: 149.0557628}
+ - { name: Wjr-PWf,stop_code: Wjr-PWf, lat: -35.225611, lng: 149.0504341}
+ - { name: Wjr-PyX,stop_code: Wjr-PyX, lat: -35.2259882, lng: 149.0472724}
+ - { name: WjrZKZn,stop_code: WjrZKZn, lat: -35.