PolyLabel samples #402
This commit is contained in:
parent
4f78fed094
commit
e5043447e3
@ -64,6 +64,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".MapsforgeMapActivity$ThemeFilePicker"
|
android:name=".MapsforgeMapActivity$ThemeFilePicker"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
|
<activity
|
||||||
|
android:name=".MapsforgePolyLabelActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".MapsforgeStyleActivity"
|
android:name=".MapsforgeStyleActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
|
@ -59,8 +59,6 @@ public class MapsforgeMapActivity extends MapActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
//LabelLayer.POLY_LABEL = true;
|
|
||||||
|
|
||||||
startActivityForResult(new Intent(this, MapFilePicker.class),
|
startActivityForResult(new Intent(this, MapFilePicker.class),
|
||||||
SELECT_MAP_FILE);
|
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(createLabel("Vector Features"));
|
||||||
linearLayout.addView(createButton(MapsforgeStyleActivity.class));
|
linearLayout.addView(createButton(MapsforgeStyleActivity.class));
|
||||||
|
linearLayout.addView(createButton(MapsforgePolyLabelActivity.class));
|
||||||
linearLayout.addView(createButton(AtlasThemeActivity.class));
|
linearLayout.addView(createButton(AtlasThemeActivity.class));
|
||||||
linearLayout.addView(createButton(POTTextureActivity.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 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.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.StreamRenderTheme;
|
||||||
import org.oscim.theme.XmlRenderThemeMenuCallback;
|
import org.oscim.theme.XmlRenderThemeMenuCallback;
|
||||||
import org.oscim.theme.XmlRenderThemeStyleLayer;
|
import org.oscim.theme.XmlRenderThemeStyleLayer;
|
||||||
import org.oscim.theme.XmlRenderThemeStyleMenu;
|
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.io.File;
|
||||||
import java.util.Set;
|
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
|
@Override
|
||||||
public void createLayers() {
|
protected void loadTheme(final String styleId) {
|
||||||
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) {
|
|
||||||
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) {
|
||||||
@ -118,9 +79,7 @@ public class MapsforgeStyleTest extends GdxMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
mapFile = getMapFile(args);
|
|
||||||
|
|
||||||
GdxMapApp.init();
|
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 {
|
public class MapsforgeTest extends GdxMap {
|
||||||
|
|
||||||
private static File mapFile;
|
private File mapFile;
|
||||||
|
|
||||||
private MapsforgeTest() {
|
MapsforgeTest(File mapFile) {
|
||||||
//LabelLayer.POLY_LABEL = true;
|
this.mapFile = mapFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -51,7 +51,7 @@ public class MapsforgeTest extends GdxMap {
|
|||||||
//tileSource.setPreferredLanguage("en");
|
//tileSource.setPreferredLanguage("en");
|
||||||
|
|
||||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||||
mMap.setTheme(VtmThemes.DEFAULT);
|
loadTheme(null);
|
||||||
|
|
||||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||||
mMap.layers().add(new LabelLayer(mMap, l));
|
mMap.layers().add(new LabelLayer(mMap, l));
|
||||||
@ -74,7 +74,7 @@ public class MapsforgeTest extends GdxMap {
|
|||||||
mMap.setMapPosition(pos);
|
mMap.setMapPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getMapFile(String[] args) {
|
static File getMapFile(String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
throw new IllegalArgumentException("missing argument: <mapFile>");
|
throw new IllegalArgumentException("missing argument: <mapFile>");
|
||||||
}
|
}
|
||||||
@ -90,10 +90,12 @@ public class MapsforgeTest extends GdxMap {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
protected void loadTheme(final String styleId) {
|
||||||
mapFile = getMapFile(args);
|
mMap.setTheme(VtmThemes.DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
GdxMapApp.init();
|
GdxMapApp.init();
|
||||||
GdxMapApp.run(new MapsforgeTest());
|
GdxMapApp.run(new MapsforgeTest(getMapFile(args)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user