Merge branch 'master' of https://code.tolabaki.gr/gkaklas/databus
This commit is contained in:
commit
3e049cd5bb
3 changed files with 41 additions and 7 deletions
|
@ -29,7 +29,7 @@ if (isValidStop($_GET["stop"])){
|
||||||
echo '<div id="routes" class="tab-pane fade in active" role="tabpanel">';
|
echo '<div id="routes" class="tab-pane fade in active" role="tabpanel">';
|
||||||
PrintRoutes($_GET["stop"]);
|
PrintRoutes($_GET["stop"]);
|
||||||
echo '</div><div id="map" class="tab-pane fade" role="tabpanel">';
|
echo '</div><div id="map" class="tab-pane fade" role="tabpanel">';
|
||||||
ShowMap(array(array($stop['lat'],$stop['lon'])),[]);
|
ShowMap(getPositionOfApproachingStop($stop['id'],'go'),getPositionOfApproachingStop($stop['id'],'come'),array(array($stop['lat'],$stop['lon'])));
|
||||||
echo '</div></div>';
|
echo '</div></div>';
|
||||||
} else {
|
} else {
|
||||||
echo '<span style="display:inline-block" class="alert alert-danger" role="alert">No such stop. <a href="javascript:history.back()">Go back?</a></span>';
|
echo '<span style="display:inline-block" class="alert alert-danger" role="alert">No such stop. <a href="javascript:history.back()">Go back?</a></span>';
|
||||||
|
|
|
@ -22,17 +22,17 @@ function getRoutesOfLine($line){
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRoutesByStop($stopId){
|
function getRoutesByStop($stopId,$direction){
|
||||||
global $routes;
|
global $routes;
|
||||||
$tmp = array();
|
$res = array();
|
||||||
foreach ($routes as $route){
|
foreach ($routes as $route){
|
||||||
foreach ($route['stops'] as $stop){
|
foreach ($route['stops'][$direction] as $stop){
|
||||||
if ($stop == $stopId){
|
if ($stop == $stopId){
|
||||||
array_push($tmp, $route);
|
array_push($res, $route["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $tmp;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidRoute($id){
|
function isValidRoute($id){
|
||||||
|
@ -131,4 +131,14 @@ function getPositionOfLine($line,$direction){
|
||||||
return $locations;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
function ShowMap($coordsRed,$coordsGreen){
|
function ShowMap($coordsRed,$coordsGreen,$coordsBlue){
|
||||||
if(count($coordsRed)>0 || count($coordsGreen)>0){
|
if(count($coordsRed)>0 || count($coordsGreen)>0){
|
||||||
?>
|
?>
|
||||||
<div id="mymap"></div>
|
<div id="mymap"></div>
|
||||||
|
@ -65,6 +65,30 @@ echo '['. $coordsGreen[$i][1] . ',' . $coordsGreen[$i][0] . ']];';
|
||||||
features.push(feat);
|
features.push(feat);
|
||||||
}
|
}
|
||||||
<?php
|
<?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});
|
var vectorSource = new ol.source.Vector({features:features});
|
||||||
|
|
Reference in a new issue