update Indoor example

This commit is contained in:
Hannes Janetzek 2014-02-28 23:43:43 +01:00
parent bb439236d6
commit 2c133a87cb
2 changed files with 31 additions and 30 deletions

View File

@ -1,9 +1,9 @@
package org.oscim.jeo.android;
import java.io.File;
import java.io.FileInputStream;
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;
@ -23,7 +23,6 @@ import org.slf4j.LoggerFactory;
import android.content.Context;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Toast;
import android.widget.ToggleButton;
@ -31,11 +30,9 @@ import android.widget.ToggleButton;
public class TestActivity extends MapActivity {
public static final Logger log = LoggerFactory.getLogger(TestActivity.class);
//String PATH = "http://opensciencemap.org/featureserver/featureserver.cgi/osm_indoor";
// from http://overpass-turbo.eu/s/2vp
String PATH = "https://gist.github.com/hjanetzek/8959418/raw/overpass.geojson";
//String PATH = "https://gist.github.com/anonymous/8960337/raw/overpass.geojson";
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;
@ -52,13 +49,13 @@ public class TestActivity extends MapActivity {
showToast("load data");
InputStream is = null;
try {
File file = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath(), "osmindoor.json");
is = new FileInputStream(file);
//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();
URL url = new URL(PATH);
URLConnection conn = url.openConnection();
is = conn.getInputStream();
loadJson(is);
} catch (IOException e) {
e.printStackTrace();
@ -73,8 +70,8 @@ public class TestActivity extends MapActivity {
mMap.layers().add(new LabelLayer(mMap, baseLayer));
mMap.setTheme(VtmThemes.TRON2);
mMap.setMapPosition(49.417, 8.673, 1 << 17);
// mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
//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();

View File

@ -71,11 +71,13 @@ public class OSMIndoorLayer extends JeoVectorLayer {
LineLayer ll = t.layers.getLineLayer(level * 3 + 1);
boolean active = activeLevels[level + 1];
if (ll.line == null) {
float width = rule.number(f, CartoCSS.LINE_WIDTH, 1.2f);
int color = Color.rainbow((level + 1) / 10f);
if (level > -2 && !activeLevels[level + 1])
if (level > -2 && !active)
color = Color.fade(color, 0.1f);
ll.line = new Line(0, color, width);
@ -86,7 +88,7 @@ public class OSMIndoorLayer extends JeoVectorLayer {
MeshLayer mesh = t.layers.getMeshLayer(level * 3);
if (mesh.area == null) {
int color = JeoUtils.color(rule.color(f, CartoCSS.POLYGON_FILL, RGB.red));
if (level > -2 && !activeLevels[level + 1])
if (level > -2 && !active)
color = Color.fade(color, 0.1f);
mesh.area = new Area(color);
@ -96,20 +98,22 @@ public class OSMIndoorLayer extends JeoVectorLayer {
addPolygon(t, g, mesh, ll);
Object o = f.get("name");
if (o instanceof String) {
float x = 0;
float y = 0;
int n = mGeom.index[0];
for (int i = 0; i < n;) {
x += mGeom.points[i++];
y += mGeom.points[i++];
if (active) {
Object o = f.get("name");
if (o instanceof String) {
float x = 0;
float y = 0;
int n = mGeom.index[0];
for (int i = 0; i < n;) {
x += mGeom.points[i++];
y += mGeom.points[i++];
}
TextItem ti = TextItem.pool.get();
ti.set(x / (n / 2) / 8, y / (n / 2) / 8, (String) o, mText);
mTextLayer.addText(ti);
}
TextItem ti = TextItem.pool.get();
ti.set(x / (n / 2) / 8, y / (n / 2) / 8, (String) o, mText);
mTextLayer.addText(ti);
}
}