Recent

Author Topic: Tmapviewer and mark many points  (Read 3428 times)

soymoe

  • New Member
  • *
  • Posts: 35
Re: Tmapviewer and mark many points
« Reply #15 on: March 21, 2020, 11:45:14 pm »
Thanks for all. how i can prevent execute error when internet conecction is lost and show a notification to user?.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Tmapviewer and mark many points
« Reply #16 on: March 22, 2020, 12:57:23 am »
Hi!

Windows or Linux? Version 7 or 10?
16,32 or 64 bit?
DSL, cable, WLAN or US-Robotics-Modem?
Intel 386 or AMD Ryzen?

Winni

soymoe

  • New Member
  • *
  • Posts: 35
Re: Tmapviewer and mark many points
« Reply #17 on: March 22, 2020, 01:14:27 am »
thanks for respond me. i think that the must common conecction used there in argentine is a ADSL. The OS i don't kwon but is higtly sure that maybe will be Windows 10 64 bits. Thanks for your help.

soymoe

  • New Member
  • *
  • Posts: 35
Re: Tmapviewer and mark many points
« Reply #18 on: March 22, 2020, 09:17:43 pm »
Hi. i get code to detect conexion lost.
Code: Pascal  [Select][+][-]
  1. function IsInternetAvailable(): boolean;
  2. var
  3.   bIsInternetAvailable: boolean = false;
  4.   dwBufferSize: DWORD = 0;
  5.   dwIndex: DWORD;
  6.   pRoutingTable: PMIB_IPFORWARDTABLE;
  7.   pByte: Windows.PBYTE;
  8.   dwRowCount: DWORD;
  9. begin
  10.   // Get the required buffer size
  11.   if (ERROR_INSUFFICIENT_BUFFER = GetIpForwardTable(nil, &dwBufferSize, false)) then
  12.   begin
  13.     pByte := GetMem(dwBufferSize);
  14.     if (pByte<>nil) then
  15.     begin
  16.       pRoutingTable := PMIB_IPFORWARDTABLE(pByte);
  17.       // Attempt to fill buffer with routing table information
  18.       if (NO_ERROR = GetIpForwardTable(pRoutingTable, dwBufferSize, false)) then
  19.       begin
  20.         dwRowCount := pRoutingTable^.dwNumEntries; // Get row count
  21.         // Look for default route to gateway
  22.         for dwIndex := 0 to  dwRowCount-1 do
  23.         begin
  24.           if (pRoutingTable^.table[dwIndex].dwForwardDest = 0) then
  25.           begin // Default route designated by 0.0.0.0 in table
  26.             bIsInternetAvailable := true; // Found it
  27.             break; // Short circuit loop
  28.           end;
  29.         end;
  30.       end;
  31.       FreeMem(pByte); // Clean up. Just say "No" to memory leaks
  32.     end;
  33.   end;
  34.   Result := bIsInternetAvailable;
  35. end;                          

soymoe

  • New Member
  • *
  • Posts: 35
Re: Tmapviewer and mark many points
« Reply #19 on: March 23, 2020, 10:42:35 pm »
Hi everyone. Now i need delete all point add to the map like this:
Code: Pascal  [Select][+][-]
  1. procedure TGPSListViewer.BtnDeletePointClick(Sender: TObject);
  2. var
  3.   gpsObj: TGpsObj;
  4.   i: Integer;
  5.   rPt: TRealPoint;
  6.   item: TListItem;
  7. begin
  8.   if ListView.Selected <> nil then begin
  9.     gpsObj := FList[ListView.Selected.Index];
  10.     ListView.Selected.Free;
  11.     FViewer.GpsItems.Clear(_CLICKED_POINTS_);
  12.     for i:=0 to ListView.Items.Count-1 do begin
  13.       item := ListView.Items[i];
  14.       if TryStrToGps(item.SubItems[2], rPt.Lon) and TryStrToGps(item.SubItems[1], rPt.Lat) then
  15.       begin
  16.         gpsObj := TGpsPoint.CreateFrom(rPt);
  17.         gpsObj.Name := item.SubItems[0];
  18.         FViewer.GPSItems.Add(gpsObj, _CLICKED_POINTS_);
  19.       end;
  20.     end;
  21.   end;
  22. end;                                        
but from main form. i need update the gps points list with the taxi position every minute.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Tmapviewer and mark many points
« Reply #20 on: March 23, 2020, 11:36:27 pm »
The TMapView stores the GPS points and tracks in a list called GPSItems (type TGPSObjectList). GPS points and tracks are distiguished by their ID (integer). The demo assignes the value 10 (_CLICKED_POINTS) to the GPS points clicked into the mapview, and the value 20 (_TRACK_POINTS) to the points of a track. Similarly you could assign another ID to your taxis and thus keep them separate from other GPS points of interest. Or you could give each taxi its own ID, maybe 100+<taxi_index>. So, all IDS >= 100 are for taxis in this example.

The TGPSObjectList has a method DeleteByID(const Ids: Array of integer). So, if you want to delete taxis #0 and #1 you simply call MapView.GPSItems.DeleteByID([100, 101]).

Not tested, though...


soymoe

  • New Member
  • *
  • Posts: 35
Re: Tmapviewer and mark many points
« Reply #21 on: March 25, 2020, 10:34:42 pm »
Hi, i can add point to the map using TRealPoint, but now when i want add point using TGPSPoint type the compile lunch error:"argument can not be asigned to". In MainForm. Oncreate i add this code:
Code: Pascal  [Select][+][-]
  1.  PuntoAgregar:=TGPSPoint.Create(0,0,0,Now);
  2.  
PuntoAgregar is TGPSPonit. Later i do:
Code: Pascal  [Select][+][-]
  1. PuntoAgregar.RealPoint.Lat:=1.252525;
and the compiler lunch error. The problem is create PuntoAgregar  but i dont know how do it.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Tmapviewer and mark many points
« Reply #22 on: March 25, 2020, 11:06:35 pm »
This is part of the public declaration of TGPSPoint and TRealPoint:

Code: Pascal  [Select][+][-]
  1. type
  2.   TRealPoint = Record
  3.     Lon : Double;
  4.     Lat : Double;
  5.   end;
  6.  
  7.   TGPSPoint = class(TGPSObj)
  8.     ...
  9.    public
  10.      ...
  11.      property Lon: Double read GetLon;
  12.      property Lat: Double read GetLat;
  13.      property Ele: double read FEle;
  14.      property DateTime: TDateTime read FDateTime;
  15.      property RealPoint: TRealPoint read FRealPt;
  16.   end;                            

As you can see, "RealPoint" is a public property of TGPSPoint. But RealPoint is a record which does not have a setter/getter for its elements. Therefore, you cannot directly change the elements of the Realpoint property of a TGPSPoint. But you can use an intermediate record:

Code: Pascal  [Select][+][-]
  1. var
  2.   realpoint: TRealPoint;
  3. ...
  4.   PuntoAgregar := TGPSPoint.Create(0, 0, 0, Now);
  5.   realPoint := PuntoAgregar.RealPoint;
  6.   realPoint.Lat := 1.252525;
  7.   PuntoAgregar.RealPoint := realPoint;  
« Last Edit: March 25, 2020, 11:14:14 pm by wp »

 

TinyPortal © 2005-2018