[josm-dev] [PATCH] SlippyMap plugin engancements
dave at sr71.net
Sun Apr 19 20:08:46 BST 2009
With the API down, I'm a little bored. So, I hacked up the SlippyMap
plugin a bit. If anything here looks interesting, I'd be happy to break
this out into some slightly more manageable pieces.
Also, has anyone tried adding some caching to the tile fetching? I'm
using a local squid cache which makes things much nicer, but I'm sure it
would be even better to have something internal to the plugin.
1. Change tileStorage from being a set of arrays of hashmaps (one per
zoom level) to being a single hash. We do this by adding a 'level'
variable to the SlippyMapKey class. This simplifies the code a good
amount, and gets rid of a warning when allocating the HashMap array.
2. Introduce SlippyMapLayer.loadSingleTile(). This not only forces
the image to get loaded, but also checks the state of the entire
tileStorage, looking for extra tiles.
3. Add crude timestamping to SlippyMapTile. Whenever a load of a
SlippyMapTile is requested, we timestamp it. This lets us figure
out which have been least recently used later.
4. Bound the size of the tileStorage. Every so often, go look at all
of the tiles. Sort them by access time. Drop the image from the
tile if it isn't one of the 100 most recent ones. (Make this a
5. Add some sanity checks to SlippyMapKey to make sure we don't add
negative indexes. This keeps us from requesting urls like:
6. Introduce a new auto-zoom mechanism. Right now, it attempts to
see how many tiles are on the screen. This is OK, but it can cause
autozoom changes on just scrolling. Say you have a screen which
exactly fits 6x6 tiles. If you scroll over just a bit, you'll see
all of those 16 tiles, plus a few pixels of the next row over.
You'll all of a sudden be seeing 6x7 tiles, and autozoom will kick
in. This new mechanism attempts to detect how much tiles are being
squished or stretched. Since it has to load a tile before it can
actually find out the tile's size, it also has the nice side-effect
of getting things drawn on the screen earlier. Should these be
7. Add debugging to imageUpdate, printing the URL of images that fail to
load. Also add a SlippyMapTile.getImageURL() helper to facilitate
8. Make sure we redraw sooner when changing zoom levels
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 16086 bytes
Desc: not available
More information about the josm-dev