Patch #1233

Bugfixes in samples/geotag.cpp

Added by Anton Keks 12 months ago. Updated 5 months ago.

Status:ClosedStart date:26 Sep 2016
Priority:NormalDue date:
Assignee:Robin Mills% Done:

100%

Category:samplesEstimated time:6.00 hours
Target version:0.26

Description

I have found a fixed a couple of bugs in geotag.cpp sample, here is the diff:

$ diff geotag-orig.cpp geotag.cpp
352c352
< if ( me->bEle && len > 5 ) {
---

if ( me->bEle && len > 2 ) {

405a406

T.tm_isdst = -1 ; // determine value automatically (otherwise hour may shift)

855c856
< printf("tz,dsl,adjust = %d,%d,%d total = %dsecs (= %d:%d:%d)\n",t,d,a,A,h,m,s);
---

printf("tz,dst,adjust = %d,%d,%d total = %dsecs (= %d:%d:%d)\n",t,d,a,A,h,m,s);

1. First change fixes parsing of shorter elevations, e.g. '25.0', which is only four chars.
2. Second change makes sure times are parsed correctly our of GPX file if DST is currently active (passing tm_isdst==0 to mktime adjusts time by +1 hour, at least on Linux, probably because it thinks it needs to assume timezone of GMT plus DST)
3. Third change was just a typo

geotag.cpp Magnifier (28.6 KB) Anton Keks, 26 Sep 2016 21:29

MissionPeak.zip (2.02 MB) Robin Mills, 07 May 2017 19:20

Associated revisions

Revision 4568
Added by Robin Mills 12 months ago

#1233 Thank You to Anton for reporting this and providing a patch. I've updated the test suite.

Revision 4569
Added by Robin Mills 12 months ago

#1233 Changes to geotag-test to avoid full paths. Added make geotag-test. Sanitized geotag.cpp code

Revision 4571
Added by Robin Mills 12 months ago

#1233 geotag.cpp added option -ascii. The degree sign in the output was upsetting test harness on some platforms.

Revision 4572
Added by Robin Mills 12 months ago

#1233 Fixes for the test suite on msvc.

Revision 4573
Added by Robin Mills 12 months ago

#1233 Fixed issue on MacOS-X 10.4 (32 big big-endian PPC, 2003 OS) with realpath() and added additional images for future testing.

Revision 4574
Added by Robin Mills 12 months ago

#1233 Correction to r4573

History

#1 Updated by Robin Mills 12 months ago

  • Category set to samples
  • Status changed from New to Assigned
  • Assignee set to Robin Mills
  • Target version set to 0.26

Anton

Thanks for reporting this and providing changes. Can you attach your copy of geotag.cpp and I'll submit to the repository.

I wrote that sample in 2012 and I never finished it. I've been so busy with other matters, that I have never got round to working on it again. If you'd like to work on a little test script for geotag, I'd be delight to accept your contribution! I can mentor you about writing test scripts - it's painless.

Robin

#2 Updated by Anton Keks 12 months ago

Thanks for the quick response!
Here is my copy.

#3 Updated by Robin Mills 12 months ago

  • Tracker changed from Bug to Patch
  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100
  • Estimated time set to 2.00

Anton: Thank You for reporting this and providing a patch. I've submitted your code and added a simple test script. r4568

I'm sure there are subtle things wrong with this such as handling of time-zones. Anyway, it worked first time on some GPX/JPG data I have from a trip to Death Valley California in 2008. If you find issue with this, please provide your GPX and images. We can extract the .exv metadata from your images to keep down the size of the test suite - and it's useful to chop irrelevant data from the GPX. For example, my GPX was 1.5mb which I chopped to 6k.

#4 Updated by Robin Mills 12 months ago

  • Estimated time changed from 2.00 to 6.00

This is taken up more time that expected. However the code is now being tested. And I discovered an interesting bug on MacOS-X 10.4 (testing is a good thing!). I still feel this can be best described as "experimental - use at your own risk". I now have a camera with a built-in GPS (Nikon 5300), so I don't have a reason to use this.

#5 Updated by Robin Mills 5 months ago

Tobias Jakobs wrote to me on 2017-04-29 about an article on clanmills.com

Hello Robin,

I found your article about GPS Exif Tags:
http://clanmills.com/articles/gpsexiftags/

Sadly I had some problems with the links in the article.
1. The link to http://tilloy.net/dev/pyexiv2/ goes to http://www.exiv2.org/
2. http://picasaweb.google.com/robinwmills/GPSTesting shows a 404
3. http://tilloy.net/dev/pyexiv2/developers.htm is a 404
4. http://jbrout.python-hosting.com/ does no longer exist

Perhaps you can update the article or write a new one, how you use
GPS data in images.

Kind regards,
Tobias
I rewrote the article and referred him to using geotag(.exe) in Exiv2 v0.26. I did some testing and discovered it's a little buggy. The issue is with the cache code. You can only use the shipping version on one file at a time. The work around is:
$ for i in *.jpg; do exiv2 -M'set ..GPS...' $i *.gpx; done

I've fixed the bug and submitted the fix to GitHub.

628 rmills@rmillsmbp:~/Pictures/2012/MissionPeak $ for tag in $(exiv2 -Pk -g GPS IMG_0199.jpg); do exiv2 -M"del $tag" *.jpg; done 
629 rmills@rmillsmbp:~/Pictures/2012/MissionPeak $ ./geotag -verbose -tz -8:00 *
IMG_0176.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0176.jpg 1339021084 Wed Jun  6 23:18:04 2012
IMG_0177.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0177.jpg 1339021088 Wed Jun  6 23:18:08 2012
IMG_0178.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0178.jpg 1339021340 Wed Jun  6 23:22:20 2012
IMG_0179.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0179.jpg 1339021344 Wed Jun  6 23:22:24 2012
IMG_0180.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0180.jpg 1339021501 Wed Jun  6 23:25:01 2012
IMG_0181.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0181.jpg 1339022017 Wed Jun  6 23:33:37 2012
IMG_0182.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0182.jpg 1339022070 Wed Jun  6 23:34:30 2012
IMG_0183.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0183.jpg 1339022301 Wed Jun  6 23:38:21 2012
IMG_0184.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0184.jpg 1339022527 Wed Jun  6 23:42:07 2012
IMG_0185.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0185.jpg 1339022820 Wed Jun  6 23:47:00 2012
IMG_0186.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0186.jpg 1339023215 Wed Jun  6 23:53:35 2012
IMG_0187.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0187.jpg 1339023407 Wed Jun  6 23:56:47 2012
IMG_0188.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0188.jpg 1339023544 Wed Jun  6 23:59:04 2012
IMG_0189.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0189.jpg 1339023569 Wed Jun  6 23:59:29 2012
IMG_0190.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0190.jpg 1339024776 Thu Jun  7 00:19:36 2012
IMG_0191.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0191.jpg 1339025004 Thu Jun  7 00:23:24 2012
IMG_0192.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0192.jpg 1339025103 Thu Jun  7 00:25:03 2012
IMG_0193.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0193.jpg 1339025142 Thu Jun  7 00:25:42 2012
IMG_0194.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0194.jpg 1339025155 Thu Jun  7 00:25:55 2012
IMG_0195.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0195.jpg 1339025298 Thu Jun  7 00:28:18 2012
IMG_0196.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0196.jpg 1339025338 Thu Jun  7 00:28:58 2012
IMG_0197.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0197.jpg 1339026307 Thu Jun  7 00:45:07 2012
IMG_0198.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0198.jpg 1339026971 Thu Jun  7 00:56:11 2012
IMG_0199.jpg image /Users/rmills/Pictures/2012/MissionPeak/IMG_0199.jpg 1339027018 Thu Jun  7 00:56:58 2012
trkseg 2012-05-19 02:21:37 begin 2012-05-19 14:40:59 end
2012-05-20 18:35:26 end
2012-06-02 17:58:27 end
2012-06-07 00:57:55 end
MissionPeak.gpx xml geotag file tz,dst,adjust = -28800,0,0 total = -28800secs (= -8:0:0)
/Users/rmills/Pictures/2012/MissionPeak/IMG_0176.jpg 121°53'21"W 037°30'51"N 530.785  -1
/Users/rmills/Pictures/2012/MissionPeak/IMG_0177.jpg 121°53'21"W 037°30'50"N 531.746   3
/Users/rmills/Pictures/2012/MissionPeak/IMG_0178.jpg 121°53'15"W 037°30'51"N 550.973  -4
/Users/rmills/Pictures/2012/MissionPeak/IMG_0179.jpg 121°53'15"W 037°30'51"N 552.415   1
/Users/rmills/Pictures/2012/MissionPeak/IMG_0180.jpg 121°53'17"W 037°30'56"N 580.774  -2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0181.jpg 121°53'16"W 037°31'00"N 595.193   2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0182.jpg 121°53'14"W 037°31'00"N 605.287   2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0183.jpg 121°53'09"W 037°31'00"N 640.856   2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0184.jpg 121°53'05"W 037°30'58"N 662.005  -1
/Users/rmills/Pictures/2012/MissionPeak/IMG_0185.jpg 121°53'01"W 037°30'50"N 703.342  -1
/Users/rmills/Pictures/2012/MissionPeak/IMG_0186.jpg 121°52'56"W 037°30'48"N 724.971  -1
/Users/rmills/Pictures/2012/MissionPeak/IMG_0187.jpg 121°52'53"W 037°30'46"N 761.021   2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0188.jpg 121°52'53"W 037°30'45"N 756.214  -2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0189.jpg 121°52'53"W 037°30'45"N 752.850   4
/Users/rmills/Pictures/2012/MissionPeak/IMG_0190.jpg 121°53'27"W 037°30'53"N 525.498  -2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0191.jpg 121°53'29"W 037°30'48"N 489.448  -1
/Users/rmills/Pictures/2012/MissionPeak/IMG_0192.jpg 121°53'29"W 037°30'46"N 467.338   2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0193.jpg 121°53'31"W 037°30'46"N 458.686   2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0194.jpg 121°53'32"W 037°30'46"N 456.283  -2
/Users/rmills/Pictures/2012/MissionPeak/IMG_0195.jpg 121°53'35"W 037°30'43"N 421.195  -3
/Users/rmills/Pictures/2012/MissionPeak/IMG_0196.jpg 121°53'37"W 037°30'43"N 408.698  -5
/Users/rmills/Pictures/2012/MissionPeak/IMG_0197.jpg 121°54'05"W 037°30'23"N 177.981   0
/Users/rmills/Pictures/2012/MissionPeak/IMG_0198.jpg 121°54'31"W 037°30'15"N 112.612  -1
/Users/rmills/Pictures/2012/MissionPeak/IMG_0199.jpg 121°54'31"W 037°30'15"N 121.744   1
630 rmills@rmillsmbp:~/Pictures/2012/MissionPeak $ exiv2 -Pk -g GPS IMG_0199.jpg
Exif.Image.GPSTag                           
Exif.GPSInfo.GPSVersionID                   
Exif.GPSInfo.GPSLatitudeRef                 
Exif.GPSInfo.GPSLatitude                    
Exif.GPSInfo.GPSLongitudeRef                
Exif.GPSInfo.GPSLongitude                   
Exif.GPSInfo.GPSAltitudeRef                 
Exif.GPSInfo.GPSAltitude                    
Exif.GPSInfo.GPSTimeStamp                   
Exif.GPSInfo.GPSMapDatum                    
Exif.GPSInfo.GPSProcessingMethod            
Exif.GPSInfo.GPSDateStamp                   
631 rmills@rmillsmbp:~/Pictures/2012/MissionPeak $ for tag in $(exiv2 -Pk -g GPS IMG_0199.jpg); do exiv2 -M"del $tag" *.jpg; done 
632 rmills@rmillsmbp:~/Pictures/2012/MissionPeak $ 
632 rmills@rmillsmbp:~/Pictures/2012/MissionPeak $
I attach the test directory.

Also available in: Atom PDF

Redmine Appliance - Powered by TurnKey Linux