You've already forked lazarus-ccr
LazMapViewer: Fix crash in demo when "go to point" is selected after loading a saved track.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8183 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -2,6 +2,8 @@ unit gpslistform;
|
|||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -233,14 +235,17 @@ begin
|
|||||||
OpenDialog.InitialDir := ExtractFileDir(OpenDialog.FileName);
|
OpenDialog.InitialDir := ExtractFileDir(OpenDialog.FileName);
|
||||||
if not OpenDialog.Execute then exit;
|
if not OpenDialog.Execute then exit;
|
||||||
|
|
||||||
|
// Create a gpsTrack, read the track points, and add the track to the viewer.
|
||||||
gpsTrack := TGpsTrack.Create;
|
gpsTrack := TGpsTrack.Create;
|
||||||
L := TStringList.Create;
|
L := TStringList.Create;
|
||||||
try
|
try
|
||||||
L.LoadFromFile(OpenDialog.FileName);
|
L.LoadFromFile(OpenDialog.FileName);
|
||||||
for i := 1 to L.Count - 1 do begin // i=1 --> skip header line
|
for i := 1 to L.Count - 1 do // i=1 --> skip header line
|
||||||
|
begin
|
||||||
if L[i] = '' then Continue;
|
if L[i] = '' then Continue;
|
||||||
sa := L[i].Split(#9);
|
sa := L[i].Split(#9);
|
||||||
if TryStrToGps(sa[2], lon) and TryStrToGps(sa[3], lat) then begin
|
if TryStrToGps(sa[2], lon) and TryStrToGps(sa[3], lat) then
|
||||||
|
begin
|
||||||
gpsPt := TGpsPoint.Create(lon, lat);
|
gpsPt := TGpsPoint.Create(lon, lat);
|
||||||
gpsPt.Name := sa[1];
|
gpsPt.Name := sa[1];
|
||||||
gpsTrack.Points.Add(gpsPt);
|
gpsTrack.Points.Add(gpsPt);
|
||||||
@ -252,10 +257,21 @@ begin
|
|||||||
L.Free;
|
L.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// The track points are needed internally in the FList --> copy the track points
|
||||||
|
FList.Free;
|
||||||
|
FList := TGPSObjList.Create(false);
|
||||||
|
for i := 0 to gpsTrack.Points.Count - 1do
|
||||||
|
begin
|
||||||
|
gpsPt := gpsTrack.Points[i];
|
||||||
|
FList.Add(gpsPt);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Display the track points in the ListView
|
||||||
ListView.Items.BeginUpdate;
|
ListView.Items.BeginUpdate;
|
||||||
try
|
try
|
||||||
ListView.Items.Clear;
|
ListView.Items.Clear;
|
||||||
for i:=0 to gpsTrack.Points.Count - 1 do begin
|
for i:=0 to gpsTrack.Points.Count - 1 do
|
||||||
|
begin
|
||||||
gpsPt := gpsTrack.Points[i];
|
gpsPt := gpsTrack.Points[i];
|
||||||
item := ListView.Items.Add;
|
item := ListView.Items.Add;
|
||||||
item.SubItems.Add(gpsPt.Name);
|
item.SubItems.Add(gpsPt.Name);
|
||||||
@ -265,6 +281,7 @@ begin
|
|||||||
finally
|
finally
|
||||||
ListView.Items.EndUpdate;
|
ListView.Items.EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGPSListViewer.SetViewer(AValue: TMapView);
|
procedure TGPSListViewer.SetViewer(AValue: TMapView);
|
||||||
|
Reference in New Issue
Block a user