2

I am trying to parse a Nikon RAW file using LibRAW library. The library gives me a 32 byte int array of GPS Data. I have been unable to find any documentation that explains how to interpret this 32 x int array.

Here is an example GPS Data I extracted -

GPS:32
GPS:1
GPS:112393
GPS:10000
GPS:0
GPS:1
GPS:104
GPS:1
GPS:253126
GPS:10000
GPS:0
GPS:1
GPS:18
GPS:1
GPS:35
GPS:1
GPS:4800
GPS:100
GPS:1204
GPS:1
GPS:538976288
GPS:538976288
GPS:32
GPS:875638834
GPS:976302138
GPS:13361
GPS:0
GPS:0
GPS:0
GPS:78
GPS:87
GPS:0
2
  • Does this help?
    – Rik
    Commented Jan 27, 2014 at 8:32
  • No :-(. While useful, it does not help me parse the unsigned int [32] that I am dealing with.
    – Lord Loh.
    Commented Jan 27, 2014 at 18:37

1 Answer 1

1

Well... i couldn't find any documentation about the unsigned int [32] for gpsdata.

I did find some snippet of code here from the LibRAW source.
Look at the parse_gps. This code parses the Exif information to the gpsdata[32] array.

#define FORC(cnt) for (c=0; c < cnt; c++)
...
void CLASS parse_gps (int base)
{
  unsigned entries, tag, type, len, save, c;

  entries = get2();
  while (entries--) {
    tiff_get (base, &tag, &type, &len, &save);
    switch (tag) {
      case 1: case 3: case 5:
        gpsdata[29+tag/2] = getc(ifp);            break;
      case 2: case 4: case 7:
        FORC(6) gpsdata[tag/3*6+c] = get4();      break;
      case 6:
        FORC(2) gpsdata[18+c] = get4();           break;
      case 18: case 29:
        fgets ((char *) (gpsdata+14+tag/3), MIN(len,12), ifp);
    }
    fseek (ifp, save, SEEK_SET);
  }
}

Forgive my lack of C++ knowledge... but with the help of this source i found that

GPSLatitudeRef  = gpsdata[29+1/2]  (Exif tag 0x0001) = [29]  1 char
GPSLongitudeRef = gpsdata[29+3/2]  (Exif tag 0x0003) = [30]  1 char
GPSAltitudeRef  = gpsdata[29+5/2]  (Exif tag 0x0005) = [31]  1 char

GPSLatitude     = gpsdata[2/3*6+c] (Exif tag 0x0002) = [ 0]  6 int
GPSLongitude    = gpsdata[4/3*6+c] (Exif tag 0x0004) = [ 6]  6 int
GPSTimeStamp    = gpsdata[7/3*6+c] (Exif tag 0x0007) = [12]  6 int

GPSAltitude     = gpsdata[18+c]    (Exif tag 0x0006) = [18]  2 int
GPSMapDatum     = gpsdata+14+18/3  (Exif tag 0x0012) = [20]  3 int
GPSDateStamp    = gpsdata+14+29/3  (Exif tag 0x001d) = [23]  3 int

In your case this would translate in:

00 GPS:32           GPSLatitude  #1
01 GPS:1                         #2
02 GPS:112393                    #3
03 GPS:10000                     #4
04 GPS:0                         #5
05 GPS:1                         #6
06 GPS:104          GPSLongitude #1
07 GPS:1                         #2
08 GPS:253126                    #3
09 GPS:10000                     #4
10 GPS:0                         #5
11 GPS:1                         #6
12 GPS:18           GPSTimeStamp #1
13 GPS:1                         #2
14 GPS:35                        #3
15 GPS:1                         #4
16 GPS:4800                      #5
17 GPS:100                       #6
18 GPS:1204         GPSAltitude  #1
19 GPS:1                         #2
20 GPS:538976288    GPSMapDatum  #1
21 GPS:538976288                 #2
22 GPS:32                        #3
23 GPS:875638834    GPSDateStamp #1
24 GPS:976302138                 #2
25 GPS:13361                     #3
26 GPS:0
27 GPS:0
28 GPS:0
29 GPS:78    N      GPSLatitudeRef
30 GPS:87    W      GPSLongitudeRef
31 GPS:0     ?      GPSAltitudeRef

This is just done by some digging in the source-code so forgive any mistakes...

I hope this will get you a bit further.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .