PolyLabel samples #402
This commit is contained in:
parent
4f78fed094
commit
e5043447e3
@ -64,6 +64,9 @@
|
||||
<activity
|
||||
android:name=".MapsforgeMapActivity$ThemeFilePicker"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgePolyLabelActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name=".MapsforgeStyleActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
|
@ -59,8 +59,6 @@ public class MapsforgeMapActivity extends MapActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//LabelLayer.POLY_LABEL = true;
|
||||
|
||||
startActivityForResult(new Intent(this, MapFilePicker.class),
|
||||
SELECT_MAP_FILE);
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 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.android.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
|
||||
public class MapsforgePolyLabelActivity extends MapsforgeMapActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
LabelLayer.POLY_LABEL = true;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
@ -96,6 +96,7 @@ public class Samples extends Activity {
|
||||
|
||||
linearLayout.addView(createLabel("Vector Features"));
|
||||
linearLayout.addView(createButton(MapsforgeStyleActivity.class));
|
||||
linearLayout.addView(createButton(MapsforgePolyLabelActivity.class));
|
||||
linearLayout.addView(createButton(AtlasThemeActivity.class));
|
||||
linearLayout.addView(createButton(POTTextureActivity.class));
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 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.gdx.GdxMapApp;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MapsforgePolyLabelTest extends MapsforgeTest {
|
||||
|
||||
private MapsforgePolyLabelTest(File mapFile) {
|
||||
super(mapFile);
|
||||
|
||||
LabelLayer.POLY_LABEL = true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MapsforgePolyLabelTest(getMapFile(args)));
|
||||
}
|
||||
}
|
@ -16,62 +16,23 @@ package org.oscim.test;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.gdx.GdxMap;
|
||||
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.StreamRenderTheme;
|
||||
import org.oscim.theme.XmlRenderThemeMenuCallback;
|
||||
import org.oscim.theme.XmlRenderThemeStyleLayer;
|
||||
import org.oscim.theme.XmlRenderThemeStyleMenu;
|
||||
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||
import org.oscim.tiling.source.mapfile.MapInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
public class MapsforgeStyleTest extends GdxMap {
|
||||
public class MapsforgeStyleTest extends MapsforgeTest {
|
||||
|
||||
private static File mapFile;
|
||||
private MapsforgeStyleTest(File mapFile) {
|
||||
super(mapFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLayers() {
|
||||
MapFileTileSource tileSource = new MapFileTileSource();
|
||||
tileSource.setMapFile(mapFile.getAbsolutePath());
|
||||
//tileSource.setPreferredLanguage("en");
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
loadTheme(null);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
|
||||
MapInfo info = tileSource.getMapInfo();
|
||||
MapPosition pos = new MapPosition();
|
||||
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||
mMap.setMapPosition(pos);
|
||||
}
|
||||
|
||||
private static File getMapFile(String[] args) {
|
||||
if (args.length == 0) {
|
||||
throw new IllegalArgumentException("missing argument: <mapFile>");
|
||||
}
|
||||
|
||||
File file = new File(args[0]);
|
||||
if (!file.exists()) {
|
||||
throw new IllegalArgumentException("file does not exist: " + file);
|
||||
} else if (!file.isFile()) {
|
||||
throw new IllegalArgumentException("not a file: " + file);
|
||||
} else if (!file.canRead()) {
|
||||
throw new IllegalArgumentException("cannot read file: " + file);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
private void loadTheme(final String styleId) {
|
||||
protected void loadTheme(final String styleId) {
|
||||
mMap.setTheme(new StreamRenderTheme("", getClass().getResourceAsStream("/assets/vtm/stylemenu.xml"), new XmlRenderThemeMenuCallback() {
|
||||
@Override
|
||||
public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) {
|
||||
@ -118,9 +79,7 @@ public class MapsforgeStyleTest extends GdxMap {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
mapFile = getMapFile(args);
|
||||
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MapsforgeStyleTest());
|
||||
GdxMapApp.run(new MapsforgeStyleTest(getMapFile(args)));
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ import java.io.File;
|
||||
|
||||
public class MapsforgeTest extends GdxMap {
|
||||
|
||||
private static File mapFile;
|
||||
private File mapFile;
|
||||
|
||||
private MapsforgeTest() {
|
||||
//LabelLayer.POLY_LABEL = true;
|
||||
MapsforgeTest(File mapFile) {
|
||||
this.mapFile = mapFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,7 +51,7 @@ public class MapsforgeTest extends GdxMap {
|
||||
//tileSource.setPreferredLanguage("en");
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
loadTheme(null);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
@ -74,7 +74,7 @@ public class MapsforgeTest extends GdxMap {
|
||||
mMap.setMapPosition(pos);
|
||||
}
|
||||
|
||||
private static File getMapFile(String[] args) {
|
||||
static File getMapFile(String[] args) {
|
||||
if (args.length == 0) {
|
||||
throw new IllegalArgumentException("missing argument: <mapFile>");
|
||||
}
|
||||
@ -90,10 +90,12 @@ public class MapsforgeTest extends GdxMap {
|
||||
return file;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
mapFile = getMapFile(args);
|
||||
protected void loadTheme(final String styleId) {
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GdxMapApp.init();
|
||||
GdxMapApp.run(new MapsforgeTest());
|
||||
GdxMapApp.run(new MapsforgeTest(getMapFile(args)));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user