Update vtm-jeo module (#770)

This commit is contained in:
Jan Lippert 2020-04-13 18:55:27 +02:00 committed by Emux
parent 29634d29b5
commit 18ee0a393f
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
19 changed files with 829 additions and 427 deletions

View File

@ -42,7 +42,6 @@ def versionName() { return version }
subprojects { subprojects {
repositories { repositories {
google() google()
//maven { url 'https://repo.boundlessgeo.com/main/' }
jcenter() jcenter()
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
} }

View File

@ -14,7 +14,7 @@ include ':vtm-gdx-poi3d'
include ':vtm-http' include ':vtm-http'
include ':vtm-ios' include ':vtm-ios'
include ':vtm-ios-example' include ':vtm-ios-example'
//include ':vtm-jeo' include ':vtm-jeo'
include ':vtm-json' include ':vtm-json'
include ':vtm-jts' include ':vtm-jts'
include ':vtm-models' include ':vtm-models'

View File

@ -42,9 +42,9 @@
<activity <activity
android:name=".GdxPoi3DActivity" android:name=".GdxPoi3DActivity"
android:configChanges="keyboardHidden|orientation|screenSize" /> android:configChanges="keyboardHidden|orientation|screenSize" />
<!--<activity <activity
android:name=".JeoIndoorActivity" android:name=".JeoIndoorActivity"
android:configChanges="keyboardHidden|orientation|screenSize" />--> android:configChanges="keyboardHidden|orientation|screenSize" />
<activity <activity
android:name=".LineTexActivity" android:name=".LineTexActivity"
android:configChanges="keyboardHidden|orientation|screenSize" /> android:configChanges="keyboardHidden|orientation|screenSize" />

View File

@ -5,7 +5,7 @@ dependencies {
implementation project(':vtm-android-mvt') implementation project(':vtm-android-mvt')
implementation project(':vtm-extras') implementation project(':vtm-extras')
implementation project(':vtm-http') implementation project(':vtm-http')
//implementation project(':vtm-jeo') implementation project(':vtm-jeo')
implementation project(':vtm-json') implementation project(':vtm-json')
implementation project(':vtm-jts') implementation project(':vtm-jts')
implementation project(':vtm-mvt') implementation project(':vtm-mvt')

View File

@ -1,186 +1,185 @@
///* /*
// * Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
// * Copyright 2016-2018 devemux86 * Copyright 2016-2018 devemux86
// * *
// * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * 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
// * Foundation, either version 3 of the License, or (at your option) any later version. * 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 * 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 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * 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 * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
// */ */
//package org.oscim.android.test; package org.oscim.android.test;
//
//import android.content.Context; import android.content.Context;
//import android.os.Bundle; import android.os.Bundle;
//import android.view.View; import android.view.View;
//import android.widget.Toast; import android.widget.Toast;
//import android.widget.ToggleButton; import android.widget.ToggleButton;
// import io.jeo.map.Style;
//import org.jeo.map.Style; import io.jeo.vector.VectorDataset;
//import org.jeo.vector.VectorDataset; import org.oscim.backend.CanvasAdapter;
//import org.oscim.backend.CanvasAdapter; import org.oscim.backend.canvas.Color;
//import org.oscim.backend.canvas.Color; import org.oscim.layers.OSMIndoorLayer;
//import org.oscim.layers.OSMIndoorLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
//import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
//import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.test.JeoTest;
//import org.oscim.test.JeoTest; import org.oscim.theme.VtmThemes;
//import org.oscim.theme.VtmThemes; import org.oscim.theme.styles.TextStyle;
//import org.oscim.theme.styles.TextStyle; import org.oscim.utils.IOUtils;
//import org.oscim.utils.IOUtils; import org.slf4j.Logger;
//import org.slf4j.Logger; import org.slf4j.LoggerFactory;
//import org.slf4j.LoggerFactory;
// import java.io.IOException;
//import java.io.IOException; import java.io.InputStream;
//import java.io.InputStream; import java.net.URL;
//import java.net.URL; import java.net.URLConnection;
//import java.net.URLConnection; import java.util.Arrays;
//import java.util.Arrays;
// public class JeoIndoorActivity extends BaseMapActivity {
//public class JeoIndoorActivity extends BaseMapActivity { public static final Logger log = LoggerFactory.getLogger(JeoIndoorActivity.class);
// public static final Logger log = LoggerFactory.getLogger(JeoIndoorActivity.class);
// // from http://overpass-turbo.eu/s/2vp
// // from http://overpass-turbo.eu/s/2vp String PATH = "https://gist.githubusercontent.com/anonymous/09062103a66844a96048f25626078c8d/raw/1d3af6a5a55e9ea4adc9551fa633a051a44a5a9c/overpass.geojson";
// String PATH = "https://gist.githubusercontent.com/anonymous/09062103a66844a96048f25626078c8d/raw/1d3af6a5a55e9ea4adc9551fa633a051a44a5a9c/overpass.geojson";
// private OSMIndoorLayer mIndoorLayer;
// private OSMIndoorLayer mIndoorLayer;
// public JeoIndoorActivity() {
// public JeoIndoorActivity() { super(R.layout.jeo_indoor_map);
// super(R.layout.jeo_indoor_map); }
// }
// @Override
// @Override public void onCreate(Bundle savedInstanceState) {
// public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// super.onCreate(savedInstanceState);
// mMap.addTask(new Runnable() {
// mMap.addTask(new Runnable() { @Override
// @Override public void run() {
// public void run() { 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(); } finally {
// } finally { IOUtils.closeQuietly(is);
// IOUtils.closeQuietly(is); }
// } }
// } });
// });
// mMap.setTheme(VtmThemes.DEFAULT);
// mMap.setTheme(VtmThemes.DEFAULT);
// mMap.layers().add(new BuildingLayer(mMap, mBaseLayer));
// mMap.layers().add(new BuildingLayer(mMap, mBaseLayer)); mMap.layers().add(new LabelLayer(mMap, mBaseLayer));
// mMap.layers().add(new LabelLayer(mMap, mBaseLayer));
// // String file = Environment.getExternalStorageDirectory().getAbsolutePath();
// // String file = Environment.getExternalStorageDirectory().getAbsolutePath(); // VectorDataset data = (VectorDataset) JeoTest.getJsonData(file + "/states.json", true);
// // 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(); // Style style = JeoTest.getStyle();
// TextStyle textStyle = TextStyle.builder() // mMap.layers().add(new JeoVectorLayer(mMap, data, style));
// .isCaption(true) }
// .fontSize(16 * CanvasAdapter.getScale()).color(Color.BLACK)
// .strokeWidth(2.2f * CanvasAdapter.getScale()).strokeColor(Color.WHITE) void loadJson(InputStream is) {
// .build(); showToast("got data");
// mIndoorLayer = new OSMIndoorLayer(mMap, data, style, textStyle);
// mMap.layers().add(mIndoorLayer); VectorDataset data = JeoTest.readGeoJson(is);
// Style style = JeoTest.getStyle();
// showToast("data ready"); TextStyle textStyle = TextStyle.builder()
// mMap.updateMap(true); .isCaption(true)
// .fontSize(16 * CanvasAdapter.getScale()).color(Color.BLACK)
// mIndoorLayer.activeLevels[0] = true; .strokeWidth(2.2f * CanvasAdapter.getScale()).strokeColor(Color.WHITE)
// shift(); .build();
// } mIndoorLayer = new OSMIndoorLayer(mMap, data, style, textStyle);
// mMap.layers().add(mIndoorLayer);
// public void showToast(final String text) {
// final Context ctx = this; showToast("data ready");
// runOnUiThread(new Runnable() { mMap.updateMap(true);
// @Override
// public void run() { mIndoorLayer.activeLevels[0] = true;
// Toast toast = Toast.makeText(ctx, text, Toast.LENGTH_SHORT); shift();
// toast.show(); }
// }
// }); public void showToast(final String text) {
// } final Context ctx = this;
// runOnUiThread(new Runnable() {
// boolean mShift = true; @Override
// public void run() {
// public void shift() { Toast toast = Toast.makeText(ctx, text, Toast.LENGTH_SHORT);
// if (!mShift) toast.show();
// return; }
// });
// mMap.postDelayed(new Runnable() { }
//
// @Override boolean mShift = true;
// public void run() {
// for (int i = 0; i < 10; i++) { public void shift() {
// if (mIndoorLayer.activeLevels[i]) { if (!mShift)
// mIndoorLayer.activeLevels[i] = false; return;
// mIndoorLayer.activeLevels[(i + 1) % 9] = true;
// mIndoorLayer.update(); mMap.postDelayed(new Runnable() {
// break;
// } @Override
// } public void run() {
// shift(); for (int i = 0; i < 10; i++) {
// } if (mIndoorLayer.activeLevels[i]) {
// }, 200); mIndoorLayer.activeLevels[i] = false;
// mIndoorLayer.activeLevels[(i + 1) % 9] = true;
// } mIndoorLayer.update();
// break;
// public void onClick(View v) { }
// mShift = false; }
// shift();
// if (mIndoorLayer == null) }
// return; }, 200);
//
// int i = 0; }
//
// if (v instanceof ToggleButton) { public void onClick(View v) {
// ToggleButton b = (ToggleButton) v; mShift = false;
// i = (b.getTextOn().charAt(0) - '0') + 1;
// } if (mIndoorLayer == null)
// return;
// if (i < 0 || i > 9)
// i = 0; int i = 0;
//
// mIndoorLayer.activeLevels[i] ^= true; if (v instanceof ToggleButton) {
// if (v instanceof ToggleButton) ToggleButton b = (ToggleButton) v;
// ((ToggleButton) v).setChecked(mIndoorLayer.activeLevels[i]); i = (b.getTextOn().charAt(0) - '0') + 1;
// log.debug(Arrays.toString(mIndoorLayer.activeLevels)); }
// mIndoorLayer.update();
// } if (i < 0 || i > 9)
// i = 0;
// @Override
// protected void onStop() { mIndoorLayer.activeLevels[i] ^= true;
// super.onStop(); if (v instanceof ToggleButton)
// } ((ToggleButton) v).setChecked(mIndoorLayer.activeLevels[i]);
// log.debug(Arrays.toString(mIndoorLayer.activeLevels));
// @Override mIndoorLayer.update();
// protected void onResume() { }
// super.onResume();
// @Override
// /* ignore saved position */ protected void onStop() {
// //mMap.setMapPosition(49.417, 8.673, 1 << 17); super.onStop();
// mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16); }
// }
//} @Override
protected void onResume() {
super.onResume();
/* ignore saved position */
//mMap.setMapPosition(49.417, 8.673, 1 << 17);
mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
}
}

View File

@ -128,7 +128,7 @@ public class Samples extends Activity {
linearLayout.addView(createLabel("Experiments")); linearLayout.addView(createLabel("Experiments"));
linearLayout.addView(createButton(ReverseGeocodeActivity.class)); linearLayout.addView(createButton(ReverseGeocodeActivity.class));
linearLayout.addView(createButton(ThemeStylerActivity.class)); linearLayout.addView(createButton(ThemeStylerActivity.class));
//linearLayout.addView(createButton(JeoIndoorActivity.class)); linearLayout.addView(createButton(JeoIndoorActivity.class));
linearLayout.addView(createButton(GdxPoi3DActivity.class)); linearLayout.addView(createButton(GdxPoi3DActivity.class));
linearLayout.addView(createButton(OverpassActivity.class)); linearLayout.addView(createButton(OverpassActivity.class));
linearLayout.addView(createButton(ClusterMarkerOverlayActivity.class)); linearLayout.addView(createButton(ClusterMarkerOverlayActivity.class));

View File

@ -3,10 +3,7 @@ apply plugin: 'maven'
dependencies { dependencies {
api project(':vtm') api project(':vtm')
api('org.jeo:jeo:0-SNAPSHOT') { api('com.github.jeo.jeo:jeo-carto:master-SNAPSHOT') {
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
}
api('org.jeo:jeo-carto:0-SNAPSHOT') {
exclude group: 'org.slf4j', module: 'slf4j-jdk14' exclude group: 'org.slf4j', module: 'slf4j-jdk14'
} }
} }

View File

@ -1,6 +1,6 @@
package org.oscim.jeo; package org.oscim.jeo;
import org.jeo.map.RGB; import io.jeo.map.RGB;
public class JeoUtils { public class JeoUtils {
public static int color(RGB rgb) { public static int color(RGB rgb) {

View File

@ -16,8 +16,8 @@
*/ */
package org.oscim.layers; package org.oscim.layers;
import org.jeo.tile.Tile; import io.jeo.tile.Tile;
import org.jeo.tile.TileDataset; import io.jeo.tile.TileDataset;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.layers.tile.MapTile; import org.oscim.layers.tile.MapTile;
@ -30,9 +30,7 @@ import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import static org.oscim.tiling.QueryResult.FAILED; import static org.oscim.tiling.QueryResult.*;
import static org.oscim.tiling.QueryResult.SUCCESS;
import static org.oscim.tiling.QueryResult.TILE_NOT_FOUND;
public class JeoTileSource extends TileSource { public class JeoTileSource extends TileSource {
static final Logger log = LoggerFactory.getLogger(JeoTileSource.class); static final Logger log = LoggerFactory.getLogger(JeoTileSource.class);

View File

@ -19,16 +19,11 @@ package org.oscim.layers;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.LineString;
import io.jeo.geom.Geom;
import org.jeo.geom.Geom; import io.jeo.map.*;
import org.jeo.map.CartoCSS; import io.jeo.vector.Feature;
import org.jeo.map.RGB; import io.jeo.vector.VectorDataset;
import org.jeo.map.Rule; import io.jeo.vector.VectorQuery;
import org.jeo.map.RuleList;
import org.jeo.map.Style;
import org.jeo.vector.Feature;
import org.jeo.vector.VectorDataset;
import org.jeo.vector.VectorQuery;
import org.oscim.jeo.JeoUtils; import org.oscim.jeo.JeoUtils;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.renderer.bucket.LineBucket; import org.oscim.renderer.bucket.LineBucket;
@ -77,7 +72,7 @@ public class JeoVectorLayer extends JtsLayer {
VectorQuery q = new VectorQuery().bounds(b); VectorQuery q = new VectorQuery().bounds(b);
if (dbg) if (dbg)
log.debug("query {}", b); log.debug("query {}", b);
for (Feature f : mDataset.cursor(q)) { for (Feature f : mDataset.read(q)) {
if (dbg) if (dbg)
log.debug("feature {}", f); log.debug("feature {}", f);

View File

@ -21,13 +21,8 @@ package org.oscim.layers;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import io.jeo.geom.CoordinatePath;
import org.jeo.geom.CoordinatePath; import org.oscim.core.*;
import org.oscim.core.Box;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
import org.oscim.core.Tile;
import org.oscim.layers.vector.AbstractVectorLayer; import org.oscim.layers.vector.AbstractVectorLayer;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.renderer.bucket.LineBucket; import org.oscim.renderer.bucket.LineBucket;

View File

@ -21,13 +21,12 @@ package org.oscim.layers;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.LineString;
import io.jeo.map.CartoCSS;
import org.jeo.map.CartoCSS; import io.jeo.map.RGB;
import org.jeo.map.RGB; import io.jeo.map.Rule;
import org.jeo.map.Rule; import io.jeo.map.Style;
import org.jeo.map.Style; import io.jeo.vector.Feature;
import org.jeo.vector.Feature; import io.jeo.vector.VectorDataset;
import org.jeo.vector.VectorDataset;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.jeo.JeoUtils; import org.oscim.jeo.JeoUtils;
import org.oscim.map.Map; import org.oscim.map.Map;

View File

@ -18,21 +18,15 @@
package org.oscim.test; package org.oscim.test;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import io.jeo.carto.Carto;
import org.jeo.carto.Carto; import io.jeo.data.Dataset;
import org.jeo.data.Dataset; import io.jeo.data.mem.MemVectorDataset;
import org.jeo.data.mem.MemVector; import io.jeo.data.mem.MemWorkspace;
import org.jeo.data.mem.MemWorkspace; import io.jeo.geojson.GeoJSONDataset;
import org.jeo.geojson.GeoJSONDataset; import io.jeo.geojson.GeoJSONReader;
import org.jeo.geojson.GeoJSONReader; import io.jeo.geom.GeomBuilder;
import org.jeo.geom.GeomBuilder; import io.jeo.map.Style;
import org.jeo.map.Style; import io.jeo.vector.*;
import org.jeo.vector.Feature;
import org.jeo.vector.Features;
import org.jeo.vector.Schema;
import org.jeo.vector.SchemaBuilder;
import org.jeo.vector.VectorDataset;
import org.jeo.vector.VectorQuery;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.layers.OSMIndoorLayer; import org.oscim.layers.OSMIndoorLayer;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
@ -42,11 +36,7 @@ import org.oscim.renderer.MapRenderer;
import org.oscim.theme.styles.TextStyle; import org.oscim.theme.styles.TextStyle;
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
public class JeoTest { public class JeoTest {
@ -101,13 +91,13 @@ public class JeoTest {
GeoJSONReader r = new GeoJSONReader(); GeoJSONReader r = new GeoJSONReader();
@SuppressWarnings("resource") @SuppressWarnings("resource")
MemWorkspace mem = new MemWorkspace(); MemWorkspace mem = new MemWorkspace("");
//mem.put("layer", data); //mem.put("layer", data);
try { try {
Schema s = new SchemaBuilder("way").schema(); Schema s = new SchemaBuilder("way").schema();
MemVector memData = mem.create(s); MemVectorDataset memData = mem.create(s);
for (Feature f : r.features(is)) { for (Feature f : r.features(is)) {
//System.out.println("loaded: " + f); //System.out.println("loaded: " + f);
@ -133,7 +123,7 @@ public class JeoTest {
if (memory) { if (memory) {
@SuppressWarnings("resource") @SuppressWarnings("resource")
MemWorkspace mem = new MemWorkspace(); MemWorkspace mem = new MemWorkspace("");
//mem.put("layer", data); //mem.put("layer", data);
try { try {
@ -141,9 +131,9 @@ public class JeoTest {
Schema s = data.schema(); Schema s = data.schema();
VectorQuery q = new VectorQuery(); VectorQuery q = new VectorQuery();
MemVector memData = mem.create(s); MemVectorDataset memData = mem.create(s);
for (Feature f : data.cursor(q)) { for (Feature f : data.read(q)) {
memData.add(f); memData.add(f);
} }
@ -160,14 +150,14 @@ public class JeoTest {
GeomBuilder gb = new GeomBuilder(4326); GeomBuilder gb = new GeomBuilder(4326);
@SuppressWarnings("resource") @SuppressWarnings("resource")
MemWorkspace mem = new MemWorkspace(); MemWorkspace mem = new MemWorkspace("");
Schema schema = new SchemaBuilder(layer) Schema schema = new SchemaBuilder(layer)
.field("geometry", Geometry.class) .field("geometry", Geometry.class)
.field("id", Integer.class) .field("id", Integer.class)
.field("name", String.class) .field("name", String.class)
.field("cost", Double.class).schema(); .field("cost", Double.class).schema();
MemVector data; MemVectorDataset data;
try { try {
data = mem.create(schema); data = mem.create(schema);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
@ -181,15 +171,16 @@ public class JeoTest {
Geometry g = gb.point(0, 0).toPoint(); Geometry g = gb.point(0, 0).toPoint();
//g.setSRID(4326); //g.setSRID(4326);
data.add(Features.create(null, data.schema(),
data.add(new ListFeature(data.schema(),
g, 1, "anvil", g, 1, "anvil",
10.99)); 10.99));
data.add(Features.create(null, data.schema(), data.add(new ListFeature(data.schema(),
gb.points(10, 10, 20, 20).toLineString(), gb.points(10, 10, 20, 20).toLineString(),
2, "bomb", 11.99)); 2, "bomb", 11.99));
data.add(Features.create(null, data.schema(), data.add(new ListFeature(data.schema(),
gb.point(100, 10).toPoint().buffer(10), gb.point(100, 10).toPoint().buffer(10),
3, "dynamite", 12.99)); 3, "dynamite", 12.99));

View File

@ -0,0 +1,452 @@
/* Copyright 2013 The jeo project. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.oscim.theme.carto;
import com.vividsolutions.jts.geom.Geometry;
import io.jeo.util.Util;
import io.jeo.vector.Feature;
import io.jeo.vector.Field;
import io.jeo.vector.Schema;
import io.jeo.vector.SchemaBuilder;
import org.osgeo.proj4j.CoordinateReferenceSystem;
import java.util.*;
/**
* Basic feature implementation.
*
* @author Justin Deoliveira, Boundless
* <p>
* Adapted by Jan Lippert to the changes made in https://github.com/jeo/jeo/commit/e28695ccc8530ae6d1a2dff1fbd1e11449ef949f
*/
public class BasicFeature implements Feature {
/**
* feature identifier
*/
protected String id;
/**
* Underlying feature storage.
*/
protected Storage storage;
/**
* Constructor taking a feature identifier.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
*/
public BasicFeature(String id) {
this(id, (Schema) null);
}
/**
* Constructor taking a feature identifier and an explicit schema object.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param schema The feature schema, if <code>null</code> the schema will be always be derived
*/
public BasicFeature(String id, Schema schema) {
this(id, (Storage)
(schema != null ? new ListStorage(null, schema) : new MapStorage(null, schema)));
}
/**
* Constructs a feature from an identifier and a list of values.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param values The feature values.
*/
public BasicFeature(String id, List<Object> values) {
this(id, values, null);
}
/**
* Constructs a feature from an identifier, a list of values, and a schema.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param values The feature values.
* @param schema The feature schema, if <code>null</code> the schema will be always be derived
*/
public BasicFeature(String id, List<Object> values, Schema schema) {
this(id, new ListStorage(values, schema));
}
/**
* Constructs a feature from an identifier and a map of values.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param values The feature values.
*/
public BasicFeature(String id, Map<String, Object> values) {
this(id, values, null);
}
/**
* Constructs a feature from an identifier, a map of values, and a schema.
*
* @param id The feature id, if <code>null</code> an identifier will be generated.
* @param values The feature values.
* @param schema The feature schema, if <code>null</code> the schema will be always be derived
*/
public BasicFeature(String id, Map<String, Object> values, Schema schema) {
this(id, new MapStorage(values, schema));
}
/**
* Constructor taking an identifier and feature storage object directly.
* <p>
* This constructor is typically only used for subclasses that need to implement custom feature
* storage.
* </p>
*/
protected BasicFeature(String id, Storage storage) {
this.id = id != null ? id : Util.uuid();
this.storage = storage;
}
@Override
public String id() {
return id;
}
/*@Override
public CoordinateReferenceSystem getCRS() {
return crs;
}*/
public BasicFeature crs(CoordinateReferenceSystem crs) {
storage.crs(crs);
return this;
}
@Override
public boolean has(String key) {
return storage.has(key);
}
@Override
public Object get(String key) {
return storage.get(key);
}
@Override
public BasicFeature put(String key, Object val) {
storage.put(key, val);
return this;
}
@Override
public BasicFeature put(Geometry g) {
//TODO:optimize before triggering schema creation
Field gf = storage.schema(true).geometry();
if (gf == null) {
throw new IllegalArgumentException("Feature schema has no geometry");
}
return put(gf.name(), g);
}
@Override
public Geometry geometry() {
return storage.geometry();
}
@Override
public Map<String, Object> map() {
return storage.map();
}
@Override
public String toString() {
return new StringBuilder(id).append(map()).toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((storage == null) ? 0 : storage.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BasicFeature other = (BasicFeature) obj;
if (id == null) {
return other.id == null;
}
return id.equals(other.id);
}
protected static abstract class Storage {
Schema schema;
CoordinateReferenceSystem crs;
protected Storage(Schema schema) {
this.schema = schema;
}
protected Storage crs(CoordinateReferenceSystem crs) {
this.crs = crs;
return this;
}
protected Schema schema() {
return schema(true);
}
protected Schema schema(boolean derive) {
if (schema == null && derive) {
schema = buildSchema();
// hack to apply crs override
if (crs != null && schema.crs() == null) {
schema = SchemaBuilder.crs(schema, crs);
}
}
return schema;
}
protected Geometry geometry() {
if (schema != null) {
Field f = schema.geometry();
if (f != null) {
return (Geometry) get(f.name());
}
}
return findGeometry();
}
protected CoordinateReferenceSystem crs() {
if (crs != null) {
return crs;
}
if (schema != null) {
return schema.crs();
}
return null;
}
/**
* Method for subclasses to implement to build a schema for the feature from its underlying
* attributes.
*/
protected abstract Schema buildSchema();
/**
* Method for subclasses to implement in order to find a geometry object when no schema
* information is available.
*/
protected abstract Geometry findGeometry();
protected abstract Object get(String key);
protected abstract Object get(int index);
protected abstract void put(String key, Object value);
protected abstract void set(int index, Object value);
protected abstract List<Object> list();
protected abstract Map<String, Object> map();
protected abstract boolean has(String key);
}
static class ListStorage extends Storage {
List<Object> list;
ListStorage(List<Object> values, Schema schema) {
super(schema);
this.list = pad(values, schema);
}
List<Object> pad(List<Object> values, Schema schema) {
//copy list passed in
values = values != null ? new ArrayList<Object>(values) : new ArrayList<Object>();
//expand up to size of schema if necessary
if (schema != null) {
while (values.size() < schema.size()) {
values.add(null);
}
}
return values;
}
@Override
protected Geometry findGeometry() {
for (Object o : list) {
if (o instanceof Geometry) {
return (Geometry) o;
}
}
return null;
}
@Override
protected Schema buildSchema() {
List<Field> fields = new ArrayList<Field>();
int i = 0;
boolean g = false;
for (Object o : list) {
if (o instanceof Geometry && !g) {
//first geometry
fields.add(new Field("geometry", o.getClass()));
g = true;
} else {
//regular field
fields.add(new Field(String.format(Locale.ROOT, "field%d", i++), o != null ? o.getClass() : null));
}
}
return new Schema("feature", fields);
}
@Override
protected boolean has(String key) {
return schema().indexOf(key) >= 0;
}
@Override
protected Object get(int i) {
return list.get(i);
}
@Override
protected void set(int i, Object value) {
list.set(i, value);
}
@Override
protected Object get(String key) {
int i = schema().indexOf(key);
return i != -1 ? get(i) : null;
}
@Override
protected void put(String key, Object val) {
int i = schema().indexOf(key);
if (i == -1) {
throw new IllegalArgumentException("No such key " + key);
}
set(i, val);
}
@Override
protected List<Object> list() {
return Collections.unmodifiableList(list);
}
@Override
protected Map<String, Object> map() {
LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
for (Field f : schema()) {
map.put(f.name(), get(f.name()));
}
return map;
}
}
static class MapStorage extends Storage {
Map<String, Object> map;
MapStorage(Map<String, Object> values, Schema schema) {
super(schema);
this.map = values != null ?
new LinkedHashMap<String, Object>(values) : new LinkedHashMap<String, Object>();
}
@Override
protected Schema buildSchema() {
List<Field> fields = new ArrayList<Field>();
for (Map.Entry<String, Object> e : map.entrySet()) {
fields.add(new Field(e.getKey(), e.getValue() != null ? e.getValue().getClass() : null));
}
return new Schema("feature", fields);
}
@Override
protected Geometry findGeometry() {
for (Object obj : map.values()) {
if (obj instanceof Geometry) {
return (Geometry) obj;
}
}
return null;
}
@Override
protected boolean has(String key) {
return map.containsKey(key);
}
@Override
protected Object get(String key) {
return map.get(key);
}
@Override
protected void put(String key, Object val) {
if (!map.containsKey(key)) {
//new field, clear cached schema
schema = null;
}
map.put(key, val);
}
@Override
protected Object get(int index) {
return Util.get(map, index);
}
@Override
protected void set(int index, Object value) {
Util.set(map, index, value);
}
@Override
protected List<Object> list() {
List<Object> list = new ArrayList<Object>();
for (Field f : schema()) {
list.add(get(f.name()));
}
return list;
}
@Override
protected Map<String, Object> map() {
return Collections.unmodifiableMap(map);
}
}
}

View File

@ -16,11 +16,9 @@
*/ */
package org.oscim.theme.carto; package org.oscim.theme.carto;
import org.jeo.vector.BasicFeature;
import org.oscim.core.Tag; import org.oscim.core.Tag;
import org.oscim.core.TagSet; import org.oscim.core.TagSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import static java.lang.System.out; import static java.lang.System.out;
@ -64,27 +62,10 @@ class MatcherFeature extends BasicFeature {
return null; return null;
} }
@Override
public List<Object> list() {
out.println("EEEK list()");
return null;
}
@Override @Override
public Map<String, Object> map() { public Map<String, Object> map() {
out.println("EEEK map()"); out.println("EEEK map()");
return null; return null;
} }
@Override
public Object get(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public BasicFeature set(int arg0, Object arg1) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -1,11 +1,7 @@
package org.oscim.theme.carto; package org.oscim.theme.carto;
import org.jeo.carto.Carto; import io.jeo.carto.Carto;
import org.jeo.map.CartoCSS; import io.jeo.map.*;
import org.jeo.map.RGB;
import org.jeo.map.Rule;
import org.jeo.map.RuleList;
import org.jeo.map.Style;
import org.oscim.core.GeometryBuffer.GeometryType; import org.oscim.core.GeometryBuffer.GeometryType;
import org.oscim.core.MapElement; import org.oscim.core.MapElement;
import org.oscim.core.Tag; import org.oscim.core.Tag;
@ -19,9 +15,9 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static io.jeo.map.CartoCSS.BACKGROUND_COLOR;
import static io.jeo.map.CartoCSS.OPACITY;
import static java.lang.System.out; import static java.lang.System.out;
import static org.jeo.map.CartoCSS.BACKGROUND_COLOR;
import static org.jeo.map.CartoCSS.OPACITY;
public class RenderTheme implements IRenderTheme { public class RenderTheme implements IRenderTheme {

View File

@ -8,7 +8,7 @@ dependencies {
implementation project(':vtm-extras') implementation project(':vtm-extras')
implementation project(':vtm-gdx-poi3d') implementation project(':vtm-gdx-poi3d')
implementation project(':vtm-http') implementation project(':vtm-http')
//implementation project(':vtm-jeo') implementation project(':vtm-jeo')
implementation project(':vtm-json') implementation project(':vtm-json')
implementation project(':vtm-jts') implementation project(':vtm-jts')
implementation project(':vtm-models') implementation project(':vtm-models')

View File

@ -1,92 +1,92 @@
///* /*
// * Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
// * Copyright 2016-2017 devemux86 * Copyright 2016-2017 devemux86
// * *
// * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * 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
// * Foundation, either version 3 of the License, or (at your option) any later version. * 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 * 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 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * 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 * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
// */ */
//package org.oscim.test.jeo; package org.oscim.test.jeo;
//
//import org.jeo.map.Style; import io.jeo.map.Style;
//import org.jeo.vector.VectorDataset; import io.jeo.vector.VectorDataset;
//import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
//import org.oscim.gdx.GdxMapApp; import org.oscim.gdx.GdxMapApp;
//import org.oscim.layers.JeoVectorLayer; import org.oscim.layers.JeoVectorLayer;
//import org.oscim.layers.OSMIndoorLayer; import org.oscim.layers.OSMIndoorLayer;
//import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.bitmap.BitmapTileLayer;
//import org.oscim.test.JeoTest; import org.oscim.test.JeoTest;
//import org.oscim.theme.styles.TextStyle; import org.oscim.theme.styles.TextStyle;
//
//import java.io.IOException; import java.io.IOException;
//import java.io.InputStream; import java.io.InputStream;
//import java.net.URL; import java.net.URL;
//import java.net.URLConnection; import java.net.URLConnection;
//
//import static org.oscim.tiling.source.bitmap.DefaultSources.STAMEN_TONER; import static org.oscim.tiling.source.bitmap.DefaultSources.STAMEN_TONER;
//
//public class LayerTest extends GdxMapApp { public class LayerTest extends GdxMapApp {
//
// // from http://overpass-turbo.eu/s/2vp // from http://overpass-turbo.eu/s/2vp
// String PATH = "https://gist.githubusercontent.com/anonymous/09062103a66844a96048f25626078c8d/raw/1d3af6a5a55e9ea4adc9551fa633a051a44a5a9c/overpass.geojson"; String PATH = "https://gist.githubusercontent.com/anonymous/09062103a66844a96048f25626078c8d/raw/1d3af6a5a55e9ea4adc9551fa633a051a44a5a9c/overpass.geojson";
//
// private OSMIndoorLayer mIndoorLayer; private OSMIndoorLayer mIndoorLayer;
//
// @Override @Override
// public void createLayers() { public void createLayers() {
// mMap.setBaseMap(new BitmapTileLayer(mMap, STAMEN_TONER.build())); mMap.setBaseMap(new BitmapTileLayer(mMap, STAMEN_TONER.build()));
//
// mMap.addTask(new Runnable() { mMap.addTask(new Runnable() {
// @Override @Override
// public void run() { public void run() {
// try { try {
// URL url = new URL(PATH); URL url = new URL(PATH);
// URLConnection conn = url.openConnection(); URLConnection conn = url.openConnection();
// InputStream is = conn.getInputStream(); InputStream is = conn.getInputStream();
//
// VectorDataset data = JeoTest.readGeoJson(is); VectorDataset data = JeoTest.readGeoJson(is);
Style style = JeoTest.getStyle();
TextStyle textStyle = TextStyle.builder()
.isCaption(true)
.fontSize(16).color(Color.BLACK)
.strokeWidth(2.2f).strokeColor(Color.WHITE)
.build();
mIndoorLayer = new OSMIndoorLayer(mMap, data, style, textStyle);
mIndoorLayer.activeLevels[0] = true;
mIndoorLayer.activeLevels[1] = true;
mIndoorLayer.activeLevels[2] = true;
mIndoorLayer.activeLevels[3] = true;
mMap.layers().add(new JeoVectorLayer(mMap, data, style));
mMap.layers().add(mIndoorLayer);
mMap.updateMap(true);
} catch (IOException e) {
e.printStackTrace();
}
}
});
mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
//VectorDataset data = (VectorDataset) JeoTest.getJsonData("states.json", true);
//Style style = JeoTest.getStyle(); //Style style = JeoTest.getStyle();
// TextStyle textStyle = TextStyle.builder()
// .isCaption(true)
// .fontSize(16).color(Color.BLACK)
// .strokeWidth(2.2f).strokeColor(Color.WHITE)
// .build();
// mIndoorLayer = new OSMIndoorLayer(mMap, data, style, textStyle);
// mIndoorLayer.activeLevels[0] = true;
// mIndoorLayer.activeLevels[1] = true;
// mIndoorLayer.activeLevels[2] = true;
// mIndoorLayer.activeLevels[3] = true;
//
//mMap.layers().add(new JeoVectorLayer(mMap, data, style)); //mMap.layers().add(new JeoVectorLayer(mMap, data, style));
// mMap.layers().add(mIndoorLayer);
// }
// mMap.updateMap(true);
// public static void main(String[] args) {
// } catch (IOException e) { GdxMapApp.init();
// e.printStackTrace(); GdxMapApp.run(new LayerTest(), null, 256);
// } }
// } }
// });
//
// mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
//
// //VectorDataset data = (VectorDataset) JeoTest.getJsonData("states.json", true);
// //Style style = JeoTest.getStyle();
// //mMap.layers().add(new JeoVectorLayer(mMap, data, style));
//
// }
//
// public static void main(String[] args) {
// GdxMapApp.init();
// GdxMapApp.run(new LayerTest(), null, 256);
// }
//}

View File

@ -1,50 +1,50 @@
///* /*
// * Copyright 2016-2017 devemux86 * Copyright 2016-2017 devemux86
// * *
// * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * 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
// * Foundation, either version 3 of the License, or (at your option) any later version. * 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 * 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 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * 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 * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
// */ */
//package org.oscim.test.jeo; package org.oscim.test.jeo;
//
//import org.oscim.gdx.GdxMapApp; import org.oscim.gdx.GdxMapApp;
//import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
//import org.oscim.renderer.MapRenderer; import org.oscim.renderer.MapRenderer;
//import org.oscim.theme.carto.RenderTheme; import org.oscim.theme.carto.RenderTheme;
//import org.oscim.tiling.source.OkHttpEngine; import org.oscim.tiling.source.OkHttpEngine;
//import org.oscim.tiling.source.UrlTileSource; import org.oscim.tiling.source.UrlTileSource;
//import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
//
//public class ThemeTest extends GdxMapApp { public class ThemeTest extends GdxMapApp {
//
// public static void main(String[] args) { public static void main(String[] args) {
// GdxMapApp.init(); GdxMapApp.init();
// GdxMapApp.run(new ThemeTest(), null, 256); GdxMapApp.run(new ThemeTest(), null, 256);
// } }
//
// @Override @Override
// public void createLayers() { public void createLayers() {
// UrlTileSource ts = OSciMap4TileSource.builder() UrlTileSource ts = OSciMap4TileSource.builder()
// .httpFactory(new OkHttpEngine.OkHttpFactory()) .httpFactory(new OkHttpEngine.OkHttpFactory())
// .build(); .build();
//
// VectorTileLayer l = mMap.setBaseMap(ts); VectorTileLayer l = mMap.setBaseMap(ts);
//
// l.setRenderTheme(new RenderTheme()); l.setRenderTheme(new RenderTheme());
//
// MapRenderer.setBackgroundColor(0xffcccccc); MapRenderer.setBackgroundColor(0xffcccccc);
//
// // mMap.getLayers().add(new LabelLayer(mMap, // mMap.getLayers().add(new LabelLayer(mMap,
// // mMapLayer.getTileLayer())); // mMapLayer.getTileLayer()));
// // mMap.getLayers().add(new JeoMapLayer(mMap)); // mMap.getLayers().add(new JeoMapLayer(mMap));
// } }
//} }