lazmapviewer: Use E/W and N/S suffixes to GPS coordinates.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6868 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
fb276886e4
commit
efd629624c
@ -46,7 +46,7 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
mvTypes;
|
mvTypes, mvEngine;
|
||||||
|
|
||||||
destructor TGPSListViewer.Destroy;
|
destructor TGPSListViewer.Destroy;
|
||||||
begin
|
begin
|
||||||
@ -55,8 +55,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGPSListViewer.Populate;
|
procedure TGPSListViewer.Populate;
|
||||||
const
|
|
||||||
GPS_FORMAT = '0.00000°';
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
item: TListItem;
|
item: TListItem;
|
||||||
@ -80,8 +78,8 @@ begin
|
|||||||
// item.Caption := IntToStr(gpsObj.ID);
|
// item.Caption := IntToStr(gpsObj.ID);
|
||||||
if gpsObj is TGpsPoint then begin
|
if gpsObj is TGpsPoint then begin
|
||||||
item.SubItems.Add(gpsObj.Name);
|
item.SubItems.Add(gpsObj.Name);
|
||||||
item.Subitems.Add(FormatFloat(GPS_FORMAT, TGpsPoint(gpsObj).Lat));
|
item.Subitems.Add(LatToStr(TGpsPoint(gpsObj).Lat, true));
|
||||||
item.Subitems.Add(FormatFloat(GPS_FORMAT, TGpsPoint(gpsObj).Lon));
|
item.Subitems.Add(LonToStr(TGpsPoint(gpsObj).Lon, true));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
@ -625,6 +625,7 @@ object MainForm: TMainForm
|
|||||||
OnZoomChange = MapViewZoomChange
|
OnZoomChange = MapViewZoomChange
|
||||||
OnChange = MapViewChange
|
OnChange = MapViewChange
|
||||||
OnDrawGpsPoint = MapViewDrawGpsPoint
|
OnDrawGpsPoint = MapViewDrawGpsPoint
|
||||||
|
OnMouseLeave = MapViewMouseLeave
|
||||||
OnMouseMove = MapViewMouseMove
|
OnMouseMove = MapViewMouseMove
|
||||||
OnMouseUp = MapViewMouseUp
|
OnMouseUp = MapViewMouseUp
|
||||||
end
|
end
|
||||||
|
@ -67,8 +67,8 @@ type
|
|||||||
const ALoc: TRealPoint);
|
const ALoc: TRealPoint);
|
||||||
procedure MapViewChange(Sender: TObject);
|
procedure MapViewChange(Sender: TObject);
|
||||||
procedure MapViewDrawGpsPoint(Sender, ACanvas: TObject; APoint: TGpsPoint);
|
procedure MapViewDrawGpsPoint(Sender, ACanvas: TObject; APoint: TGpsPoint);
|
||||||
procedure MapViewMouseMove(Sender: TObject; Shift: TShiftState; X,
|
procedure MapViewMouseLeave(Sender: TObject);
|
||||||
Y: Integer);
|
procedure MapViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
||||||
procedure MapViewMouseUp(Sender: TObject; Button: TMouseButton;
|
procedure MapViewMouseUp(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
procedure MapViewZoomChange(Sender: TObject);
|
procedure MapViewZoomChange(Sender: TObject);
|
||||||
@ -78,6 +78,7 @@ type
|
|||||||
|
|
||||||
private
|
private
|
||||||
procedure ClearFoundLocations;
|
procedure ClearFoundLocations;
|
||||||
|
procedure UpdateCoords(X, Y: Integer);
|
||||||
procedure UpdateDropdownWidth(ACombobox: TCombobox);
|
procedure UpdateDropdownWidth(ACombobox: TCombobox);
|
||||||
procedure UpdateLocationHistory(ALocation: String);
|
procedure UpdateLocationHistory(ALocation: String);
|
||||||
procedure UpdateViewportSize;
|
procedure UpdateViewportSize;
|
||||||
@ -110,10 +111,12 @@ const
|
|||||||
MAX_LOCATIONS_HISTORY = 50;
|
MAX_LOCATIONS_HISTORY = 50;
|
||||||
HOMEDIR = '';
|
HOMEDIR = '';
|
||||||
MAP_PROVIDER_FILENAME = 'map-providers.xml';
|
MAP_PROVIDER_FILENAME = 'map-providers.xml';
|
||||||
|
USE_DMS = true;
|
||||||
|
|
||||||
var
|
var
|
||||||
PointFormatSettings: TFormatsettings;
|
PointFormatSettings: TFormatsettings;
|
||||||
|
|
||||||
|
|
||||||
function CalcIniName: String;
|
function CalcIniName: String;
|
||||||
begin
|
begin
|
||||||
Result := ChangeFileExt(Application.ExeName, '.ini');
|
Result := ChangeFileExt(Application.ExeName, '.ini');
|
||||||
@ -339,32 +342,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.MapViewMouseLeave(Sender: TObject);
|
||||||
|
begin
|
||||||
|
UpdateCoords(MaxInt, MaxInt);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.MapViewMouseMove(Sender: TObject; Shift: TShiftState;
|
procedure TMainForm.MapViewMouseMove(Sender: TObject; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
const
|
const
|
||||||
DELTA = 3;
|
DELTA = 3;
|
||||||
var
|
var
|
||||||
rPt: TRealPoint;
|
|
||||||
rArea: TRealArea;
|
rArea: TRealArea;
|
||||||
gpsList: TGpsObjList;
|
gpsList: TGpsObjList;
|
||||||
L: TStrings;
|
L: TStrings;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
rPt := MapView.Center;
|
UpdateCoords(X, Y);
|
||||||
InfoCenterLongitude.Caption := Format('%.6f° = %s', [rPt.Lon, GPSToDMS(rPt.Lon)]);
|
|
||||||
InfoCenterLatitude.Caption := Format('%.6f° = %s', [rPt.Lat, GPSToDMS(rPt.Lat)]);
|
|
||||||
{
|
|
||||||
InfoCenterLongitude.Caption := Format('%.6f°', [rPt.Lon]);
|
|
||||||
InfoCenterLatitude.Caption := Format('%.6f°', [rPt.Lat]);
|
|
||||||
}
|
|
||||||
|
|
||||||
rPt := MapView.ScreenToLonLat(Point(X, Y));
|
|
||||||
InfoPositionLongitude.Caption := Format('%.6f° = %s', [rPt.Lon, GPSToDMS(rPt.Lon)]);
|
|
||||||
InfoPositionLatitude.Caption := Format('%.6f° = %s', [rPt.Lat, GPSToDMS(rPt.Lat)]);
|
|
||||||
{
|
|
||||||
InfoPositionLongitude.Caption := Format('%.6f°', [rPt.Lon]);
|
|
||||||
InfoPositionLatitude.Caption := Format('%.6f°', [rPt.Lat]);
|
|
||||||
}
|
|
||||||
|
|
||||||
rArea.TopLeft := MapView.ScreenToLonLat(Point(X-DELTA, Y-DELTA));
|
rArea.TopLeft := MapView.ScreenToLonLat(Point(X-DELTA, Y-DELTA));
|
||||||
rArea.BottomRight := MapView.ScreenToLonLat(Point(X+DELTA, Y+DELTA));
|
rArea.BottomRight := MapView.ScreenToLonLat(Point(X+DELTA, Y+DELTA));
|
||||||
@ -376,11 +369,9 @@ begin
|
|||||||
for i:=0 to gpsList.Count-1 do
|
for i:=0 to gpsList.Count-1 do
|
||||||
if gpsList[i] is TGpsPoint then
|
if gpsList[i] is TGpsPoint then
|
||||||
with TGpsPoint(gpsList[i]) do
|
with TGpsPoint(gpsList[i]) do
|
||||||
L.Add(Format('%s' + Lineending + ' (lat=%.6f°=%s, lon=%.6f°=%s°)', [
|
L.Add(Format('%s (%s / %s)', [
|
||||||
Name, Lat, GPSToDMS(Lat), Lon, GPSToDMS(Lon)
|
Name, LatToStr(Lat, USE_DMS), LonToStr(Lon, USE_DMS)
|
||||||
]));
|
]));
|
||||||
//L.Add(Format('%s' + Lineending + ' (lat=%.6f°, lon=%.6f°)', [Name, Lat, Lon]));
|
|
||||||
|
|
||||||
GPSPointInfo.Caption := L.Text;
|
GPSPointInfo.Caption := L.Text;
|
||||||
finally
|
finally
|
||||||
L.Free;
|
L.Free;
|
||||||
@ -461,6 +452,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.UpdateCoords(X, Y: Integer);
|
||||||
|
var
|
||||||
|
rPt: TRealPoint;
|
||||||
|
begin
|
||||||
|
rPt := MapView.Center;
|
||||||
|
InfoCenterLongitude.Caption := LonToStr(rPt.Lon, USE_DMS);
|
||||||
|
InfoCenterLatitude.Caption := LatToStr(rPt.Lat, USE_DMS);
|
||||||
|
|
||||||
|
if (X <> MaxInt) and (Y <> MaxInt) then begin
|
||||||
|
rPt := MapView.ScreenToLonLat(Point(X, Y));
|
||||||
|
InfoPositionLongitude.Caption := LonToStr(rPt.Lon, USE_DMS);
|
||||||
|
InfoPositionLatitude.Caption := LatToStr(rPt.Lat, USE_DMS);
|
||||||
|
end else begin
|
||||||
|
InfoPositionLongitude.Caption := '-';
|
||||||
|
InfoPositionLatitude.Caption := '-';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.UpdateDropdownWidth(ACombobox: TCombobox);
|
procedure TMainForm.UpdateDropdownWidth(ACombobox: TCombobox);
|
||||||
var
|
var
|
||||||
cnv: TControlCanvas;
|
cnv: TControlCanvas;
|
||||||
|
@ -73,7 +73,7 @@ begin
|
|||||||
{$IF FPC_FullVersion >= 30000}
|
{$IF FPC_FullVersion >= 30000}
|
||||||
http.AllowRedirect := true;
|
http.AllowRedirect := true;
|
||||||
{$IFEND}
|
{$IFEND}
|
||||||
http.AddHeader('User-Agent','Mozilla/5.0 (compatible; fpweb)');
|
http.AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)');
|
||||||
{$IF FPC_FullVersion >= 30101}
|
{$IF FPC_FullVersion >= 30101}
|
||||||
if UseProxy then begin
|
if UseProxy then begin
|
||||||
http.Proxy.Host := FProxyHost;
|
http.Proxy.Host := FProxyHost;
|
||||||
|
@ -168,6 +168,9 @@ function CalcGeoDistance(Lat1, Lon1, Lat2, Lon2: double;
|
|||||||
|
|
||||||
function GPSToDMS(Angle: Double): string;
|
function GPSToDMS(Angle: Double): string;
|
||||||
|
|
||||||
|
function LatToStr(ALatitude: Double; DMS: Boolean): String;
|
||||||
|
function LonToStr(ALongitude: Double; DMS: Boolean): String;
|
||||||
|
|
||||||
procedure SplitGps(AValue: Double; out ADegs, AMins, ASecs: Double);
|
procedure SplitGps(AValue: Double; out ADegs, AMins, ASecs: Double);
|
||||||
|
|
||||||
|
|
||||||
@ -1123,6 +1126,31 @@ begin
|
|||||||
Result := Format('%.0f° %.0f'' %.1f"', [deg, min, sec]);
|
Result := Format('%.0f° %.0f'' %.1f"', [deg, min, sec]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function LatToStr(ALatitude: Double; DMS: Boolean): String;
|
||||||
|
begin
|
||||||
|
if DMS then
|
||||||
|
Result := GPSToDMS(abs(ALatitude))
|
||||||
|
else
|
||||||
|
Result := Format('%.6f°',[abs(ALatitude)]);
|
||||||
|
if ALatitude > 0 then
|
||||||
|
Result := Result + ' N'
|
||||||
|
else
|
||||||
|
if ALatitude < 0 then
|
||||||
|
Result := Result + 'E';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function LonToStr(ALongitude: Double; DMS: Boolean): String;
|
||||||
|
begin
|
||||||
|
if DMS then
|
||||||
|
Result := GPSToDMS(abs(ALongitude))
|
||||||
|
else
|
||||||
|
Result := Format('%.6f°', [abs(ALongitude)]);
|
||||||
|
if ALongitude > 0 then
|
||||||
|
Result := Result + ' E'
|
||||||
|
else if ALongitude < 0 then
|
||||||
|
Result := Result + ' W';
|
||||||
|
end;
|
||||||
|
|
||||||
{ Returns the direct distance (air-line) between two geo coordinates
|
{ Returns the direct distance (air-line) between two geo coordinates
|
||||||
If latitude NOT between -90°..+90° and longitude NOT between -180°..+180°
|
If latitude NOT between -90°..+90° and longitude NOT between -180°..+180°
|
||||||
the function returns -1.
|
the function returns -1.
|
||||||
|
Loading…
Reference in New Issue
Block a user