Page 1 of 2
Geo Location of Images
Posted: 22 Jan 2009, 14:23
by wonga
Hello
First of all...x2 is cool. And since I have added a few features myself it's the best photo gallery on the web.
Since I have added additional meta stuff to my photos incl. GPS coordinates I told myself to use these.
Of course I don't want to keep this to myself beacuse I think many would also desire to re-use and display their hard worked meta information.
Visit following galleries and view the image information displayed when moving the mouse over the image -> All information is based on retrieving EXIF data (incl. the info about the town located nearest):
http://www.hirst.ch/#/content/08%20Ausf ... 0-%20Jura/
http://www.hirst.ch/#/content/08%20Ausf ... lchenflue/
http://www.hirst.ch/#/content/09%20Feri ... Jordanien/
http://www.hirst.ch/#/content/09%20Feri ... ustralien/
... and more
This would be great to see in one of the releases to come.
Keep up the fantastic work
wonga
Posted: 22 Jan 2009, 16:43
by Nick
After first extracting EXIF geo tags from images and storing to xml, one could make himself sort of google map with images placed where they been take on the map... Have to think about it. For 2.2
Posted: 23 Jan 2009, 02:35
by wonga
Having a map to display the images would be a pretty cool feature too.
However, let me know if you are interested in my modified EXIF file from the include folder which retrieves EXIF information and localizes the nearest place where the photo has been taken.
Posted: 23 Jan 2009, 18:19
by Nick
Sorry I didnt get it at first, have you actually implemented it? How are you using exif data in frontend though? Am I missing something?
Did you converted geotags to human readable titles?
Posted: 24 Jan 2009, 11:02
by wonga
Yes, I did some modfifications to the "ivExifParser.class.php" to read out some more EXIF data such as:
-> $exifData['ImageDescription']
-> $exifData['DocumentName']
-> $exifData['GPSLatitudeRef']
-> $exifData['GPSLongitudeRef']
I then use a service from
www.geonames.org to find the nearest place according to that GPS location.
There is actually not much to it. The X2 displays the things almost automatically the way I want it.
Note: The text on the image is entirely EXIF data.
Posted: 24 Jan 2009, 17:43
by Nick
How did you run data thru geonames? Do they have some script? And how did you string everything together?
Posted: 24 Jan 2009, 18:33
by wonga
You just send the coordinates as string attached to an URL and you receive back either an XML or JSON. e.g.
http://ws5.geonames.org/findNearbyPlace ... style=full
ws.geonames.org would be the correct subdomain, but the are having problems on that one, hence I use their backup system on ws5.geonames.org
Within that XML you get a bunch of data of which you pick out what you want. I used simple_xml in my script. Then you play arround and format the output to your needs. You then add this to a variable like all the others in your PHP file for EXIF extraction.
If you want I can post the modification (or just the modifications) here or if you prefer send the modified file to your mail account. I am sure you would be able to streamline my code since I am not too familiar with PHP.
Before that I would need to add some comments in the script. Since there are some things to keep in mind.
Posted: 25 Jan 2009, 15:49
by wonga
hmmmm... geonames.org is having quite some availability issues. Hence no data shown on my site, or very delayed.
With a small payment you can buy better availability on their commercial server.
Posted: 26 Jan 2009, 03:35
by globetrotter
Can I use Exif GPS data to create a link to Google Maps like this:
http://maps.google.nl/maps?ie=UTF8&ll=5 ... 49316&z=12
And make a clickable link in my Exif field, which is shown on my pictures?
Posted: 26 Jan 2009, 05:03
by wonga
hi globetrotter
Good point, this would be a nice to have too.
I tried this during my modifications, but I could not get this to work since you can not create any link element. Only output as plain text was possible.
Posted: 28 Jan 2009, 01:47
by globetrotter
wonga wrote:hi globetrotter
Good point, this would be a nice to have too.
I tried this during my modifications, but I could not get this to work since you can not create any link element. Only output as plain text was possible.
I also tried to show the GPS data, but the only thing I saw was
undefined. What did you add/change in the code?
Posted: 28 Jan 2009, 02:10
by wonga
I had to add quite a bit of code to get this work as you see it on my gallery. The part of showing dosument-name and image-description was an easy modification. Also the display of the GPS coordinates is actually quite simple.
Most hard part was getting the information on getting the coordinates translated into "nearByPlaceName".
What did you change in the code and where?
Posted: 28 Jan 2009, 03:06
by globetrotter
The first step for me was to show the GPS data latitude and longitude. In
ivExifParser.class.php I added the codes:
First code is added to the list on the top of the php-file. Second code is at the end of the php-file.
I am not a programmer, so I have no idea what I am doing

Posted: 28 Jan 2009, 05:12
by wonga
I'll have a look at this tonight, cause I have no access to my files currently.
On first view it looks fine to me

Posted: 28 Jan 2009, 14:00
by wonga
Hi globetrotter
The values you get are not actual values. It returns an array. This why you get undified messages.
Try my part of the code:
/**
* Format GpsCoords fields
*
* @param array $filtered
* @param array $exifData
*/
function GpsCoords(&$filtered, $exifData)
{
/** Re-write different GPS coordinate syntax such as. 47° 7' 10'' or 47° 7.678' and turn it to 47.1234 (There might be more, but these are the ones I found) */
function EvalCoords($coord,$prefix)
{
/* S and W are minus (-), N and E are plus (+) */
$prefix = $prefix=='S' || $prefix=='W' ? -1 : 1;
list ($coord00,$coord01) = split('[/.-]', $coord[0]);
list ($coord10,$coord11) = split('[/.-]', $coord[1]);
list ($coord20,$coord21) = split('[/.-]', $coord[2]);
$coord0 = $coord00/$coord01;
$coord1 = $coord10/$coord11;
$coord2 = $coord20/$coord21;
$coord1 = $coord2!=0 ? $coord1+$coord2/60 : $coord1;
$coord = round($coord0+$coord1/60,4)*$prefix; /* i.e. -47.1234 */
return $coord;
}
/** Retreive GPS EXIF information and set params */
if (isset($exifData['GPSLatitude']) && isset($exifData['GPSLongitude']))
{
$latitude = EvalCoords($exifData['GPSLatitude'],$exifData['GPSLatitudeRef']);
$longitude = EvalCoords($exifData['GPSLongitude'],$exifData['GPSLongitudeRef']);
if (!empty($latitude) && !empty($longitude))
{
$filtered['GPS'] =$latitude.", ".$longitude;
}
}
}
Surely the code could be optimized, but at least you get what you want. Also not that you forgot the prefix in your code. The prefix is either S, W, E or N. My code will just add a minus (-) if its W or S.
also do not forget to set the CSS classes if you want them look different
.exif_name_gps{
display: none;
}
.exif_value_gps{
font-size:10px;
color: #0066CC;
}
Good luck