Recent

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

MarkMLl

  • Hero Member
  • *****
  • Posts: 8035
Lazmapviewer: overlaying a semi-transparent area
« on: June 10, 2024, 10:35:35 am »
Given a closed area specified by lat/long coordinates, is it possible to overlay this onto LazMapViewer as a semi-transparent image?

Context is roughly "be aware that this is controlled airspace and you should be telling somebody you're entering it", so I'd like to be able to wash it in e.g. pink in a way that didn't obscure the underlying map or any tracks drawn over it.

Xref to https://forum.lazarus.freepascal.org/index.php/topic,66345.msg507828.html which discussed drawing tracks.

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: 8035
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #1 on: June 11, 2024, 09:26:54 am »
Does anybody have any thoughts on this please?

Do I have to do something baroque like setting up a custom map provider server?

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: 1302
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #2 on: June 11, 2024, 10:56:46 am »
Currently the only way to draw with alpha channel is with the DrawingEngine's DrawBitmap method.
Quote
Do I have to do something baroque like setting up a custom map provider server?
You can take a look at TGPSTileLayerLabels in mvmapviewer.pas - when added it will draw a text label over each tile containing the tile's X,Y,Z. The same way a bitmap can be drawn over. Most of the drawing complications are because the MapView.Cyclic property, but with enough zoom or Cyclic=false it should be much simpler.   

PS: I had the idea to implement just that, recently more pressing issues emerged and work on LazMapViewer went on the back burner. Maybe it's time to get back to it after one needs it.
« Last Edit: June 11, 2024, 11:13:58 am by alpine »
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

loaded

  • Hero Member
  • *****
  • Posts: 853
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #3 on: June 11, 2024, 11:03:42 am »
I think making Lazmapviewer use BGRABitmap for drawing map tiles will give you the effect you want.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

MarkMLl

  • Hero Member
  • *****
  • Posts: 8035
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #4 on: June 11, 2024, 11:17:31 am »
Thanks for that, will investigate.

The only other way that occurs to me is to draw a track, convert the points to screen coordinates, and draw a filled polygon... provided of course that I can access the canvas, and work out how to refresh when needed.

https://forum.lazarus.freepascal.org/index.php?topic=12674.60 appears relevant.

Considering the image I posted at https://forum.lazarus.freepascal.org/index.php/topic,65082.msg495499.html#msg495499 (which was actually a screenshot from QGIS), I now have fairly good capabilities for classifying a "point of interest", i.e. distance from field, alignment with circuit and strip, incursion into prohibited areas, observational azimuth/elevation and so on. That leaves the bulk of my problems being graphical: overlays for circuit/strip and prohibited areas, and then addition/removal of live tracks.

In practice I have to drop this for a while: I have a couple of tax returns to do and some hardware I've promised to look at.

However any thoughts appended here would be welcome.

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: 8035
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #5 on: June 11, 2024, 12:47:03 pm »
I think making Lazmapviewer use BGRABitmap for drawing map tiles will give you the effect you want.

Looking (very briefly) at the source, I see the drawing engine interface has a Polygon() function as standard. However I haven't yet investigated fill and opacity... if the example images you posted were done from inside LazMapviewer then it's obviously encouraging (any chance of appending example code?).

Anyway, as I've said: I have to drop this for a while do to pressing demands on my time.

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

loaded

  • Hero Member
  • *****
  • Posts: 853
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #6 on: June 11, 2024, 01:29:42 pm »
Looking (very briefly) at the source, I see the drawing engine interface has a Polygon() function as standard. However I haven't yet investigated fill and opacity... if the example images you posted were done from inside LazMapviewer then it's obviously encouraging (any chance of appending example code?).

Hey MarkMLl

Sample images above;
It was prepared in the simple CAD application I wrote before. The purpose here is; To see the houses within the parcel when field color fills are on. Actually the same logic.

A long time ago, about 5 years ago, I had a project where I was working on Drawing Transparent Polygons to perform area calculations on an immutable Satellite View loaded on a BGRABitmap object, without using Lazmapviewer. That's where the idea for BGRABitmap comes from.
If I can find the project when I get home in the evening, I will share it here.

During this time, I am not aware of any changes or updates made to Lazmapviewer. I know wp (I would like to take this opportunity to thank him very much. He has a great influence on me) is very talented and knowledgeable on this subject. I hope he also gives his opinion.
« Last Edit: June 11, 2024, 01:31:55 pm by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

MarkMLl

  • Hero Member
  • *****
  • Posts: 8035
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #7 on: June 11, 2024, 02:00:07 pm »
...immutable Satellite View loaded on a BGRABitmap object, without using Lazmapviewer. That's where the idea for BGRABitmap comes from.
If I can find the project when I get home in the evening, I will share it here.

That's the issue. The questions are (a) from a program which relies heavily on LMV, are the drawing engine functions relevant to semi-opaque arbitrary polygons accessible and (b) since the bulk of the program uses lat/long coordinates can these be converted to canvas x/y coordinates (which are presumably what are used by the drawing engine) in a way that tracks zoom and pan?

It might turn out to be expedient to add polygon/opacity support to the drawing engine interface, even if LMV itself doesn't make use of them.

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

loaded

  • Hero Member
  • *****
  • Posts: 853
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #8 on: June 11, 2024, 02:20:55 pm »
The questions are (a) ... (b)

The answers to your questions are available in the application I wrote on the Android platform.
https://youtu.be/gBS0AMrJ50s?si=rkEJ6t7mQCJBaJ3w
If you watch it, you will please me.

Surfaceview object is used in the application.
https://developer.android.com/reference/android/view/SurfaceView

I believe these can be easily done in Lazmapviewer.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

alpine

  • Hero Member
  • *****
  • Posts: 1302
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #9 on: June 11, 2024, 02:58:40 pm »
The questions are (a) from a program which relies heavily on LMV, are the drawing engine functions relevant to semi-opaque arbitrary polygons accessible and
While there is a Polygon() engine method, the transparency is not yet supported. That is due to the fact several graphics libraries can be used (BGRA included) and just the lowest common functionality is implemented.
(b) since the bulk of the program uses lat/long coordinates can these be converted to canvas x/y coordinates (which are presumably what are used by the drawing engine) in a way that tracks zoom and pan?
Yes, definitely.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 8035
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #10 on: June 11, 2024, 03:23:38 pm »
While there is a Polygon() engine method, the transparency is not yet supported. That is due to the fact several graphics libraries can be used (BGRA included) and just the lowest common functionality is implemented.

When I'm next on it, I'll be tempted to add transparency etc. even if in some cases it has to have a dummy implementation.

What I'm trying to do is basically fuse https://forum.lazarus.freepascal.org/index.php/topic,65082.msg495499.html#msg495499 and https://www.deanland-airfield.co.uk/templates/g5_anacron/custom/images/misc/OS_shot_circuit_path.png : live data collection I've done and backend storage etc. is no problem.

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

loaded

  • Hero Member
  • *****
  • Posts: 853
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #11 on: June 11, 2024, 09:49:47 pm »
My basic work for drawing interactive transparent polygon on fixed satellite view. The aim here was to understand the logic of drawing interactive transparent polygons.
I cleared the Timage object due to size issue. If you want, you can add a satellite view. So it can be understood more clearly.
This is a very old work of mine, so I may make mistakes, I hope you will forgive me. Respects.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

alpine

  • Hero Member
  • *****
  • Posts: 1302
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #12 on: July 03, 2024, 11:35:02 am »
@MarkMLl
As of r9377 LazMapViewer is now capable to draw a semi-transparent areas. I'm attaching a sample screenshot and project.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 8035
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #13 on: July 03, 2024, 11:37:24 am »
Thanks for that, I'll grab an update as soon as I've got some more of the underlying Rx issues sorted... couple of days perhaps.

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: 8035
Re: Lazmapviewer: overlaying a semi-transparent area
« Reply #14 on: July 12, 2024, 10:37:59 am »
OK, working with r9380. I can see how that hangs together nicely from the POV of the designer, but am struggling to work out the equivalent runtime code: there are simply too many layers of generics etc. and I find it unclear what can be done in-situ and what has to be done by building objects as local variables and then adding them to the layer.

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.

If I could have something along those lines which I can work into my own code, I'll then write it up in the wiki article to try to save other people similar effort.

Xref to related discussion at https://forum.lazarus.freepascal.org/index.php/topic,66345.msg507828.html#msg507828

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