Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/#1145 - using the new DirectRenderer class of mapsforge #1152

Merged
merged 7 commits into from Sep 26, 2019

Conversation

@monsieurtanuki
Copy link
Collaborator

commented Sep 9, 2018

That fixes the issue.

Not to be merged as is, because we still rely on a SNAPSHOT version of mapsforge.
As soon as mapsforge issues a new version, the build.gradle file must be edited and marginally also a comment in MapsForgeTileSource about the mapsforge version number.

Impacted files

  • osmdroid-mapsforge/build.gradle: now using the latest version of mapsforge, that includes the new DirectRenderer class that I coded in mapsforge
  • MapsForgeTileSource: used DirectRenderer instead of DatabaseRenderer
That fixes the issue.

Not to be merged as is, because we still rely on a `SNAPSHOT` version of `mapsforge`.
As soon as `mapsforge` issues a new version, the `build.gradle` file must be edited and marginally also a comment in `MapsForgeTileSource` about the `mapsforge` version number.

Impacted files
* `osmdroid-mapsforge/build.gradle`: now using the latest version of `mapsforge`, that includes the new `DirectRenderer` class that I coded in `mapsforge`
* `MapsForgeTileSource`: used `DirectRenderer` instead of `DatabaseRenderer`
Impacted classes:
* `MapTileProviderBase`: created method `expireInMemoryCache`, in order to "expire" a MapsForge tile that needs to be refreshed due to new overlapping labels from new neighboring tiles
* `MapsForgeTileProvider`: added a call to a tile refresher callback whenever a tile needs to be refreshed
* `MapsForgeTileSource`: method `renderTile` now returns `null` when MapsForge doesn't know the tile - used to be a yellow bitmap instead; created method `addTileRefresher`
@monsieurtanuki

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 13, 2018

In this version (not to be merged until MapsForge's new version is released):

  • the "out-of-box tile returns NULL" feature is implemented (cf. @secaw)
  • the labels are never broken anymore - I mean - they still are but are immediately refreshed whenever needed

@secaw I finally left the TileWriter as it was. Still, there's confusion with MapsForge being used and its tiles being computed then stored into a TileWriter:

  1. the data is stored twice
  2. the labels cannot be consistent as there's no such thing as definite MapsForge displayed labels for a tile (the display depends on the order in which the other tiles were sequentially displayed)
@monsieurtanuki

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 3, 2019

@spyhunter99 It looks like the new mapsforge version (0.11.0) has been released.
I don't know if you plan to include this osmdroid PR into the next osmdroid release.

* edited the build.gradle according to the new mapsforge version number
* marginally edited a comment in MapsForgeTileSource
@spyhunter99

This comment has been minimized.

Copy link
Collaborator

commented Sep 2, 2019

i made a quick fix, however it is crashing for me....

ader.nextTile() on provider: MapsforgeTiles Provider found tile in working queue: /3/3/4
TileLoader.nextTile() on provider: MapsforgeTiles Provider adding tile to working queue: 864691130065747972
TileLoader.run() processing next tile: /3/3/4, pending:1, working:1
MapsForgeTileModuleProvider.TileLoader.loadTile(/3/3/4): tileSource.renderTile
W/System.err: at org.osmdroid.util.BoundingBox.set(BoundingBox.java:67)
at org.osmdroid.util.BoundingBox.(BoundingBox.java:43)
at org.osmdroid.mapsforge.MapsForgeTileSource.getBoundsOsmdroid(MapsForgeTileSource.java:109)
at org.osmdroid.samplefragments.tileproviders.OfflinePickerSample$3$1$1.run(OfflinePickerSample.java:299)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
W/DirectRenderer: Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.app.Application.getAssets()' on a null object reference
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
D/OsmDroid: TileLoader.tileLoadedFailed() on provider: MapsforgeTiles Provider with tile: /3/3/4

probably missing as asset but i have no clue what

@monsieurtanuki

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 3, 2019

@spyhunter99 I ran my tests with the file provided in #1145. Which mapsforge .map file are you using? Would you be able to share it?

@monsieurtanuki

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 3, 2019

@spyhunter99 Hmm, I guess the file is world.map in the root of the git project.

@monsieurtanuki

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 3, 2019

@spyhunter99 This is what I've just done:

  • I copied the world.map file from my desktop osmdroid github root folder to my smartphone in /osmdroid
  • I ran the demo: "More Samples / Mapsforge tiles" on my 1145 branch
  • It crashed because of the tile bounds, which explained your fix merge
  • I copied your fix code into mine, and still had the java.lang.IllegalArgumentException: north must be in [-85.05112877980659,85.05112877980659] crash
  • because the correct fix is:
double latNorth= Math.min(MapView.getTileSystem().getMaxLatitude(),boundingBox.maxLatitude);
double latSouth= Math.max(MapView.getTileSystem().getMinLatitude(),boundingBox.minLatitude);
  • with that, the demo works like a charm, even on the Antarctica / Arctic junction (btw I never noticed before that Tierra de Fuego is kind of reflected on the Antarctica side)
Impacted class:
* `MapsForgeTileSource`: fine-tuned method `getBoundsOsmdroid` about the latitude 90/-90 side effect
# Conflicts:
#	osmdroid-mapsforge/src/main/java/org/osmdroid/mapsforge/MapsForgeTileSource.java
@monsieurtanuki

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 24, 2019

@spyhunter99 I've just pushed the fix.

@spyhunter99

This comment has been minimized.

Copy link
Collaborator

commented Sep 26, 2019

just tested it, after a good old clean and build, its working! good job

@spyhunter99 spyhunter99 merged commit d80cc67 into master Sep 26, 2019
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/travis-ci/push The Travis CI build could not complete due to an error
Details
@spyhunter99 spyhunter99 added this to the v6.1.1 milestone Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.