Forum > Graphics

LazMapViewer - Lines between realpoints

(1/6) > >>

Arctic_Eddie:
I've been using the viewer package from the OPM for a ham radio propagation project. The purpose is to display the path from a sending station (TX) using WSPR (Weak Signal Propagation Report) and all those hearing the signal (RX) and reporting the spot to the WSPR website. There is one problem trying to draw lines from the TX station to all RX stations. The only thing that has worked so far is the below code.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.DisplayTrack( trpt1, trpt2 :TRealPoint );var     rxpt, txpt         :TPoint;begin     // Display a line between the TX and Rx stations     WSPRMap.DrawingEngine.PenWidth:=1;     WSPRMap.DrawingEngine.PenColor:=clRed;     txpt := WSPRMap.LonLatToScreen( trpt1 );      // TX screen point     rxpt := WSPRMap.LonLatToScreen( trpt2 );      // RX screen point     WSPRMap.DrawingEngine.Line(txpt.x,txpt.y,rxpt.x,rxpt.y);end; 
The problem is that when the map is zoomed or panned then the drawing engine deletes the tracks and they have to be displayed again. So my question is: what method should be used to draw these lines whereby the engine is aware of the change and redraws them?

wp:
Don't paint outside the paint cycle - that's a general rule, not related to the MapViewer. Because each control must be able to repaint itself at any time if the operating system requires that.

The "official" way to add a line to the mapview is to add a TGpsTrack to the GpsItems list of the MapViewer. The MapViewer "knows" what a track is and how to draw it because a track consists of discrete points connected by straight lines.

If the endpoints of your line are close to each other it is sufficient to simply add the endpoints to the track. When the line covers a large distance, however, you must divide the line into several segements and add these to the track as well; this way it is guaranteed that the line is curved due to the spherical projection of the grand circle between start and end point.

In the attachment you find a simple example for adding such a segmented "line" to the mapviewer.

Arctic_Eddie:
Thank you so much. I'll add that to my project tomorrow.

I have other questions but will put them in a separate post.

Arctic_Eddie:
Unfortunately, the compile failed in the same way as your ADrawer example. The error list is shown below. I'm missing something common in both situations.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Compile Project, Target: bin\x86_64-win64\mapviewer_line_demo.exe: Exit code 1, Errors: 4, Hints: 2Hint: Start of reading config file C:\lazarus\fpc\3.2.0\bin\x86_64-win64\fpc.cfgHint: End of reading config file C:\lazarus\fpc\3.2.0\bin\x86_64-win64\fpc.cfgmain.pas(55,12) Error: identifier idents no member "LineColor"main.pas(56,12) Error: identifier idents no member "LineWidth"main.pas(63,46) Error: Identifier not found "TRealPoint"main.pas(82,23) Error: Identifier not found "RealPoint" 

wp:
Ah, I see - you seem to be using the OPM version which is not in sync with the development version. Please install the version from ccr; either by using svn, or get the snapshot from https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/lazmapviewer/

Navigation

[0] Message Index

[#] Next page

Go to full version