You've already forked lazarus-ccr
LazMapViewer: Add support of GPX files.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6913 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -82,7 +82,7 @@
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Exceptions Count="4">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
@@ -92,6 +92,9 @@
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Name Value="EHTTPClient"/>
|
||||
</Item4>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
||||
@@ -243,14 +243,16 @@ object GPSListViewer: TGPSListViewer
|
||||
end
|
||||
end
|
||||
object SaveDialog: TSaveDialog
|
||||
Title = 'Save gps points as'
|
||||
DefaultExt = '.*.gps'
|
||||
Filter = 'GPS points (*.gps)|*.gps|All files (*.*)|*.*'
|
||||
left = 472
|
||||
top = 256
|
||||
end
|
||||
object OpenDialog: TOpenDialog
|
||||
Title = 'Open gps points file'
|
||||
DefaultExt = '.gps'
|
||||
Filter = 'GPS points (*.gps)|*.gps|All files (*.*)|*.*'
|
||||
Filter = 'GPS files (*.gps)|*.gps|All files (*.*)|*.*'
|
||||
left = 560
|
||||
top = 256
|
||||
end
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 345
|
||||
Height = 581
|
||||
Height = 640
|
||||
Top = 121
|
||||
Width = 869
|
||||
Width = 883
|
||||
Caption = 'MainForm'
|
||||
ClientHeight = 581
|
||||
ClientWidth = 869
|
||||
ClientHeight = 640
|
||||
ClientWidth = 883
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
ShowHint = True
|
||||
LCLVersion = '2.1.0.0'
|
||||
object ControlPanel: TPanel
|
||||
Left = 592
|
||||
Height = 581
|
||||
Left = 606
|
||||
Height = 640
|
||||
Top = 0
|
||||
Width = 277
|
||||
Align = alRight
|
||||
ClientHeight = 581
|
||||
ClientHeight = 640
|
||||
ClientWidth = 277
|
||||
TabOrder = 1
|
||||
object CbProviders: TComboBox
|
||||
@@ -299,7 +299,7 @@ object MainForm: TMainForm
|
||||
TabOrder = 7
|
||||
end
|
||||
object CbFoundLocations: TComboBox
|
||||
AnchorSideLeft.Control = CbLocations
|
||||
AnchorSideLeft.Control = LblProviders
|
||||
AnchorSideTop.Control = Label8
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = BtnGoTo
|
||||
@@ -352,10 +352,10 @@ object MainForm: TMainForm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = BtnGoTo
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 8
|
||||
Left = 9
|
||||
Height = 52
|
||||
Top = 450
|
||||
Width = 260
|
||||
Top = 483
|
||||
Width = 259
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = False
|
||||
BorderSpacing.Top = 8
|
||||
@@ -364,11 +364,12 @@ object MainForm: TMainForm
|
||||
WordWrap = True
|
||||
end
|
||||
object BtnGPSPoints: TButton
|
||||
AnchorSideTop.Control = CbFoundLocations
|
||||
AnchorSideLeft.Control = LblProviders
|
||||
AnchorSideTop.Control = BtnSaveToFile
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 8
|
||||
Left = 9
|
||||
Height = 25
|
||||
Top = 417
|
||||
Top = 450
|
||||
Width = 92
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
@@ -382,10 +383,10 @@ object MainForm: TMainForm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = InfoBtnGPSPoints
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 8
|
||||
Left = 9
|
||||
Height = 64
|
||||
Top = 502
|
||||
Width = 260
|
||||
Top = 535
|
||||
Width = 259
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = False
|
||||
Caption = 'GPSPointInfo'
|
||||
@@ -493,15 +494,15 @@ object MainForm: TMainForm
|
||||
OnClick = BtnSaveMapProvidersClick
|
||||
end
|
||||
object BtnSaveToFile: TButton
|
||||
AnchorSideLeft.Control = BtnGPSPoints
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = BtnGPSPoints
|
||||
Left = 108
|
||||
AnchorSideLeft.Control = LblProviders
|
||||
AnchorSideTop.Control = CbFoundLocations
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 9
|
||||
Height = 25
|
||||
Top = 417
|
||||
Width = 110
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Save map to file'
|
||||
OnClick = BtnSaveToFileClick
|
||||
TabOrder = 11
|
||||
@@ -606,13 +607,27 @@ object MainForm: TMainForm
|
||||
TabOrder = 13
|
||||
Text = 'km'
|
||||
end
|
||||
object BtnLoadGPXFile: TButton
|
||||
AnchorSideLeft.Control = BtnSaveToFile
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = BtnSaveToFile
|
||||
Left = 127
|
||||
Height = 25
|
||||
Top = 417
|
||||
Width = 105
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
Caption = 'Load GPX file...'
|
||||
OnClick = BtnLoadGPXFileClick
|
||||
TabOrder = 14
|
||||
end
|
||||
end
|
||||
object MapView: TMapView
|
||||
Left = 0
|
||||
Height = 581
|
||||
Height = 640
|
||||
Hint = 'Displays the map'
|
||||
Top = 0
|
||||
Width = 592
|
||||
Width = 606
|
||||
Active = False
|
||||
Align = alClient
|
||||
CacheOnDisk = True
|
||||
@@ -634,4 +649,10 @@ object MainForm: TMainForm
|
||||
left = 328
|
||||
top = 224
|
||||
end
|
||||
object OpenDialog: TOpenDialog
|
||||
DefaultExt = '.pgx'
|
||||
Filter = 'GPX files (*.gpx)|*.gpx|All files (*.*)|*.*'
|
||||
left = 832
|
||||
top = 424
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,6 +18,7 @@ type
|
||||
BtnGoTo: TButton;
|
||||
BtnGPSPoints: TButton;
|
||||
BtnSaveToFile: TButton;
|
||||
BtnLoadGPXFile: TButton;
|
||||
CbDoubleBuffer: TCheckBox;
|
||||
CbFoundLocations: TComboBox;
|
||||
CbLocations: TComboBox;
|
||||
@@ -49,8 +50,10 @@ type
|
||||
ControlPanel: TPanel;
|
||||
BtnLoadMapProviders: TSpeedButton;
|
||||
BtnSaveMapProviders: TSpeedButton;
|
||||
OpenDialog: TOpenDialog;
|
||||
ZoomTrackBar: TTrackBar;
|
||||
procedure BtnGoToClick(Sender: TObject);
|
||||
procedure BtnLoadGPXFileClick(Sender: TObject);
|
||||
procedure BtnSearchClick(Sender: TObject);
|
||||
procedure BtnGPSPointsClick(Sender: TObject);
|
||||
procedure BtnSaveToFileClick(Sender: TObject);
|
||||
@@ -98,7 +101,7 @@ implementation
|
||||
|
||||
uses
|
||||
LCLType, IniFiles, Math, FPCanvas, FPImage, IntfGraphics,
|
||||
mvEngine, mvExtraData,
|
||||
mvEngine, mvExtraData, mvGPX,
|
||||
globals, gpslistform;
|
||||
|
||||
type
|
||||
@@ -189,6 +192,31 @@ begin
|
||||
MapView.Invalidate;
|
||||
end;
|
||||
|
||||
procedure TMainForm.BtnLoadGPXFileClick(Sender: TObject);
|
||||
var
|
||||
reader: TGpxReader;
|
||||
pt: TGpsPoint;
|
||||
item: TGpsObj;
|
||||
begin
|
||||
if OpenDialog.FileName <> '' then
|
||||
OpenDialog.InitialDir := ExtractFileDir(OpenDialog.Filename);
|
||||
if OpenDialog.Execute then begin
|
||||
reader := TGpxReader.Create;
|
||||
try
|
||||
reader.LoadFromFile(OpenDialog.FileName, MapView.GPSItems);
|
||||
item := MapView.GPSItems.Items[MapView.GPSItems.Count-1];
|
||||
if item is TGpsPoint then
|
||||
pt := TGpsPoint(item)
|
||||
else
|
||||
if item is TGpsTrack then
|
||||
pt := TGpsTrack(item).Points[0];
|
||||
MapView.Center := pt.RealPoint;
|
||||
finally
|
||||
reader.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.BtnSaveToFileClick(Sender: TObject);
|
||||
begin
|
||||
MapView.SaveToFile(TPortableNetworkGraphic, 'mapview.png');
|
||||
|
||||
Reference in New Issue
Block a user