And finally, the last function call from our single frame page, and the one that will output (if they exist) the user comment in a caption below the image frame, and the GPS data that's available, as well as a map reference link out to WikiMapia.org. We'll refer to this link again in our closing discussion.
print_data() is the HTML factory for the page (excluding the IMG tag already generated). All of the little bits that have been floating around out in the global scope will now get put in their proper place. We have created the variable $z which holds the calculated value for &z= cast as a string, for use in generating the WMO link. Note we added $h to the global list:
PHP Code:
function print_data() {
global $errStr, $exif, $gps_alt, $lat_deg, $lat_min, $lat_sec, $lat_hem, $lat_dec, $log_deg, $log_min, $log_sec, $log_hem, $lon_dec, $zindx, $use_com, $h;
$str = "";
if ($use_com) { $str .= " <tr>\n <td colspan=\"3\">\n <p class=\"comment\">$use_com</p>\n </td>\n </tr>\n"; }
if (!$errStr) {
$str .= " <tr><th scope=\"col\">LATITUDE</th><th scope=\"col\">LONGITUDE</th><th scope=\"col\">ALTITUDE</th></tr>\n <tr>\n";
$str .= " <td>\n <p>$lat_deg° $lat_min’ $lat_sec” $lat_hem</p>\n <p>$lat_dec°</p>\n </td>\n";
$str .= " <td>\n <p>$log_deg° $log_min’ $log_sec” $log_hem</p>\n <p>$lon_dec°</p>\n </td>\n";
$z = isset($h) ? ((intval($h) <= 4 && intval($h) >= -4) ? "&z=" . (string)(17 + intval($h)) : "&z=17") : "&z=17";
$str .= " <td>\n <p>" . (($gps_alt == "N/A") ? $gps_alt : "$gps_alt m " . (($alt_ref) ? "Below" : "Above") . " Sea Level.") . "</p>\n <p>Go to this <a href=\"http://www.wikimapia.org/#lat=" . $lat_dec . "&lon=" . $lon_dec . $z . "\">location on the map</a></p>\n </td>\n";
} else {
$str .= $errStr;
}
$str .= " </tr>";
echo $str;
}