Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

To run the desktop samples can use the Gradle `run` task.

e.g. for `vtm-playground` can change the [mainClassName](../vtm-playground/build.gradle) to run each sample and pass args:
```groovy
./gradlew :vtm-playground:run -Pargs=/path/to/map
For `vtm-playground` can change the main class in `build.gradle` and pass args:
```
./gradlew :vtm-playground:run -Pargs=/path/to/theme,/path/to/hgt,/path/to/map1,/path/to/map2
```

To create a standalone executable jar, adapt the main class in [build gradle](../vtm-playground/build.gradle), then run:
```groovy
To create a standalone executable jar, change the main class in `build gradle` and run:
```
./gradlew :vtm-playground:fatJar
```
The jar file can be found in `build/libs` folder. Depending on the main class, pass args on execution via command line:
```
java -jar vtm-playground-master-SNAPSHOT-jar-with-dependencies.jar /path/to/map
java -jar vtm-playground-master-SNAPSHOT-jar-with-dependencies.jar /path/to/theme /path/to/hgt /path/to/map1 /path/to/map2
```
The theme file and SRTM hgt folder are optional arguments.

To change the libGDX backend can replace the dependency: `vtm-desktop-lwjgl` or `vtm-desktop-lwjgl3`.
12 changes: 8 additions & 4 deletions vtm-playground/src/org/oscim/test/MapsforgePoi3DTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@

public class MapsforgePoi3DTest extends MapsforgeTest {

private MapsforgePoi3DTest(File demFolder, List<File> mapFiles) {
super(demFolder, mapFiles, false, true);
private MapsforgePoi3DTest(File demFolder, List<File> mapFiles, File themeFile) {
super(demFolder, mapFiles, false, true, themeFile);
}

/**
* @param args command line args: expects the map files as multiple parameters
* with possible SRTM hgt folder as 1st argument.
* with possible theme file as 1st argument
* and possible SRTM hgt folder as 2nd argument.
*/
public static void main(String[] args) {
GdxMapApp.init();
File themeFile = getThemeFile(args);
if (themeFile != null)
args = Arrays.copyOfRange(args, 1, args.length);
File demFolder = getDemFolder(args);
if (demFolder != null)
args = Arrays.copyOfRange(args, 1, args.length);
GdxMapApp.run(new MapsforgePoi3DTest(demFolder, getMapFiles(args)));
GdxMapApp.run(new MapsforgePoi3DTest(demFolder, getMapFiles(args), themeFile));
}
}
12 changes: 8 additions & 4 deletions vtm-playground/src/org/oscim/test/MapsforgeS3DBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@

public class MapsforgeS3DBTest extends MapsforgeTest {

private MapsforgeS3DBTest(File demFolder, List<File> mapFiles) {
super(demFolder, mapFiles, true, false);
private MapsforgeS3DBTest(File demFolder, List<File> mapFiles, File themeFile) {
super(demFolder, mapFiles, true, false, themeFile);
}

/**
* @param args command line args: expects the map files as multiple parameters
* with possible SRTM hgt folder as 1st argument.
* with possible theme file as 1st argument
* and possible SRTM hgt folder as 2nd argument.
*/
public static void main(String[] args) {
GdxMapApp.init();
File themeFile = getThemeFile(args);
if (themeFile != null)
args = Arrays.copyOfRange(args, 1, args.length);
File demFolder = getDemFolder(args);
if (demFolder != null)
args = Arrays.copyOfRange(args, 1, args.length);
GdxMapApp.run(new MapsforgeS3DBTest(demFolder, getMapFiles(args)));
GdxMapApp.run(new MapsforgeS3DBTest(demFolder, getMapFiles(args), themeFile));
}
}
12 changes: 8 additions & 4 deletions vtm-playground/src/org/oscim/test/MapsforgeStyleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

public class MapsforgeStyleTest extends MapsforgeTest {

private MapsforgeStyleTest(File demFolder, List<File> mapFiles) {
super(demFolder, mapFiles);
private MapsforgeStyleTest(File demFolder, List<File> mapFiles, File themeFile) {
super(demFolder, mapFiles, themeFile);
}

@Override
Expand Down Expand Up @@ -81,13 +81,17 @@ protected boolean onKeyDown(int keycode) {

/**
* @param args command line args: expects the map files as multiple parameters
* with possible SRTM hgt folder as 1st argument.
* with possible theme file as 1st argument
* and possible SRTM hgt folder as 2nd argument.
*/
public static void main(String[] args) {
GdxMapApp.init();
File themeFile = getThemeFile(args);
if (themeFile != null)
args = Arrays.copyOfRange(args, 1, args.length);
File demFolder = getDemFolder(args);
if (demFolder != null)
args = Arrays.copyOfRange(args, 1, args.length);
GdxMapApp.run(new MapsforgeStyleTest(demFolder, getMapFiles(args)));
GdxMapApp.run(new MapsforgeStyleTest(demFolder, getMapFiles(args), themeFile));
}
}
36 changes: 26 additions & 10 deletions vtm-playground/src/org/oscim/test/MapsforgeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@
import org.oscim.renderer.ExtrusionRenderer;
import org.oscim.renderer.GLViewport;
import org.oscim.scalebar.*;
import org.oscim.theme.ExternalRenderTheme;
import org.oscim.theme.internal.VtmThemes;
import org.oscim.tiling.source.hills.HillshadingTileSource;
import org.oscim.tiling.source.mapfile.MapFileTileSource;
import org.oscim.tiling.source.mapfile.MultiMapFileTileSource;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.*;

public class MapsforgeTest extends GdxMapApp {

Expand All @@ -57,16 +55,18 @@ public class MapsforgeTest extends GdxMapApp {
private final List<File> mapFiles;
private final boolean poi3d;
private final boolean s3db;
private final File themeFile;

MapsforgeTest(File demFolder, List<File> mapFiles) {
this(demFolder, mapFiles, false, false);
MapsforgeTest(File demFolder, List<File> mapFiles, File themeFile) {
this(demFolder, mapFiles, false, false, themeFile);
}

MapsforgeTest(File demFolder, List<File> mapFiles, boolean s3db, boolean poi3d) {
MapsforgeTest(File demFolder, List<File> mapFiles, boolean s3db, boolean poi3d, File themeFile) {
this.demFolder = demFolder;
this.mapFiles = mapFiles;
this.s3db = s3db;
this.poi3d = poi3d;
this.themeFile = themeFile;
}

@Override
Expand Down Expand Up @@ -186,19 +186,35 @@ static List<File> getMapFiles(String[] args) {
return result;
}

static File getThemeFile(String[] args) {
if (args.length == 0) {
throw new IllegalArgumentException("missing argument: <mapFile>");
}

File themeFile = new File(args[0]);
if (themeFile.exists() && themeFile.isFile() && themeFile.canRead() && themeFile.getName().toLowerCase(Locale.ROOT).endsWith(".xml")) {
return themeFile;
}
return null;
}

void loadTheme(final String styleId) {
mMap.setTheme(VtmThemes.MOTORIDER);
mMap.setTheme(themeFile != null ? new ExternalRenderTheme(themeFile.getAbsolutePath()) : VtmThemes.MOTORIDER);
}

/**
* @param args command line args: expects the map files as multiple parameters
* with possible SRTM hgt folder as 1st argument.
* with possible theme file as 1st argument
* and possible SRTM hgt folder as 2nd argument.
*/
public static void main(String[] args) {
GdxMapApp.init();
File themeFile = getThemeFile(args);
if (themeFile != null)
args = Arrays.copyOfRange(args, 1, args.length);
File demFolder = getDemFolder(args);
if (demFolder != null)
args = Arrays.copyOfRange(args, 1, args.length);
GdxMapApp.run(new MapsforgeTest(demFolder, getMapFiles(args)));
GdxMapApp.run(new MapsforgeTest(demFolder, getMapFiles(args), themeFile));
}
}