opensciencemap / vtm

a vector-tile map library written in java - running on android, desktop and within the browser
GNU Lesser General Public License v3.0
238 stars 176 forks source link

wrong min and max zoom levels in BitmapTileSource #120

Closed stleusc closed 9 years ago

stleusc commented 9 years ago

Quick summary:

UrlTileSource:

    protected UrlTileSource(Builder<?> builder) {
        this(builder.url, builder.tilePath, builder.zoomMin, builder.zoomMax);
        mHttpFactory = builder.engineFactory;
    }

It uses zoomMin and zoomMax from abstract builder defined in UrlTileSource.

BitmapTileSource has implementation of abstract builder with following Constructor:

    public Builder() {
        super(null, "/{Z}/{X}/{Y}.png", 0, 17);
    }

This sets the default zoomMin = 0 and zoomMax = 17.

Constructor of BitmapTileSource is like this:

    public BitmapTileSource(String url, String tilePath, int zoomMin, int zoomMax) {
        super(builder()
            .url(url)
            .tilePath(tilePath)
            .zoomMin(zoomMin)
            .zoomMax(zoomMax));
    }

however .zoomMin() and .zoomMax() are defined in the base class here:

        public T zoomMin(int zoom) {
            minZoom = zoom;
            return self();
        }

        public T zoomMax(int zoom) {
            maxZoom = zoom;
            return self();
        }

saving the max and min zoom in variables maxZoom and minZoom!

So even though it seems like they get set correctly, in fact they are not! They are stored in the wrong variables...

public abstract class TileSource {

    public abstract static class Builder<T extends Builder<T>> {
        int minZoom, maxZoom;
        FadeStep[] fadeSteps;

minZoom, maxZoom, fadeSteps are effectifly hidden and not used anywhere.

This also means that setting max/min zoom or fadeSteps in DefaultSources like

    public static Builder<?> MAPQUEST_AERIAL = BitmapTileSource.builder()
        .url("http://otile1.mqcdn.com/tiles/1.0.0/sat")
        .tilePath("/{Z}/{X}/{Y}.jpg")
        .fadeSteps(fadeSteps)
        .zoomMax(8);

does not have any impact!

hjanetzek commented 9 years ago

Thanks for the thorough investigation! Should be fixed now.