2015-07-15 16:41:33 +03:00
< ? php
include 'data.php' ;
2016-02-10 14:09:30 +02:00
include 'libher/libher.php' ;
2015-07-15 16:41:33 +03:00
function getStopsOfRoute ( $id ){
global $routes ;
foreach ( $routes as $route ){
if ( $route [ 'id' ] == $id ){
return $route [ 'stops' ];
}
}
}
function getRoutesOfLine ( $line ){
global $routes ;
$tmp = array ();
foreach ( $routes as $route ){
if ( $route [ 'line' ] == $line ){
array_push ( $tmp , $route );
}
}
return $tmp ;
}
function getRoutesByStop ( $stopId ){
global $routes ;
$tmp = array ();
foreach ( $routes as $route ){
foreach ( $route [ 'stops' ] as $stop ){
if ( $stop == $stopId ){
array_push ( $tmp , $route );
}
}
}
return $tmp ;
}
2015-07-16 13:46:50 +03:00
function isValidRoute ( $id ){
global $routes ;
foreach ( $routes as $route ){
if ( $route [ 'id' ] == $id ){
return true ;
}
}
return false ;
}
function isValidLine ( $line ){
global $routes ;
foreach ( $routes as $route ){
if ( $route [ 'line' ] == $line ){
return true ;
}
}
return false ;
}
2015-07-16 20:13:06 +03:00
function isValidStop ( $stp ){
global $stops ;
foreach ( $stops as $stop ){
if ( $stop [ 'id' ] == $stp ){
return true ;
}
}
return false ;
}
2015-07-16 13:46:50 +03:00
function getRouteInfo ( $id ){
global $routes ;
foreach ( $routes as $route ){
if ( $route [ 'id' ] == $id ){
return $route ;
}
}
return false ;
}
function getStopInfo ( $id ){
global $stops ;
foreach ( $stops as $stop ){
if ( $stop [ 'id' ] == $id ){
return $stop ;
}
}
return false ;
}
2015-07-17 15:14:27 +03:00
function getLabelOfDir ( $dir ){
if ( $dir == 'go' ){
return '<span class="label label-info">Go</span>' ;
} else if ( $dir == 'come' ){
return '<span class="label label-primary">Come</span>' ;
} else {
return false ;
}
}
2015-07-16 13:46:50 +03:00
2016-02-18 08:56:43 +02:00
function getLines (){
global $routes ;
$lines = array ();
foreach ( $routes as $r ){
$found = false ;
foreach ( $lines as $l ){
if ( $r [ " line " ] == $l ){
$found = true ;
}
}
if ( ! $found ){
2016-02-20 15:39:53 +02:00
array_push ( $lines , $r [ " line " ]);
2016-02-18 08:56:43 +02:00
}
}
return $lines ;
}
2016-02-20 22:02:18 +02:00
function getPositionOfRoute ( $rt , $direction ){
2016-02-20 19:52:05 +02:00
global $buspositions ;
2016-02-20 15:19:16 +02:00
$locations = array ();
2016-02-20 19:52:05 +02:00
foreach ( $buspositions as $bus ){
2016-02-20 22:02:18 +02:00
if ( $bus [ " routeid " ] == $rt && $bus [ " direction " ] == $direction ){
2016-02-20 15:19:16 +02:00
array_push ( $locations , array ( $bus [ " lat " ], $bus [ " lon " ]));
}
}
return $locations ;
}
2016-02-20 22:02:18 +02:00
function getPositionOfLine ( $line , $direction ){
2016-02-20 15:19:16 +02:00
$locations = array ();
foreach ( getRoutesOfLine ( $line ) as $route ){
2016-02-20 22:02:18 +02:00
foreach ( getPositionOfRoute ( $route [ " id " ], $direction ) as $pos ){
2016-02-20 15:19:16 +02:00
array_push ( $locations , $pos );
}
}
return $locations ;
}
2015-07-15 16:41:33 +03:00
?>