From 4ffef02bb94476afa931f5feb5c8f6889f22ab4f Mon Sep 17 00:00:00 2001 From: George Kaklamanos Date: Sun, 21 Feb 2016 20:53:00 +0200 Subject: [PATCH 1/4] Adapted getRoutesByStop(). --- modules/libdata.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/libdata.php b/modules/libdata.php index 399759e..35a2a68 100644 --- a/modules/libdata.php +++ b/modules/libdata.php @@ -21,17 +21,17 @@ function getRoutesOfLine($line){ return $tmp; } -function getRoutesByStop($stopId){ +function getRoutesByStop($stopId,$direction){ global $routes; - $tmp = array(); + $res = array(); foreach ($routes as $route){ - foreach ($route['stops'] as $stop){ + foreach ($route['stops'][$direction] as $stop){ if ($stop == $stopId){ - array_push($tmp, $route); + array_push($res, $route["id"]); } } } - return $tmp; + return $res; } function isValidRoute($id){ From 87932b880189fd37e8e0b172bdc3c902cff7daf5 Mon Sep 17 00:00:00 2001 From: George Kaklamanos Date: Sun, 21 Feb 2016 20:53:37 +0200 Subject: [PATCH 2/4] Get position of buses approaching a stop. --- modules/libdata.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/libdata.php b/modules/libdata.php index 35a2a68..ea7114c 100644 --- a/modules/libdata.php +++ b/modules/libdata.php @@ -133,4 +133,14 @@ function getPositionOfLine($line,$direction){ return $locations; } +function getPositionOfApproachingStop($stop,$direction){ + $res = array(); + foreach(getRoutesByStop($stop,$direction) as $route){ + foreach(getPositionOfRoute($route,$direction) as $bus){ + array_push($res, $bus); + } + } + return $res; +} + ?> From 2f96304eed8332ae20ffe87ae416493ac4e51088 Mon Sep 17 00:00:00 2001 From: George Kaklamanos Date: Sun, 21 Feb 2016 21:24:27 +0200 Subject: [PATCH 3/4] Support new dot group: blue. --- modules/map.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/map.php b/modules/map.php index 46281fa..b1424ff 100644 --- a/modules/map.php +++ b/modules/map.php @@ -9,7 +9,7 @@ 0 || count($coordsGreen)>0){ ?>
@@ -65,6 +65,30 @@ echo '['. $coordsGreen[$i][1] . ',' . $coordsGreen[$i][0] . ']];'; features.push(feat); } 0){ +echo "var coordinatesBlue = ["; +for ($i=0; $i + var styleBlue = new ol.style.Style({ + image: new ol.style.Circle({ + fill: new ol.style.Fill({color: '#0000FF'}), + stroke: new ol.style.Stroke({color: '#000000'}), + radius: 5 + }) + }); + for(var i=0; i var vectorSource = new ol.source.Vector({features:features}); From 1ccd9bcbdc892ae9619337e54e8725965be878e6 Mon Sep 17 00:00:00 2001 From: George Kaklamanos Date: Sun, 21 Feb 2016 21:25:15 +0200 Subject: [PATCH 4/4] Show approaching buses on the map. --- ShowStop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShowStop.php b/ShowStop.php index ef440e5..86e7d1c 100644 --- a/ShowStop.php +++ b/ShowStop.php @@ -29,7 +29,7 @@ if (isValidStop($_GET["stop"])){ echo '
'; PrintRoutes($_GET["stop"]); echo '
'; - ShowMap(array(array($stop['lat'],$stop['lon'])),[]); + ShowMap(getPositionOfApproachingStop($stop['id'],'go'),getPositionOfApproachingStop($stop['id'],'come'),array(array($stop['lat'],$stop['lon']))); echo '
'; } else { echo 'No such stop. Go back?';