Re: NetworkMapSource and ChamplainCache change proposal
- From: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
- To: Jiří Techet <techet gmail com>
- Cc: libchamplain-list gnome org
- Subject: Re: NetworkMapSource and ChamplainCache change proposal
- Date: Mon, 23 Nov 2009 08:11:22 +0100
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.
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
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.
(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
--
Emmanuel Rodriguez
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]