LazMapViewer: Improvements in GreatCircle plugin, by Ekkehard Domning.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9611 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
df186894ba
commit
bd1bc6cf8f
@ -6,9 +6,9 @@ object MainForm: TMainForm
|
|||||||
Caption = 'Great Circle Plugin Demo'
|
Caption = 'Great Circle Plugin Demo'
|
||||||
ClientHeight = 493
|
ClientHeight = 493
|
||||||
ClientWidth = 872
|
ClientWidth = 872
|
||||||
LCLVersion = '4.99.0.0'
|
|
||||||
OnActivate = FormActivate
|
OnActivate = FormActivate
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
|
LCLVersion = '3.6.0.0'
|
||||||
object ParamsPanel: TPanel
|
object ParamsPanel: TPanel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 454
|
Height = 454
|
||||||
@ -82,8 +82,8 @@ object MainForm: TMainForm
|
|||||||
Height = 25
|
Height = 25
|
||||||
Top = 58
|
Top = 58
|
||||||
Width = 108
|
Width = 108
|
||||||
Position = 0
|
|
||||||
OnChange = tbSegmentLengthChange
|
OnChange = tbSegmentLengthChange
|
||||||
|
Position = 0
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
@ -143,7 +143,7 @@ object MainForm: TMainForm
|
|||||||
Height = 25
|
Height = 25
|
||||||
Top = 58
|
Top = 58
|
||||||
Width = 164
|
Width = 164
|
||||||
Caption = 'Porto-PoS'
|
Caption = 'Porto-Port of Spain'
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
OnClick = btnPresetPortoClick
|
OnClick = btnPresetPortoClick
|
||||||
end
|
end
|
||||||
@ -195,8 +195,8 @@ object MainForm: TMainForm
|
|||||||
'Mark Center'
|
'Mark Center'
|
||||||
'Mark Destination'
|
'Mark Destination'
|
||||||
)
|
)
|
||||||
TabOrder = 3
|
|
||||||
OnItemClick = cgOptionsItemClick
|
OnItemClick = cgOptionsItemClick
|
||||||
|
TabOrder = 3
|
||||||
Data = {
|
Data = {
|
||||||
03000000020202
|
03000000020202
|
||||||
}
|
}
|
||||||
@ -244,9 +244,9 @@ object MainForm: TMainForm
|
|||||||
BorderSpacing.Bottom = 6
|
BorderSpacing.Bottom = 6
|
||||||
MaxValue = 10
|
MaxValue = 10
|
||||||
MinValue = 1
|
MinValue = 1
|
||||||
|
OnChange = seOrthodromePenWidthChange
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
Value = 3
|
Value = 3
|
||||||
OnChange = seOrthodromePenWidthChange
|
|
||||||
end
|
end
|
||||||
object clbOrthodromePenColor: TColorButton
|
object clbOrthodromePenColor: TColorButton
|
||||||
AnchorSideLeft.Control = seOrthodromePenWidth
|
AnchorSideLeft.Control = seOrthodromePenWidth
|
||||||
@ -309,9 +309,9 @@ object MainForm: TMainForm
|
|||||||
BorderSpacing.Bottom = 6
|
BorderSpacing.Bottom = 6
|
||||||
MaxValue = 10
|
MaxValue = 10
|
||||||
MinValue = 1
|
MinValue = 1
|
||||||
|
OnChange = seGreatCirclePenWidthChange
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
Value = 1
|
Value = 1
|
||||||
OnChange = seGreatCirclePenWidthChange
|
|
||||||
end
|
end
|
||||||
object clbGreatCirclePenColor: TColorButton
|
object clbGreatCirclePenColor: TColorButton
|
||||||
AnchorSideLeft.Control = seGreatCirclePenWidth
|
AnchorSideLeft.Control = seGreatCirclePenWidth
|
||||||
|
@ -154,6 +154,7 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
{ TGreatCirclePoint }
|
{ TGreatCirclePoint }
|
||||||
|
|
||||||
constructor TGreatCirclePoint.Create(const ARealPoint: TRealPoint; const ADistance : Double;
|
constructor TGreatCirclePoint.Create(const ARealPoint: TRealPoint; const ADistance : Double;
|
||||||
@ -181,6 +182,7 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{ TGreatCirclePainterPlugin }
|
{ TGreatCirclePainterPlugin }
|
||||||
|
|
||||||
// Default SortCompare sortes the points along the longitude and on same
|
// Default SortCompare sortes the points along the longitude and on same
|
||||||
// longitudes shorter distance from start first.
|
// longitudes shorter distance from start first.
|
||||||
function GreatCircleLinePointsListSortCompare(Item1, Item2: Pointer): Integer;
|
function GreatCircleLinePointsListSortCompare(Item1, Item2: Pointer): Integer;
|
||||||
@ -271,12 +273,11 @@ var
|
|||||||
i : Integer;
|
i : Integer;
|
||||||
lStart, lDest : TRealPoint;
|
lStart, lDest : TRealPoint;
|
||||||
lWorldSize : Int64;
|
lWorldSize : Int64;
|
||||||
lGCP : TGreatCirclePoint;
|
lGCP0, lGCP1 : TGreatCirclePoint;
|
||||||
ptKind : TGreatCirclePointKind;
|
ptKind : TGreatCirclePointKind;
|
||||||
lon0, lon1 : Double;
|
lon0, lon1 : Double;
|
||||||
lLastRPt : TrealPoint;
|
lLastRPt : TrealPoint;
|
||||||
cnt : Integer;
|
cnt : Integer;
|
||||||
lSuppressSort : Boolean = False;
|
|
||||||
lFullSpan : Boolean;
|
lFullSpan : Boolean;
|
||||||
pt : TPoint;
|
pt : TPoint;
|
||||||
lDateBorderOnMap : Boolean;
|
lDateBorderOnMap : Boolean;
|
||||||
@ -442,9 +443,8 @@ begin
|
|||||||
// Sort all points along their distances from Start
|
// Sort all points along their distances from Start
|
||||||
FGreatCircleLinePoints.Sort(@GreatCircleLinePolarPointsListSortCompare);
|
FGreatCircleLinePoints.Sort(@GreatCircleLinePolarPointsListSortCompare);
|
||||||
// move the last point from the end to the beginning to draw a line from this pole prior to start
|
// move the last point from the end to the beginning to draw a line from this pole prior to start
|
||||||
lGCP := TGreatCirclePoint(FGreatCircleLinePoints.Extract(FGreatCircleLinePoints.Items[FGreatCircleLinePoints.Count-1]));
|
lGCP0 := TGreatCirclePoint(FGreatCircleLinePoints.Extract(FGreatCircleLinePoints.Items[FGreatCircleLinePoints.Count-1]));
|
||||||
FGreatCircleLinePoints.Insert(0,lGCP);
|
FGreatCircleLinePoints.Insert(0,lGCP0);
|
||||||
lSuppressSort := True; // Points have been sorted here
|
|
||||||
// The North-South straight line has been processed
|
// The North-South straight line has been processed
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
@ -521,7 +521,7 @@ begin
|
|||||||
if not lDateBorderOnMap then
|
if not lDateBorderOnMap then
|
||||||
begin
|
begin
|
||||||
pt := MapView.LatLonToScreen(lScreenArea.TopLeft.Lat,-180.0);
|
pt := MapView.LatLonToScreen(lScreenArea.TopLeft.Lat,-180.0);
|
||||||
if pt.X <= MapView.Engine.MapLeft then Continue;
|
if pt.X < MapView.Engine.MapLeft then Continue;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -530,7 +530,7 @@ begin
|
|||||||
if not lDateBorderOnMap then
|
if not lDateBorderOnMap then
|
||||||
begin
|
begin
|
||||||
pt := MapView.LatLonToScreen(lScreenArea.TopLeft.Lat,180.0);
|
pt := MapView.LatLonToScreen(lScreenArea.TopLeft.Lat,180.0);
|
||||||
if pt.X >= MapView.Engine.MapLeft+lWorldSize then Continue;
|
if pt.X > MapView.Engine.MapLeft+lWorldSize then Continue;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
LatFromLonAtGreatCircle(lStart.Lat, lStart.Lon, lDest.Lat, lDest.Lon,
|
LatFromLonAtGreatCircle(lStart.Lat, lStart.Lon, lDest.Lat, lDest.Lon,
|
||||||
@ -539,14 +539,29 @@ begin
|
|||||||
ptKind := PointKindFromDist(d);
|
ptKind := PointKindFromDist(d);
|
||||||
FGreatCircleLinePoints.Add(TGreatCirclePoint.Create(rPt,d,ptKind));
|
FGreatCircleLinePoints.Add(TGreatCirclePoint.Create(rPt,d,ptKind));
|
||||||
end;
|
end;
|
||||||
|
// Finally the found points must be sorted, if not processed in a different way.
|
||||||
|
FGreatCircleLinePoints.Sort(@GreatCircleLinePointsListSortCompare);
|
||||||
|
// Check for duplicate items, if found remove them
|
||||||
|
cnt := FGreatCircleLinePoints.Count;
|
||||||
|
if cnt > 1 then
|
||||||
|
begin
|
||||||
|
for i := cnt-1 downto 1 do
|
||||||
|
begin
|
||||||
|
lGCP0 := TGreatCirclePoint(FGreatCircleLinePoints.Items[i]);
|
||||||
|
lGCP1 := TGreatCirclePoint(FGreatCircleLinePoints.Items[i-1]);
|
||||||
|
if (lGCP1.Distance = lGCP0.Distance) and
|
||||||
|
(lGCP1.FRealPoint.Lon = lGCP0.FRealPoint.Lon) and
|
||||||
|
(lGCP1.FRealPoint.Lat = lGCP0.FRealPoint.Lat) then
|
||||||
|
begin
|
||||||
|
FGreatCircleLinePoints.Extract(lGCP0);
|
||||||
|
FreeAndNil(lGCP0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
except
|
except
|
||||||
// Keep silence on any computation errors
|
// Keep silence on any computation errors
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
// Finally the found points must be sorted, if not processed in a different way.
|
|
||||||
if not lSuppressSort then
|
|
||||||
FGreatCircleLinePoints.Sort(@GreatCircleLinePointsListSortCompare);
|
|
||||||
// Give the user a message, to update the information about the current great circle
|
// Give the user a message, to update the information about the current great circle
|
||||||
if Assigned(FOnChange) then
|
if Assigned(FOnChange) then
|
||||||
FOnChange(Self);
|
FOnChange(Self);
|
||||||
|
Loading…
Reference in New Issue
Block a user