Improve various samples examples, #32
This commit is contained in:
parent
d2f61f9bfa
commit
1bfd76c3da
@ -1,16 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.oscim.android.test"
|
package="org.oscim.android.test"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0" >
|
android:versionName="1.0" >
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="10"
|
android:minSdkVersion="10"
|
||||||
android:targetSdkVersion="21" />
|
android:targetSdkVersion="22" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 Hannes Janetzek
|
* Copyright 2014 Hannes Janetzek
|
||||||
|
* Copyright 2016 devemux86
|
||||||
|
*
|
||||||
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -14,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.android.test;
|
package org.oscim.android.test;
|
||||||
|
|
||||||
import org.oscim.android.MapView;
|
|
||||||
import org.oscim.android.filepicker.FilePicker;
|
import org.oscim.android.filepicker.FilePicker;
|
||||||
import org.oscim.android.filepicker.FilterByFileExtension;
|
import org.oscim.android.filepicker.FilterByFileExtension;
|
||||||
import org.oscim.android.filepicker.ValidMapFile;
|
import org.oscim.android.filepicker.ValidMapFile;
|
||||||
@ -35,9 +37,6 @@ import android.view.MenuItem;
|
|||||||
public class MapsforgeMapActivity extends MapActivity {
|
public class MapsforgeMapActivity extends MapActivity {
|
||||||
private static final int SELECT_MAP_FILE = 0;
|
private static final int SELECT_MAP_FILE = 0;
|
||||||
|
|
||||||
MapView mMapView;
|
|
||||||
MapFileTileSource mTileSource;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -91,34 +90,21 @@ public class MapsforgeMapActivity extends MapActivity {
|
|||||||
if (intent.getStringExtra(FilePicker.SELECTED_FILE) == null)
|
if (intent.getStringExtra(FilePicker.SELECTED_FILE) == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mTileSource = new MapFileTileSource();
|
MapFileTileSource tileSource = new MapFileTileSource();
|
||||||
String file = intent.getStringExtra(FilePicker.SELECTED_FILE);
|
String file = intent.getStringExtra(FilePicker.SELECTED_FILE);
|
||||||
if (mTileSource.setMapFile(file)) {
|
if (tileSource.setMapFile(file)) {
|
||||||
|
|
||||||
VectorTileLayer l = mMap.setBaseMap(mTileSource);
|
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||||
mMap.setTheme(VtmThemes.DEFAULT);
|
mMap.setTheme(VtmThemes.DEFAULT);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
MapInfo info = mTileSource.getMapInfo();
|
MapInfo info = tileSource.getMapInfo();
|
||||||
if (info.boundingBox != null) {
|
MapPosition pos = new MapPosition();
|
||||||
MapPosition pos = new MapPosition();
|
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||||
pos.setByBoundingBox(info.boundingBox,
|
mMap.setMapPosition(pos);
|
||||||
Tile.SIZE * 4,
|
mPrefs.clear();
|
||||||
Tile.SIZE * 4);
|
|
||||||
mMap.setMapPosition(pos);
|
|
||||||
Samples.log.debug("set position {}", pos);
|
|
||||||
} else if (info.mapCenter != null) {
|
|
||||||
|
|
||||||
double scale = 1 << 8;
|
|
||||||
if (info.startZoomLevel != null)
|
|
||||||
scale = 1 << info.startZoomLevel.intValue();
|
|
||||||
|
|
||||||
mMap.setMapPosition(info.mapCenter.getLatitude(),
|
|
||||||
info.mapCenter.getLongitude(),
|
|
||||||
scale);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0" >
|
android:versionName="1.0" >
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" />
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
|
<uses-sdk
|
||||||
|
android:minSdkVersion="10"
|
||||||
|
android:targetSdkVersion="22" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.oscim.android.start"
|
package="org.oscim.android.start"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
@ -9,7 +10,7 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="10"
|
android:minSdkVersion="10"
|
||||||
android:targetSdkVersion="21" />
|
android:targetSdkVersion="22" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="VTM Start"
|
android:label="VTM Start"
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="10"
|
android:minSdkVersion="10"
|
||||||
android:targetSdkVersion="21" />
|
android:targetSdkVersion="22" />
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 devemux86
|
||||||
|
*
|
||||||
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
|
*
|
||||||
|
* 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;
|
package org.oscim.android;
|
||||||
|
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
@ -21,6 +37,12 @@ public class MapPreferences {
|
|||||||
this.PREFERENCES_FILE = name;
|
this.PREFERENCES_FILE = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
Editor editor = ctx.getSharedPreferences(PREFERENCES_FILE, Activity.MODE_PRIVATE).edit();
|
||||||
|
editor.clear();
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
private void putDouble(Editor editor, String key, double value) {
|
private void putDouble(Editor editor, String key, double value) {
|
||||||
editor.putLong(key, Double.doubleToLongBits(value));
|
editor.putLong(key, Double.doubleToLongBits(value));
|
||||||
}
|
}
|
||||||
@ -40,8 +62,7 @@ public class MapPreferences {
|
|||||||
putDouble(editor, KEY_LATITUDE, pos.y);
|
putDouble(editor, KEY_LATITUDE, pos.y);
|
||||||
putDouble(editor, KEY_LONGITUDE, pos.x);
|
putDouble(editor, KEY_LONGITUDE, pos.x);
|
||||||
putDouble(editor, KEY_SCALE, pos.scale);
|
putDouble(editor, KEY_SCALE, pos.scale);
|
||||||
putDouble(editor, KEY_LATITUDE, pos.y);
|
editor.apply();
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean containsViewport(SharedPreferences prefs) {
|
private static boolean containsViewport(SharedPreferences prefs) {
|
||||||
|
@ -1,34 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 devemux86
|
||||||
|
*
|
||||||
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
|
*
|
||||||
|
* 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;
|
package org.oscim.test;
|
||||||
|
|
||||||
|
import org.oscim.core.MapPosition;
|
||||||
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.gdx.GdxMap;
|
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.buildings.BuildingLayer;
|
||||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||||
import org.oscim.renderer.MapRenderer;
|
|
||||||
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;
|
||||||
|
|
||||||
public class MapsforgeTest extends GdxMap {
|
public class MapsforgeTest extends GdxMap {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createLayers() {
|
public void createLayers() {
|
||||||
MapRenderer.setBackgroundColor(0xff888888);
|
|
||||||
|
|
||||||
mMap.setMapPosition(53.072, 8.80, 1 << 15);
|
|
||||||
// mMap.setMapPosition(52.5, 13.3, 1 << 15);
|
|
||||||
|
|
||||||
MapFileTileSource tileSource = new MapFileTileSource();
|
MapFileTileSource tileSource = new MapFileTileSource();
|
||||||
tileSource.setMapFile("/home/jeff/Downloads/bremen.map");
|
tileSource.setMapFile(System.getProperty("user.home") + "/Downloads/berlin.map");
|
||||||
|
|
||||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||||
|
mMap.setTheme(VtmThemes.DEFAULT);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
// mMap.setTheme(VtmThemes.DEFAULT);
|
MapInfo info = tileSource.getMapInfo();
|
||||||
// mMap.setTheme(VtmThemes.TRONRENDER);
|
MapPosition pos = new MapPosition();
|
||||||
mMap.setTheme(VtmThemes.OSMARENDER);
|
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||||
|
mMap.setMapPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user