Example #1
0
function getFlightInfo(&$track, &$geoServerStatus)
{
    $id = $track['flightId'];
    $query = "SELECT * FROM flightInfo WHERE id='{$id}'";
    $result = mysql_query($query) or die('Query error: ' . mysql_error());
    if (mysql_num_rows($result) == 1) {
        $flightInfo = mysql_fetch_object($result);
    } else {
        $query = "INSERT INTO flightInfo (id) VALUES ('{$id}')";
        $result = mysql_query($query) or die('Query error: ' . mysql_error());
        $query = "SELECT * FROM flightInfo WHERE id='{$id}'";
        $result = mysql_query($query) or die('Query error: ' . mysql_error());
        $flightInfo = mysql_fetch_object($result);
    }
    // Retrieve take-off information
    if ($flightInfo->startLocation == NULL) {
        $track['start']['location'] = getNearbyPlace($track['start']['lat'], $track['start']['lon'], $geoServerStatus);
        if ($track['start']['location']['place'] != '-') {
            $query = "UPDATE flightInfo " . "SET startLocation = '" . format_mysql($track['start']['location']['place']) . "', " . "startCountry = '" . format_mysql($track['start']['location']['country']) . "' " . "WHERE id='{$id}'";
            $result = mysql_query($query) or die('Query error: ' . mysql_error());
        }
    } else {
        $track['start']['location']['place'] = $flightInfo->startLocation;
        $track['start']['location']['country'] = $flightInfo->startCountry;
    }
    // Retrieve position / landing information
    if ($flightInfo->endLocation == NULL || $track['live']) {
        $track['end']['location'] = getNearbyPlace($track['end']['lat'], $track['end']['lon'], $geoServerStatus);
        if ($track['end']['location']['place'] != '-' && !$track['live']) {
            $query = "UPDATE flightInfo " . "SET endLocation = '" . format_mysql($track['end']['location']['place']) . "', " . "endCountry = '" . format_mysql($track['end']['location']['country']) . "' " . "WHERE id='{$id}'";
            $result = mysql_query($query) or die('Query error: ' . mysql_error());
        }
    } else {
        $track['end']['location']['place'] = $flightInfo->endLocation;
        $track['end']['location']['country'] = $flightInfo->endCountry;
    }
    // Retrieve timezone information
    if ($flightInfo->timezone == NULL) {
        $flightInfo->timezone = getTimeZone($track['start']['lat'], $track['start']['lon'], $geoServerStatus);
        if ($flightInfo->timezone != NULL) {
            $query = "UPDATE flightInfo " . "SET timezone = '{$flightInfo->timezone}' " . "WHERE id='{$id}'";
            $result = mysql_query($query) or die('Query error: ' . mysql_error());
        }
    }
    return $flightInfo;
}
Example #2
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}";