Recent

Author Topic: Lazmapviewer: overlaying a semi-transparent area  (Read 4794 times)

alpine

  • Hero Member
  • *****
  • Posts: 1240
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #15 on: July 12, 2024, 12:08:30 pm »
Is there any chance of an example which shows the code-driven creation of a layer containing one of those shaded triangles from some lat/long points, and another with a track of one or two segments again from lat/long points.
Sure. Just need some time for that, probably in late afternoon...
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 7478
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #16 on: July 12, 2024, 12:34:30 pm »
At your own pace, I've got plenty else to do: initialisation files, backend database, radio reliability...

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

alpine

  • Hero Member
  • *****
  • Posts: 1240
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #17 on: July 12, 2024, 07:08:42 pm »
OK, I've modified the project from the reply #12 to add programmatically the two areas shown.

What is changed:
  • The layer with the two areas defined previously into the form was marked invisible
  • On FormCreate one of two procedures can be invoked: AddAreas_mvMapViewer or AddAreas_mvGpsObj
  • The AddAreas_mvMapViewer procedure will create a TMapLayer with two TMapArea. It should be equivalent to what is created previously with the designer.
  • The AddAreas_mvGpsObj procedure will create TGPSComboLayer with two TGPSArea. It uses the mvGpsObj unit, i.e. the "original stuff" which wasn't previously meant for the designer manipulation.   

In fact, the TMapXXX classes are (more or less) designer-oriented wrappers for classes in mvGpsObj unit.

Analogically, if you want to create tracks instead of areas, you must substitute:

in AddAreas_mvMapViewer:
  • TMapArea with TMapTrack (and use Layer.Tracks.Add instead of Layer.Areas.Add)
  • TMapAreaPoint with TMapTrackPoint

in AddAreas_mvGpsObj:
  • TGPSArea with TGPSTrack
  • TGPSPoint is used in both, no need to be substituted

Hope that helps.
 
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

lar

  • Newbie
  • Posts: 6
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #18 on: July 12, 2024, 07:25:53 pm »
Not sure if this would help, but several weeks ago I posted a component in topic "LazMapViewer v.0.2.7" that serves as an interface to LazMapViewer. It retrieves a street map image into a bitmap on which a user can then do their own custom drawing (like layers in a GIS) without needing to add the windowed TMapView control to their project. #Alpine provided some help in getting it to work.

The component has only two functions, one to set a map provider and another to return a map image centered at a given lon,lat, at a given zoom level, placed in a bitmap of specified width and height. Unlike LazMapViewer, the component user would be responsible for implementing their own zooming and panning operations. I needed this type of interface since my use case involved drawing thousands of line segments and circles representing a city's water and sewer lines over the street map.

MarkMLl

  • Hero Member
  • *****
  • Posts: 7478
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #19 on: July 12, 2024, 07:48:07 pm »
OK, I've modified the project from the reply #12 to add programmatically the two areas shown.

Thanks (and noting also Iar's comment), I'm on it and will report back.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 7478
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #20 on: July 13, 2024, 11:18:57 am »
OK, I think I see better what's going on now and hopefully this will be a good foundation for when I'm displaying live tracks.

I've extended it to display both areas and tracks but do have a slight problem in that I appear to only be able to display one or the other- even if I add a second layer.

I need to work on some RF-related stuff now, since there are various kinds of traffic which only show up at weekends. However I'm tacking in an obviously-incomplete code fragment (normally invoked in the context of form creation) below in case anybody can see my glaring mistake :-)

Code: Pascal  [Select][+][-]
  1.   procedure initMapView;
  2.  
  3.   var
  4.     scratchLayer: TMapLayer;
  5.  
  6.  
  7.     procedure addArea(const area: TRegionDegs; colour: TColor; opacity: single);
  8.  
  9.     var
  10.       scratchArea: TMapArea;
  11.       i: integer;
  12.  
  13.     begin
  14.  
  15.       (* Add an areas object to the layer which will act as a container for     *)
  16.       (* coloured static blocks, returning a reference which may be used        *)
  17.       (* locally.                                                               *)
  18.  
  19.       scratchArea := scratchLayer.Areas.Add as TMapArea;
  20.  
  21.       (* Using that reference which is retained in-scope, set up drawing style  *)
  22.       (* and add features.                                                      *)
  23.  
  24.       scratchArea.LineColor := clNone;
  25.       scratchArea.FillColor := colour;
  26.       scratchArea.Opacity := opacity;
  27.       for i := 0 to High(area) do
  28.         with scratchArea.Points.Add as TMapAreaPoint do begin
  29.           Latitude := area[i].Lat;
  30.           Longitude := area[i].Lon
  31.         end
  32.     end { addArea } ;
  33.  
  34.  
  35.     procedure addAreas(const areas: TRegionsDegs; colour: TColor; opacity: single);
  36.  
  37.     var
  38.       i: integer;
  39.  
  40.     begin
  41.       for i := 0 to High(areas) do
  42.         addArea(areas[i], colour, opacity)
  43.     end { addAreas } ;
  44.  
  45.  
  46.     procedure addTrack(const pLine: TPolylineDegs; colour: TColor; opacity: single);
  47.  
  48.     var
  49.       scratchTrack: TMapTrack;
  50.       i: integer;
  51.  
  52.     begin
  53.  
  54.       (* Add a tracks object to the layer which will act as a container for     *)
  55.       (* coloured static polylines, returning a reference which may be used     *)
  56.       (* locally.                                                               *)
  57.  
  58.       scratchTrack := scratchLayer.Tracks.Add as TMapTrack;
  59.  
  60.       (* Using that reference which is retained in-scope, set up drawing style  *)
  61.       (* and add features.                                                      *)
  62.  
  63.       scratchTrack.LineWidth := 2;
  64.       scratchTrack.LineColor := colour;
  65.       scratchTrack.ConnectWidth := scratchTrack.LineWidth;
  66.       scratchTrack.ConnectColor := scratchTrack.LineColor;
  67.       scratchTrack.Opacity := opacity;
  68.       for i := 0 to High(pLine) do
  69.         with scratchTrack.Points.Add as TMapTrackPoint do begin
  70.           Latitude := pLine[i].Lat;
  71.           Longitude := pLine[i].Lon
  72.         end
  73.     end { addTrack } ;
  74.  
  75.  
  76.     procedure addTracks(const pLines: TPolylinesDegs; colour: TColor; opacity: single);
  77.  
  78.     var
  79.       i: integer;
  80.  
  81.     begin
  82.       for i := 0 to High(pLines) do
  83.         addTrack(pLines[i], colour, opacity)
  84.     end { addTracks } ;
  85.  
  86.  
  87.   begin
  88.  
  89.   (* Add a layer object to the MapView which will act as a container for areas  *)
  90.   (* and tracks, returning a reference which may be used locally.               *)
  91.  
  92.     scratchLayer := MapView1.Layers.Add as TMapLayer;
  93.  
  94.   (* Using that reference which is retained in-scope, add coloured static areas *)
  95.   (* to represent properties or villages which should not be overflown at low-  *)
  96.   (* levels, and an "in-circuit" area within which aircraft should exercise     *)
  97.   (* caution.                                                                   *)
  98.  
  99.     addAreas(Avoids, clRed, 1/6);
  100.     addArea(InCircuit, clBlue, 1/16);
  101.  
  102. //    scratchLayer := MapView1.Layers.Add as TMapLayer;    DOESN'T HELP
  103.  
  104.   (* Again using the retained reference, add the circuit and the runway         *)
  105.   (* alignment.                                                                 *)
  106.  
  107.     addTrack(Circuit, clGreen, 1/4);
  108.     addTrack(RunwayDegs, clBlack, 1/4)
  109.   end { initMapView } ;
  110.  

In a day or so's time I'll write a test program with a mapview with "avoid" areas and a circuit diagram, trying to move all map centering etc. into the runtime. It obviously won't have any data-collection facilities etc., but I think it would be a useful demo and focus for discussion.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

alpine

  • Hero Member
  • *****
  • Posts: 1240
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #21 on: July 13, 2024, 02:09:36 pm »
Quote
However I'm tacking in an obviously-incomplete code fragment (normally invoked in the context of form creation) below in case anybody can see my glaring mistake :-)
Assuming:
Code: Pascal  [Select][+][-]
  1. type
  2.   TRegionDegs = array of TRealPoint;
  3.   TRegionsDegs = array of TRegionDegs;
  4.   TPolylineDegs = TRegionDegs; //array of TRealPoint;
  5.   TPolylinesDegs = TRegionsDegs; //array of TRegionDegs;
  6.  
Your procedure works perfectly well for me.

For what mistake you're talking about?
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 7478
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #22 on: July 13, 2024, 02:36:51 pm »
Problem at present is that I can see areas, or tracks, but not both.

Leave it with me to distill everything into a simpler program... likely Monday unless it rains first.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

alpine

  • Hero Member
  • *****
  • Posts: 1240
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #23 on: July 13, 2024, 03:12:58 pm »
Problem at present is that I can see areas, or tracks, but not both.

Leave it with me to distill everything into a simpler program... likely Monday unless it rains first.

MarkMLl
You should have described the error earlier ;)
Code: Pascal  [Select][+][-]
  1.     (* Using that reference which is retained in-scope, set up drawing style  *)
  2.     (* and add features.                                                      *)
  3.  
  4.     scratchArea.LineColor := clNone; // change it to something different

Most probably it is my mistake. Seems that clNone affects the next drawings.

"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 7478
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #24 on: July 13, 2024, 03:24:59 pm »
Damn... should have spotted that one and experimented. Leave it with me, but right now I don't want to interrupt the program run.

Having the area displayed has showed up an internal geometry error with without any doubt has been responsible for various classification mistakes, giving me a good order in which to investigate and fix things :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 7478
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #25 on: July 13, 2024, 09:15:04 pm »
I /did/ describe it earlier; second para in #20 :-)

In any event, I can confirm that if the outline is set to clBlack (which in practice is barely visible hence "not unattractive" ** ) the tracks display as well.

Things aren't quite lined up yet, the kink in the approach is intentional so that pilots respect the privacy of one of the local magnates :-)

MarkMLl

** Roughly translated: "look pretty good" :-)
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

alpine

  • Hero Member
  • *****
  • Posts: 1240
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #26 on: July 13, 2024, 09:49:41 pm »
I /did/ describe it earlier; second para in #20 :-)
Yes, you did. I don't know what to say, maybe it's that we're having such freaking hot weather here that it's slowly melting my brain.

In any event, I can confirm that if the outline is set to clBlack (which in practice is barely visible hence "not unattractive" ** ) the tracks display as well.
You may try also with LineColor:=FillColor, or/and with a low opacity.

Anyway, I fixed it locally, but will commit later as there are some other glosses.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 7478
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #27 on: July 13, 2024, 10:33:02 pm »
I /did/ describe it earlier; second para in #20 :-)
Yes, you did. I don't know what to say, maybe it's that we're having such freaking hot weather here that it's slowly melting my brain.

/Hot????/ I'm in the UK, and came indoors a couple of hours ago since it was getting chilly...

Quote
You may try also with LineColor:=FillColor, or/and with a low opacity.

Anyway, I fixed it locally, but will commit later as there are some other glosses.

Yes, it appears to only be clNone which screws things... even if there is an accessible opacity for the outline having a minimal accent there is quite attractive. Please let us know if you commit changes, but I'll get onto a stripped-down demo program.

$DEITY this takes me back: GKS in the 1980s, streamed out as a CGM Metafile... I wrote some of that stuff in the DR era.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

alpine

  • Hero Member
  • *****
  • Posts: 1240
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #28 on: July 14, 2024, 12:13:21 am »
/Hot????/ I'm in the UK, and came indoors a couple of hours ago since it was getting chilly...
At the present moment I'd trade a beer or two at your place for any whim about LMV.

Since the r9377 I'm working on an IDE track points editor. It turns out that the IDE designer mechanics is way beyond my level of comprehension (and broadly undocumented), so everything  is a complete mess at the present. I'll put some effort to isolate it and to make the commit for that fix.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 7478
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #29 on: July 14, 2024, 12:25:46 am »
At the present moment I'd trade a beer or two at your place for any whim about LMV.

10.6C outside. Somebody's 50th birthday party nearby... youngster :-)

Quote
Since the r9377 I'm working on an IDE track points editor. It turns out that the IDE designer mechanics is way beyond my level of comprehension (and broadly undocumented), so everything  is a complete mess at the present. I'll put some effort to isolate it and to make the commit for that fix.

IDE documentation is a problem. I have absolutely no suggestions, since the project has been running so long that even the current maintainers might no longer understand every possible facet.

Which is why I think moving all initialisation into a demo program is worthwhile.

MarkMLl

MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018