aspic / libgdx-maps

An OpenStreetMap widget for libgdx
GNU General Public License v3.0
26 stars 6 forks source link

no map tiles for zoom level 10 or higher #1

Closed ouya99 closed 10 years ago

ouya99 commented 10 years ago

apparently the index to pixel or view controller is not working.

I disabled isValidTile (set it to return true) then it goes up to zoom level 12 or so .. still not further though.

also think that in getTile the mod division tileX = tileX % numTilesWide; is not doing right when numTilesWide goes to down to 256 (zoom = 10) while tileX goes beyond 512. then it definitely allocates the wrong tiles via URL.

private TextureTile getTile(int tpx, int tpy, int zoom, boolean eagerLoad) { ..... int numTilesWide = getMapDimension(zoom).getWidth(); if (tileX < 0) { tileX = numTilesWide - (Math.abs(tileX) % numTilesWide); }

    int tileY = tpy;
    // TilePoint tilePoint = new TilePoint(tileX, tpy);
    String url = info.getTileUrl(tileX, tileY, zoom);// tilePoint);

// tileX = tileX % numTilesWide;

aspic commented 10 years ago

Thanks for highlighting this! I will try to look at the issue later today. There were some problems with the TiledMap in Libgdx not being able to handle close zoom levels (too many tiles were created), not sure if that is what you are seeing though.

aspic commented 10 years ago

This issue should be adressed and fixed in 8917db835fd8dd73e3437d44d8bc757d0294756c. Please let me know how it works out for you. I also refucktored/removed some code in the progress. I will probably rewrite parts of the core of this library in the future (not the api itself).

Also, zoom levels above 13 or 14 seems to eat all my JVM RAM. I will have to look into some optimization in the TiledMap soon. :-)

ouya99 commented 10 years ago

Well done so far. I can zoom up to 13/14 now.... then as you said I get an OutOfMem error. Are you allocating so many tiles? How can that be? Are you freeing the old tiles correctly from other zoom levels correctly?

Add-ons.. would be nice if you uploaded your pin asset and maybe allow setting a default zoom level other even have a slider like google maps. just in case you have too much time.....

MapManager: Layer did not exist for zoom 15 Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.OutOfMemoryError: Java heap space at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120) Caused by: java.lang.OutOfMemoryError: Java heap space at com.badlogic.gdx.maps.tiled.TiledMapTileLayer.(TiledMapTileLayer.java:76) at no.mehl.libgdx.map.info.MapManager.getLayer(MapManager.java:277) at no.mehl.libgdx.map.info.MapManager.transition(MapManager.java:292) at no.mehl.libgdx.map.info.MapManager.zoom(MapManager.java:285) at no.mehl.libgdx.map.ui.MapListener.tap(MapListener.java:30) at no.mehl.libgdx.map.example.MapView.tap(MapView.java:119) at com.badlogic.gdx.input.GestureDetector.touchUp(GestureDetector.java:195) at com.badlogic.gdx.input.GestureDetector.touchUp(GestureDetector.java:169) at com.badlogic.gdx.InputMultiplexer.touchUp(InputMultiplexer.java:94) at com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents(LwjglInput.java:303) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:200) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)

aspic commented 10 years ago

I use the libgdx tiled maps api to generate the tiles. It seems that this class allocates all tiles for each zoom level, even though the tile isn't displayed. This is pretty bad for my use case, since there could potentially be a lot of tiles that should never be loaded. I will look into the tiledmap-classes and see if I could do some optimization, or roll my own implementation.

ouya99 commented 10 years ago

So you mean you allocate like all tiles for the whole globe. This would explain the issue.

I also see that the number of layers goes up steadily while zooming in. Maybe we could just use one layer at a time for each zoom level and like populate these zoom levels.. then switching between layers would be quite fast too. (=zoom in/out)

On Tue, Jun 3, 2014 at 1:43 PM, Kjetil Mehl notifications@github.com wrote:

I use the libgdx tiled maps api https://github.com/libgdx/libgdx/wiki/Tile-maps to generate the tiles. It seems that this class allocates all tiles for each zoom level, even though the tile isn't displayed. This is pretty bad for my use case, since there could potentially be a lot of tiles that should never be loaded. I will look into the tiledmap-classes and see if I could do some optimization, or roll my own implementation.

— Reply to this email directly or view it on GitHub https://github.com/aspic/libgdx-maps/issues/1#issuecomment-44953909.

aspic commented 10 years ago

TiledMap does something like that, yes. I ended up using that because I thought it was smarter, but obviously I was wrong.

aspic commented 10 years ago

After some testing with dynamically creating the arrays instead of preloading them all (which the TiledMap does now) shows that there are no problem zooming into the maximum level. :-)

I will talk some to the core dev of TiledMap and propose a solution for the api in libgdx.

aspic commented 10 years ago

Proposed pull request: https://github.com/libgdx/libgdx/pull/1935 which will address this issue in Libgdx itself. If it gets declined I will make a similar workaround in this project. Closes this issue for now =)

aspic commented 10 years ago

Hi! My fix didn't make it into upstream (for good reasons due to how TileMaps are supposed to work in the current API). Hence I've fixed the problem in the project instead: https://github.com/aspic/libgdx-maps/commit/690d00d87d9c174a8c73ea13a55e7b3acb3cb730

ouya99 commented 10 years ago

Hi! Thanks for the local fix. Its working fine up to zoom level 19 now. maybe we should limit it to that level, cause when I continue to click, it goes on zooming, yet not displaying any content.

MapManager: Layer did not exist for zoom 20 MapManager: Layer did not exist for zoom 21 MapManager: Layer did not exist for zoom 22

Great work all in all!