Recent

Author Topic: TMapViewer  (Read 69609 times)

VTwin

  • Hero Member
  • *****
  • Posts: 664
  • Former Turbo Pascal 3 user
Re: TMapViewer
« Reply #120 on: April 30, 2019, 12:39:41 am »
For symmetry:

Code: Pascal  [Select]
  1. { DistanceToLatLong
  2.   Given a point defined by (lat,long), a distance and compass bearing, return
  3.   the coordinate of the resulting destination point. Uses mean spherical earth
  4.   radius. Angles are in radians, distances in meters.
  5.   Ref: http://www.movable-type.co.uk/scripts/latlong.html }
  6. procedure DistanceToLatLong(const lat0, long0, dist, bearing: double;
  7.   var lat1, long1: double);
  8. var
  9.   R: double = 6371000.0; // earth radius in meters
  10.   d, x, y: double;
  11. begin
  12.   d := dist/R; // angular distance
  13.   lat1 := ArcSin(Sin(lat0) * Cos(d) + Cos(lat0) * Sin(d) * Cos(bearing));
  14.   x := Cos(d) - Sin(lat0) * Sin(lat1);
  15.   y := Sin(bearing) * Sin(d) * Cos(lat0);
  16.   long1 := long0 + ArcTan2(y, x);
  17. end;  
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.11.6: Lazarus 2.1.0 svn 61357M (64 bit Cocoa trunk)
Ubuntu 18.04.2: Lazarus 2.0.0 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.0 (64 bit on VBox)

wp

  • Hero Member
  • *****
  • Posts: 5713
Re: TMapViewer
« Reply #121 on: May 01, 2019, 12:32:50 am »
Found some documentation for the HERE maps (https://developer.here.com/documentation/map-tile/topics/introduction.html) and managed to integrate some variants into the MapViewer. Note, however, that (free) registration is required at https://developer.here.com/. After registration you'll receive an APP_ID and an APP_CODE; open the ini file of the demo program (in its exe folder) and add a section with the corresponding information (replace ABC and xyz by the strings sent to you by HERE):

Code: [Select]
[HERE]
APP_ID=ABC
APP_CODE=xyz

When you run the demo program the next time the HERE maps will be included in the map provider drop down. Unfortunately, ATM, it seems that the parameters are not yet inserted correctly into the URL, and there are a lot of drawing artefacts.

Another issue is that I do not get the fphttpclient to accept the https url. Therefore, I used the synapse downloader in the demo for the moment.
« Last Edit: May 01, 2019, 12:43:16 am by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

sstvmaster

  • Full Member
  • ***
  • Posts: 100
Re: TMapViewer
« Reply #122 on: May 01, 2019, 12:33:43 pm »
Another issue is that I do not get the fphttpclient to accept the https url. Therefore, I used the synapse downloader in the demo for the moment.

Can you give me a short example, please? Is the issue with all urls, or only with the HERE url?
Lazarus 2.0.2 x32
Lazarus 2.1.0 Trunk x32
OS Win 7 32bit

wp

  • Hero Member
  • *****
  • Posts: 5713
Re: TMapViewer
« Reply #123 on: May 01, 2019, 12:49:02 pm »
HERE url only. The fphttpclient downloader reports the error: 'Project MapViewer_Demo raised exception class 'ESocketError' with message: Host name resolution for "0.base.maps.api.here.com" failed"'; the Synapse downloader works correctly.

Playing again with these maps and having this error message in mind, I get the idea that maybe the "0" in "0.base.maps..." is not valid; I replaced the %serv% in the AddMapProvider call (in TMapViewerEngine.RegisterProviders) by a hard-coded "1", and now also the fphttpclient works correctly, and even the drawing artefacts due to missing tiles that I reported yesterday are gone. So, the remaining problem is: How to convince the component to not generate URLs with a leading "0".
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

sstvmaster

  • Full Member
  • ***
  • Posts: 100
Re: TMapViewer
« Reply #124 on: May 01, 2019, 12:54:50 pm »
« Last Edit: May 01, 2019, 12:59:04 pm by sstvmaster »
Lazarus 2.0.2 x32
Lazarus 2.1.0 Trunk x32
OS Win 7 32bit

wp

  • Hero Member
  • *****
  • Posts: 5713
Re: TMapViewer
« Reply #125 on: May 01, 2019, 05:45:05 pm »
The function GetYahooSvr is constructed such as to create server numbers starting at 1 instead of 0. Putting this into the AddMapProvider for the HERE mapes calls gives error-free access to these maps (provided that the HERE credentials have been obtained and have been made known to the demo program).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Alekos

  • New member
  • *
  • Posts: 7
    • http://www.iqsoft.gr
Re: TMapViewer
« Reply #126 on: May 11, 2019, 05:40:48 pm »
Hi anyone has an example of TGPSTrack ?
Cant find anything.
Thanks!!!

wp

  • Hero Member
  • *****
  • Posts: 5713
Re: TMapViewer
« Reply #127 on: May 12, 2019, 11:52:42 pm »
A GPSTrack is a list a GPSPoints. Therefore, in order to create a GPSTrack you must create GPSPoints first and then add them to the Points list of the GPSTrack. Finally you add the track to the GPSItems of the viewer; give it a unique number to identify the track.

I added an example to the demo program of the MapViewer; find the code in unit gpslistform. At first add some gps points to the Viewer (by right-clicking at the track points). Then click "GPS points..." and "Save points" to save the points to a simple track file (just a tab-delimited file). When you want to see the track later, click again "GPS points..." and then "Load track".

[EDIT]
Added a parser for GPX files. In the demo there is a new button "Load GPX file" from which you can select your own GPX files or those downloaded from the internet (e.g.: http://www.gpsvisualizer.com/examples/google_gpx.html); the mapviewer will then display track, route and waypoints. When I have more time I'll add some machinery to assign particular icons to way points, e.g. trail head, mountain peak, etc.
« Last Edit: May 16, 2019, 12:12:28 am by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

JosepB

  • Newbie
  • Posts: 4
Re: TMapViewer
« Reply #128 on: June 10, 2019, 05:43:44 pm »
Thank you very much for the component, it works very well and every day is more complete. However, I wanted to make a suggestion to the developer, wp: would it be useful to add to the TGPSObj object a property with the IdOwner value in order to easily differentiate the different created and existing objects on the map ?.

wp

  • Hero Member
  • *****
  • Posts: 5713
Re: TMapViewer
« Reply #129 on: June 13, 2019, 12:13:54 am »
I made GpsObj.IdOwner public now. Is that ok for your needs?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

JosepB

  • Newbie
  • Posts: 4
Re: TMapViewer
« Reply #130 on: June 13, 2019, 12:11:27 pm »
Thank you!.