[josm-dev] Walking Papers Plugin broken

Dave Hansen dave at sr71.net
Fri Nov 6 16:15:48 GMT 2009


On Fri, 2009-11-06 at 16:14 +0100, Frederik Ramm wrote:
> Hi,
> 
>     I'm investigating this bug:
> 
> http://josm.openstreetmap.de/ticket/3855
> 
> The Walking Papers plugin is based on the old Slippy Map plugin, and the 
> code that leads to this bug roughly does this:
> 
> public void paint(Graphics g, MapView mv) {
> 
> LatLon topLeft = mv.getLatLon(0, 0);
> LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
> 
> viewportMinX = lonToTileX(topLeft.lon());
> viewportMaxX = lonToTileX(botRight.lon());
> viewportMinY = latToTileY(topLeft.lat());
> viewportMaxY = latToTileY(botRight.lat());
> 
> for (int x = viewportMinX-1; x <= viewportMaxX; x++) {
>    for (int y = viewportMinY-1; y <= viewportMaxY; y++) {
>      WalkingPapersKey key = new WalkingPapersKey(currentZoomLevel, x, y);
> 
> That's where it arrives at ridiculous values like 2147483647 for x and 
> -104914 for y.

I've never actually seen that particular bug.  However, there were a
bunch of issues with boundaries and limits, especially when zooming
around or being at the edges of the map.

The autozooming can also go postal sometimes.

> Before I delve further into this - is this perhaps a consequence of 
> Dirk's recent change in the projection stuff? Is there an easy 
> workaround, or should I perhaps re-write the whole plugin based on the 
> *new* Slippy Map code which (I hear) is totally different?

It's not too totally different.  It's been pretty incremental actually.
The code that was copied has a few of my changes, but not the recent
stuff.

The recent changes use the JMapViewer code for tile storage, management,
and caching.  It makes things a lot faster and lets us potentially share
a tile cache with the slippy_map_chooser.

The layer code for WalkingPapers is still awfully close to the slippymap
layer.  My suggestion would be to go make a new TileSource and just try
to hack it in to the current slippymap.  I do believe the new code is
much nicer than what was there before and it should be easier to work
with.

You can either instantiate one of these classes:

    public static class Custom extends OsmTileSource.AbstractOsmTileSource {
        public Custom(String name, String url) {
            super(name, url);
        }
        public Custom(String name, String url, String extension) {
            super(name, url);
            this.extension = extension;
        }
        String extension;
        @Override
        public String getExtension() {
            if (extension == null)
                return super.getExtension();
            return extension;
        }
        public TileUpdate getTileUpdate() {
            return TileUpdate.IfNoneMatch;
        }
    }

or just override the getURL() from OsmTileSource.

-- Dave





More information about the josm-dev mailing list