diff --git a/components/lazmapviewer/example/main.lfm b/components/lazmapviewer/example/main.lfm index 8ea4b8f1f..05f484733 100644 --- a/components/lazmapviewer/example/main.lfm +++ b/components/lazmapviewer/example/main.lfm @@ -10,7 +10,7 @@ object MainForm: TMainForm OnDestroy = FormDestroy OnShow = FormShow ShowHint = True - LCLVersion = '2.0.6.0' + LCLVersion = '2.1.0.0' object MapView: TMapView Left = 0 Height = 640 @@ -39,9 +39,9 @@ object MainForm: TMainForm Height = 640 Top = 0 Width = 275 - ActivePage = PgConfig + ActivePage = PgData Align = alRight - TabIndex = 1 + TabIndex = 0 TabOrder = 1 object PgData: TTabSheet Caption = 'Data' @@ -824,19 +824,19 @@ object MainForm: TMainForm end object GeoNames: TMVGeoNames OnNameFound = GeoNamesNameFound - left = 240 - top = 192 + Left = 240 + Top = 192 end object OpenDialog: TOpenDialog DefaultExt = '.pgx' Filter = 'GPX files (*.gpx)|*.gpx|All files (*.*)|*.*' - left = 240 - top = 456 + Left = 240 + Top = 456 end object FontDialog: TFontDialog MinFontSize = 0 MaxFontSize = 0 - left = 808 - top = 104 + Left = 808 + Top = 104 end end diff --git a/components/lazmapviewer/source/mvdlefpc.pas b/components/lazmapviewer/source/mvdlefpc.pas index 1ab1b5e03..c09103970 100644 --- a/components/lazmapviewer/source/mvdlefpc.pas +++ b/components/lazmapviewer/source/mvdlefpc.pas @@ -73,6 +73,7 @@ begin InitSSLInterface; http := TFpHttpClient.Create(nil); try + http.ConnectTimeOut := 10000; {$IF FPC_FullVersion >= 30000} http.AllowRedirect := true; {$IFEND} diff --git a/components/lazmapviewer/source/mvengine.pas b/components/lazmapviewer/source/mvengine.pas index b6da8dc14..5576e0cea 100644 --- a/components/lazmapviewer/source/mvengine.pas +++ b/components/lazmapviewer/source/mvengine.pas @@ -164,6 +164,8 @@ type property OnZoomChange: TNotifyEvent read FOnZoomChange write FOnZoomChange; end; +function RealPoint(Lat, Lon: Double): TRealPoint; + function CalcGeoDistance(Lat1, Lon1, Lat2, Lon2: double; AUnits: TDistanceUnits = duKilometers): double; @@ -661,7 +663,6 @@ begin Result.y := Round(py); end; - function TMapViewerEngine.LonLatToScreen(ALonLat: TRealPoint): TPoint; Begin Result := DegreesToMapPixels(MapWin, ALonLat); @@ -1086,7 +1087,8 @@ procedure TMapViewerEngine.SetActive(AValue: boolean); begin if FActive = AValue then Exit; FActive := AValue; - if not(FActive) then + + if not FActive then Queue.CancelAllJob(self) else begin if Cache.UseDisk then ForceDirectories(Cache.BasePath); @@ -1279,6 +1281,12 @@ end; //------------------------------------------------------------------------------ +function RealPoint(Lat, Lon: Double): TRealPoint; +begin + Result.Lon := Lon; + Result.Lat := Lat; +end; + procedure SplitGps(AValue: Double; out ADegs, AMins: Double); begin AValue := abs(AValue); diff --git a/components/lazmapviewer/source/mvgpsobj.pas b/components/lazmapviewer/source/mvgpsobj.pas index 2503110be..501c8d3e1 100644 --- a/components/lazmapviewer/source/mvgpsobj.pas +++ b/components/lazmapviewer/source/mvgpsobj.pas @@ -53,22 +53,24 @@ type TGPSPoint = class(TGPSObj) private FRealPt: TRealPoint; - FEle: Double; + FElevation: Double; FDateTime: TDateTime; function GetLat: Double; function GetLon: Double; public - constructor Create(ALon,ALat: double; AEle: double=NO_ELE; ADateTime: TDateTime=NO_DATE); - class function CreateFrom(aPt: TRealPoint): TGPSPoint; + constructor Create(ALon,ALat: double; AElevation: double = NO_ELE; + ADateTime: TDateTime = NO_DATE); + class function CreateFrom(aPt: TRealPoint; AElevation: Double = NO_ELE; + ADateTime: TDateTime = NO_DATE): TGPSPoint; procedure GetArea(out Area: TRealArea);override; - function HasEle: boolean; + function HasElevation: boolean; function HasDateTime: Boolean; - function DistanceInKmFrom(OtherPt: TGPSPoint; UseEle: boolean=true): double; + function DistanceInKmFrom(OtherPt: TGPSPoint; UseElevation: boolean=true): double; property Lon: Double read GetLon; property Lat: Double read GetLat; - property Ele: double read FEle; + property Elevation: double read FElevation; property DateTime: TDateTime read FDateTime; property RealPoint: TRealPoint read FRealPt; end; @@ -705,9 +707,9 @@ begin Area.BottomRight := FRealPt; end; -function TGPSPoint.HasEle: boolean; +function TGPSPoint.HasElevation: boolean; begin - Result := FEle <> NO_ELE; + Result := FElevation <> NO_ELE; end; function TGPSPoint.HasDateTime: Boolean; @@ -715,7 +717,8 @@ begin Result := FDateTime <> NO_DATE; end; -function TGPSPoint.DistanceInKmFrom(OtherPt: TGPSPoint; UseEle: boolean): double; +function TGPSPoint.DistanceInKmFrom(OtherPt: TGPSPoint; + UseElevation: boolean = true): double; var a: double; lat1, lat2, lon1, lon2, t1, t2, t3, t4, t5, rad_dist: double; @@ -734,27 +737,28 @@ begin t5 := t1 + t4; rad_dist := arctan(-t5/sqrt(-t5 * t5 +1)) + 2 * arctan(1); result := (rad_dist * 3437.74677 * 1.1508) * 1.6093470878864446; - if UseEle and (FEle<>OtherPt.FEle) then - if (HasEle) and (OtherPt.HasEle) then + if UseElevation and (FElevation <> OtherPt.FElevation) then + if (HasElevation) and (OtherPt.HasElevation) then begin - //FEle is assumed in Metter - DiffEle := (FEle-OtherPt.Ele)/1000; - Result := sqrt(DiffEle*DiffEle+result*result); + //FElevation is assumed in meters + DiffEle := (FElevation - OtherPt.Elevation) / 1000; + Result := sqrt(DiffEle*DiffEle + result*result); end; end; -constructor TGPSPoint.Create(ALon, ALat: double; AEle: double; +constructor TGPSPoint.Create(ALon, ALat: double; AElevation: double; ADateTime: TDateTime); begin FRealPt.Lon := ALon; FRealPt.Lat := ALat; - FEle := AEle; + FElevation := AElevation; FDateTime := ADateTime; end; -class function TGPSPoint.CreateFrom(aPt: TRealPoint): TGPSPoint; +class function TGPSPoint.CreateFrom(aPt: TRealPoint; AElevation: Double = NO_ELE; + ADateTime: TDateTime = NO_DATE): TGPSPoint; begin - Result := Create(aPt.Lon,aPt.Lat); + Result := Create(aPt.Lon, aPt.Lat, AElevation, ADateTime); end; end. diff --git a/components/lazmapviewer/source/mvmapviewer.pas b/components/lazmapviewer/source/mvmapviewer.pas index 9a273b07d..4ed54fc93 100644 --- a/components/lazmapviewer/source/mvmapviewer.pas +++ b/components/lazmapviewer/source/mvmapviewer.pas @@ -13,6 +13,8 @@ See also: https://wiki.lazarus.freepascal.org/FPC_modified_LGPL } +// ToDo: Make Active work at designtime. + unit mvMapViewer; {$MODE objfpc}{$H+} @@ -144,7 +146,7 @@ Type property PopupMenu; property UseThreads: boolean read GetUseThreads write SetUseThreads default false; property Width default 150; - property Zoom: integer read GetZoom write SetZoom; + property Zoom: integer read GetZoom write SetZoom default 0; property ZoomToCursor: Boolean read GetZoomToCursor write SetZoomToCursor default True; property OnCenterMove: TNotifyEvent read GetOnCenterMove write SetOnCenterMove; property OnZoomChange: TNotifyEvent read GetOnZoomChange write SetOnZoomChange;