Skip to content

Use local database for geolocation #467

@jmathai

Description

@jmathai

Use Exiftool's built-in Geolocation API to look up location names for media based on their EXIF data.

Geolocation lookup is currently using the MapQuest API and the logic is contained in geolocation.py.

Application behavior

  • Refer to this documentation for Exiftool's Geolocation API.
  • Use MapQuest for Geolocation if a MapQuest key is configured in a config.ini file.
  • If no MapQuest key is specified, use exiftool for geolocation lookup if it's supported by the version installed.
  • Choose the Geolocation returned by Exiftool in this order: City, Region, Subregion, Country.
  • Default to "Unknown Location" if no Geolocation values are returned by Exiftool.
  • Updating EXIF on media using the update command should look up location names using the -listgeo option of the Exiftool Geolocation API

Unit tests

  • Write tests for using Exiftool's Geolocation API similar to what exists in tests/geolocation_test.py
  • Write tests for using Exiftool's Geolocation API similar to the location tests which exist in [tests/media/*.py].
  • Hard code coordinates and location names for new tests to reflect what Exiftool's Geolocation API supports.
  • Make it easy to remove support for MapQuest API in the future.

Listing geolocation of a photo

Searching for coordinates by location name

Example output from using -api geolocation= with multiple matches.

# exiftool -api geolocation=Sunnyvale         
Warning: [Minor] Multiple Geolocation cities are possible -  

Example output from using -api geolocation= with single match.

# exiftool -api geolocation=Sunnyvale,California
Geolocation City                : Sunnyvale
Geolocation Region              : California
Geolocation Subregion           : Santa Clara County
Geolocation Country Code        : US
Geolocation Country             : United States
Geolocation Time Zone           : America/Los_Angeles
Geolocation Feature Code        : PPL
Geolocation Feature Type        : Populated Place
Geolocation Population          : 160000
Geolocation Position            : 37.3688, -122.0365

Example output from -listgeo which lists all entries in database.

# exiftool -listgeo | head -n 5
Geolocation database:
City,Region,Subregion,CountryCode,Country,TimeZone,FeatureCode,Population,Latitude,Longitude
Puerto Williams,Region of Magallanes,Provincia Antártica Chilena,CL,Chile,America/Santiago,PPLA2,2000,-54.9335,-67.6095
Ushuaia,Tierra del Fuego,Departamento de Ushuaia,AR,Argentina,America/Argentina/Ushuaia,PPLA,57000,-54.8108,-68.3161
Tolhuin,Tierra del Fuego,Tolhuin,AR,Argentina,America/Argentina/Ushuaia,PPLA2,3000,-54.5109,-67.1955

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions