This commit is contained in:
George Kaklamanos 2016-02-21 21:27:23 +02:00
commit 3e049cd5bb
3 changed files with 41 additions and 7 deletions

View file

@ -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;
}
?>

View file

@ -9,7 +9,7 @@
</style>
<?php
function ShowMap($coordsRed,$coordsGreen){
function ShowMap($coordsRed,$coordsGreen,$coordsBlue){
if(count($coordsRed)>0 || count($coordsGreen)>0){
?>
<div id="mymap"></div>
@ -65,6 +65,30 @@ echo '['. $coordsGreen[$i][1] . ',' . $coordsGreen[$i][0] . ']];';
features.push(feat);
}
<?php
}
if(count($coordsBlue)>0){
echo "var coordinatesBlue = [";
for ($i=0; $i<count($coordsBlue)-1;$i++){
$loc = $coordsBlue[$i];
echo '['. $loc[1] . ',' . $loc[0] . '],';
}
echo '['. $coordsBlue[$i][1] . ',' . $coordsBlue[$i][0] . ']];';
?>
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<coordinatesBlue.length; i++){
var feat = new ol.Feature({
geometry: new ol.geom.Point(new ol.proj.fromLonLat([coordinatesBlue[i][0],coordinatesBlue[i][1]]))
});
feat.setStyle(styleBlue);
features.push(feat);
}
<?php
}
?>
var vectorSource = new ol.source.Vector({features:features});