Exemplo n.º 1
0
        return $bound;
    }
}
# return an array of coordinates in $file
function parse_igc_coords($file)
{
    $result = array();
    while (!feof($file)) {
        $line = fgets($file, 128);
        if (!preg_match('/\\AB\\d{6}(\\d{2})(\\d{5})([NS])(\\d{3})(\\d{5})([EW])[AV]\\d{10}\\d*\\r\\n\\z/', $line, $matches)) {
            continue;
        }
        $lat = M_PI * ($matches[1] + $matches[2] / 60000.0) / 180.0;
        if ($matches[3] == 'S') {
            $lat *= -1;
        }
        $lon = M_PI * ($matches[4] + $matches[5] / 60000.0) / 180.0;
        if ($matches[6] == 'W') {
            $lon *= -1;
        }
        array_push($result, array($lat, $lon));
    }
    return $result;
}
$file = fopen('php://stdin', 'r');
$coords = parse_igc_coords($file);
$track = new Track($coords);
$bound = 0.0;
printf("Max-distance-from-take-off: %s km\n", $track->max_distance_from_take_off($bound));
printf("Open-distance: %s km\n", $track->open_distance($bound));