diff --git a/vtm-gdx-android/src/org/oscim/gdx/MainActivity.java b/vtm-gdx-android/src/org/oscim/gdx/MainActivity.java index 36be8042..d699ba5d 100644 --- a/vtm-gdx-android/src/org/oscim/gdx/MainActivity.java +++ b/vtm-gdx-android/src/org/oscim/gdx/MainActivity.java @@ -19,42 +19,41 @@ import com.badlogic.gdx.utils.SharedLibraryLoader; public class MainActivity extends AndroidApplication { - private final class AndroidGLAdapter extends AndroidGL20 implements GL20{ + private final class AndroidGLAdapter extends AndroidGL20 implements GL20 { } @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); - // set globals - CanvasAdapter.g = AndroidGraphics.INSTANCE; - GLAdapter.g = new AndroidGLAdapter(); + // set globals + CanvasAdapter.g = AndroidGraphics.INSTANCE; + GLAdapter.g = new AndroidGLAdapter(); Log.logger = new AndroidLog(); // TODO make this dpi dependent Tile.SIZE = 400; - AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); - cfg.useGL20 = true; + AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); + cfg.useGL20 = true; - new SharedLibraryLoader().load("vtm-jni"); + new SharedLibraryLoader().load("vtm-jni"); - initialize(new GdxMapAndroid(), cfg); - } + initialize(new GdxMapAndroid(), cfg); + } + + class GdxMapAndroid extends GdxMap { - class GdxMapAndroid extends GdxMap{ @Override - public void create() { - super.create(); + public void createLayers() { - //TileSource ts = new OSciMap4TileSource(); - //ts.setOption("url", "http://city.informatik.uni-bremen.de/osci/testing"); + //TileSource ts = new OSciMap4TileSource(); + //ts.setOption("url", "http://opensciencemap.org/tiles/vtm"); - TileSource ts = new OSciMap2TileSource(); - ts.setOption("url", "http://city.informatik.uni-bremen.de/osci/map-live"); + TileSource ts = new OSciMap2TileSource(); + ts.setOption("url", "http://opensciencemap.org/osci/map-live"); - initDefaultMap(ts, true, true, true); + initDefaultLayers(ts, true, true, true); } - } } \ No newline at end of file diff --git a/vtm-gdx-desktop/src/org/oscim/gdx/GdxGLAdapter.java b/vtm-gdx-desktop/src/org/oscim/gdx/GdxGLAdapter.java index 64d7a6d0..ed024ede 100644 --- a/vtm-gdx-desktop/src/org/oscim/gdx/GdxGLAdapter.java +++ b/vtm-gdx-desktop/src/org/oscim/gdx/GdxGLAdapter.java @@ -39,7 +39,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException; * compatible. Some glGetXXX methods are not implemented. * * @author mzechner */ -final class GdxGLAdapter implements org.oscim.backend.GL20 { +public final class GdxGLAdapter implements org.oscim.backend.GL20 { public void glActiveTexture (int texture) { GL13.glActiveTexture(texture); } diff --git a/vtm-gdx-desktop/src/org/oscim/gdx/Main.java b/vtm-gdx-desktop/src/org/oscim/gdx/GdxMapApp.java similarity index 65% rename from vtm-gdx-desktop/src/org/oscim/gdx/Main.java rename to vtm-gdx-desktop/src/org/oscim/gdx/GdxMapApp.java index 3d116542..ee3ab93f 100644 --- a/vtm-gdx-desktop/src/org/oscim/gdx/Main.java +++ b/vtm-gdx-desktop/src/org/oscim/gdx/GdxMapApp.java @@ -11,9 +11,22 @@ import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.badlogic.gdx.utils.SharedLibraryLoader; -public class Main { +public class GdxMapApp extends GdxMap { + + static { + // set our globals + new SharedLibraryLoader().load("vtm-jni"); + CanvasAdapter.g = AwtGraphics.INSTANCE; + GLAdapter.g = new GdxGLAdapter(); + GLAdapter.GDX_DESKTOP_QUIRKS = true; + } public static void main(String[] args) { + Tile.SIZE = 360; + new LwjglApplication(new GdxMapApp(), getConfig()); + } + + static protected LwjglApplicationConfiguration getConfig() { LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); cfg.title = "vtm-gdx"; cfg.useGL20 = true; @@ -21,34 +34,13 @@ public class Main { cfg.height = 800; cfg.stencil = 8; cfg.foregroundFPS = 20; - // cfg.samples = 4; - - // set our globals - CanvasAdapter.g = AwtGraphics.INSTANCE; - GLAdapter.g = new GdxGLAdapter(); - GLAdapter.GDX_DESKTOP_QUIRKS = true; - - Tile.SIZE = 360; - - new SharedLibraryLoader().load("vtm-jni"); - - new LwjglApplication(new GdxMapDesktop(), cfg); + return cfg; } - static class GdxMapDesktop extends GdxMap { - - public GdxMapDesktop() { - super(); - } - - @Override - public void create() { - super.create(); - - TileSource tileSource = new OSciMap4TileSource(); - tileSource.setOption("url", "http://city.informatik.uni-bremen.de/tiles/vtm"); - - initDefaultMap(tileSource, false, true, true); - } + @Override + public void createLayers() { + TileSource tileSource = new OSciMap4TileSource(); + tileSource.setOption("url", "http://opensciencemap.org/tiles/vtm"); + initDefaultLayers(tileSource, false, true, true); } } diff --git a/vtm-gdx-html/src/org/oscim/gdx/client/GwtGdxMap.java b/vtm-gdx-html/src/org/oscim/gdx/client/GwtGdxMap.java index f569c3f8..0adf3f0a 100644 --- a/vtm-gdx-html/src/org/oscim/gdx/client/GwtGdxMap.java +++ b/vtm-gdx-html/src/org/oscim/gdx/client/GwtGdxMap.java @@ -98,7 +98,7 @@ class GwtGdxMap extends GdxMap { tileSource.setOption("url", url); - initDefaultMap(tileSource, false, true, true); + initDefaultLayers(tileSource, false, true, true); if ("naturalearth".equals(c.getBackgroundLayer())) mMap.setBackgroundMap(new BitmapTileLayer(mMap, NaturalEarth.INSTANCE)); @@ -139,4 +139,8 @@ class GwtGdxMap extends GdxMap { }; timer.scheduleRepeating(5000); } + + @Override + protected void createLayers() { + } } diff --git a/vtm-gdx/src/org/oscim/gdx/GdxMap.java b/vtm-gdx/src/org/oscim/gdx/GdxMap.java index d08ac529..a3db1e53 100644 --- a/vtm-gdx/src/org/oscim/gdx/GdxMap.java +++ b/vtm-gdx/src/org/oscim/gdx/GdxMap.java @@ -2,7 +2,6 @@ package org.oscim.gdx; import org.oscim.backend.AssetAdapter; import org.oscim.backend.Log; -import org.oscim.core.MapPosition; import org.oscim.core.Tile; import org.oscim.layers.GenericLayer; import org.oscim.layers.tile.vector.BuildingLayer; @@ -10,9 +9,9 @@ import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.map.Map; import org.oscim.map.Viewport; +import org.oscim.renderer.GLState; import org.oscim.renderer.GridRenderer; import org.oscim.renderer.MapRenderer; -import org.oscim.renderer.GLState; import org.oscim.theme.InternalRenderTheme; import org.oscim.tiling.source.TileSource; @@ -29,7 +28,7 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer.Task; -public class GdxMap implements ApplicationListener { +public abstract class GdxMap implements ApplicationListener { protected final Map mMap; private final MapRenderer mMapRenderer; @@ -89,7 +88,7 @@ public class GdxMap implements ApplicationListener { } - protected void initDefaultMap(TileSource tileSource, boolean tileGrid, boolean labels, + protected void initDefaultLayers(TileSource tileSource, boolean tileGrid, boolean labels, boolean buildings) { if (tileSource != null) { @@ -133,11 +132,13 @@ public class GdxMap implements ApplicationListener { mHeight = h; mMap.getViewport().setViewport(w, h); - MapPosition p = new MapPosition(); - p.setZoomLevel(14); - p.setPosition(53.08, 8.83); + + //MapPosition p = new MapPosition(); + //p.setZoomLevel(14); + //p.setPosition(53.08, 8.83); //p.setPosition(0.0, 0.0); - mMap.setMapPosition(p); + //mMap.setMapPosition(p); + mMapRenderer.onSurfaceCreated(); mMapRenderer.onSurfaceChanged(w, h); @@ -154,8 +155,11 @@ public class GdxMap implements ApplicationListener { // fps.setPosition(10, 30); // fps.setColor(0, 1, 0, 1); // ui.addActor(fps); + createLayers(); } + protected abstract void createLayers(); + @Override public void dispose() {