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);
|
||||
type
|
||||
TCoorRec = record
|
||||
TCoordRec = record
|
||||
Lon: Double;
|
||||
Lat: Double;
|
||||
Name: String;
|
||||
end;
|
||||
var
|
||||
i, iChecked: Integer;
|
||||
gpsObj: TGpsObj;
|
||||
gpsPt: TGpsPoint;
|
||||
TCoorArr: array[0..1] of TCoorRec;
|
||||
item: TListItem;
|
||||
rPt: TRealPoint;
|
||||
CoordArr: array[0..1] of TCoordRec;
|
||||
begin
|
||||
// count checked items
|
||||
iChecked := 0;
|
||||
for i:=0 to ListView.Items.Count - 1 do begin
|
||||
if ListView.Items.Item[i].Checked then Inc(iChecked);
|
||||
end;
|
||||
//
|
||||
|
||||
if iChecked <> 2 then begin
|
||||
ShowMessage('Please select 2 items to calculate the distance.');
|
||||
end
|
||||
else begin
|
||||
iChecked := 0;
|
||||
for i:=0 to ListView.Items.Count - 1 do begin
|
||||
if ListView.Items.Item[i].Checked then begin
|
||||
gpsObj := FList.Items[i];
|
||||
if gpsObj is TGpsPoint then begin
|
||||
gpsPt := TGpsPoint(gpsObj);
|
||||
TCoorArr[iChecked].Lat := gpsPt.Lat;
|
||||
TCoorArr[iChecked].Lon := gpsPt.Lon;
|
||||
TCoorArr[iChecked].Name:= gpsPt.Name;
|
||||
Inc(iChecked);
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
|
||||
iChecked := 0;
|
||||
for i:=0 to ListView.Items.Count - 1 do begin
|
||||
if ListView.Items.Item[i].Checked then begin
|
||||
item := ListView.Items[i];
|
||||
if TryStrToGps(item.SubItems[2], rPt.Lon) and TryStrToGps(item.SubItems[1], rPt.Lat) then
|
||||
begin
|
||||
CoordArr[iChecked].Lon := rPt.Lon;
|
||||
CoordArr[iChecked].Lat := rPt.Lat;
|
||||
CoordArr[iChecked].Name:= item.SubItems[0];
|
||||
Inc(iChecked);
|
||||
end;
|
||||
end;
|
||||
// show distance between selected items
|
||||
ShowMessage('Distance between ' + TCoorArr[0].Name + ' and ' + TCoorArr[1].Name + ' is: ' +
|
||||
Format('%.2n %s.', [
|
||||
CalcGeoDistance(
|
||||
TCoorArr[0].Lat,
|
||||
TCoorArr[0].Lon,
|
||||
TCoorArr[1].Lat,
|
||||
TCoorArr[1].Lon,
|
||||
DistanceUnit
|
||||
),
|
||||
DistanceUnit_Names[DistanceUnit]
|
||||
]));
|
||||
end;
|
||||
// show distance between selected items
|
||||
ShowMessage(Format('Distance between %s and %s is: %.2n %s.', [
|
||||
CoordArr[0].Name, CoordArr[1].Name,
|
||||
CalcGeoDistance(CoordArr[0].Lat, CoordArr[0].Lon, CoordArr[1].Lat, CoordArr[1].Lon, DistanceUnit),
|
||||
DistanceUnit_Names[DistanceUnit]
|
||||
]));
|
||||
end;
|
||||
|
||||
procedure TGPSListViewer.BtnDeletePointClick(Sender: TObject);
|
||||
|
@ -517,6 +517,7 @@ begin
|
||||
{$IFDEF USE_LAZINTFIMAGE}
|
||||
bmp := TBitmap.Create;
|
||||
try
|
||||
bmp.PixelFormat := pf32Bit;
|
||||
bmp.SetSize(Buffer.Width, Buffer.Height);
|
||||
bmp.LoadFromIntfImage(Buffer);
|
||||
Canvas.Draw(0, 0, bmp);
|
||||
|
Reference in New Issue
Block a user