NetworkMapSource and ChamplainCache change proposal
- From: Jiří Techet <techet gmail com>
- To: libchamplain-list gnome org
- Subject: NetworkMapSource and ChamplainCache change proposal
- Date: Sun, 22 Nov 2009 13:47:59 +0100
first of all I'd like to thank you for your library - it looks very
useful and I believe can make many developer's life easier. But end of
praise and let's continue with some constructive criticism ;-).
I'd like to use libchamplain in my application - it will be a
satellite navigation application that uses GPS to display your current
position (something like tangoGPS, but better of course ;-). I'm quite
happy with what NetworkMapSource of libchamplain offers, but I'd like
to have a separate cache with a different tile-purging strategy than
the one used by libchamplain (plus some extra features). After looking
at the source, I've realized that this is not easy to achieve for two
1. ChamplainCache is a singleton that cannot be replaced in
NetworkMapSource (that should be easy to change).
2. The encapsulation of ChamplainCache and NetworkMapSource is broken.
Basically, NetworkMapSource shouldn't know how ChamplainCache stores
the tiles (whether they are stored in files or binary blobs in the
database for example) - there should just be an interface of
ChamplainCache that NetworkMapSource uses to get or store the tile.
This isn't the case now. NetworkMapSource accesses the tile-files
directly in file_loaded_cb to update the tiles (but it loads them by
using a method of ChamplainCache, so there is clearly an imbalance
here). I believe that all this is due to historical reasons as
ChamplainCache is new in 0.4 if I'm not mistaken.
Right now this means that one has to reimplement both NetworkMapSource
and ChamplainCache even if he wants to reimplement ChamplainCache
only. Not such a big deal if you make your implementation in C (you
just modify the sources of NetworkMapSource), but when you are using
Python, which is what I do, you have to reimplement both of these
classes completely. As a matter of fact, I did it, but had to face
several problems mainly because of the fact that libsoup for Python
doesn't look so well-supported so I used Python's default urllib2,
which doesn't have all the libsoup's features I would need to do all
the etag stuff you do in NetworkMapSource now.
By the way, this:
is missing in pychamplain-base.defs - without it, you can't override
the fill_tile in your subclass of ChamplainMapSource in Python (see
e.g. pyclutter to see how to make virtual method bindings for Python).
So I would really prefer if libchamplain changed to make
ChamplainCache overridable. What I would like to propose is the
1. Introduce ChamplainBaseCache with the very basic methods that
NetworkMapSource needs to access the cache.
2. Derive ChamplainCache from it and implement these methods -
basically means to move the code that accesses the tile-files in
NetworkMapSource here. After looking at the code I think that either
the semantics of the existing functions (namely update_tile()) will
have to change a bit or some extra methods will have to be introduced,
maybe both (this might not be such a big problem since I think that
nobody uses these methods of ChamplainCache directly now).
3. ChamplainCache singleton instance would remain as the default cache
(this preserves the compatibility with existing applications), but
there should be a method that changes the cache used by
4. Anyone who wants to implement his own cache would derive
ChamplainBaseCache, implement its methods and assign it to
And now some good news - if you decide you like the proposed changes,
I'd be happy to implement them (well, the patch might be shorter than
this email :-). What's your opinion?
[Date Prev][Date Next
] [Thread Prev][Thread Next