Beispiel #1
0
     $zoom = 11;
 } else {
     $zoom = $_GET['zoom'];
 }
 $link = mysql_connect(dbHost, dbUser, dbPassword) or die('Could not connect: ' . mysql_error());
 mysql_select_db(dbName) or die('Database does not exist');
 // Map size
 $w = $h = 180;
 $query = sprintf("SELECT latitude, longitude, elevation, time FROM pilot, flight, point " . "WHERE pseudo = '%s' AND " . "pilotId = pilot.id AND " . "flightId = flight.id " . "ORDER BY point.time DESC " . "LIMIT 0,1", format_mysql($_GET['id']));
 $result = mysql_query($query) or die('Query error: ' . mysql_error());
 if (mysql_num_rows($result) == 1) {
     $position = mysql_fetch_object($result);
     // Center psotion
     $lat = isset($_GET['lat']) ? floatval($_GET['lat']) : $position->latitude;
     $lon = isset($_GET['lon']) ? floatval($_GET['lon']) : $position->longitude;
     $img = sprintf("Date: {$position->time}<br/>\n" . "Lieu: " . getNearbyPlace($position->latitude, $position->longitude) . " [" . $position->latitude . " - " . $position->longitude . "]<br/>\n" . "h: " . $position->elevation . "m (" . max(0, $position->elevation - GetElevGnd($position->latitude, $position->longitude)) . "m/sol)<br/>\n" . "<img src='http://maps.google.com/staticmap?zoom=%d&size={$w}x{$h}&" . "center={$lat},{$lon}&" . "maptype=mobile&markers={$position->latitude},{$position->longitude},smallgreen&" . "key=ABQIAAAAJPvmQMZVrrV3inIwT2t4RBQf-JSUIEMNUNF63gcoYgskNGvaZRQmUvzGcFUdj4nlylxP8SK4sRKYsg'></img>\n", $zoom);
     $zoomIn = $zoomOut = $up = $down = $left = $right = "<a href='http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id'];
     $zoomIn .= "&zoom=" . ($zoom + 1) . "&lat={$lat}&lon={$lon}'>+</a>\n";
     $zoomOut .= "&zoom=" . ($zoom - 1) . "&lat={$lat}&lon={$lon}'>-</a>\n";
     $projection = new Mercator($zoom, 256);
     $latUp = $latDown = $projection->Y($lat);
     $lonLeft = $lonRight = $projection->X($lon);
     $latUp = $projection->Lat($latUp - $h / 2);
     $latDown = $projection->Lat($latDown + $h / 2);
     $lonLeft = $projection->Lon($lonLeft - $w / 2);
     $lonRight = $projection->Lon($lonRight + $w / 2);
     $up .= "&zoom={$zoom}&lat={$latUp}&lon={$lon}'>^</a>\n";
     $down .= "&zoom={$zoom}&lat={$latDown}&lon={$lon}'>V</a>\n";
     $left .= "&zoom={$zoom}&lat={$lat}&lon={$lonLeft}'>&lt;</a>\n";
     $right .= "&zoom={$zoom}&lat={$lat}&lon={$lonRight}'>&gt;</a>\n";
     echo "{$img}<br/>{$zoomIn} | {$zoomOut} | {$up} | {$down} | {$left} | {$right}";
Beispiel #2
0
function buildJsonTrack($track)
{
    if (isset($track['kmlUrl'])) {
        return ['kmlUrl' => $track['kmlUrl']];
    }
    if (isset($track['error'])) {
        return ['error' => $track['error']];
    }
    $track['nbPt'] = $nbPts = count($track['lat']);
    // Generate the time in second
    for ($i = 0; $i < count($track['time']['hour']); $i++) {
        $track['timeSec'][$i] = $track['time']['hour'][$i] * 3600 + $track['time']['min'][$i] * 60 + $track['time']['sec'][$i];
    }
    // Generate CHART_NBLBL labels
    for ($i = 0, $idx = 0, $step = ($nbPts - 1) / (CHART_NBLBL - 1); $i < CHART_NBLBL; $i++, $idx += $step) {
        $jsTrack['time']['label'][$i] = sprintf("%02dh%02d", $track['time']['hour'][$idx], $track['time']['min'][$idx]);
    }
    // Change the number of points to CHART_NBPTS
    for ($i = 0, $idx = 0, $step = ($nbPts - 1) / (CHART_NBPTS - 1); $i < CHART_NBPTS; $i++, $idx += $step) {
        $jsTrack['elev'][$i] = $track['elev'][$idx];
        $jsTrack['time']['hour'][$i] = sprintf("%02d", $track['time']['hour'][$idx]);
        $jsTrack['time']['min'][$i] = sprintf("%02d", $track['time']['min'][$idx]);
        $jsTrack['time']['sec'][$i] = sprintf("%02d", $track['time']['sec'][$idx]);
    }
    $jsTrack['lat'] = array();
    foreach ($track['lat'] as $lat) {
        $jsTrack['lat'][] = round($lat, 5);
    }
    $jsTrack['lon'] = array();
    foreach ($track['lon'] as $lon) {
        $jsTrack['lon'][] = round($lon, 5);
    }
    $jsTrack['elevGnd'] = GetElevGnd($track, CHART_NBPTS);
    $jsTrack['speed'] = GetSpeed($track, CHART_NBPTS);
    $jsTrack['vario'] = GetVario($track, CHART_NBPTS);
    $jsTrack['nbTrackPt'] = $track['nbPt'];
    $jsTrack['nbChartPt'] = CHART_NBPTS;
    $jsTrack['nbChartLbl'] = CHART_NBLBL;
    $jsTrack['date'] = $track['date'];
    $jsTrack['pilot'] = $track['pilot'];
    return $jsTrack;
}
Beispiel #3
0
function MakeTrack($url)
{
    $file = implode('', file($url));
    $track['date'] = array('day' => 0, 'month' => 0, 'year' => 0);
    $track['pilot'] = '';
    $nbPts = ParseIgc($file, $track);
    if ($nbPts < 5) {
        $nbPts = ParseGpx($file, $track);
    }
    if ($nbPts < 5) {
        $nbPts = ParseTrk($file, $track);
    }
    if ($nbPts < 5) {
        $nbPts = ParseNmea($file, $track);
    }
    if ($nbPts < 5) {
        $nbPts = ParseOzi($file, $track);
    }
    if ($nbPts < 5) {
        if (IsKml($file)) {
            $jsTrack['kmlUrl'] = $url;
        } else {
            $jsTrack['error'] = 'Unsupported track format!';
        }
    } else {
        // Generate the time in second
        for ($i = 0; $i < count($track['time']['hour']); $i++) {
            $track['timeSec'][$i] = $track['time']['hour'][$i] * 3600 + $track['time']['min'][$i] * 60 + $track['time']['sec'][$i];
        }
        // Generate CHART_NBLBL labels
        for ($i = 0, $idx = 0, $step = ($nbPts - 1) / (CHART_NBLBL - 1); $i < CHART_NBLBL; $i++, $idx += $step) {
            $jsTrack['time']['label'][$i] = $track['time']['hour'][$idx] . "h" . $track['time']['min'][$idx];
        }
        // Change the number of points to CHART_NBPTS
        for ($i = 0, $idx = 0, $step = ($nbPts - 1) / (CHART_NBPTS - 1); $i < CHART_NBPTS; $i++, $idx += $step) {
            $jsTrack['elev'][$i] = $track['elev'][$idx];
            $jsTrack['time']['hour'][$i] = $track['time']['hour'][$idx];
            $jsTrack['time']['min'][$i] = $track['time']['min'][$idx];
            $jsTrack['time']['sec'][$i] = $track['time']['sec'][$idx];
        }
        $jsTrack['lat'] = $track['lat'];
        $jsTrack['lon'] = $track['lon'];
        $jsTrack['elevGnd'] = GetElevGnd($track, CHART_NBPTS);
        $jsTrack['speed'] = GetSpeed($track, CHART_NBPTS);
        $jsTrack['vario'] = GetVario($track, CHART_NBPTS);
        $jsTrack['nbTrackPt'] = $track['nbPt'];
        $jsTrack['nbChartPt'] = CHART_NBPTS;
        $jsTrack['nbChartLbl'] = CHART_NBLBL;
        $jsTrack['date'] = $track['date'];
        $jsTrack['pilot'] = $track['pilot'];
    }
    //print_r($jsTrack);
    $data = json::encode($jsTrack);
    //print_r($data );
    // if (!isset($jsTrack['error']) && !isset($jsTrack['kmlUrl'])) {
    //    $cache->set($data, $url);
    // }
    return $data;
}