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'
|
||||
ClientHeight = 493
|
||||
ClientWidth = 872
|
||||
LCLVersion = '4.99.0.0'
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '3.6.0.0'
|
||||
object ParamsPanel: TPanel
|
||||
Left = 8
|
||||
Height = 454
|
||||
@ -82,8 +82,8 @@ object MainForm: TMainForm
|
||||
Height = 25
|
||||
Top = 58
|
||||
Width = 108
|
||||
Position = 0
|
||||
OnChange = tbSegmentLengthChange
|
||||
Position = 0
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
@ -143,7 +143,7 @@ object MainForm: TMainForm
|
||||
Height = 25
|
||||
Top = 58
|
||||
Width = 164
|
||||
Caption = 'Porto-PoS'
|
||||
Caption = 'Porto-Port of Spain'
|
||||
TabOrder = 2
|
||||
OnClick = btnPresetPortoClick
|
||||
end
|
||||
@ -195,8 +195,8 @@ object MainForm: TMainForm
|
||||
'Mark Center'
|
||||
'Mark Destination'
|
||||
)
|
||||
TabOrder = 3
|
||||
OnItemClick = cgOptionsItemClick
|
||||
TabOrder = 3
|
||||
Data = {
|
||||
03000000020202
|
||||
}
|
||||
@ -244,9 +244,9 @@ object MainForm: TMainForm
|
||||
BorderSpacing.Bottom = 6
|
||||
MaxValue = 10
|
||||
MinValue = 1
|
||||
OnChange = seOrthodromePenWidthChange
|
||||
TabOrder = 0
|
||||
Value = 3
|
||||
OnChange = seOrthodromePenWidthChange
|
||||
end
|
||||
object clbOrthodromePenColor: TColorButton
|
||||
AnchorSideLeft.Control = seOrthodromePenWidth
|
||||
@ -309,9 +309,9 @@ object MainForm: TMainForm
|
||||
BorderSpacing.Bottom = 6
|
||||
MaxValue = 10
|
||||
MinValue = 1
|
||||
OnChange = seGreatCirclePenWidthChange
|
||||
TabOrder = 0
|
||||
Value = 1
|
||||
OnChange = seGreatCirclePenWidthChange
|
||||
end
|
||||
object clbGreatCirclePenColor: TColorButton
|
||||
AnchorSideLeft.Control = seGreatCirclePenWidth
|
||||
|
@ -154,6 +154,7 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
{ TGreatCirclePoint }
|
||||
|
||||
constructor TGreatCirclePoint.Create(const ARealPoint: TRealPoint; const ADistance : Double;
|
||||
@ -181,6 +182,7 @@ end;
|
||||
|
||||
|
||||
{ TGreatCirclePainterPlugin }
|
||||
|
||||
// Default SortCompare sortes the points along the longitude and on same
|
||||
// longitudes shorter distance from start first.
|
||||
function GreatCircleLinePointsListSortCompare(Item1, Item2: Pointer): Integer;
|
||||
@ -271,12 +273,11 @@ var
|
||||
i : Integer;
|
||||
lStart, lDest : TRealPoint;
|
||||
lWorldSize : Int64;
|
||||
lGCP : TGreatCirclePoint;
|
||||
lGCP0, lGCP1 : TGreatCirclePoint;
|
||||
ptKind : TGreatCirclePointKind;
|
||||
lon0, lon1 : Double;
|
||||
lLastRPt : TrealPoint;
|
||||
cnt : Integer;
|
||||
lSuppressSort : Boolean = False;
|
||||
lFullSpan : Boolean;
|
||||
pt : TPoint;
|
||||
lDateBorderOnMap : Boolean;
|
||||
@ -442,9 +443,8 @@ begin
|
||||
// Sort all points along their distances from Start
|
||||
FGreatCircleLinePoints.Sort(@GreatCircleLinePolarPointsListSortCompare);
|
||||
// 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]));
|
||||
FGreatCircleLinePoints.Insert(0,lGCP);
|
||||
lSuppressSort := True; // Points have been sorted here
|
||||
lGCP0 := TGreatCirclePoint(FGreatCircleLinePoints.Extract(FGreatCircleLinePoints.Items[FGreatCircleLinePoints.Count-1]));
|
||||
FGreatCircleLinePoints.Insert(0,lGCP0);
|
||||
// The North-South straight line has been processed
|
||||
Exit;
|
||||
end;
|
||||
@ -521,7 +521,7 @@ begin
|
||||
if not lDateBorderOnMap then
|
||||
begin
|
||||
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
|
||||
else
|
||||
@ -530,7 +530,7 @@ begin
|
||||
if not lDateBorderOnMap then
|
||||
begin
|
||||
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;
|
||||
LatFromLonAtGreatCircle(lStart.Lat, lStart.Lon, lDest.Lat, lDest.Lon,
|
||||
@ -539,14 +539,29 @@ begin
|
||||
ptKind := PointKindFromDist(d);
|
||||
FGreatCircleLinePoints.Add(TGreatCirclePoint.Create(rPt,d,ptKind));
|
||||
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
|
||||
// Keep silence on any computation errors
|
||||
end;
|
||||
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
|
||||
if Assigned(FOnChange) then
|
||||
FOnChange(Self);
|
||||
|
Loading…
Reference in New Issue
Block a user