從現有的CCRExif內的文檔1.5.1 -
GPS
Exif標準允許設置GPS(即,定位)數據, 其被存儲在它自己的部分/子IFD。使用TExifData,您可以 讀取和寫入,GPS標記的標準集合 作爲該類別的屬性。然而,需要注意的重要一點是,GPS座標可以用兩種不同的方式表示,即 單個十進制值或以度,分和秒錶示。 Exif使用第二種形式,所以如果您希望將GPS座標分配給 圖像,並且所有數值都是表示爲 小數的必需值,則需要先轉換爲其他形式。 (對於「一個 關」的轉換,可以使用以下網址: http://www.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html)一旦你 有需要的形式座標然而,它們分配到 圖像會爲這樣的:
with TExifData.Create do
try
LoadFromGraphic(ImageFile);
GPSLatitude.Assign(51, 25, 32.1, ltNorth);
GPSLongitude.Assign(0, 12, 29.2, lnEast);
SaveToGraphic(ImageFile);
finally
Free;
end;
尋找源代碼瘦到裏面:
TGPSLatitude = class(TGPSCoordinate)
和TGPSCoordinate類的聲明在公開區
property Degrees: TExifFraction index 0 read GetValue;
property Minutes: TExifFraction index 1 read GetValue;
property Seconds: TExifFraction index 2 read GetValue;
property Direction: AnsiChar read GetDirectionChar write SetDirectionChar;
此外,zip文件中還有幾個演示應用程序。
LE:看了評論後,我再次演示了一下,並在ExifList演示中,你有ExifListFrame.pas下面的代碼:
procedure AddValue(const Name: string; Coord: TGPSCoordinate); overload;
var
DirectionStr: string;
{$IFDEF BUGGYCOMPILER}
Degrees, Minutes, Seconds: TExifFraction; //work around D2006 compiler bug with intermediate vars
{$ENDIF}
begin
if Coord.MissingOrInvalid then Exit;
case Coord.Direction of
'N': DirectionStr := 'north';
'S': DirectionStr := 'south';
'W': DirectionStr := 'west';
'E': DirectionStr := 'east';
else DirectionStr := '';
end;
{$IFDEF BUGGYCOMPILER}
Degrees := Coord.Degrees;
Minutes := Coord.Minutes;
Seconds := Coord.Seconds;
AddValue(Name, '%g°, %g minutes and %g seconds %s', [Degrees.Quotient,
Minutes.Quotient, Seconds.Quotient, DirectionStr]);
{$ELSE}
AddValue(Name, '%g°, %g minutes and %g seconds %s', [Coord.Degrees.Quotient,
Coord.Minutes.Quotient, Coord.Seconds.Quotient, DirectionStr]);
{$ENDIF}
end;
來源
2016-04-03 13:19:38
RBA
*我當前沒有編譯的代碼*哪個編譯器錯誤,哪一行?另外,什麼是'TdmSH'及其方法'DMStoDec'? –
@TomBrunberg DMStoDec需要3個實際值並將其轉換爲GPS Decimal。但是我簡化了源代碼示例。編譯器停止在我嘗試賦值GPS_D的錯誤「[DCC Error] Main.pas(205):E2010不兼容的類型:'Real'和'TTiffLongWordFraction'」這顯然是因爲我無法將Degrees屬性指定給一個真實的。問題是如何從TGPSLongitude中提取度數或小數值?謝謝你的時間。 –