Archive for septembre, 2007
Opening of the “Just for the fun” category
XiaoXiao
You certainly remenber the first appearance of the stickman in Xiaoxiao. Alan Becker make him relive with…
Animator vs animation - the victim
Animation vs Animator II - The revenge of the Chosen One!
No commentsGoogle Map module for Gallery 2.2
This article will be written in English, eventually to be readable by the maintainers of the development I’ll talk about. Sorry for the French speakers and, especially, for the English speakers for my terrible poor language practice.
So, like my frequently users know, this homepage is made with Wordpress and Gallery for the photos. Both of them are linked by a plugin called WPG2. I found last week a great module for gallery2 => GMAP module.
It is a module which allow to retrieve EXIF GPS data from picture and to embed a Google Map in Gallery in order to show the place the photo has been taken.
Unfortunately, after install, the plugin didn’t work… very well. Pictures were located under Africa (in spite of I do not remember Italy was so far), lot of pages failed (with indigestible error messages) etc.
After few nights remembering my far PHP knowledge and discovering the evolution of coding during my inactive development period (the object oriented concept is now strongly embed in PHP), I debugged the functionalities I wanted.
I do not support the idea my improvement are perfect or universal (eg. I circumvented a switch to detect the GPS coordinates format to put my own reading coordinates algorithm) but maybe it can help some users to make GMAP module working or maintainers to unblock the subversion files.
In all case, I provide my modifications first to save and eventually reapply them after a apti-get update of my server.
In modules/map/MapGroupAdmin.inc AND modules/map/MapRouteAdmin.inc (exactly the same modification)
Put these two lines in comment
GalleryCoreApi::requireOnce(’modules/core/classes/helpers/GalleryPermissionHelper_medium.class’);
list($ret,$perms)=GalleryPermissionHelper_medium::fetchPermissionsForItems($ids,$gallery->getActiveUserId());
And add these ones instead
GalleryCoreApi::requireOnce(’modules/core/classes/helpers/GalleryPermissionHelper_advanced.class’);
list($ret,$perms)=GalleryPermissionHelper_advanced::fetchAllPermissionsForItem($ids);
The GalleryPermissionHelper_medium class does not (no longer ?) exists, I had to adapt function with GalleryPermission_Helper_advanced one. Note this modification must be done in the two files with the same way.
In modules/map/MapSiteAdmin.inc
Find these two lines:
$lat = explode(" ",str_replace(",",".",$exifData[$id]['GPS/Latitude']['value']));
$lon = explode(" ",str_replace(",",".",$exifData[$id]['GPS/Longitude']['value']));
And replace the $id index by $i like that:
$lat = explode(" ",str_replace(",",".",$exifData[$i]['GPS/Latitude']['value']));
$lon = explode(" ",str_replace(",",".",$exifData[$i]['GPS/Longitude']['value']));
It certainly was a typing mistake by a developer.
In modules/exif/lib/exifer/makers/gps.inc
Put into comment the following lines:
$hour = GPSRational(substr($data,0,16),$intel);
$minutes = GPSRational(substr($data,16,16),$intel);
$seconds = GPSRational(substr($data,32,16),$intel);
And add these ones:
$hour = hexdec(substr($data,40,8));
$minutes = hexdec(substr($data,24,8))/((float)hexdec(substr($data,16,8)));
$seconds = 0;
For this… I do not have any idea about why my EXIF data do not correspond with the reading algorithm of the original module… But with my modification, they do.
So, use this patch if and only if you have some problem of reading of GPS coordinates.
In modules/map/ShowMap.inc
AFTER these lines:
SELECT [GallerymapMap::itemId],
[GallerymapMap::value]
FROM [GallerymapMap]
WHERE [GallerymapMap::field] = \’GPS\’
ADD (and NOT REPLACE) this one:
AND [GallerymapMap::value] <> \’0,0\’
This modification is to avoid timeout problem if the majority of your pictures have none or unreadable GPS data.
That’s all
Thanks to make me know if you have some difficulty with my explanation (or with my English
) and do not hesitate to:
- Execute
- Study
- Redistribute
- Improve
my code… like GPL licence oblige me and you
