diff --git a/ShowStop.php b/ShowStop.php index f3a144d..2c076a6 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?'; diff --git a/modules/libdata.php b/modules/libdata.php index 584eede..ba970b3 100644 --- a/modules/libdata.php +++ b/modules/libdata.php @@ -22,17 +22,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){ @@ -131,4 +131,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; +} + ?> 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});