You've already forked lazarus-ccr
fpexif: combine value and unit field of some GPS tags to direct Exifdata properties. Issue #38423.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7968 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -59,11 +59,13 @@ type
|
|||||||
function GetImgHeight: Integer;
|
function GetImgHeight: Integer;
|
||||||
function GetImgWidth: Integer;
|
function GetImgWidth: Integer;
|
||||||
function GetOrientation: TExifOrientation;
|
function GetOrientation: TExifOrientation;
|
||||||
|
function GetGPSPosition(AKind: Integer): double;
|
||||||
function GetTagByID(ATagID: TTagID): TTag;
|
function GetTagByID(ATagID: TTagID): TTag;
|
||||||
function GetTagByIndex(AIndex: Integer): TTag;
|
function GetTagByIndex(AIndex: Integer): TTag;
|
||||||
function GetTagByName(AFullTagName: String): TTag;
|
function GetTagByName(AFullTagName: String): TTag;
|
||||||
function GetTagCount: Integer;
|
function GetTagCount: Integer;
|
||||||
procedure SetExportOptions(const AValue: TExportOptions);
|
procedure SetExportOptions(const AValue: TExportOptions);
|
||||||
|
procedure SetGPSPosition(AKind: Integer; AValue: Double);
|
||||||
procedure SetTagByID(ATagID: TTagID; ATag: TTag);
|
procedure SetTagByID(ATagID: TTagID; ATag: TTag);
|
||||||
procedure SetTagByIndex(AIndex: Integer; ATag: TTag);
|
procedure SetTagByIndex(AIndex: Integer; ATag: TTag);
|
||||||
procedure SetTagByName(AFullTagName: String; ATag: TTag);
|
procedure SetTagByName(AFullTagName: String; ATag: TTag);
|
||||||
@ -129,12 +131,16 @@ type
|
|||||||
property TagCount: Integer
|
property TagCount: Integer
|
||||||
read GetTagCount;
|
read GetTagCount;
|
||||||
|
|
||||||
|
// Special tags
|
||||||
property ImgHeight: Integer
|
property ImgHeight: Integer
|
||||||
read GetImgHeight;
|
read GetImgHeight;
|
||||||
property ImgWidth: Integer
|
property ImgWidth: Integer
|
||||||
read GetImgWidth;
|
read GetImgWidth;
|
||||||
property ImgOrientation: TExifOrientation
|
property ImgOrientation: TExifOrientation
|
||||||
read GetOrientation;
|
read GetOrientation;
|
||||||
|
property GPSAltitude: Double index 2 read GetGPSPosition write SetGPSPosition;
|
||||||
|
property GPSLatitude: Double index 1 read GetGPSPosition write SetGPSPosition;
|
||||||
|
property GPSLongitude: Double index 0 read GetGPSPosition write SetGPSPosition;
|
||||||
|
|
||||||
property OnBeginReading: TExifBeginReadingEvent
|
property OnBeginReading: TExifBeginReadingEvent
|
||||||
read FOnBeginReading write FOnBeginReading;
|
read FOnBeginReading write FOnBeginReading;
|
||||||
@ -274,6 +280,17 @@ uses
|
|||||||
Math, DateUtils, StrUtils,
|
Math, DateUtils, StrUtils,
|
||||||
fpeStrConsts, fpeUtils;
|
fpeStrConsts, fpeUtils;
|
||||||
|
|
||||||
|
const
|
||||||
|
GPSPositionTags: array[0..2] of string = (
|
||||||
|
'GPSLongitude', 'GPSLatitude', 'GPSAltitude'
|
||||||
|
);
|
||||||
|
GPSPositionRefTags: array[0..2] of string = (
|
||||||
|
'GPSLongitudeRef', 'GPSLatitudeRef', 'GPSAltitudeRef'
|
||||||
|
);
|
||||||
|
PosGPSRef: array[0..2] of String = ('E', 'N', '');
|
||||||
|
NegGPSRef: array[0..2] of String = ('W', 'S', '');
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// Tag definitions (TagDef)
|
// Tag definitions (TagDef)
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
@ -885,6 +902,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ Combines the GPS<kind> and GPS<kind>Ref tags for Longitude (AKind = 0),
|
||||||
|
Latitude (AKind = 1), Aligutude (AKind = 2) to a floating point value }
|
||||||
|
function TExifdata.GetGPSPosition(AKind: Integer): double;
|
||||||
|
var
|
||||||
|
tag: TTag;
|
||||||
|
begin
|
||||||
|
Result := NaN;
|
||||||
|
|
||||||
|
tag := TagByName[GPSPositionTags[AKind]];
|
||||||
|
if (tag = nil) then
|
||||||
|
exit;
|
||||||
|
Result := TGPSPositionTag(tag).AsFloat;
|
||||||
|
|
||||||
|
tag := TagByName[GPSPositionRefTags[AKind]];
|
||||||
|
if Assigned(tag) then
|
||||||
|
case AKind of
|
||||||
|
0..1: if (tag.AsString[1] = NegGPSRef[AKind]) then Result := -Result;
|
||||||
|
2 : if (tag.AsInteger = 1) then Result := -Result;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ Finds the tag which defines the sub-IFD to which the specified tag belongs }
|
{ Finds the tag which defines the sub-IFD to which the specified tag belongs }
|
||||||
function TExifData.GetParentTag(ATag: TTag): TTag;
|
function TExifData.GetParentTag(ATag: TTag): TTag;
|
||||||
var
|
var
|
||||||
@ -1104,6 +1142,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TExifData.SetGPSPosition(AKind: Integer; AValue: Double);
|
||||||
|
var
|
||||||
|
tag: TTag;
|
||||||
|
begin
|
||||||
|
tag := TagByName[GPSPositionTags[AKind]];
|
||||||
|
if tag = nil then
|
||||||
|
tag := AddTagByName(GPSPositionTags[AKind]);
|
||||||
|
tag.AsFloat := abs(AValue);
|
||||||
|
|
||||||
|
tag := TagByName[GPSPositionRefTags[AKind]];
|
||||||
|
if tag = nil then
|
||||||
|
tag := AddTagByName(GPSPositionRefTags[AKind]);
|
||||||
|
case AKind of
|
||||||
|
0..1: if AValue >= 0 then tag.AsString := PosGPSRef[AKind] else tag.AsString := NegGPSRef[AKind];
|
||||||
|
2 : if AValue >= 0 then tag.AsInteger := 0 else tag.AsInteger := 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TExifData.SetTagByID(ATagID: TTagID; ATag: TTag);
|
procedure TExifData.SetTagByID(ATagID: TTagID; ATag: TTag);
|
||||||
var
|
var
|
||||||
idx: Integer;
|
idx: Integer;
|
||||||
|
Reference in New Issue
Block a user