Samples improvements
This commit is contained in:
parent
701ac43746
commit
f7acfd9017
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016-2017 devemux86
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
|
||||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
|
||||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.oscim.test;
|
|
||||||
|
|
||||||
import org.oscim.core.MapPosition;
|
|
||||||
import org.oscim.core.Tile;
|
|
||||||
import org.oscim.gdx.GdxMapApp;
|
|
||||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
|
||||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
|
||||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
|
||||||
import org.oscim.theme.VtmThemes;
|
|
||||||
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.List;
|
|
||||||
|
|
||||||
public class MapsforgeMultiTest extends GdxMapApp {
|
|
||||||
|
|
||||||
private final List<File> mapFiles;
|
|
||||||
|
|
||||||
private MapsforgeMultiTest(List<File> mapFiles) {
|
|
||||||
this.mapFiles = mapFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createLayers() {
|
|
||||||
MultiMapFileTileSource tileSource = new MultiMapFileTileSource();
|
|
||||||
for (File mapFile : mapFiles) {
|
|
||||||
MapFileTileSource mapFileTileSource = new MapFileTileSource();
|
|
||||||
mapFileTileSource.setMapFile(mapFile.getAbsolutePath());
|
|
||||||
tileSource.add(mapFileTileSource);
|
|
||||||
}
|
|
||||||
//tileSource.setPreferredLanguage("en");
|
|
||||||
|
|
||||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
|
||||||
mMap.setTheme(VtmThemes.DEFAULT);
|
|
||||||
|
|
||||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
|
||||||
mMap.layers().add(new LabelLayer(mMap, l));
|
|
||||||
|
|
||||||
MapPosition pos = new MapPosition();
|
|
||||||
pos.setByBoundingBox(tileSource.getBoundingBox(), Tile.SIZE * 4, Tile.SIZE * 4);
|
|
||||||
mMap.setMapPosition(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<File> getMapFiles(String[] args) {
|
|
||||||
if (args.length == 0) {
|
|
||||||
throw new IllegalArgumentException("missing argument: <mapFile>");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<File> result = new ArrayList<>();
|
|
||||||
for (String arg : args) {
|
|
||||||
File mapFile = new File(arg);
|
|
||||||
if (!mapFile.exists()) {
|
|
||||||
throw new IllegalArgumentException("file does not exist: " + mapFile);
|
|
||||||
} else if (!mapFile.isFile()) {
|
|
||||||
throw new IllegalArgumentException("not a file: " + mapFile);
|
|
||||||
} else if (!mapFile.canRead()) {
|
|
||||||
throw new IllegalArgumentException("cannot read file: " + mapFile);
|
|
||||||
}
|
|
||||||
result.add(mapFile);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
GdxMapApp.init();
|
|
||||||
GdxMapApp.run(new MapsforgeMultiTest(getMapFiles(args)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018 devemux86
|
* Copyright 2018-2019 devemux86
|
||||||
* Copyright 2018 Gustl22
|
* Copyright 2018 Gustl22
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
@ -18,15 +18,16 @@ package org.oscim.test;
|
|||||||
import org.oscim.gdx.GdxMapApp;
|
import org.oscim.gdx.GdxMapApp;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MapsforgePoi3DTest extends MapsforgeTest {
|
public class MapsforgePoi3DTest extends MapsforgeTest {
|
||||||
|
|
||||||
private MapsforgePoi3DTest(File mapFile) {
|
private MapsforgePoi3DTest(List<File> mapFiles) {
|
||||||
super(mapFile, false, true);
|
super(mapFiles, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
GdxMapApp.init();
|
GdxMapApp.init();
|
||||||
GdxMapApp.run(new MapsforgePoi3DTest(getMapFile(args)));
|
GdxMapApp.run(new MapsforgePoi3DTest(getMapFiles(args)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018 devemux86
|
* Copyright 2018-2019 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
@ -17,15 +17,16 @@ package org.oscim.test;
|
|||||||
import org.oscim.gdx.GdxMapApp;
|
import org.oscim.gdx.GdxMapApp;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MapsforgeS3DBTest extends MapsforgeTest {
|
public class MapsforgeS3DBTest extends MapsforgeTest {
|
||||||
|
|
||||||
private MapsforgeS3DBTest(File mapFile) {
|
private MapsforgeS3DBTest(List<File> mapFiles) {
|
||||||
super(mapFile, true, false);
|
super(mapFiles, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
GdxMapApp.init();
|
GdxMapApp.init();
|
||||||
GdxMapApp.run(new MapsforgeS3DBTest(getMapFile(args)));
|
GdxMapApp.run(new MapsforgeS3DBTest(getMapFiles(args)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2017 devemux86
|
* Copyright 2016-2019 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
@ -22,16 +22,17 @@ import org.oscim.theme.XmlRenderThemeStyleLayer;
|
|||||||
import org.oscim.theme.XmlRenderThemeStyleMenu;
|
import org.oscim.theme.XmlRenderThemeStyleMenu;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class MapsforgeStyleTest extends MapsforgeTest {
|
public class MapsforgeStyleTest extends MapsforgeTest {
|
||||||
|
|
||||||
private MapsforgeStyleTest(File mapFile) {
|
private MapsforgeStyleTest(List<File> mapFiles) {
|
||||||
super(mapFile);
|
super(mapFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadTheme(final String styleId) {
|
void loadTheme(final String styleId) {
|
||||||
mMap.setTheme(new StreamRenderTheme("", getClass().getResourceAsStream("/assets/vtm/stylemenu.xml"), new XmlRenderThemeMenuCallback() {
|
mMap.setTheme(new StreamRenderTheme("", getClass().getResourceAsStream("/assets/vtm/stylemenu.xml"), new XmlRenderThemeMenuCallback() {
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) {
|
public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) {
|
||||||
@ -79,6 +80,6 @@ public class MapsforgeStyleTest extends MapsforgeTest {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
GdxMapApp.init();
|
GdxMapApp.init();
|
||||||
GdxMapApp.run(new MapsforgeStyleTest(getMapFile(args)));
|
GdxMapApp.run(new MapsforgeStyleTest(getMapFiles(args)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.test;
|
package org.oscim.test;
|
||||||
|
|
||||||
|
import org.oscim.core.BoundingBox;
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.event.Event;
|
import org.oscim.event.Event;
|
||||||
@ -33,33 +34,39 @@ import org.oscim.renderer.GLViewport;
|
|||||||
import org.oscim.scalebar.*;
|
import org.oscim.scalebar.*;
|
||||||
import org.oscim.theme.VtmThemes;
|
import org.oscim.theme.VtmThemes;
|
||||||
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||||
import org.oscim.tiling.source.mapfile.MapInfo;
|
import org.oscim.tiling.source.mapfile.MultiMapFileTileSource;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MapsforgeTest extends GdxMapApp {
|
public class MapsforgeTest extends GdxMapApp {
|
||||||
|
|
||||||
private static final boolean SHADOWS = false;
|
private static final boolean SHADOWS = false;
|
||||||
|
|
||||||
private File mapFile;
|
private final List<File> mapFiles;
|
||||||
private boolean poi3d;
|
private final boolean poi3d;
|
||||||
private boolean s3db;
|
private final boolean s3db;
|
||||||
|
|
||||||
MapsforgeTest(File mapFile) {
|
MapsforgeTest(List<File> mapFiles) {
|
||||||
this(mapFile, false, false);
|
this(mapFiles, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MapsforgeTest(File mapFile, boolean s3db, boolean poi3d) {
|
MapsforgeTest(List<File> mapFiles, boolean s3db, boolean poi3d) {
|
||||||
this.mapFile = mapFile;
|
this.mapFiles = mapFiles;
|
||||||
this.s3db = s3db;
|
this.s3db = s3db;
|
||||||
this.poi3d = poi3d;
|
this.poi3d = poi3d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createLayers() {
|
public void createLayers() {
|
||||||
MapFileTileSource tileSource = new MapFileTileSource();
|
MultiMapFileTileSource tileSource = new MultiMapFileTileSource();
|
||||||
tileSource.setMapFile(mapFile.getAbsolutePath());
|
for (File mapFile : mapFiles) {
|
||||||
|
MapFileTileSource mapFileTileSource = new MapFileTileSource();
|
||||||
|
mapFileTileSource.setMapFile(mapFile.getAbsolutePath());
|
||||||
|
tileSource.add(mapFileTileSource);
|
||||||
|
}
|
||||||
//tileSource.setPreferredLanguage("en");
|
//tileSource.setPreferredLanguage("en");
|
||||||
|
|
||||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||||
@ -86,10 +93,10 @@ public class MapsforgeTest extends GdxMapApp {
|
|||||||
mMap.layers().add(mapScaleBarLayer);
|
mMap.layers().add(mapScaleBarLayer);
|
||||||
|
|
||||||
MapPosition pos = MapPreferences.getMapPosition();
|
MapPosition pos = MapPreferences.getMapPosition();
|
||||||
MapInfo info = tileSource.getMapInfo();
|
BoundingBox bbox = tileSource.getBoundingBox();
|
||||||
if (pos == null || !info.boundingBox.contains(pos.getGeoPoint())) {
|
if (pos == null || !bbox.contains(pos.getGeoPoint())) {
|
||||||
pos = new MapPosition();
|
pos = new MapPosition();
|
||||||
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
|
pos.setByBoundingBox(bbox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||||
}
|
}
|
||||||
mMap.setMapPosition(pos);
|
mMap.setMapPosition(pos);
|
||||||
|
|
||||||
@ -123,28 +130,32 @@ public class MapsforgeTest extends GdxMapApp {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
static File getMapFile(String[] args) {
|
static List<File> getMapFiles(String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
throw new IllegalArgumentException("missing argument: <mapFile>");
|
throw new IllegalArgumentException("missing argument: <mapFile>");
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(args[0]);
|
List<File> result = new ArrayList<>();
|
||||||
if (!file.exists()) {
|
for (String arg : args) {
|
||||||
throw new IllegalArgumentException("file does not exist: " + file);
|
File mapFile = new File(arg);
|
||||||
} else if (!file.isFile()) {
|
if (!mapFile.exists()) {
|
||||||
throw new IllegalArgumentException("not a file: " + file);
|
throw new IllegalArgumentException("file does not exist: " + mapFile);
|
||||||
} else if (!file.canRead()) {
|
} else if (!mapFile.isFile()) {
|
||||||
throw new IllegalArgumentException("cannot read file: " + file);
|
throw new IllegalArgumentException("not a file: " + mapFile);
|
||||||
|
} else if (!mapFile.canRead()) {
|
||||||
|
throw new IllegalArgumentException("cannot read file: " + mapFile);
|
||||||
|
}
|
||||||
|
result.add(mapFile);
|
||||||
}
|
}
|
||||||
return file;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadTheme(final String styleId) {
|
void loadTheme(final String styleId) {
|
||||||
mMap.setTheme(VtmThemes.DEFAULT);
|
mMap.setTheme(VtmThemes.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
GdxMapApp.init();
|
GdxMapApp.init();
|
||||||
GdxMapApp.run(new MapsforgeTest(getMapFile(args)));
|
GdxMapApp.run(new MapsforgeTest(getMapFiles(args)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user