if ($embed) { if ($myquadrant == "E") { $nw_coord = $gridLon . "," . $gridLat . ",0"; $ne_coord = $gridLon + 0.25 . "," . $gridLat . ",0"; $se_coord = $gridLon + 0.25 . "," . ($gridLat - 0.25) . ",0"; $sw_coord = $gridLon . "," . ($gridLat - 0.25) . ",0"; } else { $nw_coord = $gridLon . "," . $gridLat . ",0"; $ne_coord = $gridLon + 0.125 . "," . $gridLat . ",0"; $se_coord = $gridLon + 0.125 . "," . ($gridLat - 0.125) . ",0"; $sw_coord = $gridLon . "," . ($gridLat - 0.125) . ",0"; } $buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://earth.google.com/kml/2.1\">\n<Document>\n <name>CAP Search Grids for {$gridLabel}</name>\n <open>1</open>\n <description><![CDATA[CAP Conventional Search Grids covering the {$abbrev} - {$mygrid} Sectional Chart<br><br>\nBy Capt Charles Jackson<br>nightbeacons@gmail.com<br>\nbased on original work by<br>\n2Lt Landis Bennett, CAP<br>\nlandis@mac.com]]></description>\n<Placemark>\n<name>Polyline 1</name>\n <description> xx</description>\n <Style>\n <LineStyle>\n <color>88000000</color>\n <width>3</width>\n </LineStyle>\n </Style>\n <LineString>\n <coordinates>{$nw_coord} {$ne_coord} {$se_coord} {$sw_coord} {$nw_coord}</coordinates>\n </LineString>\n </Placemark>\n</Document>\n</kml>"; } else { # Fetch and output the Styles section $styles = makePreamble($gridLabel); # Create the "<Style>" sections of the KML. No folders. $firstRegion = makeRegion($gridLon, $gridLat); $boundingBox = makeBBfolder($gridLon, $gridLat, $abbrev, $mygrid); $gridFolder = makeGridFolder($gridLon, $gridLat, $abbrev, $mygrid); $ending = "\t\t</Folder>\n\t</Folder>\n</Folder>\n</Document>\n</kml>\n"; $buffer = $styles . "<Folder>\n" . $firstRegion . $boundingBox . $gridFolder . $ending; } header($kmlHeader); header($filenameHeader); echo "{$buffer}"; # =================================================================================================== # Create the Sectionals Region # Return the text string function makeRegion($lon, $lat) {
#!/usr/bin/php <?php #$grid="SEATTLE"; include_once "includes/coordinates.php"; include_once "includes/styles.php"; $offset = "0.000000000001"; $altitude = 45; foreach ($coordinates as $grid => $value) { $coordinates[$grid]['avgLon'] = ($coordinates[$grid]['MaxLon'] + $coordinates[$grid]['MinLon']) / 2; # Fetch and output the Styles section $preamble = makePreamble($grid); $view = initialView($coordinates[$grid]); $folder = initialFolder($coordinates[$grid]); $grids = doGrid($coordinates[$grid]); $gridNums = makeGridNumbers($coordinates[$grid]); $alphaGrid = makeAlphaGrid($coordinates[$grid]); $numberGrid = makeNumbers($coordinates[$grid]); $ending = "\t\t\t</Folder>\n\t\t</Folder>\n\t</Folder>\n</Document>\n</kml>\n"; $output = $preamble . $view . $folder . $grids . $gridNums . $alphaGrid . $numberGrid . $ending; $fh = fopen("doc.kml", "w"); fwrite($fh, $output); fclose($fh); $kmzFileName = $coordinates[$grid]['Abbrev'] . "_grid.kmz"; $cmd = "/usr/bin/zip -9q {$kmzFileName} doc.kml"; $tmp = `{$cmd}`; $cmd = "/bin/mv {$kmzFileName} overlays"; $tmp = `{$cmd}`; echo $coordinates[$grid]['Abbrev'] . "\tchart: " . $coordinates[$grid]['endGrid'] . "\tCalc: " . (1 + $gridCounter - $coordinates[$grid]['startGrid']) . "\tStart: " . $coordinates[$grid]['startGrid']; if ($coordinates[$grid]['endGrid'] == 1 + $gridCounter - $coordinates[$grid]['startGrid']) { echo "\tOK"; }