You've already forked lazarus-ccr
lazmapviewer: Fix mismatch of checked items for distance calculation after r6879 (https://forum.lazarus.freepascal.org/index.php/topic,12674.msg319432.html, patch by sstvmaster).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6883 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -97,53 +97,47 @@ end;
|
|||||||
|
|
||||||
procedure TGPSListViewer.BtnCalcDistanceClick(Sender: TObject);
|
procedure TGPSListViewer.BtnCalcDistanceClick(Sender: TObject);
|
||||||
type
|
type
|
||||||
TCoorRec = record
|
TCoordRec = record
|
||||||
Lon: Double;
|
Lon: Double;
|
||||||
Lat: Double;
|
Lat: Double;
|
||||||
Name: String;
|
Name: String;
|
||||||
end;
|
end;
|
||||||
var
|
var
|
||||||
i, iChecked: Integer;
|
i, iChecked: Integer;
|
||||||
gpsObj: TGpsObj;
|
item: TListItem;
|
||||||
gpsPt: TGpsPoint;
|
rPt: TRealPoint;
|
||||||
TCoorArr: array[0..1] of TCoorRec;
|
CoordArr: array[0..1] of TCoordRec;
|
||||||
begin
|
begin
|
||||||
// count checked items
|
// count checked items
|
||||||
iChecked := 0;
|
iChecked := 0;
|
||||||
for i:=0 to ListView.Items.Count - 1 do begin
|
for i:=0 to ListView.Items.Count - 1 do begin
|
||||||
if ListView.Items.Item[i].Checked then Inc(iChecked);
|
if ListView.Items.Item[i].Checked then Inc(iChecked);
|
||||||
end;
|
end;
|
||||||
//
|
|
||||||
if iChecked <> 2 then begin
|
if iChecked <> 2 then begin
|
||||||
ShowMessage('Please select 2 items to calculate the distance.');
|
ShowMessage('Please select 2 items to calculate the distance.');
|
||||||
end
|
exit;
|
||||||
else begin
|
end;
|
||||||
|
|
||||||
iChecked := 0;
|
iChecked := 0;
|
||||||
for i:=0 to ListView.Items.Count - 1 do begin
|
for i:=0 to ListView.Items.Count - 1 do begin
|
||||||
if ListView.Items.Item[i].Checked then begin
|
if ListView.Items.Item[i].Checked then begin
|
||||||
gpsObj := FList.Items[i];
|
item := ListView.Items[i];
|
||||||
if gpsObj is TGpsPoint then begin
|
if TryStrToGps(item.SubItems[2], rPt.Lon) and TryStrToGps(item.SubItems[1], rPt.Lat) then
|
||||||
gpsPt := TGpsPoint(gpsObj);
|
begin
|
||||||
TCoorArr[iChecked].Lat := gpsPt.Lat;
|
CoordArr[iChecked].Lon := rPt.Lon;
|
||||||
TCoorArr[iChecked].Lon := gpsPt.Lon;
|
CoordArr[iChecked].Lat := rPt.Lat;
|
||||||
TCoorArr[iChecked].Name:= gpsPt.Name;
|
CoordArr[iChecked].Name:= item.SubItems[0];
|
||||||
Inc(iChecked);
|
Inc(iChecked);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// show distance between selected items
|
// show distance between selected items
|
||||||
ShowMessage('Distance between ' + TCoorArr[0].Name + ' and ' + TCoorArr[1].Name + ' is: ' +
|
ShowMessage(Format('Distance between %s and %s is: %.2n %s.', [
|
||||||
Format('%.2n %s.', [
|
CoordArr[0].Name, CoordArr[1].Name,
|
||||||
CalcGeoDistance(
|
CalcGeoDistance(CoordArr[0].Lat, CoordArr[0].Lon, CoordArr[1].Lat, CoordArr[1].Lon, DistanceUnit),
|
||||||
TCoorArr[0].Lat,
|
|
||||||
TCoorArr[0].Lon,
|
|
||||||
TCoorArr[1].Lat,
|
|
||||||
TCoorArr[1].Lon,
|
|
||||||
DistanceUnit
|
|
||||||
),
|
|
||||||
DistanceUnit_Names[DistanceUnit]
|
DistanceUnit_Names[DistanceUnit]
|
||||||
]));
|
]));
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGPSListViewer.BtnDeletePointClick(Sender: TObject);
|
procedure TGPSListViewer.BtnDeletePointClick(Sender: TObject);
|
||||||
|
@ -517,6 +517,7 @@ begin
|
|||||||
{$IFDEF USE_LAZINTFIMAGE}
|
{$IFDEF USE_LAZINTFIMAGE}
|
||||||
bmp := TBitmap.Create;
|
bmp := TBitmap.Create;
|
||||||
try
|
try
|
||||||
|
bmp.PixelFormat := pf32Bit;
|
||||||
bmp.SetSize(Buffer.Width, Buffer.Height);
|
bmp.SetSize(Buffer.Width, Buffer.Height);
|
||||||
bmp.LoadFromIntfImage(Buffer);
|
bmp.LoadFromIntfImage(Buffer);
|
||||||
Canvas.Draw(0, 0, bmp);
|
Canvas.Draw(0, 0, bmp);
|
||||||
|
Reference in New Issue
Block a user