Page 1 of 2

CC snippet - EXIF GPS coordinates

Posted: 22 Mar 2018 12:13
by highend
How to set up a custom column with a snippet: viewtopic.php?f=7&t=18653

This one displays the EXIF GPS coordinates of all .jpg and .tiff files in a folder in a custom column.

It does not require external tools like exiv2 (http://www.exiv2.org/index.html)

The snippet code:

Code: Select all

Snip: CustomColumn 1
  XYplorer 26.50.0004, 10.10.2024 09:45:38
Action
  ConfigureColumn
Caption
  GPS
Type
  3
Definition
      $latitude  = get("exif", 0x0002, <cc_item>); // 52/1 13/1 85053/2500  => 52° 13' 34.02"N => 52.2261166667
      $longitude = get("exif", 0x0004, <cc_item>); // 13/1 13/1 134931/2500 => 13° 13' 53.97"E => 13.2316583333
      if ($latitude == "" || $longitude == "") { return "<no gps coordinates>"; }
  
      $latRef      = get("exif", 0x0001, <cc_item>); // N / S
      $longRef     = get("exif", 0x0003, <cc_item>); // W / E
      $latDegree   = gettoken(gettoken($latitude, 1), 1, "/");
      $latMinutes  = gettoken(gettoken($latitude, 2), 1, "/");
      $latSeconds  = replace(round(eval(gettoken($latitude, 3)), 2), ",", ".");
      $longDegree  = gettoken(gettoken($longitude, 1), 1, "/");
      $longMinutes = gettoken(gettoken($longitude, 2), 1, "/");
      $longSeconds = replace(round(eval(gettoken($longitude, 3)), 2), ",", ".");
  
      return $latDegree . "° " . $latMinutes . "' " . $latSeconds . '"' . $latRef . "  ". $longDegree . "° " . $longMinutes . "' " . $longSeconds . '"' . $longRef;
Format
  0
Trigger
  0
Item Type
  0
Item Filter
  jpg;tiff
It looks like this:
cc_setup.png
cc_setup.png (16.72 KiB) Viewed 4969 times

Re: CC snippet - EXIF GPS coordinates

Posted: 15 Mar 2019 15:35
by Alan_CLarke59
Hi All,
This function is exactly what I need, however, I can't get it to work.
I am following the instructions correctly I believe, but no success.

This is the exif data from my picture:
Image

Can anyone help please?


Regards,

Alan C

Re: CC snippet - EXIF GPS coordinates

Posted: 15 Mar 2019 16:19
by highend
There is no image...

Re: CC snippet - EXIF GPS coordinates

Posted: 15 Mar 2019 16:41
by admin
Strange, but you can right-click the word "Image" to show the image... :?

Re: CC snippet - EXIF GPS coordinates

Posted: 15 Mar 2019 16:49
by highend
Mh, not here. Regardless of any exif data, what exactly does the custom column show? Provide a picture^^

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 00:36
by Mr_Inc
Holy thread resurrection.......!

I stumbled across this suggestion for a Custom Column and got it to work nicely as described (with a couple of formatting amendments in the script to make it Google Maps URL friendly).

Image

How could this GPS column/data be made to open Google maps and append the GPS 'data' in the column to this URL https://www.google.com/maps/place/ and make it a clickable link to open in a browser?

I am not sure if it can be done in the Custom Column itself or whether a TAG needs to be generated using the data in the GPS column.

Any ideas would be welcome!

Thanks.

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 09:40
by highend
You can't do this in the same column but you could add another one with a Trigger set to "Click" (which adds a button) to it.

Clicking that button would then execute a script that gets a report() from the current pane and then you have to parse it, dissect the content of your GPS column, calculate the decimal degrees value, construct the url for google maps and open it.

Easily done but it requires scripting knowledge^^

As a starting point to get the correct content of the belonging custom column when clicking the button:

Code: Select all

    $report = report("{FullName}|{GPS}<crlf>");
    $esc    = regexreplace(<cc_item>, "([\\^$.+()\[{])", "\$1");
    $gps    = regexmatches($report, "^" . $esc . "\|.*?$", , 1);
    $gps    = gettoken($gps, 2, "|");
    open "https://www.google.com/maps/place/" . $gps;
Btw, I've updated the snippet in the first post to look more like this:

Code: Select all

52° 13' 34.02"N  13° 13' 53.97"E

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 16:38
by Mr_Inc
Thanks for the reply.

Google Maps can accept locations directly in Degrees Minutes and Seconds format without resorting to converting to decimal.

So I just replaced the last line with:

Code: Select all

open 'https://www.google.com/maps/place/'.$gps;
and it worked a treat! Yay!

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 16:54
by admin
Cool. :tup:

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 21:30
by phred
Thanks to highend for the original snippet and tip to get a button to paste/open the coordinates. And to Mr_Lee for the modification to get it to open in Google Maps.

I now have saved both both columns in a column layout, which I can load whenever I'm in a directory of photos. There is one further enhancement I'd like to add but I haven't found how to accomplish it when searching through the massive PDF user manual. Is there a way to add this specific column layout to a toolbar button?

Thanks.

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 21:43
by highend
columnlayout()...

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 22:15
by phred
Thanks highend.

I've now been able to find it in the user manual. Following what you showed, I've got the Columns directory opening on a click of the button. Now I'm trying to simply one the column layout I've created for the coordinates and map button.

Per the user manual, I should be entering

Code: Select all

columnlayout(file, [mode="load"])
When I enter

Code: Select all

columnlayout(D:\Utilities\XYplorer\Columns\gps + map location.txt)
the script crashes with an overflow error. I also tried

Code: Select all

columnlayout(D:\Utilities\XYplorer\Columns\gps + map location.txt, "load");
with the same overflow error.

Would you kindly show me what I'm doing wrong?

Thanks again.

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 23:01
by highend
Quote your paths? oO

Save the layout while you're showing the GPS + button column:

Code: Select all

columnlayout("D:\Utilities\XYplorer\Columns\gps + map location.txt", "save");
And then, whenever you need it elsewhere, load it:

Code: Select all

columnlayout("D:\Utilities\XYplorer\Columns\gps + map location.txt");

Re: CC snippet - EXIF GPS coordinates

Posted: 10 Oct 2024 23:34
by phred
highend wrote: 10 Oct 2024 23:01 Quote your paths? oO
So simple! I'm embarrassed to admit I should've tried that before posting.
And I've got the Save and Load under control.

Thanks again, highend.

Re: CC snippet - EXIF GPS coordinates

Posted: 11 Oct 2024 20:50
by admin
The next beta will make that column definition a lot simpler:

Code: Select all

return get("exif", "gps", <cc_item>);
:)