Author Topic: GPS-coordinate bug  (Read 6907 times)

Offline Johnny Johansson

  • Newcomer
  • *
  • Posts: 22
    • View Profile
GPS-coordinate bug
« on: July 17, 2007, 09:33:33 AM »
I have downloaded PM 4.5.2 beta 3 for testing and one of the things I am excited about in this release is the possibility to see on a map where an image was taken (based on GPS coordinates).

When testing this, I have however discovered a bug in the handling of GPS coordinates in PM:

The GPS coordinates for the attached image are N 57°35'22,8" E 11°54'44,6". These are as given by Nikon Capture NX and I have verified them to be correct with several online map services.

In PM however, the lattitude is different and looking really strange with a part being negative. On the map, a slightly different coordinate is used and the location indicated on the map is *not* correct.



I am not sure if this is relevant, but when uploading this image to www.flickr.com, it will be placed at the same incorrect position on the map.

[attachment deleted by admin]

Offline dennis

  • President
  • Camera Bits Staff
  • Sr. Member
  • *****
  • Posts: 456
    • View Profile
    • Camera Bits, Inc.
Re: GPS-coordinate bug
« Reply #1 on: July 18, 2007, 01:55:31 PM »
Hi Johnny,

Thanks for the heads-up on this bug.  It looks like this is due to the GPS coordinates being formatted in a way that causes the PM to read the "rational" numerator/denominator value to be negative.  The GPS coordinates are stored internally as "rational" values which is a numerator / denominator.  In this case, the denominator for seconds is 100,000,000  :o (quite large considering that the actual precision is much smaller).  So in order to get a lattitude seconds as 22.764 the numerator needs to be 2,276,400,000 (or thereabouts), and this number will appear negative if treated as a signed 32 bit value instead of an unsigned 32 bit value.

I've fixed this and now this photo puts you North in the bay on Stora Amundö, right?

But my question to you is what kind of GPS did you use for this?  It is a bit silly to have 100 million as a denominator (i.e. 8 digits of precision for seconds).  I'm not sure what the limit is here on precision (non-US military) but the actual numerator for this photo is 2,276,399,999 which suggests that the GPS only has 5 digits of precision for seconds.

It may also be that Nikon Capture NX is (re)writing this GPS data.  Do you get the same results looking at the original file (before processing with Capture NX)?

--dennis

Offline Johnny Johansson

  • Newcomer
  • *
  • Posts: 22
    • View Profile
Re: GPS-coordinate bug
« Reply #2 on: July 18, 2007, 03:10:34 PM »
I've fixed this and now this photo puts you North in the bay on Stora Amundö, right?

Hi Dennis!
Yes that sounds right!

I am using a Globalsat BR-355 GPS unit which is connected to a Nikon MC-35 adapter which is connected to my Nikon D2X. GPS coordinates are embedded when the images are taken, so the data you have in that image is as original as it can be (the JPG was created by Capture NX, but the same problem existed with the original NEF, so I am sure the GPS data was copied unaltered from the NEF to the JPG).

But anyway, it is great that this is now fixed. Thanks!

// Johnny

Offline IanGoldstein

  • Member
  • **
  • Posts: 98
    • View Profile
Re: GPS-coordinate bug
« Reply #3 on: July 18, 2007, 06:27:33 PM »
Dennis,

I just picked up an N2 di-GPS mini  from Dawn Technology Limited (www.di-gps.com) and can see this "bug" as well.  If I select "Show Map..." what is interesting is that it does appear to pull up the correct location on the map with the marker correctly positioned, but the displayed coordinates are incorrect in the caption. Here's are the various coordinates from a sample image...

  PM Show Map Caption = +41°4'15.01", -72°8'34.79"
  PM {latitude} and {longitude} vars = N41°04.250', W71°51.420'
  Capture NX = N 41°4'15.0", W 71°51'25.2"
  Exiftool = 41°4'15.00" N, 71°51'25.20" W

So it would seem that PM is extracting the correct latitude and longitude as demonstrated by both the {latitude} & {longitude} variables and the fact that the show map window does appear to select the correct location. Also, these coordinates match with Capture NX and Exiftool, as well as what appears to be more or less the correct location when I looked at it with Google Earth.

FWIW, this was all based on an original NEF file.

-Ian

Offline dennis

  • President
  • Camera Bits Staff
  • Sr. Member
  • *****
  • Posts: 456
    • View Profile
    • Camera Bits, Inc.
Re: GPS-coordinate bug
« Reply #4 on: July 19, 2007, 11:18:42 PM »
If I select "Show Map..." what is interesting is that it does appear to pull up the correct location on the map with the marker correctly positioned, but the displayed coordinates are incorrect in the caption.
  PM Show Map Caption = +41°4'15.01", -72°8'34.79"

Hi Ian,

Well I guess you found another "bug" - but this time it was due to our server's interface to Google Maps.  When you request a map with the Show Map command, PM contacts Google maps via our server, and it is that interface that did some bad geo-math when it tried to report the GPS coordinates.  Although the map would correctly position the location of the photo, the reported coordinates would be wrong if the latitude was South or the longitude was West since these are handled as negative coordinates.  The coordinates reported would be off by a degree or so.  The good news is that this bug is fixed on our server and so there is no need for an update to PM!

And I think we should change the formatting of this to just use 'N' for positive latitude, 'S' for negative latitude, 'E' for positive longitude, and 'W' for negative longitude so that it matches our {glat} and {glon} variables.  Easy fix.  (Although I can already hear people yelling "variables for map captions!"...)

--dennis

Offline IanGoldstein

  • Member
  • **
  • Posts: 98
    • View Profile
Re: GPS-coordinate bug
« Reply #5 on: July 20, 2007, 06:32:44 AM »
Although the map would correctly position the location of the photo, the reported coordinates would be wrong if the latitude was South or the longitude was West since these are handled as negative coordinates.  The coordinates reported would be off by a degree or so.  The good news is that this bug is fixed on our server and so there is no need for an update to PM!

That's great. As always, you guys seem to fix bugs and make improvements faster than anyone else.

Quote from: dennis
And I think we should change the formatting of this to just use 'N' for positive latitude, 'S' for negative latitude, 'E' for positive longitude, and 'W' for negative longitude so that it matches our {glat} and {glon} variables.  Easy fix.  (Although I can already hear people yelling "variables for map captions!"...)

Funny you should mention this. I actually posted a separate message about it under Feature Requests (http://forums.camerabits.com/index.php?topic=1873.0). The N/S and E/W references is one of the items I had suggested. Any thoughts on the other items in that post?

-Ian

Offline dennis

  • President
  • Camera Bits Staff
  • Sr. Member
  • *****
  • Posts: 456
    • View Profile
    • Camera Bits, Inc.
Re: GPS-coordinate bug
« Reply #6 on: July 21, 2007, 11:52:49 AM »
Ian,

I responded to your post on the Feature Requests section.  Good points.

--dennis