Recent

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

MarkMLl

  • Hero Member
  • *****
  • Posts: 6950
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.
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: 6950
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.
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: 1142
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: 845
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: 6950
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.
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: 6950
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.
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: 845
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: 6950
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.
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: 845
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: 1142
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: 6950
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.
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: 845
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

 

TinyPortal © 2005-2018