Hallo zusammen,
nachdem ich hier im Forum keine einfache Lösung gefunden habe, die GPS Exif Informationen der Bilder mittels Google Maps darzustellen, habe ich mal schnell einen Hack integriert, der die Daten aus den Bilder ausliest und als kleine Google Map darstellt.
Ein Screenshot, wie das ganze aussieht, im Anhang.
Habe dazu die integrierte EXIF Funktion von 4Images 1.7.4 erweitert. Alle Änderungen sind in der Datei functions.php eingebunden, Exif Flags Namen sind in der Sparchdatei main.php im Verzeichnis "lang\deutsch" eingefügt (Abschnitt "EXIF Tags")
$lang['exif_GPSLatitudeRef'] = "GPS Breitengrad Referenz:";
$lang['exif_GPSLatitude'] = "GPS Breitengrad";
$lang['exif_GPSLongitudeRef'] = "GPS Längengrad Referenz";
$lang['exif_GPSLongitude'] = "GPS Längengrad:";
$lang['exif_GPSAltitude'] = "GPS Höhe:";
Hier meine Ergänzungen und die EXIF Funktion der functions.php (aus dem Include Verzeichnis):
function get_exif_info($exif) {
$exif_match = array();
$exif_match['Make'] = "make";
$exif_match['Model'] = "model";
$exif_match['DateTimeOriginal'] = "datetime";
$exif_match['ISOSpeedRatings'] = "isospeed";
$exif_match['ExposureTime'] = "exposure";
$exif_match['FNumber'] = "aperture";
$exif_match['FocalLength'] = "focallen";
// GPS EXIF Variablen Start - Changes by Erik Groennerud - www.koelschwasser.de 8.2007
$exif_match['GPSLatitude'] = "GPSLatitude";
$exif_match['GPSLatitudeRef'] = "GPSLatitudeRef";
$exif_match['GPSLongitude'] = "GPSLongitude";
$exif_match['GPSLongitudeRef'] = "GPSLongitudeRef";
$exif_match['GPSAltitude'] = "GPSAltitude";
// GPS EXIF Variablen Ende
$exif_array = array();
if (is_array($exif)) {
foreach ($exif as $key => $val) {
if (isset($exif_match[$key])) {
$exif_info = $val;
if ($key == "DateTimeOriginal") {
$exif_array[$exif_match[$key]] = preg_replace("/([0-9]{4}):([0-9]{2}):([0-9]{2})/", "\\3.\\2.\\1", $exif_info);
}
elseif ($key == "ExposureTime") {
$exposure = explode("/", $exif_info);
$exif_array[$exif_match[$key]] = "1/" . ($exposure[1] / $exposure[0]);
}
elseif ($key == "FNumber") {
$aperture = explode("/", $exif_info);
$exif_array[$exif_match[$key]] = "F/" . ($aperture[0] / $aperture[1]);
}
elseif ($key == "FocalLength") {
$focalLen = explode("/", $exif_info);
$exif_array[$exif_match[$key]] = ($focalLen[0] / $focalLen[1]) . "mm";
}
// GPS EXIF START - Changes by Erik Groennerud - www.koelschwasser.de 8.2007
elseif ($key == "GPSLatitudeRef") {
if ($exif_info == "N") {
$GPSLatitudeRef = "Nord";
$GPSLatfaktor = 1;
} else {
$GPSLatitudeRef = "Süd";
$GPSLatfaktor = -1;
}
}
elseif ($key == "GPSLongitudeRef") {
if ($exif_info == "E") {
$GPSLongitudeRef = "Ost";
$GPSLongfaktor = 1;
} else {
$GPSLongitudeRef = "West";
$GPSLongfaktor = -1;
}
}
elseif ($key == "GPSLatitude") {
$GPSLatitude_h = explode("/", $exif_info[0]);
$GPSLatitude_m = explode("/", $exif_info[1]);
$GPSLatitude_s = explode("/", $exif_info[2]);
$GPSLat_h = $GPSLatitude_h[0] / $GPSLatitude_h[1];
$GPSLat_m = $GPSLatitude_m[0] / $GPSLatitude_m[1];
$GPSLat_s = $GPSLatitude_s[0] / $GPSLatitude_s[1];
$GPSLatGrad = $GPSLatfaktor * ($GPSLat_h + ($GPSLat_m + ($GPSLat_s / 60))/60);
$exif_array[$exif_match[$key]] = $GPSLatitudeRef . " " .$GPSLat_h . "° ". $GPSLat_m . "' " . $GPSLat_s . "'' ($GPSLatGrad)";
}
elseif ($key == "GPSLongitude") {
$GPSLongitude_h = explode("/", $exif_info[0]);
$GPSLongitude_m = explode("/", $exif_info[1]);
$GPSLongitude_s = explode("/", $exif_info[2]);
$GPSLong_h = $GPSLongitude_h[0] / $GPSLongitude_h[1];
$GPSLong_m = $GPSLongitude_m[0] / $GPSLongitude_m[1];
$GPSLong_s = $GPSLongitude_s[0] / $GPSLongitude_s[1];
$GPSLongGrad = $GPSLatfaktor * ($GPSLong_h + ($GPSLong_m + ($GPSLong_s / 60))/60);
$exif_array[$exif_match[$key]] = $GPSLongitudeRef . " " . $GPSLong_h . "° ". $GPSLong_m . "' " . $GPSLong_s . "'' ($GPSLongGrad)";
}
elseif ($key == "GPSAltitude") {
$GPSAltitude = explode("/", $exif_info);
$exif_array[$exif_match[$key]] = ($GPSAltitude[0] / $GPSAltitude[1]) . " Meter über NN";
}
// GPS EXIF ENDE
else {
$exif_array[$exif_match[$key]] = $exif_info;
}
}
}
}
return $exif_array;
}
Desweiteren habe ich die EXIF Ausgabe Funktion ergänzt:
foreach ($exif_array as $key => $val) {
// GPS EXIF Modifikatio START
if (($key != "GPSLongitudeRef") && ($key != "GPSLatitudeRef")) {
if ($key == "GPSLongitude") {
$GPSLongtude = substr (strrchr($val, "("), 1);
$GPSLongtude = substr ($GPSLongtude,0, strlen($GPSLongtude)-1);
}
if ($key == "GPSLatitude") {
$GPSLatitude = substr (strrchr($val, "("), 1);
$GPSLatitude = substr ($GPSLatitude,0, strlen($GPSLatitude)-1);
}
// GPS EXIF Modifikatio ENDE
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$site_template->register_vars(array(
"exif_value" => format_text($val),
"exif_name" => $lang['exif_'.$key],
"row_bg_number" => $row_bg_number
));
$exif_info .= $site_template->parse_template("exif_bit");
// GPS EXIF Modifikatio START
}
}
if (($GPSLongtude != "") && ($GPSLatitude != "")) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$Beschreibung = "Google Map";
// Google Map Settings & Google API Key (http://www.google.com/apis/maps/)
$Karte = "<a href = 'http://maps.google.de/maps?ll=$GPSLatitude,$GPSLongtude&spn=0.005,0.005&t=h' target='_blank'>Position in neuer Google Maps öffnen</a><br>
<script src='http://maps.google.com/maps?file=api&v=2&key=PUT_YOUR_API_KEY_HERE!!!'
type='text/javascript'></script>
<script type='text/javascript'>
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById('map'));
map.setCenter(new GLatLng($GPSLatitude,$GPSLongtude), 18, G_HYBRID_MAP);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.addControl(new GOverviewMapControl());
var infoTabs = [
new GInfoWindowTab('Info', '<font color=\'#000000\'>Die Aufnahme wurde an dieser Position aufgenommen</font>'),
new GInfoWindowTab('Koordinaten','<font color=\'#000000\'>Breitengrad: $GPSLatitude<br>Längengrad: $GPSLongtude</font>')
];
var marker = new GMarker(map.getCenter());
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowTabsHtml(infoTabs);
});
map.addOverlay(marker);
marker.openInfoWindowTabsHtml(infoTabs);
}
}
//]]>
</script>
<body onload='load()' onunload='GUnload()'>
<div id='map' style='width: 700px; height: 300px'></div>
";
$site_template->register_vars(array(
"exif_value" => $Karte,
"exif_name" => $Beschreibung,
"row_bg_number" => $row_bg_number
));
$exif_info .= $site_template->parse_template("exif_bit");
}
// GPS EXIF Modifikatio ENDE
}
}
}
$site_template->register_vars(array(
Wer keine Lust hat die zwei Blöcke in die functions.php hinzukopieren, der läd sich einfach meine functions.php herunter.
Ihr müßt auf jeden Fall für Euch einen eigenen Google Map Api Key erstellen, den es einfach hier gibt:
http://www.google.com/apis/maps/signup.html Sucht Anschließend in Eurer modifizierten functions.php nach "PUT_YOUR_API_KEY_HERE!!!" und kopiert diesen dorthin.
Das ganze ist bestimmt nicht die schönste Art, wie die Google Mapp integriert ist, aber sie funktioniert.
Die Größe der Google Karte kann über die Parameter innerhalb des Google Codes verändert werden.
Über Eure Anregungen und Verbesserungen würde ich mich freuen, auch ob es bei Euch auch funktioniert.
Gerade noch entdeckt: Hatte kleinen Fehler in der Extrahierung der GPS Koordinaten für Google, sollte nun gefixt sein.
- Ein weiterer kleiner Bug, der Koordinaten südlich des Äquators und Westlich von Greenwich falsch darstellte. Koordinaten für Google müssen dann negativ sein.
- Ost und West Längengrad wurden nicht unterschieden, da IF-Abfrage auf "O" eingestellt war. Muß "E" heißen. Der Block muß dann so aussehen:
elseif ($key == "GPSLongitudeRef") {
if ($exif_info == "E") {
$GPSLongitudeRef = "Ost";
$GPSLongfaktor = 1;
} else {
$GPSLongitudeRef = "West";
$GPSLongfaktor = -1;
}
Viel Spaß
Erik
http://www.koelschwasser.dehttp://www.koelschwetter.dePS: Wer GPS Wegdaten hat, kann diese mit dem kostenlosen Programm "Location Stamper" von MS in seine Bilder schreiben:
http://research.microsoft.com/research/downloads/Details/eadb6a33-b1b8-4c4d-b713-64fae728f74f/Details.aspxPPS: Habe meine erweiterte Functions.php mal angehangen. Kleine kosmetische Verbesserungen.
PPPS: Die angehangene function.php ist für Version 1.7.4 - eine aktualisierte Version wird demnächst erscheinen.