Fr0sT-Brutal / Delphi_OSMMap

Visual control for Delphi and Lazarus to display OSM map
Mozilla Public License 2.0
65 stars 22 forks source link

TileProvider small modifications #15

Closed fabianopaolini closed 11 months ago

fabianopaolini commented 1 year ago

Is possible to define TTilesProvider.Create as Virtual? So I can create more TTilesProvider of the same type using a variable as: TilesProviderClass : Class of TTilesProvider and I can do: TileProviderClass.Create;

Is possible to add a new virtual string property to TTilesProvider: MapCacheName: string; so we can use this to initialize TTileStorage with a subpath in cache path to have eache Provider cached in a different subdirectory?

In OSMMapDemo the TTilesProvider is created now twice: NetRequest := TNetworkRequestQueue.Create(4, 3, NetworkRequest, TOSMTilesProvider.Create); mMap.TilesProvider := TOSMTilesProvider.Create;

Is possible to use the same instance of TOSMTilesProvider in both parts? If I use the same instance now when I close the App, it will be destroyed twice with error!

Fr0sT-Brutal commented 1 year ago

Good points, thanks!

Is possible to define TTilesProvider.Create as Virtual?

Done in v.0.9.2

Is possible to add a new virtual string property to TTilesProvider: MapCacheName: string;

TTilesProvider shouldn't care about tile storage so I added TTilesProvider.Name that can be used for this purpose

Demo now handles multiple providers and allows changing them on-the-fly.

Is possible to use the same instance of TOSMTilesProvider in both parts?

You're right of course and I dislike that duplication as well. Alas, change is not so easy. Provider is used in bg threads by network queue so using a single instance of provider can cause random AVs. I've got no idea currently on how to make it reliably enough. I thought about making providers static classes to get rid of instances at all but later we could implement switching layers within the provider (like scheme/satellite/mixed/etc) so it will likely require writable instance properties.

Fr0sT-Brutal commented 1 year ago

As for double-releasing provider instance, it is documented that queue and map control take ownership on the instance and release it when needed. Not a solid solution though but better than nothing...

Fr0sT-Brutal commented 1 year ago

@fabianopaolini BTW I added OpenTopoMap in the latest version

Fr0sT-Brutal commented 11 months ago

Single tile provider instance (well, single from the user's POV) done in d92a1fecda64a183ba4abdcb98b2803a595a3e25