Re: NetworkMapSource and ChamplainCache change proposal
- From: Jiří Techet <techet gmail com>
- To: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
- Cc: libchamplain-list gnome org
- Subject: Re: NetworkMapSource and ChamplainCache change proposal
- Date: Mon, 23 Nov 2009 23:59:34 +0100
On Mon, Nov 23, 2009 at 08:11, Emmanuel Rodriguez
<emmanuel rodriguez gmail com> wrote:
> On Mon, Nov 23, 2009 at 1:32 AM, Jiří Techet <techet gmail com> wrote:
>>
>> Hello Emmanuel,
>>
>> Notice that Cache is basically a MapSource - it's a source whose tiles
>> are stored offline and, in addition, you can store some tiles into it.
>
> If Cache and MapSource share the same "method" names that provide the
> functionality of loading tiles it would make things even easier, at least
> from the view's perspective. This could be achieved if they both inherit
> from a common ancestor or if they implement the same interface.
>
Exactly.
>> So we could inherit a cache from MapSource + add the extra methods for
>> storing tiles. Now, for fill_tile(), we could use the chain of
>> responsibility like this:
>>
>> ChamplainView --> cache1 --> cache2 --> NetworkMapSource
>
> Interresting idea, the chain of responsibility makes also sense for
> MapSources. Consider this user case scenario where some governments or
> companies have different map sources that are limited small geographical
> regions; for example the region of Cataluña in Spain has maps lots of maps
> for its region [1]. If one has the rights to use the tiles for Cataluña it
> would make sense to chain the CatalunaMapSource to another map source (for
> instance OpenStreetMaps) in order to make sure that the MapView is always
> able to find tiles to render.
>
> [1]
> http://www.icc.cat/vissir2/?lang=ca_ES&zoom=3&lat=4628118.29268&lon=404056.09756&layers=B00FFFFFTF
>
Yes, but there might be problems with the caches. First, there should
be some assignment of caches and map sources - one cache can store
tiles of multiple map sources and it has to know tiles of which map
source it should retrieve. I would suggest that all caches retrieve
tiles of the nearest map source that follows them, so in
cache1 --> cache2 --> mapSource1 --> cache3 --> mapSource2
cache1 and cache2 retrieve tiles of mapSource1 and cache3 retrieves
tiles of mapSource2. Second, if you want to cache two map sources in a
chain, you must have
cache1 --> MapSource1 --> cache2 --> MapSource2
Caching with a single cache for both map sources isn't possible in a
single cache within a chain (the cache wouldn't know whose tiles it
should provide).
> This pattern addresses a lot of issues but adds a bit of complexity when
> comes the moment of replacing the default cache and map source to use.
> Imagine if you want to change the current map source. We will need to walk
> the responsibility list until we find the map source and swap it with the
> new one. The same thing applies to the caches replacing a cache
> implementation has to take care to keep the chain intact otherwise the map
> source is lost. Note that ChamplainView could take care of that and make it
> transparent to the user or somehow easier.
Exactly, ChamplainView can take care of that (see my email to
Pierre-Luc - this time referring to an existing email ;-)
>
>> (Where the number of caches is arbitrary, or even 0, and the last in
>> the chain is NetworkMapSource.) If the tile is not present in cache1,
>> it asks the next one in the chain and so on. When it reaches
>> NetworkMapSource, it will load the tile from the network and a reverse
>> procedure will occur to store the tile into a cache:
>>
>> NetworkMapSource --> cache2 --> cache1
>>
>> (This means that caches would have to contain references to MapSources
>> and vice versa.) If cache2 doesn't want to store the tile, it just
>> delegates the work to cache1.
>>
>> Other functions of MapSource (like
>> champlain_map_source_get_longitude()) will be simply delegated to
>> subordinate caches until they they reach NetworkMapSource which will
>> be the one that returns the value. Notice that this solution is very
>> elegant for ChamplainView - it doesn't have to care whether it is
>> attached to a cache or a NetworkMapSource - it will always do the very
>> same thing.
>>
>> After thinking about it this looks as a much more elegant solution so
>> I'm inclined to implement this one. Your opinion?
>
> I like the idea. Will be nice to have Pierre-Luc's opinion too!
>
>>
>> Thanks,
>
> Prosim
¡Tu checo está muy bien!
(And I hope I haven't offended you much by speaking Spanish if you are
from Cataluña ;-)
Jiří
>
> --
> Emmanuel Rodriguez
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]