Toll Distance Calculation
Posted: Fri May 05, 2023 5:44 am
Hi there,
i have a problem to calculate the toll distance per country. I get toll events in france from type "PASS" in the xserver response. These events don't have a relatedEventIndex or a "EXIT" event. So i don't have the chance to calculate the distance.
Here is my code snippet in PHP from which i use:
With this snippet i get 88.6km toll distance in france. But in real it must be around 152km. Can anybody help me to get a functional calculation based on the attached response?
i have a problem to calculate the toll distance per country. I get toll events in france from type "PASS" in the xserver response. These events don't have a relatedEventIndex or a "EXIT" event. So i don't have the chance to calculate the distance.
Here is my code snippet in PHP from which i use:
Code: Select all
if ( $event[ '$type' ] === 'TollEvent' )
{
if ( $event[ 'accessType' ] === 'ENTER' )
{
$tollDistance = $response[ 'events' ][ $event[ 'relatedEventIndex' ] ][ 'distanceFromStart' ] - $event[ 'distanceFromStart' ];
if ( isset( $tollDistancesByCountry[ $currentCountry ] ) )
{
$tollDistancesByCountry[ $currentCountry ][ 'tollDistance' ] += $tollDistance;
}
$totalTollDistance += $tollDistance;
}
}