It's quite easy setting the GPS coordinates using the GPSLatitude and GPSLatitude properties Assign method, but reading the coords has me stumped. I've trying to access the TGPSLongitude class, but none of the properties or methods would render me a real / float or even DMS of the coordinates.
Sample image: http://www.cde.co.za/share/IMG_5889.JPG
My current code that's not compiling:
imgJpg: TJpegImageEx;
GPS_D: Real;
try
imgJpg.LoadFromFile(FolderName+'\'+SR.Name);
GPS_D:= imgJpg.ExifData.GPSLatitude.Degrees;
except
GPS_D:= 0;
end;
The compiler stops at where I try to assign GPS_D with the error "[DCC Error] Main.pas(205): E2010 Incompatible types: 'Real' and 'TTiffLongWordFraction'" This is obviously because I can't assign the Degrees property to a real. The question is how do I extract the degrees or decimal value from TGPSLongitude ?
From the documentation existing inside the CCRExif 1.5.1 -
Looking inside of the source code lean to:
and the declaration of the TGPSCoordinate class has in the public section
Also, there are several demo applications inside the zip file.
LE: After reading the comments, I took a look again at the demos, and in the ExifList demo you have in ExifListFrame.pas the following code:
Looking in depth at the source, it seems one can use the "Quotient" property. In stead of storing the decimal float, the developer chose to store the components Numerator, Denominator and Quotient.
I don't think it's how it's meant to be used, but it's working! Thanks for everyone's time.
So, to read the GPS Coordinates from a JPG file using CCR.EXIF, I do the following:
lat now contains the latitude. Same can be done for long of course.
Easy way to extract GPS information as a
string
: