Piwigo / piwigo-openstreetmap

OpenStreetMap integration for Piwigo
http://piwigo.org/ext/extension_view.php?eid=701
GNU General Public License v3.0
36 stars 35 forks source link

Addon return null on map #1

Closed GandyCZ closed 11 years ago

GandyCZ commented 11 years ago

When I enter map view. (On left menu) Zoom on any photo. Click on photo the link is opened totally wrong. http://iphoto.macweb.cz/iphoto/picture.php?/null is there any mismatch for settings or that a bug? On RV plugin links work ok so i think is not a problem with GPS or picture DB.

xbgmsharp commented 11 years ago

All data for world map are generate via one mysql query. Those image does not below to any album? I believe the field storage_category_id is not use in your setting.

Could you change a line to check if it fix the issue: in file https://github.com/xbgmsharp/piwigo-openstreetmap/blob/master/osmmap.php#L102

Replace the first line by the second one.

-CONCAT(`id`, '/category/', `storage_category_id`) as imgurl, 
+CONCAT( IFNULL(`id`, ''), '/category', IFNULL( CONCAT( '/', `storage_category_id` , '') ) as imgurl, 

If it work i will commit the change

raarset commented 11 years ago

I have the same problem as "GandyCZ".
When I replace the first line with the second one, then I get a error-message.

---Kind regards, Rune -----

Warning: [mysql error 1582] Incorrect parameter count in the call to native function 'IFNULL' SELECT lat, lon, name, IF(representative_ext IS NULL, CONCAT(SUBSTRING_INDEX(TRIM(LEADING '.' FROM path), '.', 1 ), '-sq.', SUBSTRING_INDEX(TRIM(LEADING '.' FROM path), '.', -1 )), TRIM(LEADING '.' FROM REPLACE(path, file, CONCAT('pwg_representative/', CONCAT( TRIM(TRAILING '.' FROM SUBSTRING_INDEX(file, '.', 1 )), CONCAT('-sq.', representative_ext) ) ) ) ) ) AS pathurl,
CONCAT( IFNULL(id, ''), '/category', IFNULL( CONCAT( '/', storage_category_id , '') ) as imgurl, IFNULL(comment, '') AS comment, IFNULL(author, '') AS author, width FROM piwigo_images AS i INNER JOIN piwigo_image_category AS ic ON id = ic.image_id WHERE lat IS NOT NULL AND lon IS NOT NULL AND (category_id NOT IN (686,223,224,249,250,255,256,257,692,261,691,293,294,295,296,297,298,299,300,301,302,309,687,690,315,316,318,319,347,360,689,375,376,377,378,379,688)) grou in /var/www/piwigo/include/dblayer/functions_mysqli.inc.php on line 834 Fatal error: Call to a member function fetch_assoc() on a non-object in /var/www/piwigo/include/dblayer/functions_mysqli.inc.php on line 181

GandyCZ commented 11 years ago

Actually I use this solution... I have one folder named photobank and there subfolders named by event location. All photos are taged and then tags used in smartfolders created by SmartAlbum plugin... But maybe the problem is on that subfoldering...

xbgmsharp commented 11 years ago

my misstake I miss one closing Could you change a line to check if it fix the issue: in file https://github.com/xbgmsharp/piwigo-openstreetmap/blob/master/osmmap.php#L102

The correct line:

-CONCAT(`id`, '/category/', `storage_category_id`) as imgurl, 
+CONCAT( IFNULL(`id`, ''), '/category', IFNULL( CONCAT( '/', `storage_category_id` , '') ) ) as imgurl, 
raarset commented 11 years ago

I'm getting the same error-message.

......................................................................................

Warning: [mysql error 1582] Incorrect parameter count in the call to native function 'IFNULL' SELECT lat, lon, name, IF(representative_ext IS NULL, CONCAT(SUBSTRING_INDEX(TRIM(LEADING '.' FROM path), '.', 1 ), '-sq.', SUBSTRING_INDEX(TRIM(LEADING '.' FROM path), '.', -1 )), TRIM(LEADING '.' FROM REPLACE(path, file, CONCAT('pwg_representative/', CONCAT( TRIM(TRAILING '.' FROM SUBSTRING_INDEX(file, '.', 1 )), CONCAT('-sq.', representative_ext) ) ) ) ) ) AS pathurl,
CONCAT( IFNULL(id, ''), '/category', IFNULL( CONCAT( '/', storage_category_id , '') ) ) as imgurl, IFNULL(comment, '') AS comment, IFNULL(author, '') AS author, width FROM piwigo_images AS i INNER JOIN piwigo_image_category AS ic ON id = ic.image_id WHERE lat IS NOT NULL AND lon IS NOT NULL group by name; in /var/www/piwigo/include/dblayer/functions_mysqli.inc.php on line 834 Fatal error: Call to a member function fetch_assoc() on a non-object in /var/www/piwigo/include/dblayer/functions_mysqli.inc.php on line 181

xbgmsharp commented 11 years ago

Even so the query I provided works fine for me on my dev box, I believe Mysql version differ and does not support the same 'IFNULL' parameter. So here is an another way, It is a little bit more CPU consuming but should be fine. I want to keep the 'storage_category_id' parameter when present, in this case the album is selected when you click on the thumbnail.

So in file https://github.com/xbgmsharp/piwigo-openstreetmap/blob/master/osmmap.php#L102

-CONCAT(`id`, '/category/', `storage_category_id`) as imgurl, 
+TRIM(TRAILING '/' FROM CONCAT( `id`, '/category/', IFNULL(`storage_category_id`, '') ) ) as imgurl, 

The new query:

SELECT `lat`, `lon`, `name`, IF(`representative_ext` IS NULL, CONCAT(SUBSTRING_INDEX(TRIM(LEADING '.' FROM `path`), '.', 1 ), '-sq.', SUBSTRING_INDEX(TRIM(LEADING '.' FROM `path`), '.', -1 )), TRIM(LEADING '.' FROM REPLACE(`path`, `file`, CONCAT('pwg_representative/', CONCAT( TRIM(TRAILING '.' FROM SUBSTRING_INDEX(`file`, '.', 1 )), CONCAT('-sq.', `representative_ext`) ) ) ) ) ) AS pathurl, TRIM(TRAILING '/' FROM CONCAT( `id`, '/category/', IFNULL(`storage_category_id`, '') ) ) as imgurl, IFNULL(`comment`, '') AS `comment`, IFNULL(`author`, '') AS `author`, `width` FROM piwigo_images AS i INNER JOIN piwigo_image_category AS ic ON id = ic.image_id WHERE `lat` IS NOT NULL AND `lon` IS NOT NULL group by `name`;

If this does not work, I would need a dump of one affected entry from the images table by email.

raarset commented 11 years ago

The new line works fine. The map is fine, and when I click on one photo the right picture is shown... Thank You I have 7300 GPS tagged pictures, and it takes no more than 2 sec. to show the map.

:+1:

xbgmsharp commented 11 years ago

Thanks for the help. Commit push closing.