move vtm-jeo-android to vtm-android-example

This commit is contained in:
Hannes Janetzek
2014-03-29 14:53:19 +01:00
parent 5f14a87abd
commit 04391815e4
10 changed files with 23 additions and 156 deletions

View File

@@ -62,6 +62,11 @@
android:name="org.oscim.android.test.ThemeStylerActivity"
android:label="@string/title_activity_map" >
</activity>
<activity
android:name="org.oscim.android.test.JeoIndoorMapActivity"
android:label="@string/title_activity_map" >
</activity>
</application>
</manifest>

View File

@@ -10,9 +10,8 @@ buildscript {
apply plugin: 'android'
dependencies {
//compile 'org.oscim:vtm-android:0.5.9-SNAPSHOT'
//compile 'org.oscim:vtm-themes:0.5.9-SNAPSHOT'
compile project(':vtm-android')
compile project(':vtm-jeo')
compile project(':vtm-themes')
}
@@ -32,6 +31,9 @@ android {
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
packagingOptions {
exclude 'META-INF/services/org.jeo.data.Driver'
}
}
// Including configurations into Eclipse

View File

@@ -0,0 +1,93 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<org.oscim.android.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</org.oscim.android.MapView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:alpha="0.7"
android:gravity="center"
android:orientation="vertical" >
<ToggleButton
android:id="@+id/level7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="7"
android:textOn="7" />
<ToggleButton
android:id="@+id/level6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="6"
android:textOn="6" />
<ToggleButton
android:id="@+id/level5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="5"
android:textOn="5" />
<ToggleButton
android:id="@+id/level4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="4"
android:textOn="4" />
<ToggleButton
android:id="@+id/level3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="3"
android:textOn="3" />
<ToggleButton
android:id="@+id/level2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="2"
android:textOn="2" />
<ToggleButton
android:id="@+id/level1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="1"
android:textOn="1" />
<ToggleButton
android:id="@+id/level0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="0"
android:textOn="0" />
<ToggleButton
android:id="@+id/level_u1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:textOff="-1"
android:textOn="-1" />
</LinearLayout>
</RelativeLayout>

View File

@@ -0,0 +1,155 @@
package org.oscim.android.test;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
import org.jeo.data.VectorDataset;
import org.jeo.map.Style;
import org.oscim.layers.OSMIndoorLayer;
import org.oscim.layers.tile.vector.BuildingLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.test.JeoTest;
import org.oscim.theme.VtmThemes;
import org.oscim.utils.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import android.widget.ToggleButton;
public class JeoIndoorMapActivity extends BaseMapActivity {
public static final Logger log = LoggerFactory.getLogger(JeoIndoorMapActivity.class);
// from http://overpass-turbo.eu/s/2vp
String PATH = "https://gist.github.com/anonymous/8960337/raw/overpass.geojson";
//String PATH = "https://gist.github.com/hjanetzek/9280925/raw/overpass.geojson";
private OSMIndoorLayer mIndoorLayer;
public JeoIndoorMapActivity() {
super(R.layout.jeo_indoor_map);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mMap.addTask(new Runnable() {
@Override
public void run() {
showToast("load data");
InputStream is = null;
try {
// File file = new File(Environment.getExternalStorageDirectory()
// .getAbsolutePath(), "osmindoor.json");
// is = new FileInputStream(file);
URL url = new URL(PATH);
URLConnection conn = url.openConnection();
is = conn.getInputStream();
loadJson(is);
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
}
}
});
mMap.layers().add(new BuildingLayer(mMap, mBaseLayer));
mMap.layers().add(new LabelLayer(mMap, mBaseLayer));
mMap.setTheme(VtmThemes.TRONRENDER);
//mMap.setMapPosition(49.417, 8.673, 1 << 17);
mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
// mMap.layers().add(new TileGridLayer(mMap));
// String file = Environment.getExternalStorageDirectory().getAbsolutePath();
// VectorDataset data = (VectorDataset) JeoTest.getJsonData(file + "/states.json", true);
// Style style = JeoTest.getStyle();
// mMap.layers().add(new JeoVectorLayer(mMap, data, style));
}
void loadJson(InputStream is) {
showToast("got data");
VectorDataset data = JeoTest.readGeoJson(is);
Style style = JeoTest.getStyle();
mIndoorLayer = new OSMIndoorLayer(mMap, data, style);
mMap.layers().add(mIndoorLayer);
showToast("data ready");
mMap.updateMap(true);
mIndoorLayer.activeLevels[0] = true;
shift();
}
public void showToast(final String text) {
final Context ctx = this;
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast toast = Toast.makeText(ctx, text, Toast.LENGTH_SHORT);
toast.show();
}
});
}
boolean mShift = true;
public void shift() {
if (!mShift)
return;
mMap.postDelayed(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
if (mIndoorLayer.activeLevels[i]) {
mIndoorLayer.activeLevels[i] = false;
mIndoorLayer.activeLevels[(i + 1) % 9] = true;
mIndoorLayer.update();
break;
}
}
shift();
}
}, 200);
}
public void onClick(View v) {
mShift = false;
if (mIndoorLayer == null)
return;
int i = 0;
if (v instanceof ToggleButton) {
ToggleButton b = (ToggleButton) v;
i = (b.getTextOn().charAt(0) - '0') + 1;
}
if (i < 0 || i > 9)
i = 0;
mIndoorLayer.activeLevels[i] ^= true;
((ToggleButton) v).setChecked(mIndoorLayer.activeLevels[i]);
log.debug(Arrays.toString(mIndoorLayer.activeLevels));
mIndoorLayer.update();
}
@Override
protected void onStop() {
super.onStop();
}
}

View File

@@ -47,6 +47,7 @@ public class Samples extends Activity {
linearLayout.addView(createButton(MarkerOverlayActivity.class));
linearLayout.addView(createButton(ThemeStylerActivity.class));
linearLayout.addView(createButton(S3DBMapActivity.class));
linearLayout.addView(createButton(JeoIndoorMapActivity.class));
}
private Button createButton(final Class<?> clazz) {