[VTM] Simple Eclipse RCP app which is using VTM desktop

204 views
Skip to first unread message

Wolfgang Schramm

unread,
May 9, 2017, 9:17:58 AM5/9/17
to mapsforge-dev
Because I havn't found an example which is using the VMT desktop in an Eclipse view, I created a very simple Eclipse RCP app https://github.com/wolfgang-ch/vtm-with-rcp which demonstrates it.

The first plugin contains the Eclipse app code.
The second plugin contains all external jar's.

This app is build with gradle which is my first gradle project, so it is very likely that it could be improved.

@Emux
You can add this app to the page https://github.com/mapsforge/vtm/blob/master/docs/Applications.md if you want

Emux

unread,
May 9, 2017, 3:41:20 PM5/9/17
to mapsfo...@googlegroups.com
Thanks seems nice!

I added it in VTM applications list.

How do you find the integration libGDX LWJGL backend and SWT?

LWJGL and Swing can have some areas with less flexibility for the developer.

--
Emux

Wolfgang Schramm

unread,
May 10, 2017, 4:03:51 AM5/10/17
to mapsforge-dev
>How do you find the integration libGDX LWJGL backend and SWT?
After many many try and error experience it is very simple (after I discovered it) to show the map in an Eclipse view.

>LWJGL and Swing can have some areas with less flexibility for the developer.
I'm not an OpenGL/LWJGL/Swing expert, I just got it running, so I can't tell you now what could be better.

I'm planning to integrate this map in MyTourbook, so the following experience is not from the vtm-with-rcp demo project, it is from vtm in MyTourbook.

Until now I discovered these issues:

1. When resizing the vtm map view in the UI to a height of 0 then this exception occur

Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: top == bottom
 at org.oscim.renderer.GLMatrix.frustumM(GLMatrix.java:331)
 at org.oscim.map.ViewController.setScreenSize(ViewController.java:50)
 at org.oscim.gdx.GdxMap.resize(GdxMap.java:122)
 at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:192)
 at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)
 

2. When closing the view (not the app) and reopen it then this exception occur
 
Exception in thread "LWJGL Application" java.lang.RuntimeException: No OpenGL context found in the current thread.
 at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124)
 at org.lwjgl.opengl.GL11.glGetError(GL11.java:1299)
 at org.lwjgl.opengl.Util.checkGLError(Util.java:57)
 at org.lwjgl.opengl.WindowsContextImplementation.setSwapInterval(WindowsContextImplementation.java:113)
 at org.lwjgl.opengl.ContextGL.setSwapInterval(ContextGL.java:232)
 at org.lwjgl.opengl.DrawableGL.setSwapInterval(DrawableGL.java:86)
 at org.lwjgl.opengl.Display.setSwapInterval(Display.java:1129)
 at org.lwjgl.opengl.Display.setVSyncEnabled(Display.java:1142)
 at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setVSync(LwjglGraphics.java:558)
 at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
 
 
Have you any idea how these exceptions can be solved? 
 

3. I also discovered that the map data seems to be loaded always from the internet and not cached.
   Are there plans to cache the data?

Emux

unread,
May 10, 2017, 4:32:26 AM5/10/17
to mapsfo...@googlegroups.com
> 1. When resizing the vtm map view in the UI to a height of 0 then this exception occur

Doesn't seem to happen when resizing via mouse the VTM desktop samples, why having size 0 window?


> 2. When closing the view (not the app) and reopen it then this exception occur

Probably related to how initialize / free the GL resources at start / end of view.
There is Map.destroy and LWJGL could have life cycle methods too to check.

> 3. Are there plans to cache the data?

What tile source do you use?
It's recommended to use OkHttp for best results, see an example in MapboxTest.
You can pass a Cache in OkHttpEngine.OkHttpFactory(cache).

--
Emux

Wolfgang Schramm

unread,
May 10, 2017, 10:08:12 AM5/10/17
to mapsforge-dev

> 1. When resizing the vtm map view in the UI to a height of 0 then this exception occur

Doesn't seem to happen when resizing via mouse the VTM desktop samples, why having size 0 window?

I discovered this by accident when I resized the view, that a size 0 causes the exception

I changed the code which will now cause the exception. In the previous version I disable the close button (and other custom settings) of the view because when you close the view, then you have to cleanup the runtime workspace/config that the view is displayed again.

 

> 2. When closing the view (not the app) and reopen it then this exception occur

Probably related to how initialize / free the GL resources at start / end of view.
There is Map.destroy and LWJGL could have life cycle methods too to check.

I will test this

 

> 3. Are there plans to cache the data?

What tile source do you use?
It's recommended to use OkHttp for best results, see an example in MapboxTest.
You can pass a Cache in OkHttpEngine.OkHttpFactory(cache).

I will also test this 

Wolfgang Schramm

unread,
May 11, 2017, 10:48:35 AM5/11/17
to mapsforge-dev
I update the example rcp vtm-with-rcp to open the VTM map view, all exceptions can now be tested.

Wolfgang Schramm

unread,
May 19, 2017, 9:57:25 AM5/19/17
to mapsforge-dev
On Wednesday, 10 May 2017 10:32:26 UTC+2, Emux wrote:
> 1. When resizing the vtm map view in the UI to a height of 0 then this exception occur

Doesn't seem to happen when resizing via mouse the VTM desktop samples, why having size 0 window?

> 2. When closing the view (not the app) and reopen it then this exception occur

Probably related to how initialize / free the GL resources at start / end of view.
There is Map.destroy and LWJGL could have life cycle methods too to check.

I didn't find a solution to solve this problem.

When using LwjglApplication.stop() or Display.destroy() then not only the view, the whole app will be closed.

I update the VTM with RCP to show a restart button when the map view is opened a 2nd time but this is not a fancy solution.


 

Emux

unread,
May 19, 2017, 4:57:43 PM5/19/17
to mapsfo...@googlegroups.com, Wolfgang Schramm
On 19/05/2017 04:57 μμ, Wolfgang Schramm wrote:
When using LwjglApplication.stop() or Display.destroy() then not only the view, the whole app will be closed.

Note that LwjglApplicationConfiguration.forceExit (whether to call System.exit() on tear-down) is default true.

--
Emux

Wolfgang Schramm

unread,
May 21, 2017, 4:54:52 AM5/21/17
to mapsforge-dev, wolfgang...@gmail.com
When using LwjglApplication.stop() or Display.destroy() then not only the view, the whole app will be closed.
Note that LwjglApplicationConfiguration.forceExit (whether to call System.exit() on tear-down) is default true.

Setting forceExit to false is working :-)

After using this tile cache, the app is still working but sometimes these exception occures

java.lang.NullPointerException
    at org.oscim.tiling.source.PbfDecoder.readUnsignedInt(PbfDecoder.java:547)
    at org.oscim.tiling.source.oscimap4.TileDecoder.decode(TileDecoder.java:91)
    at org.oscim.tiling.source.UrlTileDataSource.query(UrlTileDataSource.java:86)
    at org.oscim.layers.tile.vector.VectorTileLoader.loadTile(VectorTileLoader.java:136)
    at org.oscim.layers.tile.TileLoader.doWork(TileLoader.java:66)
    at org.oscim.utils.PausableThread.run(PausableThread.java:141)
java.lang.NullPointerException
    at org.oscim.tiling.source.PbfDecoder.readUnsignedInt(PbfDecoder.java:547)
    at org.oscim.tiling.source.oscimap4.TileDecoder.decode(TileDecoder.java:91)
    at org.oscim.tiling.source.UrlTileDataSource.query(UrlTileDataSource.java:86)
    at org.oscim.layers.tile.vector.VectorTileLoader.loadTile(VectorTileLoader.java:136)
    at org.oscim.layers.tile.TileLoader.doWork(TileLoader.java:66)
    at org.oscim.utils.PausableThread.run(PausableThread.java:141)
...

Emux

unread,
May 21, 2017, 5:09:20 AM5/21/17
to mapsfo...@googlegroups.com, Wolfgang Schramm
> Setting forceExit to false is working :-)

Nice!

Regarding the exceptions, OpenScienceMap vector tiles server is often not working properly leading to request timeouts and slow responses.

I'd suggest to try also the Mapzen tiles (via .mvt Mapbox binary format), we provide a decoder and a theme.
See MapboxTest for the sample.

--
Emux

Wolfgang Schramm

unread,
May 21, 2017, 9:53:28 AM5/21/17
to mapsforge-dev, wolfgang...@gmail.com

I'd suggest to try also the Mapzen tiles (via .mvt Mapbox binary format), we provide a decoder and a theme.
See MapboxTest for the sample.
I would like to use VTM map in an open source app. Mapbox is using tiles from mapzen.com which requires an API key which will cause costs when a limit is reached. This is not what I want.

I there an alternative vector tile server which VTM supports but is more stable than OpenScienceMap and has no costs?

There are many vector tile projects but I cannot say (I'm new in this "business") which are reliable or old
Reply all
Reply to author
Forward
0 new messages