function kmlGetTrack($lineColor = "ff0000", $exaggeration = 1, $lineWidth = 2, $extended = 1) { global $takeoffRadious, $landingRadious; global $moduleRelPath, $baseInstallationPath; global $langEncodings, $currentlang; $getFlightKML = $this->getFlightKML() . "&c={$lineColor}&w={$lineWidth}&an={$extended}"; // do some basic check for saned igc file if (!$this->checkSanedFiles()) { return ""; } if ($extended == 1) { //$kml_file_contents.="<Placemark >\n<name>".$this->filename."</name>"; // $kml_file_contents.=$this->kmlGetDescription($extended,$getFlightKML); //$kml_file_contents.="</Placemark>"; require_once dirname(__FILE__) . "/FN_kml.php"; kmlGetTrackAnalysis($this->getKMLFilename(1), $this->getIGCFilename(2), 1); $kml_file_contents = "\n<NetworkLink>\n <name>Extended analysis</name>\n <visibility>1</visibility>\n <open>1</open>\n <description> Extra analysis generation by Man\\'s GPS2GE V2.0 (http://www.parawing.net)</description>\n <refreshVisibility>0</refreshVisibility>\n <flyToView>0</flyToView>\n <Link>\n\t<href>http://" . $_SERVER['SERVER_NAME'] . "/{$baseInstallationPath}/" . $this->getKMLRelPath(1) . "</href>\n </Link>\n</NetworkLink>"; return $kml_file_contents; } $KMLlineColor = "ff" . substr($lineColor, 4, 2) . substr($lineColor, 2, 2) . substr($lineColor, 0, 2); $kmzFile = $this->getKMLFilename(0); $kmlTempFile = $kmzFile . ".tmp.kml"; // DEBUG MANOLIS force creation if (!file_exists($kmzFile)) { // create the kmz file containg the points only $filename = $this->getIGCFilename(2); $lines = file($filename); if ($lines) { $i = 0; /* new ge features http://googlegeodevelopers.blogspot.com/2010/07/making-tracks-new-kml-extensions-in.html http://google-latlong.blogspot.com/2010/06/relive-your-hiking-biking-and-other.html ****** !!!! **** http://code.google.com/intl/el-GR/apis/kml/documentation/kmlreference.html#trackexample http://sketchup.google.com/3dwarehouse/cldetails?mid=c166a0a48065f4403a426bad1ca64772&ct=mdcc&prevstart=0 */ $str = '<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"> '; $str .= "<Document>\n\t\t<name>Tracklog File</name>\n\t\t<Schema id=\"schema\">\n\t\t <gx:SimpleArrayField name=\"Climb\" type=\"float\">\n\t\t\t <displayName>CLimb (m/s)</displayName>\n\t\t </gx:SimpleArrayField>\n\t\t</Schema>"; $strXXX .= '<!-- Normal multiTrack style --> <Style id="Track_n"> <LineStyle> <color>ff0000ff</color> <width>2</width> </LineStyle> <IconStyle> <Icon> <href>http://earth.google.com/images/kml-icons/track-directional/track-0.png</href> </Icon> </IconStyle> </Style> <!-- Highlighted multiTrack style --> <Style id="Track_h"> <LineStyle> <color>ff0000ff</color> <width>1</width> </LineStyle> <IconStyle> <scale>1.2</scale> <Icon> <href>http://earth.google.com/images/kml-icons/track-directional/track-0.png</href> </Icon> </IconStyle> </Style> <StyleMap id="TrackStyle"> <Pair> <key>normal</key> <styleUrl>#Track_n</styleUrl> </Pair> <Pair> <key>highlight</key> <styleUrl>#Track_h</styleUrl> </Pair> </StyleMap> '; $str .= "<Placemark id='timeTrack'>\n\t\t\t\t\t<name>Tracklog</name>\n\t\t\t\t\t <Style id='Track1'>\n <LineStyle>\n\t\t\t<color>ff0000ff</color>\n\t\t\t<width>2</width>\n </LineStyle>\n <IconStyle>\n <Icon>\n <href>http://earth.google.com/images/kml-icons/track-directional/track-0.png</href>\n </Icon>\n </IconStyle>\n </Style>"; $str .= "<gx:MultiTrack id=\"MultiTrack\">\n\t\t\t\t<gx:Track>\t\t\t\t\t\n\t\t\t\t<altitudeMode>absolute</altitudeMode>\n\n"; //$kml_file_contents=str_replace("&","&",$kml_file_contents); // $kml_file_contents=utf8_encode(str_replace(" "," ",$kml_file_contents)); $str = str_replace(" ", " ", $str); $timeStampStr = ''; foreach ($lines as $line) { $line = trim($line); if (strlen($line) == 0) { continue; } if ($line[0] == 'B') { if (strlen($line) < 23) { continue; } // also check for bad points // 012345678901234567890123456789 // B1522144902558N00848090EV0058400000 if ($line[24] == 'V') { continue; } $thisPoint = new gpsPoint($line, $this->timezone); $alt = $thisPoint->getAlt(); $lon = -$thisPoint->lon; $lat = $thisPoint->lat; // $data_alt[$i]=$thisPoint->getAlt(); if ($alt > $this->maxAllowedHeight) { continue; } // $str.=$lon.",".$lat.",".($alt*$exaggeration)." "; if ($tm0) { $dalt = $alt - $alt0; $dt = $thisPoint->getTime() - $tm0; $climb = sprintf("%.1f", $dalt / $dt); if (abs($climb) > 20) { $climb = 0; } } else { $climb = 0; } $tm0 = $thisPoint->getTime(); $alt0 = $alt; $strWhen .= "<when>" . $this->DATE . "T" . sec2Time24h($thisPoint->getTime() % (3600 * 24)) . "Z</when>\n"; $strCord .= "<gx:coord>" . sprintf("%.5f", $lon) . " " . sprintf("%.5f", $lat) . " " . round($alt) . "</gx:coord>\n"; $strClimb .= "<gx:value>{$climb}</gx:value>\n"; $simpleTrackStr .= sprintf("%.5f", $lon) . "," . sprintf("%.5f", $lat) . "," . round($alt) . " "; if ($i % 50 == 0) { $simpleTrackStr .= "\n"; } $i++; } } //$str.="</coordinates>\n</LineString>\n"; $str .= $strWhen . "\n\n" . $strCord . "<ExtendedData>\n\t\t <SchemaData schemaUrl=\"#schema\">\n\t\t <gx:SimpleArrayData name=\"Climb\">\n\t\t\t\t\t\t" . $strClimb . "\n\t\t\t\t\t\t </gx:SimpleArrayData>\n\t\t\t\t\t</SchemaData>\n\t\t\t\t </ExtendedData>\n\t\t\t\t "; $str .= "\t\n\t\t\t\t\t</gx:Track>\n\t\t\t\t</gx:MultiTrack>\n\t\t\t\t\t\t"; $str .= "</Placemark>"; $str .= ' <Placemark id="simpleTrack"> <name>Simple Track</name> <Style id="Track2"> <LineStyle> <color>ff0000ff</color> <width>2</width> </LineStyle> </Style> <LineString > <extrude>0</extrude> <altitudeMode>absolute</altitudeMode> <coordinates>' . $simpleTrackStr . '</coordinates> </LineString> </Placemark>'; $str .= "\n\t\t<Style id='s_camera'>\n\t\t<IconStyle>\n\t\t\t<color>ff00ff00</color>\n\t\t\t<scale>0.8</scale>\n\t\t\t<Icon>\n\t\t\t\t<href>http://maps.google.com/mapfiles/kml/shapes/camera.png</href>\n\t\t\t</Icon>\n\t\t\t<hotSpot x='0.5' y='0' xunits='fraction' yunits='fraction'/>\n\t\t</IconStyle>\n\t\t<ListStyle>\n\t\t</ListStyle>\n\t\t</Style>"; // now the photos if ($this->hasPhotos) { require_once dirname(__FILE__) . "/CL_flightPhotos.php"; global $CONF; $flightPhotos = new flightPhotos($this->flightID); $flightPhotos->getFromDB(); // get geoinfo $flightPhotos->computeGeoInfo(); $imagesHtml = ""; foreach ($flightPhotos->photos as $photoNum => $photoInfo) { if ($photoInfo['lat'] && $photoInfo['lon']) { $imgIconRel = $flightPhotos->getPhotoRelPath($photoNum) . ".icon.jpg"; $imgBigRel = $flightPhotos->getPhotoRelPath($photoNum); $imgIcon = $flightPhotos->getPhotoAbsPath($photoNum) . ".icon.jpg"; $imgBig = $flightPhotos->getPhotoAbsPath($photoNum); if (file_exists($imgBig)) { list($width, $height, $type, $attr) = getimagesize($imgBig); list($width, $height) = CLimage::getJPG_NewSize($CONF['photos']['mid']['max_width'], $CONF['photos']['mid']['max_height'], $width, $height); $imgTarget = $imgBigRel; } else { if (file_exists($imgIcon)) { list($width, $height, $type, $attr) = getimagesize($imgIcon); list($width, $height) = CLimage::getJPG_NewSize($CONF['photos']['mid']['max_width'], $CONF['photos']['mid']['max_height'], $width, $height); $imgTarget = $imgIconRel; } } $imgIconRel = "http://" . $_SERVER['SERVER_NAME'] . $baseInstallationPath . "/" . $imgIconRel; $imgTarget = "http://" . $_SERVER['SERVER_NAME'] . str_replace('//', '/', $baseInstallationPath . "/" . $imgTarget); $altitudeMode = "absolute"; if ($photoInfo['alt'] == 0) { $altitudeMode = "clampToGround"; } $str .= "\n\t\t\t<Placemark>\n\t\t <name>Photo</name>\n\t\t\t<styleUrl>#s_camera</styleUrl>\n\t\t\t<Snippet maxLines='0' ></Snippet>\n\t\t\t<description><![CDATA[<a href='{$imgTarget}'><img src='{$imgTarget}' width='" . $CONF['photos']['mid']['max_width'] . "' border='0'></a>\n]]></description>\n\t\t\t<Point>\n\t\t\t\t<altitudeMode>{$altitudeMode}</altitudeMode> \t \n\t\t\t\t<coordinates>" . $photoInfo['lon'] . "," . $photoInfo['lat'] . "," . $photoInfo['alt'] . "</coordinates>\n\t\t\t</Point>\n\t\t\t</Placemark>"; } } } $str .= "\n</Document>\n</kml>"; writeFile($kmlTempFile, $str); // zip the file require_once dirname(__FILE__) . "/lib/pclzip/pclzip.lib.php"; $archive = new PclZip($kmzFile); $v_list = $archive->create($kmlTempFile, PCLZIP_OPT_REMOVE_ALL_PATH); $this->deleteFile($kmlTempFile); } } $getFlightKMLcolorUpdater = $this->getFlightKML() . "&c={$lineColor}&w={$lineWidth}&an={$extended}&updateColor=1"; $kml_file_contents = ''; $kml_file_contents .= "\n<NetworkLink>\n <name>Tracklog</name>\n <visibility>1</visibility>\n <open>1</open>\n <refreshVisibility>1</refreshVisibility>\n <flyToView>1</flyToView>\n <Link>\n\t<href>http://" . str_replace('//', '/', $_SERVER['SERVER_NAME'] . "/{$baseInstallationPath}/" . $this->getKMLRelPath(0)) . "</href>\n </Link>\n</NetworkLink>"; $kml_file_contents .= "\n<NetworkLink>\n <name>UpdateColor</name>\n <Link>\n <href>" . str_replace("&", "&", $getFlightKMLcolorUpdater) . "</href>\n\t</Link>\n</NetworkLink>\n"; //echo "## $getFlightKMLcolorUpdater ## "; //exit; return $kml_file_contents; }
$nearestWaypoint->getFromDB(); $name = getPilotRealName($row["userID"], $row["userServerID"], 1); $link = htmlspecialchars("http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'show_flight', 'flightID' => $row['ID']))); $this_year = substr($row[DATE], 0, 4); $linkIGC = htmlspecialchars("http://" . $_SERVER['SERVER_NAME'] . getRelMainDir() . str_replace("%PILOTID%", getPilotID($row["userServerID"], $row["userID"]), str_replace("%YEAR%", $this_year, $CONF['paths']['igc'])) . '/' . $row['filename']); //$flightsRelPath."/".$row[userID]."/flights/".$this_year."/".$row[filename] ); if ($row['takeoffVinicity'] > $takeoffRadious) { $location = getWaypointName($row['takeoffID']) . " [~" . sprintf("%.1f", $row['takeoffVinicity'] / 1000) . " km]"; } else { $location = getWaypointName($row['takeoffID']); } if ($i > 0) { $JSON_str .= ", "; } $START_TIME = sec2Time24h($row['START_TIME'], 1); $END_TIME = sec2Time24h($row['END_TIME'], 1); $duration = sec2Time($row['DURATION'], 1); $linearDistance = formatDistanceOpen($row["LINEAR_DISTANCE"]); $olcDistance = formatDistanceOpen($row["FLIGHT_KM"]); $olcScore = formatOLCScore($row["FLIGHT_POINTS"]); $scoreSpeed = formatSpeed($row["SCORE_SPEED"]); // get the OLC score type $olcScoreType = $row['BEST_FLIGHT_TYPE']; if ($olcScoreType == "FREE_FLIGHT") { $olcScoreTypeImg = "icon_turnpoints.gif"; } else { if ($olcScoreType == "FREE_TRIANGLE") { $olcScoreTypeImg = "icon_triangle_free.gif"; } else { if ($olcScoreType == "FAI_TRIANGLE") { $olcScoreTypeImg = "icon_triangle_fai.gif";