Ejemplo n.º 1
0
 function getMapFromServer($num = 0)
 {
     global $moduleRelPath, $mapServerActive;
     if (!$mapServerActive) {
         return;
     }
     require_once dirname(__FILE__) . "/CL_map.php";
     $filename = $this->getIGCFilename(1);
     $lines = @file($filename);
     if (!$lines) {
         return;
     }
     $i = 0;
     $min_lat = 1000;
     $max_lat = -1000;
     $min_lon = 1000;
     $max_lon = -1000;
     foreach ($lines as $line) {
         $line = trim($line);
         if (strlen($line) == 0) {
             continue;
         }
         if ($line[0] == 'B') {
             $thisPoint = new gpsPoint($line, $this->timezone);
             if ($thisPoint->lat > $max_lat) {
                 $max_lat = $thisPoint->lat;
             }
             if ($thisPoint->lat < $min_lat) {
                 $min_lat = $thisPoint->lat;
             }
             if ($thisPoint->lon > $max_lon) {
                 $max_lon = $thisPoint->lon;
             }
             if ($thisPoint->lon < $min_lon) {
                 $min_lon = $thisPoint->lon;
             }
             $i++;
         }
     }
     if ($i == 0) {
         return;
     }
     // no B records found
     $lat_diff = $max_lat - $min_lat;
     $lon_diff = $max_lon - $min_lon;
     DEBUG("MAP", 1, "MAP  min_lat: {$min_lat}, min_lon: {$min_lon}, max_lat: {$max_lat}, max_lon: {$max_lon} <BR>");
     if ($lat_diff > 20 || $lon_diff > 20) {
         return;
     }
     // too much
     list($MAP_LEFT, $MAP_TOP, $UTMzone, $UTMlatZone) = utm(-$max_lon, $max_lat);
     list($MAP_RIGHT, $MAP_BOTTOM, $UTMzone2, $UTMlatZone2) = utm(-$min_lon, $min_lat);
     $totalWidth1 = calc_distance($min_lat, $min_lon, $min_lat, $max_lon);
     $totalWidth2 = calc_distance($max_lat, $min_lon, $max_lat, $max_lon);
     $totalWidth = max($totalWidth1, $totalWidth2);
     $totalWidth_initial = $totalWidth;
     $totalHeight = $MAP_TOP - $MAP_BOTTOM;
     DEBUG("MAP", 1, "MAP (right, left) :" . $MAP_RIGHT . " [" . $UTMzone2 . "] ," . $MAP_LEFT . "[" . $UTMzone . "]<BR>");
     DEBUG("MAP", 1, "MAP (top, bottom) :" . $MAP_TOP . " ," . $MAP_BOTTOM . "<BR>");
     DEBUG("MAP", 1, "MAP (witdh,height) :" . $totalWidth . "," . $totalHeight . "<BR>");
     if ($totalWidth > $totalHeight) {
         // Landscape  style
         DEBUG("MAP", 1, "Landscape style <BR>");
         DEBUG("MAP", 1, "totalWidth: {$totalWidth}, totalHeight: {$totalHeight}, totalHeight/totalWidth: " . $totalHeight / $totalWidth . "<br>");
         if ($totalHeight / $totalWidth < 3 / 4) {
             $totalHeight = 3 / 4 * $totalWidth;
         }
     } else {
         // portait style
         DEBUG("MAP", 1, "Portait style <BR>");
         DEBUG("MAP", 1, "totalWidth: {$totalWidth}, totalHeight: {$totalHeight}, totalWidth/totalHeight: " . $totalWidth / $totalHeight . "<br>");
         if ($totalWidth / $totalHeight < 3 / 4) {
             $totalWidth = 3 / 4 * $totalHeight;
         }
     }
     $marginHor = 2000 + floor($totalWidth / 20000) * 1000 + ($totalWidth - $totalWidth_initial) / 2;
     //in meters
     $marginVert = 2000 + floor($totalHeight / 20000) * 1000 + ($totalHeight - ($MAP_TOP - $MAP_BOTTOM)) / 2;
     //in meters
     if ($marginHor > $marginVert) {
         // landscape style ...
         if ($marginVert / $marginHor < 3 / 4) {
             $marginVert = 3 / 4 * $marginHor;
         }
     } else {
         // portait style
         if ($marginHor / $marginVert < 3 / 4) {
             $marginHor = 3 / 4 * $marginVert;
         }
     }
     DEBUG("MAP", 1, "marginHor: {$marginHor}, marginVert:{$marginVert} <br>");
     $flMap = new flightMap($UTMzone, $UTMlatZone, $MAP_TOP + $marginVert, $MAP_LEFT - $marginHor, $UTMzone2, $UTMlatZone2, $MAP_BOTTOM - $marginVert, $MAP_RIGHT + $marginHor, 600, 800, $this->getIGCFilename(1), $this->getMapFilename(0), $this->is3D());
     DEBUG("MAP", 1, "MAP Required m/pixel = " . $flMap->metersPerPixel . "<br>");
     $flMap->drawFlightMap();
 }
Ejemplo n.º 2
0
            // portait style
            DEBUG("MAP", 1, "Portait style <BR>");
            DEBUG("MAP", 1, "totalWidth: {$totalWidth}, totalHeight: {$totalHeight}, totalWidth/totalHeight: " . $totalWidth / $totalHeight . "<br>");
            if ($totalWidth / $totalHeight < 3 / 4) {
                $totalWidth = 3 / 4 * $totalHeight;
            }
        }
        $marginHor = 2000 + floor($totalWidth / 20000) * 1000 + ($totalWidth - $totalWidth_initial) / 2;
        //in meters
        $marginVert = 1000 + floor($totalHeight / 20000) * 1000 + ($totalHeight - ($MAP_TOP - $MAP_BOTTOM)) / 2;
        //in meters
        if ($marginHor > $marginVert) {
            // landscape style ...
            if ($marginVert / $marginHor < 3 / 4) {
                $marginVert = 3 / 4 * $marginHor;
            }
        } else {
            // portait style
            if ($marginHor / $marginVert < 3 / 4) {
                $marginHor = 3 / 4 * $marginVert;
            }
        }
        DEBUG("MAP", 1, "marginHor: {$marginHor}, marginVert:{$marginVert} <br>");
        $flMap = new flightMap($UTMzone, $UTMlatZone, $MAP_TOP + $marginVert, $MAP_LEFT - $marginHor, $UTMzone2, $UTMlatZone2, $MAP_BOTTOM - $marginVert, $MAP_RIGHT + $marginHor, 600, 800, "", "", 0);
        DEBUG("MAP", 1, "MAP Required m/pixel = " . $flMap->metersPerPixel . "<br>");
        $flMap->showTrack = 0;
        $flMap->showWaypoints = 0;
        header('Content-Type: image/jpeg');
        $flMap->drawFlightMap();
    }
}