Hi Patrick
I have a unit to handle all my EXIF tasks. Here are the relevant GPS ones:
function DegreesMinutesSecondsToDecimal(dDeg, dMin, dSec: Double): Extended;
begin
Result := dDeg + (dMin / 60) + (dSec / 3600);
end;
function GPSAsDecimal(const dGPSDegrees, dGPSMinutes, dGPSSeconds: Double; const sGPSReference: string): Extended;
begin
Result := DegreesMinutesSecondsToDecimal(dGPSDegrees, dGPSMinutes, dGPSSeconds);
if SameText(RemoveNull(sGPSReference), 'S') or
SameText(RemoveNull(sGPSReference), 'W') then
Result := -1 * Result;
end;
function GPSLatitudeDecimal(AParams: TIOParams): Extended;
begin
with AParams do
Result := GPSAsDecimal(EXIF_GPSLatitudeDegrees, EXIF_GPSLatitudeMinutes, EXIF_GPSLatitudeSeconds, EXIF_GPSLatitudeRef);
end;
function GPSLongitudeDecimal(AParams: TIOParams): Extended;
begin
with AParams do
Result := GPSAsDecimal(EXIF_GPSLongitudeDegrees, EXIF_GPSLongitudeMinutes, EXIF_GPSLongitudeSeconds, EXIF_GPSLongitudeRef);
end;
function HasExifGPSData(AParams: TIOParams): Extended;
begin
Result := (GPSLatitudeDecimal(AParams) <> 0) or
(GPSLongitudeDecimal(AParams) <> 0)
end;
// return the GPS fields from the exif fields
function ExifGPSData(sFilename: string;
AnImageEnIO:TImageENIO;
out xGPSLatitudeDegrees: Extended;
out xGPSLongitudeDegrees: Extended
): Boolean;
begin
result := False;
xGPSLatitudeDegrees := 0;
xGPSLongitudeDegrees := 0;
if IsJPEG(sFilename, TRUE) then
try
// use get params from file to fill the _ImageEnIO with the EXIF data
AnImageEnIO.paramsfromfile(sFilename);
if AnImageEnIO.params.EXIF_HasEXIFData then
begin
xGPSLatitudeDegrees := GPSLatitudeDecimal(AnImageEnIO.Params);
xGPSLongitudeDegrees := GPSLongitudeDecimal(AnImageEnIO.Params);
end;
Result := (xGPSLatitudeDegrees <> 0) or (xGPSLongitudeDegrees <> 0);
except
// ERROR
end;
end;
Nigel
Xequte Software
www.xequte.com
nigel@xequte.com