update Indoor example
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
package org.oscim.jeo.android;
|
package org.oscim.jeo.android;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.jeo.data.VectorDataset;
|
import org.jeo.data.VectorDataset;
|
||||||
@@ -23,7 +23,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
@@ -31,11 +30,9 @@ import android.widget.ToggleButton;
|
|||||||
public class TestActivity extends MapActivity {
|
public class TestActivity extends MapActivity {
|
||||||
public static final Logger log = LoggerFactory.getLogger(TestActivity.class);
|
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
|
// 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;
|
private OSMIndoorLayer mIndoorLayer;
|
||||||
|
|
||||||
@@ -52,13 +49,13 @@ public class TestActivity extends MapActivity {
|
|||||||
showToast("load data");
|
showToast("load data");
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
try {
|
try {
|
||||||
File file = new File(Environment.getExternalStorageDirectory()
|
//File file = new File(Environment.getExternalStorageDirectory()
|
||||||
.getAbsolutePath(), "osmindoor.json");
|
// .getAbsolutePath(), "osmindoor.json");
|
||||||
is = new FileInputStream(file);
|
//is = new FileInputStream(file);
|
||||||
|
|
||||||
//URL url = new URL(PATH);
|
URL url = new URL(PATH);
|
||||||
//URLConnection conn = url.openConnection();
|
URLConnection conn = url.openConnection();
|
||||||
//is = conn.getInputStream();
|
is = conn.getInputStream();
|
||||||
loadJson(is);
|
loadJson(is);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -73,8 +70,8 @@ public class TestActivity extends MapActivity {
|
|||||||
mMap.layers().add(new LabelLayer(mMap, baseLayer));
|
mMap.layers().add(new LabelLayer(mMap, baseLayer));
|
||||||
mMap.setTheme(VtmThemes.TRON2);
|
mMap.setTheme(VtmThemes.TRON2);
|
||||||
|
|
||||||
mMap.setMapPosition(49.417, 8.673, 1 << 17);
|
//mMap.setMapPosition(49.417, 8.673, 1 << 17);
|
||||||
// mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
|
mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
|
||||||
|
|
||||||
// mMap.layers().add(new TileGridLayer(mMap));
|
// mMap.layers().add(new TileGridLayer(mMap));
|
||||||
// String file = Environment.getExternalStorageDirectory().getAbsolutePath();
|
// String file = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||||
|
|||||||
@@ -71,11 +71,13 @@ public class OSMIndoorLayer extends JeoVectorLayer {
|
|||||||
|
|
||||||
LineLayer ll = t.layers.getLineLayer(level * 3 + 1);
|
LineLayer ll = t.layers.getLineLayer(level * 3 + 1);
|
||||||
|
|
||||||
|
boolean active = activeLevels[level + 1];
|
||||||
|
|
||||||
if (ll.line == null) {
|
if (ll.line == null) {
|
||||||
float width = rule.number(f, CartoCSS.LINE_WIDTH, 1.2f);
|
float width = rule.number(f, CartoCSS.LINE_WIDTH, 1.2f);
|
||||||
int color = Color.rainbow((level + 1) / 10f);
|
int color = Color.rainbow((level + 1) / 10f);
|
||||||
|
|
||||||
if (level > -2 && !activeLevels[level + 1])
|
if (level > -2 && !active)
|
||||||
color = Color.fade(color, 0.1f);
|
color = Color.fade(color, 0.1f);
|
||||||
|
|
||||||
ll.line = new Line(0, color, width);
|
ll.line = new Line(0, color, width);
|
||||||
@@ -86,7 +88,7 @@ public class OSMIndoorLayer extends JeoVectorLayer {
|
|||||||
MeshLayer mesh = t.layers.getMeshLayer(level * 3);
|
MeshLayer mesh = t.layers.getMeshLayer(level * 3);
|
||||||
if (mesh.area == null) {
|
if (mesh.area == null) {
|
||||||
int color = JeoUtils.color(rule.color(f, CartoCSS.POLYGON_FILL, RGB.red));
|
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);
|
color = Color.fade(color, 0.1f);
|
||||||
|
|
||||||
mesh.area = new Area(color);
|
mesh.area = new Area(color);
|
||||||
@@ -96,20 +98,22 @@ public class OSMIndoorLayer extends JeoVectorLayer {
|
|||||||
|
|
||||||
addPolygon(t, g, mesh, ll);
|
addPolygon(t, g, mesh, ll);
|
||||||
|
|
||||||
Object o = f.get("name");
|
if (active) {
|
||||||
if (o instanceof String) {
|
Object o = f.get("name");
|
||||||
float x = 0;
|
if (o instanceof String) {
|
||||||
float y = 0;
|
float x = 0;
|
||||||
int n = mGeom.index[0];
|
float y = 0;
|
||||||
for (int i = 0; i < n;) {
|
int n = mGeom.index[0];
|
||||||
x += mGeom.points[i++];
|
for (int i = 0; i < n;) {
|
||||||
y += mGeom.points[i++];
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user