Recent

Author Topic: TMapViewer  (Read 103522 times)

CV

  • Newbie
  • Posts: 6
Re: TMapViewer
« Reply #150 on: April 03, 2022, 03:03:55 pm »
I'm brand new to this forum, therefore sorry if my request is not properly placed..
I've played around with MapView for quite a while on Windows and Raspberry. Many thanks to all creators and supporters for all the wunderfull functions!

My questions: Is there a way to apply a (digital) zoom factor to the drawing canvas itself? To stretch each of the 256x256 tiles to a (e.g) 512x512 pixels?
Or where would be the best place to access the respective canvas code and insert my own additional copy and zoom code? I'm a bit lost by the huge amount of files and wasn't able to track it down..

Why? For simple magnification for better visibility. My display is physically small and a digital zoom would help very much to recognize tiny details. My application is intended for offline use. All tiles have been created upfront (for my area of interest) and stored to the cache folder. To limit the amount of tiles I've restricted the zoom level to 15. Therefore it is not possible to just go to the next tiles' zoom level.

Many thanks in advance.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: TMapViewer
« Reply #151 on: April 03, 2022, 03:21:47 pm »
I suppose you are talking of the LazMapViewer package. The tiles are delivered from the server as 256x256 png bitmapped images. There is no easy way to upscale the images in order to better resolve details - normally the images just get blurry. I don't know what they do in the movies when the hero asks the assistant to zoom in further so that the tiny license plate becomes readable...

If you somehow manage to get 512x512 images of good quality, it is possibly enough to simply change the constant TILE_SIZE in unit mvTypes to 512.


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: TMapViewer
« Reply #152 on: April 03, 2022, 03:41:57 pm »
Use opengl and hw anti aliassing?

CV

  • Newbie
  • Posts: 6
Re: TMapViewer
« Reply #153 on: April 03, 2022, 03:51:02 pm »
Yes, the LazMapViewer package :-[

I will check the 512x512 option, thanks for the hint.

For now I'm applying a workaround. On each "OnChange" event of the MapViewer component I copy the canvas to a larger one (CopyRect), thus magnifying it. But that is not really synchronised, I assume due to the Threading.
Do you have a better code position (than in main.pas) in mind to do this?

Yes, blurrying is starting to become visible. But 2x magnification is all I need.

Btw, I'm already running two MapViewer components in parallel, at different zoom levels. Works great and smooth :).

bobby100

  • Full Member
  • ***
  • Posts: 161
    • Malzilla
Re: TMapViewer
« Reply #154 on: April 03, 2022, 04:02:54 pm »
I don't know what they do in the movies when the hero asks the assistant to zoom in further so that the tiny license plate becomes readable...
There was a program that converted image to fractals (ca. 1996-1997, I got it from some BBS). It replaced the tiles of BMP with appropriate fractals. The generated fractalized pictures were at least 10x more "zoomable" than a BMP.
A fractalized picture looks somewhat synthetic compared to the original (something like a bad anti-aliasing). By zooming over some extent, you could see the fractals that all of us know.
Nothing like the zoom in the movies, but still something.

Related:
https://en.wikipedia.org/wiki/Fractal_compression

I apologize for going off-topic
https://gitlab.com/bobby100 - my Lazarus components and units
https://sourceforge.net/u/boban_spasic/profile/ - my open source apps

https://malzilla.org/ - remainder at my previous life as a web security expert

CV

  • Newbie
  • Posts: 6
Re: TMapViewer
« Reply #155 on: April 22, 2022, 08:56:46 pm »
I'm still playing with and learning from the examples that come the LazMapViewer package.
Another question came up about the handling of GpsItems. I've create such an object with the following code:
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.btCreatePointClick(Sender: TObject);
  2. var
  3.   rPt: TRealPoint;
  4.   gpsPt: TGpsPoint;
  5.   gpsName: String = '';
  6. begin
  7.   rPt := MapView.Center;
  8.   gpsPt := TGpsPoint.CreateFrom(rPt);
  9.   gpsPt.Name := '';
  10.   MapView.GpsItems.Add(gpsPt, _CLICKED_POINTS_);
  11. end;  
So far so good. The marker appears where it should be (at the center of the screen). It also shows up correctly in the GPS points list (part of the example). 
Next I've moved the window a bit and tried to move/change the location of the GpsObject to the new center by applying:
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.btRelocateToCenterClick(Sender: TObject);
  2. var
  3.   rPt: TRealPoint;
  4.   gpsObj: TGpsObj;
  5. begin
  6.   rPt := MapView.Center;
  7.   if (MapView.GpsItems.Count > 0) then begin
  8.     gpsObj := MapView.GpsItems[0];
  9.     if gpsObj is TGpsPoint then begin
  10.       TGpsPoint(gpsObj).MoveTo(MapView.Center.Lon, MapView.Center.Lat, NO_ELE ,NO_DATE );
  11.     end;
  12.   end;
  13. end;
From now on the painting of the marker get's weird, or disappears completely, also depeding on zoom level.
What am I doing wrong?

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: TMapViewer
« Reply #156 on: April 23, 2022, 07:02:01 pm »
Did you try to call MapView.Redraw at the end of btRelocateToCenterClick?

CV

  • Newbie
  • Posts: 6
Re: TMapViewer
« Reply #157 on: April 24, 2022, 09:58:52 am »
No improvement with .Redraw.
I've also altered the settings for DrawingEngines, Threads and Double Buffering: no improvement.

The workaround I found is to clear the list and create a new entry with updated coordinates:
Code: Pascal  [Select][+][-]
  1.       MapView.GpsItems.Clear(_CLICKED_POINTS_);
  2.       gpsObj := TGpsPoint.CreateFrom(rPt);
  3.       gpsObj.Name := '';
  4.       MapView.GPSItems.Add(gpsObj, _CLICKED_POINTS_);
  5.  

(This marker shows the current GPS-position. New coordinates about every 0.5 second)

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: TMapViewer
« Reply #158 on: April 24, 2022, 11:42:38 am »
I cannot reproduce this - although I agree that sometimes the markers disappear. This is a consequence of the tiled painting routine which draws the map tile by tile in individual threads and unpredictable order, and puts the markers on top of it which may be overwritten if the image tile is painted later. I think the painting routine requires a major overhaul...

Since you have to erase the marker list I assume that you already have some markers before your code is executed. Please be aware that gpsObj := MapView.GpsItems[0] refers to the first marker added which is not necessarily the one you are interested in.

CV

  • Newbie
  • Posts: 6
Re: TMapViewer
« Reply #159 on: April 24, 2022, 03:46:36 pm »
Maybe the drawing routine somehow memorizes the GPS location when adding/creating a new element?..
Btw, my workaround idea was inspired by the GPSListViewer (TGPSListViewer.BtnDeletePointClick, deleting a point from the list).
(And thanks, I'm aware of affecting all elements of the list)


All in all I'm still very happy how nice and smooth this component works. Keeping the effort in mind it took to come to this level I feel a bit bad to propose some improvements. Also the idea contradicts the tiles-approach. But this would be my wishlist:

For offline usage it's a pain to handle all the tiles. Even for small areas I have to deal with several 100k of tiles/files. Would it be possible to get the data out of one single file (regardless its size)? I've seen this approach based on vector data:
https://github.com/serbod/osmap

CV

  • Newbie
  • Posts: 6
Re: TMapViewer
« Reply #160 on: May 25, 2022, 08:55:09 pm »
I've been playing around with MapViewer for some weeks now and want to share my observations, .. and problems. My main machine is a typical Win10-64 bit. The second (and final) target is a small tablet Win10-32 bit, 1GB RAM, Intel Atom Z3735G processor.
All tiles are stored in the disk-cache, online connection is not used.
At a first glance the component works as expected and smoothly.

But randomly an exceptions is raised when shutting down: "External: ACCESS VIOLATION" executing address $0.." . Seems to be caused somewhere around the "TMapViewerEngine.Destroy" execution. Any idea what might cause this?

Second the program does not terminate properly on the small machine (1 GB RAM). Exceution has to be killed in the IDE ("Halt"), or by the Windows Task Manager.

Third the program seems to eat RAM. "Process Explorer" (from the Sysinternal Suite) reports increasing RAM size, each time new tiles are loaded for display. Is this behavior normal? Or limited to a certain point?

Any help is greatly appreciated.

 

TinyPortal © 2005-2018