How to use TGpsStatus.SatelliteCount?

1

Hello good afternoon everyone I'm trying to get the number of satellites with which a specific point was obtained in the GPS in Delphi 10.2 Tokyo.

My program simply captures latitude and longitude with the TLocationSensor component and its onLocationChanged event. I know there is a class called TGpsStatus which has the function SatelliteCount and that is the function I need to use; the problem is that I do not know how to use it, I try everything and I do not get a good result, I only get the message

  

"Abstract Error"

Could someone help me save the number of satellites with which a GPS point was obtained ?, I hope you can help me a little.

Greetings and Thanks for your help!

    
asked by Kenneth 18.06.2018 в 23:26
source

1 answer

1

As far as I could see, I would qualify as BUG the implementation of the classes TGpsStatus / TPlatformGpsStatus , so when calling TPlatformGpsStatus.Current , which should return the specific class of the platform on which it is running the code results in an EAbstractError, because it references the GetCurrent abstract method.

However, the matter can be easily turned around using an interposed class. The following code will show you the number of satellites. The inconvenience is that it is specific to a platform. (in the example code, it is Windows), although it could be adapted to work with different platforms using {$ifdef} .

uses
  System.Win.Sensors;

{$R *.fmx}

type
  TMyPlatformGpsStatus = class(TPlatformGpsStatus)
  public
    class function GetGpsStatusImplementer: TGpsStatusClass; override;
  end;

{ TMyPlatformGpsStatus }

class function TMyPlatformGpsStatus.GetGpsStatusImplementer: TGpsStatusClass;
begin
  Result := inherited;
end;

{TForm1}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(Format('GPS con %d satélites', [TMyPlatformGpsStatus.GetGpsStatusImplementer.SatelliteCount]));
end;
    
answered by 19.06.2018 в 00:58