From 086ebdfebb1b2edcd777bae4c829834d3656b6a9 Mon Sep 17 00:00:00 2001 From: Emux Date: Wed, 19 Jun 2024 14:58:48 +0300 Subject: [PATCH] Update workflow --- .github/workflows/android.yml | 8 +- README.md | 1 - docs/Changelog.md | 4 +- docs/Integration.md | 134 +++---- settings.gradle | 5 +- vtm-android-example/AndroidManifest.xml | 4 +- vtm-android-example/build.gradle | 4 +- .../oscim/android/test/JeoIndoorActivity.java | 336 +++++++++--------- .../src/org/oscim/android/test/Samples.java | 2 +- 9 files changed, 226 insertions(+), 272 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 30589a247..c8ec0e8bd 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' @@ -24,9 +24,3 @@ jobs: run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build - - name: Publish - if: github.event_name != 'pull_request' - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - run: ./gradlew -PSONATYPE_USERNAME="$SONATYPE_USERNAME" -PSONATYPE_PASSWORD="$SONATYPE_PASSWORD" publish diff --git a/README.md b/README.md index 5ec7ceee3..a16c817b8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Maven Central](https://img.shields.io/maven-central/v/org.mapsforge/vtm.svg)](https://repo1.maven.org/maven2/org/mapsforge/) [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0) # V™ diff --git a/docs/Changelog.md b/docs/Changelog.md index f1ea51682..44cb26bdd 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -3,6 +3,8 @@ ## New since 0.21.0 - `vtm-themes` change package [#1130](https://github.com/mapsforge/vtm/issues/1130) +- Enable `vtm-jeo` +- Disable `vtm-theme-comparator` - Minor improvements and bug fixes - [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.22.0) @@ -13,7 +15,7 @@ - Line style `transparent` option [#1100](https://github.com/mapsforge/vtm/pull/1100) - Canvas adapter: line scale option [#1075](https://github.com/mapsforge/vtm/pull/1075) - Disable `vtm-app` -- Disable `vtm-web` [#1110](https://github.com/mapsforge/vtm/issues/1110) +- Disable `vtm-web`, `vtm-web-app` [#1110](https://github.com/mapsforge/vtm/issues/1110) - Minor improvements and bug fixes - [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.21.0) diff --git a/docs/Integration.md b/docs/Integration.md index 746188d64..d2144f3cc 100644 --- a/docs/Integration.md +++ b/docs/Integration.md @@ -1,41 +1,44 @@ # Integration guide -This article describes how to integrate the library in your project, with Gradle / Maven / Jars or SNAPSHOT builds. +This article describes how to integrate the library in your project. -Current version is [![Maven Central](https://img.shields.io/maven-central/v/org.mapsforge/vtm.svg)](https://repo1.maven.org/maven2/org/mapsforge/) - -## Gradle +```groovy +repositories { + maven { url 'https://jitpack.io' } +} +``` -### Core ```groovy -implementation 'org.mapsforge:vtm:[CURRENT-VERSION]' -implementation 'org.mapsforge:vtm-themes:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-themes:[CURRENT-VERSION]' implementation 'org.slf4j:slf4j-api:1.7.28' ``` ### Android + ```groovy -runtimeOnly 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-armeabi-v7a' -runtimeOnly 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-arm64-v8a' -runtimeOnly 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-x86' -runtimeOnly 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-x86_64' -implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]:natives-armeabi-v7a' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]:natives-arm64-v8a' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]:natives-x86' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]:natives-x86_64' +implementation 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]' implementation 'com.caverock:androidsvg:1.4' ``` ### Android (libGDX) + ```groovy -runtimeOnly 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-armeabi-v7a' -runtimeOnly 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-arm64-v8a' -runtimeOnly 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-x86' -runtimeOnly 'org.mapsforge:vtm-android:[CURRENT-VERSION]:natives-x86_64' -implementation 'org.mapsforge:vtm-android:[CURRENT-VERSION]' -implementation 'org.mapsforge:vtm-gdx:[CURRENT-VERSION]' -runtimeOnly 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-armeabi-v7a' -runtimeOnly 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-arm64-v8a' -runtimeOnly 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-x86' -runtimeOnly 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]:natives-x86_64' -implementation 'org.mapsforge:vtm-android-gdx:[CURRENT-VERSION]' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]:natives-armeabi-v7a' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]:natives-arm64-v8a' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]:natives-x86' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]:natives-x86_64' +implementation 'com.github.mapsforge.vtm:vtm-android:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-gdx:[CURRENT-VERSION]' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android-gdx:[CURRENT-VERSION]:natives-armeabi-v7a' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android-gdx:[CURRENT-VERSION]:natives-arm64-v8a' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android-gdx:[CURRENT-VERSION]:natives-x86' +runtimeOnly 'com.github.mapsforge.vtm:vtm-android-gdx:[CURRENT-VERSION]:natives-x86_64' +implementation 'com.github.mapsforge.vtm:vtm-android-gdx:[CURRENT-VERSION]' implementation 'com.badlogicgames.gdx:gdx:1.11.0' implementation 'com.badlogicgames.gdx:gdx-backend-android:1.11.0' implementation 'com.caverock:androidsvg:1.4' @@ -46,21 +49,23 @@ implementation 'com.caverock:androidsvg:1.4' Detailed iOS instructions can be found [here](ios.md). ### Desktop + ```groovy -implementation 'org.mapsforge:vtm-gdx:[CURRENT-VERSION]' -implementation 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]' -runtimeOnly 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-linux' -runtimeOnly 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-osx' -runtimeOnly 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows' +implementation 'com.github.mapsforge.vtm:vtm-gdx:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-desktop:[CURRENT-VERSION]' +runtimeOnly 'com.github.mapsforge.vtm:vtm-desktop:[CURRENT-VERSION]:natives-linux' +runtimeOnly 'com.github.mapsforge.vtm:vtm-desktop:[CURRENT-VERSION]:natives-osx' +runtimeOnly 'com.github.mapsforge.vtm:vtm-desktop:[CURRENT-VERSION]:natives-windows' implementation 'com.badlogicgames.gdx:gdx:1.11.0' runtimeOnly 'com.badlogicgames.gdx:gdx-platform:1.11.0:natives-desktop' implementation 'guru.nidi.com.kitfox:svgSalamander:1.1.3' implementation 'net.sf.kxml:kxml2:2.3.0' ``` -### Desktop (LWJGL) +#### LWJGL 2 + ```groovy -implementation 'org.mapsforge:vtm-desktop-lwjgl:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-desktop-lwjgl:[CURRENT-VERSION]' implementation 'com.badlogicgames.gdx:gdx-backend-lwjgl:1.11.0' implementation 'org.lwjgl.lwjgl:lwjgl:2.9.3' runtimeOnly 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-linux' @@ -68,9 +73,10 @@ runtimeOnly 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-osx' runtimeOnly 'org.lwjgl.lwjgl:lwjgl-platform:2.9.3:natives-windows' ``` -### Desktop (LWJGL 3) +#### LWJGL 3 + ```groovy -implementation 'org.mapsforge:vtm-desktop-lwjgl3:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-desktop-lwjgl3:[CURRENT-VERSION]' implementation 'com.badlogicgames.gdx:gdx-backend-lwjgl3:1.11.0' implementation 'org.lwjgl:lwjgl:3.3.1' runtimeOnly 'org.lwjgl:lwjgl:3.3.1:natives-linux' @@ -78,10 +84,10 @@ runtimeOnly 'org.lwjgl:lwjgl:3.3.1:natives-macos' runtimeOnly 'org.lwjgl:lwjgl:3.3.1:natives-windows' ``` -### JTS geometries +### JTS overlays ```groovy -implementation 'org.mapsforge:vtm-jts:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-jts:[CURRENT-VERSION]' // https://github.com/locationtech/jts/issues/145 implementation 'org.locationtech.jts:jts-core:1.15.1' ``` @@ -89,17 +95,17 @@ implementation 'org.locationtech.jts:jts-core:1.15.1' ### Online tiles ```groovy -implementation 'org.mapsforge:vtm-http:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-http:[CURRENT-VERSION]' // https://github.com/square/okhttp/issues/4481 implementation 'com.squareup.okhttp3:okhttp:3.12.13' implementation 'com.squareup.okio:okio:1.15.0' ``` -### MBTiles (Android) +### MBTiles ```groovy -implementation 'org.mapsforge:vtm-android-mvt:[CURRENT-VERSION]' -implementation 'org.mapsforge:vtm-mvt:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-android-mvt:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-mvt:[CURRENT-VERSION]' implementation 'com.google.protobuf:protobuf-java:3.6.1' implementation 'com.wdtinc:mapbox-vector-tile:3.1.0' // https://github.com/locationtech/jts/issues/145 @@ -109,7 +115,7 @@ implementation 'org.locationtech.jts:jts-core:1.15.1' ### Mapbox vector tiles ```groovy -implementation 'org.mapsforge:vtm-mvt:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-mvt:[CURRENT-VERSION]' implementation 'com.google.protobuf:protobuf-java:3.6.1' implementation 'com.wdtinc:mapbox-vector-tile:3.1.0' // https://github.com/locationtech/jts/issues/145 @@ -119,7 +125,7 @@ implementation 'org.locationtech.jts:jts-core:1.15.1' ### GeoJSON vector tiles ```groovy -implementation 'org.mapsforge:vtm-json:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-json:[CURRENT-VERSION]' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.9' implementation 'com.fasterxml.jackson.core:jackson-core:2.9.9' implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9' @@ -128,54 +134,8 @@ implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9' ### jeo (indoor maps) ```groovy -repositories { - maven { url 'https://jitpack.io' } -} - -implementation 'org.mapsforge:vtm-jeo:[CURRENT-VERSION]' +implementation 'com.github.mapsforge.vtm:vtm-jeo:[CURRENT-VERSION]' implementation('com.github.jeo.jeo:jeo-carto:master-SNAPSHOT') { exclude group: 'org.slf4j', module: 'slf4j-jdk14' } ``` - -## Snapshots - -We publish SNAPSHOT builds to Sonatype OSS Repository Hosting. - -You need to add the repository: -```groovy -repositories { - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } -} -``` - -And declare the dependencies like: -```groovy -implementation 'org.mapsforge:vtm:master-SNAPSHOT' -... -``` - -For checking latest snapshot on every build: -```groovy -configurations.all { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' -} -``` - -## Maven - -The dependencies for Maven are declared in a similar way. For example: - -```xml - - org.mapsforge - vtm - [CURRENT-VERSION] - -``` - -## Jars - -You can find release and snapshot jars (regular and with dependencies) in [Maven Central](https://repo1.maven.org/maven2/org/mapsforge/) and [Sonatype OSS Repository Hosting](https://oss.sonatype.org/content/repositories/snapshots/org/mapsforge/). - -Third party jars can be found at their respective sites or in Maven Central repository. diff --git a/settings.gradle b/settings.gradle index cc9cdde5d..8b78e5078 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,7 +10,6 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url 'https://jitpack.io' } } } @@ -30,14 +29,14 @@ include ':vtm-gdx-poi3d' include ':vtm-http' include ':vtm-ios' include ':vtm-ios-example' -//include ':vtm-jeo' +include ':vtm-jeo' include ':vtm-json' include ':vtm-jts' include ':vtm-models' include ':vtm-mvt' include ':vtm-playground' //include ':vtm-tests' -include ':vtm-theme-comparator' +//include ':vtm-theme-comparator' include ':vtm-themes' //include ':vtm-web' //include ':vtm-web-app' diff --git a/vtm-android-example/AndroidManifest.xml b/vtm-android-example/AndroidManifest.xml index 95fb8e66b..6ed4e9f92 100644 --- a/vtm-android-example/AndroidManifest.xml +++ b/vtm-android-example/AndroidManifest.xml @@ -50,9 +50,9 @@ - + android:configChanges="keyboardHidden|orientation|screenSize" /> diff --git a/vtm-android-example/build.gradle b/vtm-android-example/build.gradle index a3d99f1a1..4662f2fd8 100644 --- a/vtm-android-example/build.gradle +++ b/vtm-android-example/build.gradle @@ -5,7 +5,7 @@ dependencies { implementation project(':vtm-android-mvt') implementation project(':vtm-extras') implementation project(':vtm-http') - //implementation project(':vtm-jeo') + implementation project(':vtm-jeo') implementation project(':vtm-json') implementation project(':vtm-jts') implementation project(':vtm-mvt') @@ -16,7 +16,7 @@ dependencies { implementation project(':vtm-gdx') implementation project(':vtm-gdx-poi3d') - implementation 'org.mapsforge:mapsforge-poi-android:master-SNAPSHOT' + implementation 'com.github.mapsforge.mapsforge:mapsforge-poi-android:master-SNAPSHOT' } android { diff --git a/vtm-android-example/src/org/oscim/android/test/JeoIndoorActivity.java b/vtm-android-example/src/org/oscim/android/test/JeoIndoorActivity.java index 61538119b..c28abc57f 100644 --- a/vtm-android-example/src/org/oscim/android/test/JeoIndoorActivity.java +++ b/vtm-android-example/src/org/oscim/android/test/JeoIndoorActivity.java @@ -15,171 +15,171 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -//package org.oscim.android.test; -// -//import android.content.Context; -//import android.os.Bundle; -//import android.view.View; -//import android.widget.Toast; -//import android.widget.ToggleButton; -//import io.jeo.map.Style; -//import io.jeo.vector.VectorDataset; -//import org.oscim.backend.CanvasAdapter; -//import org.oscim.backend.canvas.Color; -//import org.oscim.layers.OSMIndoorLayer; -//import org.oscim.layers.tile.buildings.BuildingLayer; -//import org.oscim.layers.tile.vector.labeling.LabelLayer; -//import org.oscim.test.JeoTest; -//import org.oscim.theme.internal.VtmThemes; -//import org.oscim.theme.styles.TextStyle; -//import org.oscim.utils.IOUtils; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -// -//import java.io.IOException; -//import java.io.InputStream; -//import java.net.URL; -//import java.net.URLConnection; -//import java.util.Arrays; -// -//public class JeoIndoorActivity extends BaseMapActivity { -// public static final Logger log = LoggerFactory.getLogger(JeoIndoorActivity.class); -// -// // from http://overpass-turbo.eu/s/2vp -// String PATH = "https://gist.githubusercontent.com/anonymous/09062103a66844a96048f25626078c8d/raw/1d3af6a5a55e9ea4adc9551fa633a051a44a5a9c/overpass.geojson"; -// -// private OSMIndoorLayer mIndoorLayer; -// -// public JeoIndoorActivity() { -// 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.setTheme(VtmThemes.DEFAULT); -// -// mMap.layers().add(new BuildingLayer(mMap, mBaseLayer)); -// mMap.layers().add(new LabelLayer(mMap, mBaseLayer)); -// -// // 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(); -// TextStyle textStyle = TextStyle.builder() -// .isCaption(true) -// .fontSize(16 * CanvasAdapter.getScale()).color(Color.BLACK) -// .strokeWidth(2.2f * CanvasAdapter.getScale()).strokeColor(Color.WHITE) -// .build(); -// mIndoorLayer = new OSMIndoorLayer(mMap, data, style, textStyle); -// 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; -// if (v instanceof ToggleButton) -// ((ToggleButton) v).setChecked(mIndoorLayer.activeLevels[i]); -// log.debug(Arrays.toString(mIndoorLayer.activeLevels)); -// mIndoorLayer.update(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// } -// -// @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); -// } -//} +package org.oscim.android.test; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.widget.Toast; +import android.widget.ToggleButton; +import io.jeo.map.Style; +import io.jeo.vector.VectorDataset; +import org.oscim.backend.CanvasAdapter; +import org.oscim.backend.canvas.Color; +import org.oscim.layers.OSMIndoorLayer; +import org.oscim.layers.tile.buildings.BuildingLayer; +import org.oscim.layers.tile.vector.labeling.LabelLayer; +import org.oscim.test.JeoTest; +import org.oscim.theme.internal.VtmThemes; +import org.oscim.theme.styles.TextStyle; +import org.oscim.utils.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.Arrays; + +public class JeoIndoorActivity extends BaseMapActivity { + public static final Logger log = LoggerFactory.getLogger(JeoIndoorActivity.class); + + // from http://overpass-turbo.eu/s/2vp + String PATH = "https://gist.githubusercontent.com/anonymous/09062103a66844a96048f25626078c8d/raw/1d3af6a5a55e9ea4adc9551fa633a051a44a5a9c/overpass.geojson"; + + private OSMIndoorLayer mIndoorLayer; + + public JeoIndoorActivity() { + 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.setTheme(VtmThemes.DEFAULT); + + mMap.layers().add(new BuildingLayer(mMap, mBaseLayer)); + mMap.layers().add(new LabelLayer(mMap, mBaseLayer)); + + // 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(); + TextStyle textStyle = TextStyle.builder() + .isCaption(true) + .fontSize(16 * CanvasAdapter.getScale()).color(Color.BLACK) + .strokeWidth(2.2f * CanvasAdapter.getScale()).strokeColor(Color.WHITE) + .build(); + mIndoorLayer = new OSMIndoorLayer(mMap, data, style, textStyle); + 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; + if (v instanceof ToggleButton) + ((ToggleButton) v).setChecked(mIndoorLayer.activeLevels[i]); + log.debug(Arrays.toString(mIndoorLayer.activeLevels)); + mIndoorLayer.update(); + } + + @Override + protected void onStop() { + super.onStop(); + } + + @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); + } +} diff --git a/vtm-android-example/src/org/oscim/android/test/Samples.java b/vtm-android-example/src/org/oscim/android/test/Samples.java index 800a2544f..32cd113a0 100644 --- a/vtm-android-example/src/org/oscim/android/test/Samples.java +++ b/vtm-android-example/src/org/oscim/android/test/Samples.java @@ -121,7 +121,7 @@ protected void onCreate(Bundle savedInstanceState) { linearLayout.addView(createLabel("Experiments")); linearLayout.addView(createButton(ReverseGeocodeActivity.class)); linearLayout.addView(createButton(ThemeStylerActivity.class)); - //linearLayout.addView(createButton(JeoIndoorActivity.class)); + linearLayout.addView(createButton(JeoIndoorActivity.class)); linearLayout.addView(createButton(GdxPoi3DActivity.class)); linearLayout.addView(createButton(OverpassActivity.class)); linearLayout.addView(createButton(DraggableMarkerOverlayActivity.class));