MantisBT - Piwigo
View Issue Details
0003213Piwigometadatapublic2015.03.19 18:192015.03.20 13:41
xbgmsharp 
 
normaltweakalways
newopen 
2.7.4 
 
any
Apache 2.x
0003213: Convert IPTC location data to GPS
From http://piwigo.org/forum/viewtopic.php?pid=158156#p158156 [^]

Hello!
Unfortunately most of my photos haven't had GPS coordinates because they was scaned or made photo by camera without GPS.

I have marked IPTC position/city/state/country for them and it will be good idea!

I have a few thinks about how it will be good to work:
* Many places may be out of cities, but may contain searchable names (for example "Sognefjorden" is the fjord in Norway. I can search it by Google maps (https://www.google.com/maps/place/Sogne [^] … b81323cb38), but cann't search it by http://stevemorse.org/jcal/latlon.php [^] because I nave to type city in this service)
* It will be good if OpenStreetMap read ("city" OR/and "state") and "country" OR "position" (free text, like "Sognefjorden") if "city" is empty (for example)
* If it worked with not only English (like Google Maps) it would be great!

In attachment photo with filled IPTC fields Country = "Norway" and Position "Norway, Sognefjorden"
http://media.aronov.su/tools/metadata.php [^] show for it file:
2#005 = Ñîãíå-ôüîðä
2#025 = Sognefjorden,Íîðâåãèÿ,Ñîãíå-ôüîðä
2#080 = Leonid Aronov
2#092 = Norway, Sognefjorden
2#101 = Norway
2#116 = Leonid Aronov
No tags attached.
jpg IPTC_test.jpg (88,285) 2015.03.19 18:19
http://piwigo.org/bugs/file_download.php?file_id=214&type=bug
jpg

? functions_metadata.inc.php (9,392) 2015.03.19 18:50
http://piwigo.org/bugs/file_download.php?file_id=215&type=bug
? functions_metadata.inc.php.1426854766 (9,990) 2015.03.20 13:34
http://piwigo.org/bugs/file_download.php?file_id=216&type=bug
Issue History
2015.03.19 18:19xbgmsharpNew Issue
2015.03.19 18:19xbgmsharpFile Added: IPTC_test.jpg
2015.03.19 18:20xbgmsharpNote Added: 0007788
2015.03.19 18:49xbgmsharpNote Added: 0007789
2015.03.19 18:50xbgmsharpFile Added: functions_metadata.inc.php
2015.03.19 18:50xbgmsharpNote Edited: 0007789bug_revision_view_page.php?bugnote_id=7789#r4
2015.03.20 13:34xbgmsharpFile Added: functions_metadata.inc.php.1426854766
2015.03.20 13:41xbgmsharpNote Edited: 0007789bug_revision_view_page.php?bugnote_id=7789#r5

Notes
(0007788)
xbgmsharp   
2015.03.19 18:20   
A working PoC.

Install curl module for PHP
Code:
# apt-get install php5-curl

Add in you configuration the following parameters:
Code:
$conf['show_iptc'] = true;
$conf['use_iptc'] = true;
$conf['iptc_to_gps'] = true;
$conf['show_iptc_mapping'] = array(
  'iptc_keywords' => '2#025',
  'iptc_caption_writer' => '2#122',
  'iptc_byline_title' => '2#085',
  'iptc_caption' => '2#120',
  'iptc_country' => '2#101',
  'iptc_countrycode' => '2#100',
  'iptc_state' => '2#095',
  'iptc_sublocation' => '2#092',
  'iptc_city' => '2#090',
  );

Replace the file /include/functions_metadata.inc.php by the one attach.

When you sync metadata, it will populate the latitude and longitude with the data from http://nominatim.openstreetmap.org [^] if any.
(0007789)
xbgmsharp   
2015.03.19 18:49   
(edited on: 2015.03.20 13:41)
The code does the following:

* Check for $conf['iptc_to_gps'] to be true.
* Check for any of the location IPTC metadata are present
* If any run a CURL query to nominatim.openstreetmap.org
* If any reply, check for lat and lon.
* If any valid lat and lon return it an array to be sync in the database.