Arunkarthicknallasami / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Custom offline tiles repeats for all zoom levels #522

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using a custom offline tile rendering using ITileSource. I store my xip in 
sdcard and render tiles. I observe that when at any zoom level, the tile 
repeats everywhere. I'm reading using this format:

 public String getTileRelativeFilenameString(final MapTile tile) {
        final StringBuilder sb = new StringBuilder();

        int x = tile.getX();
        int z = tile.getZoomLevel();
        int y = tile.getY();
        int yy= (int) (Math.pow(2,z) -y-1);

        sb.append(pathBase());
        sb.append('/');
        sb.append(tile.getZoomLevel());
        sb.append('/');
        sb.append(tile.getX());
        sb.append('/');
        if(isSourceTMS)             
            sb.append(yy);
        else
            sb.append(tile.getY());
        sb.append(imageFilenameEnding()); 

        Log.d("APP","FilePath: "+sb.toString());
        return sb.toString();
    }

And here is how I'm setting to my MapView:

MapTilerCustomDataSource myNewXYTileSource = new MapTilerCustomDataSource();
myNewXYTileSource.isSourceTMS = true;
mMapViewOSM.setTileSource(myNewXYTileSource);

When at say zoom level 0, a single tile should be visible, but instead the maps 
actually repeats same tile throughout the mapView.

I'm using OSMdroid 4.0.3 version, Apache License v2.0, on a windows android 
development environment.

I'm not sure, the problem is on my end or the library, how can I resolve this, 
or is there any alternate method?

Original issue reported on code.google.com by Suraj.kv.blog@gmail.com on 31 Jan 2014 at 5:48

GoogleCodeExporter commented 9 years ago
I believe what you are describing is by design. Since we allow scrolling to 
"wrap" when scrolling east<->west we repeat drawing the tiles in each 
direction. It isn't ideal at very low zoom levels because you can see the same 
tiles repeated as you describe, but at higher zoom levels it allows for 
seamless scrolling "around" the world.

Original comment by kurtzm...@gmail.com on 31 Jan 2014 at 3:47

GoogleCodeExporter commented 9 years ago
So, is there a way to fix or temporarily hide this tile repetition?

Original comment by Suraj.kv.blog@gmail.com on 1 Feb 2014 at 2:24

GoogleCodeExporter commented 9 years ago
It would require changes to the code base. I would start with TilesOverlay 
which is what draws the tiles to the canvas.

Original comment by kurtzm...@gmail.com on 4 Feb 2014 at 3:48

GoogleCodeExporter commented 9 years ago
I guess the loop-method in the TileLooper has to be changed.
But that would only avoid drawing the tiles. The scrolling would still be 
infinite. Furthermore I believe the calculations of pixel-coordinates to 
geo-coordinates would be invalid?

Original comment by t...@innovaptor.com on 7 Feb 2014 at 2:06

GoogleCodeExporter commented 9 years ago
I tried to modify the loop-method of the TileLooper but with no real success so 
far.
I have no idea how to determine which tiles can be drawn at which position, so 
that only one map appears. 
The pViewPort rect which is gives isn't absolut either, since it sometimes 
resets because of computeScroll and scrollTo in the MapView. That can be 
handled but I am not sure if that is the right path or if there are any 
side-effects.

Furthermore other Overlays need to be changed as well, so that markers don't 
appear on a different map.

Original comment by t...@innovaptor.com on 9 Feb 2014 at 9:03