ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 EXIF_GPSLatitude and EXIF_GPSLongtitude question
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Patrick Quinn

United Kingdom
81 Posts

Posted - Sep 04 2017 :  18:38:24  Show Profile  Reply
Hi

I'm having some trouble setting TIOParams.EXIF_GPSLatitude and TIOParams.EXIF_GPSLongtitude values.

Are these read only? Do I have to calculate the degrees, minutes and seconds from Lat/Long decimal values and set these EXIF values separately?

Thanks

Patrick

xequte

39053 Posts

Posted - Sep 04 2017 :  21:46:18  Show Profile  Reply
Hi Patrick

Dealing directly with TIOParams.EXIF_GPSLatitude and TIOParams.EXIF_GPSLongtitude is difficult.

You are better to set the individual properties, e.g.

EXIF_GPSLatitudeDegrees,
EXIF_GPSLatitudeMinutes
EXIF_GPSLatitudeSeconds
EXIF_GPSLatitudeRef

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Patrick Quinn

United Kingdom
81 Posts

Posted - Sep 05 2017 :  19:15:32  Show Profile  Reply
 
Dealing directly with TIOParams.EXIF_GPSLatitude and TIOParams.EXIF_GPSLongtitude is difficult.

You are better to set the individual properties
So why are these properties published if they cannot be used?
Go to Top of Page

xequte

39053 Posts

Posted - Sep 05 2017 :  23:04:48  Show Profile  Reply
Hi

Well they can be used if you are happy to encode all of the data into a Double value, but I expect 99% of people will prefer working with the individual properties.

You might want to look at the following methods in hyieutils.pas:

function IEGPSConvertDMSToDegDec(degrees: Double; minutes: Double; seconds: Double; ref: AnsiString): Double;
procedure IEGPSConvertDegDecToDMS(dir: AnsiString; value: Double; var degrees: Double; var minutes: Double; var seconds: Double; var ref: AnsiString);




Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Patrick Quinn

United Kingdom
81 Posts

Posted - Sep 06 2017 :  16:24:53  Show Profile  Reply
 
Well they can be used if you are happy to encode all of the data into a Double value, but I expect 99% of people will prefer working with the individual properties.
What a ridiculous thing to say. Google Maps use LatLong in their APIs. public final double latitude Latitude, in degrees. public final double longitude Longitude, in degrees.
I use geonames.org services extensively and ALL their reverse geocoding APIs use Lat/Long decimal values.

See http://www.geonames.org/export/web-services.html

OpenStreetMap APIs use Lat/Long decimal values.

http://wikimapia.org/api/ use Lat/Long decimal values.

Let's look at ImageEn...
TIESlippyMap.Latitude: Declaration property Latitude: double;
TIESlippyMap.Longitude: Declaration property Longitude: double;
If, as you say 99% of people will prefer working with the individual properties then why do you use a double instead of separate Degrees, Minutes, Seconds and Reference properties?

I have paid you for support and do not like being fobbed off with such a condescending reply.
Go to Top of Page

xequte

39053 Posts

Posted - Sep 06 2017 :  19:13:32  Show Profile  Reply
Hi Patrick

I'm sorry if I came off as condescending, and I confess that your knowledge of GPS properties appears superior to mine. When I have used GPS in my own applications, I've only ever used the individual properties, so made the mistake of assuming everyone's usage was similar to mine.

Please let me retreat a step.

What problems do you encounter when setting TIOParams.EXIF_GPSLatitude and TIOParams.EXIF_GPSLongtitude?


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Patrick Quinn

United Kingdom
81 Posts

Posted - Sep 07 2017 :  16:08:53  Show Profile  Reply
 
What problems do you encounter when setting TIOParams.EXIF_GPSLatitude and TIOParams.EXIF_GPSLongtitude?
The problem I encounter is that TIOParams.EXIF_GPSLatitude and TIOParams.EXIF_GPSLongtitude properties are not saved when their Proc is saved to stream.

I have since tested some more and found that edited ImageEnView.IO.Params.EXIF_GPSLatitude and ImageEnView.IO.Params.EXIF_GPSLongitude properties are not saved when an image is saved to file.

I wrote a simple program to show this. On the form are just 3 TEdit controls, 3 TButtons, a TImageEnView, a TOpenImageEnDialog and a TSaveImageEnDialog.
procedure TfrmMain.btnLoadImageClick(Sender: TObject);
begin
  if OpenImageEnDialog1.Execute then
    with ImageEnView1 do
      begin
        IO.LoadFromFile(OpenImageEnDialog1.FileName);
        EditEXIF_GPSLatitude.Text := FloatToStr(IO.Params.EXIF_GPSLatitude);
        EditEXIF_GPSLongitude.Text := FloatToStr(IO.Params.EXIF_GPSLongitude);
        EditEXIF_UserComment.Text := IO.Params.EXIF_UserComment;
      end;
end;

procedure TfrmMain.btnWriteClick(Sender: TObject);
begin
  with ImageEnView1 do
    begin
    if not IsEmpty2 then
      with IO.Params do
        begin
          EXIF_GPSLatitude := StrToFloat(EditEXIF_GPSLatitude.Text);
          EXIF_GPSLongitude := StrToFloat(EditEXIF_GPSLongitude.Text);
          EXIF_UserComment := EditEXIF_UserComment.Text;
        end;
    end;
end;

procedure TfrmMain.btnSaveToFileClick(Sender: TObject);
begin
   with SaveImageEnDialog1 do
    if Execute then
      ImageEnView1.IO.SaveToFile(FileName);
end;

// numeric, full stop and minus only
procedure TfrmMain.EditKeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in [#8, '0'..'9', '-', '.']) then
    Key := #0
  else if ((Key = '.') or (Key = '-')) and (Pos(Key, (Sender as TEdit).Text) > 0) then
    Key := #0 else if (Key = '-') and ((Sender as TEdit).SelStart <> 0) then
  Key := #0;
end;
If an image is loaded then EXIF_GPSLatitude, EXIF_GPSLongitude and EXIF_UserComment are shown in the corresponding TEdit box and can be edited.

If the 'Write EXIF' button is pressed these values are written to the ImageEnView.IO.Params.

If the saved image is now saved then loaded again, the edited EXIF_UserComment is there but both the EXIF_GPSLatitude and EXIF_GPSLongitude are missing.
Go to Top of Page

xequte

39053 Posts

Posted - Sep 07 2017 :  22:59:07  Show Profile  Reply
Hi Patrick

Sorry, this is poorly documented, but you must have a valid GPS Version ID in order to save the GPS fields, e.g.

ImageEnView1.IO.Params.EXIF_GPSLatitude  := StrToFloat(EditEXIF_GPSLatitude);
ImageEnView1.IO.Params.EXIF_GPSLongitude := StrToFloat(EditEXIF_GPSLongitude);
ImageEnView1.IO.Params.EXIF_GPSVersionID := '2.2.0.0';


I will improve the documentation.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Patrick Quinn

United Kingdom
81 Posts

Posted - Sep 08 2017 :  17:31:12  Show Profile  Reply
That fixed the problems.

It's a bit obscure though. Couldn't this be added automatically in the Params unit if a EXIF_GPSLatitude or GPSLongitude tag is added??
Go to Top of Page

xequte

39053 Posts

Posted - Sep 08 2017 :  22:36:27  Show Profile  Reply
Hi Patrick

Yes, in 7.0.2 if you set EXIF_GPSLatitude or EXIF_GPSLongitude it sets EXIF_GPSVersionID. Plus I've added a note to all the EXIF_GPS* properties.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: