// Now we convert the long/lat coordinates into screen coordinates $result = mysql_query($sql, $db); $count = 0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $count++; if ($count % 100 == 0) { fwrite($stderr, "{$count} "); } $x1 = $row["sx"]; $y1 = $row["sy"]; $x2 = $row["dx"]; $y2 = $row["dy"]; $distance = gcPointDistance(array("x" => $x1, "y" => $y1), array("x" => $x2, "y" => $y2)); if ($distance > $GC_MIN) { // Plot great circle curve $points = gcPath(array("x" => $x1, "y" => $y1), array("x" => $x2, "y" => $y2), $distance, false); } else { // Draw straight lines $points = straightPath(array("x" => $x1, "y" => $y1), array("x" => $x2, "y" => $y2)); } $oldpt = null; foreach ($points as $loc) { if ($loc == null) { $oldpt = null; continue; } $newpt = getlocationcoords($loc["y"], $loc["x"], $scale_x, $scale_y); if ($oldpt) { imageline($im, $oldpt["x"], $oldpt["y"], $newpt["x"], $newpt["y"], $yellow); } $oldpt = $newpt;
$y1 = $row["sy"]; $z1 = $row["sz"] * $METERSPERFOOT; $x2 = $row["dx"]; $y2 = $row["dy"]; $z2 = $row["dz"] * $METERSPERFOOT; $distance = $row["distance"]; // Skip flights where src==dest if ($x1 != $x2 && $y1 != $y2) { $src_ap = format_apcode2($row["siata"], $row["sicao"]); $dst_ap = format_apcode2($row["diata"], $row["dicao"]); $code = $row["code"]; $mode = $row["mode"]; print "<Placemark>\n"; print " <name>{$src_ap}-{$dst_ap}</name>\n <description>{$modes[$mode]} {$code}</description>\n"; print " <styleUrl>#{$mode}</styleUrl>\n"; $points = gcPath(array("x" => $x1, "y" => $y1, "z" => $z1), array("x" => $x2, "y" => $y2, "z" => $z2), $distance, true); if ($row["mode"] == "F") { $altitudeMode = "absolute"; } else { $altitudeMode = "clampToGround"; } print " <MultiGeometry>\n <LineString>\n <altitudeMode>{$altitudeMode}</altitudeMode><coordinates>\n"; foreach ($points as $loc) { if (!$loc) { continue; } // skip breaks print $loc["x"] . "," . $loc["y"] . "," . $loc["z"] . "\n"; } print " </coordinates>\n </LineString>\n"; print " </MultiGeometry>\n</Placemark>\n";