From de677cb85fdbc36b3018033ba80f30f55ccf2167 Mon Sep 17 00:00:00 2001 From: Emux Date: Tue, 11 Mar 2025 10:16:31 +0200 Subject: [PATCH] Update samples --- vtm-android-example/AndroidManifest.xml | 3 - .../android/test/MapilionMvtActivity.java | 93 ------------------- .../src/org/oscim/test/MapilionMvtTest.java | 87 ----------------- .../tiling/source/bitmap/DefaultSources.java | 17 ---- 4 files changed, 200 deletions(-) delete mode 100644 vtm-android-example/src/org/oscim/android/test/MapilionMvtActivity.java delete mode 100644 vtm-playground/src/org/oscim/test/MapilionMvtTest.java diff --git a/vtm-android-example/AndroidManifest.xml b/vtm-android-example/AndroidManifest.xml index 0c884f5e1..acf0cfa1f 100644 --- a/vtm-android-example/AndroidManifest.xml +++ b/vtm-android-example/AndroidManifest.xml @@ -66,9 +66,6 @@ - diff --git a/vtm-android-example/src/org/oscim/android/test/MapilionMvtActivity.java b/vtm-android-example/src/org/oscim/android/test/MapilionMvtActivity.java deleted file mode 100644 index 42c31509e..000000000 --- a/vtm-android-example/src/org/oscim/android/test/MapilionMvtActivity.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2018-2020 devemux86 - * - * 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 - * 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 - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * 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 - * this program. If not, see . - */ -package org.oscim.android.test; - -import android.os.Build; -import android.os.Bundle; -import okhttp3.Cache; -import okhttp3.CipherSuite; -import okhttp3.ConnectionSpec; -import okhttp3.OkHttpClient; -import org.oscim.layers.tile.bitmap.BitmapTileLayer; -import org.oscim.layers.tile.buildings.BuildingLayer; -import org.oscim.layers.tile.vector.VectorTileLayer; -import org.oscim.layers.tile.vector.labeling.LabelLayer; -import org.oscim.theme.internal.VtmThemes; -import org.oscim.tiling.source.OkHttpEngine; -import org.oscim.tiling.source.UrlTileSource; -import org.oscim.tiling.source.bitmap.DefaultSources; -import org.oscim.tiling.source.mvt.MapilionMvtTileSource; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class MapilionMvtActivity extends MapActivity { - - // Metered API key for demonstration purposes - private static final String API_KEY = "3b3d8353-0fb8-4513-bfe0-d620b2d77c45"; - - private static final boolean USE_CACHE = false; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - if (USE_CACHE) { - // Cache the tiles into file system - File cacheDirectory = new File(getExternalCacheDir(), "tiles"); - int cacheSize = 10 * 1024 * 1024; // 10 MB - Cache cache = new Cache(cacheDirectory, cacheSize); - builder.cache(cache); - } - - // https://github.com/square/okhttp/issues/4053 - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { - List cipherSuites = new ArrayList<>(); - List modernTlsCipherSuites = ConnectionSpec.MODERN_TLS.cipherSuites(); - if (modernTlsCipherSuites != null) - cipherSuites.addAll(modernTlsCipherSuites); - cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA); - cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA); - ConnectionSpec legacyTls = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) - .cipherSuites(cipherSuites.toArray(new CipherSuite[0])) - .build(); - builder.connectionSpecs(Arrays.asList(legacyTls, ConnectionSpec.CLEARTEXT)); - } - - OkHttpEngine.OkHttpFactory factory = new OkHttpEngine.OkHttpFactory(builder); - - UrlTileSource tileSource = MapilionMvtTileSource.builder() - .apiKey(API_KEY) - .httpFactory(factory) - //.locale("en") - .build(); - - VectorTileLayer l = mMap.setBaseMap(tileSource); - mMap.setTheme(VtmThemes.OPENMAPTILES); - - // Hillshading - UrlTileSource shadedTileSource = DefaultSources.MAPILION_HILLSHADE_2 - .apiKey(API_KEY) - .httpFactory(factory) - .build(); - mMap.layers().add(new BitmapTileLayer(mMap, shadedTileSource)); - - mMap.layers().add(new BuildingLayer(mMap, l)); - mMap.layers().add(new LabelLayer(mMap, l)); - } -} diff --git a/vtm-playground/src/org/oscim/test/MapilionMvtTest.java b/vtm-playground/src/org/oscim/test/MapilionMvtTest.java deleted file mode 100644 index 2e4127249..000000000 --- a/vtm-playground/src/org/oscim/test/MapilionMvtTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2018-2019 devemux86 - * - * 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 - * 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 - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * 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 - * this program. If not, see . - */ -package org.oscim.test; - -import okhttp3.Cache; -import okhttp3.OkHttpClient; -import org.oscim.core.MapPosition; -import org.oscim.gdx.GdxMapApp; -import org.oscim.layers.tile.bitmap.BitmapTileLayer; -import org.oscim.layers.tile.buildings.BuildingLayer; -import org.oscim.layers.tile.vector.VectorTileLayer; -import org.oscim.layers.tile.vector.labeling.LabelLayer; -import org.oscim.theme.internal.VtmThemes; -import org.oscim.tiling.source.OkHttpEngine; -import org.oscim.tiling.source.UrlTileSource; -import org.oscim.tiling.source.bitmap.DefaultSources; -import org.oscim.tiling.source.mvt.MapilionMvtTileSource; - -import java.io.File; -import java.util.UUID; - -public class MapilionMvtTest extends GdxMapApp { - - // Metered API key for demonstration purposes - private static final String API_KEY = "3b3d8353-0fb8-4513-bfe0-d620b2d77c45"; - - private static final boolean USE_CACHE = false; - - @Override - public void createLayers() { - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - if (USE_CACHE) { - // Cache the tiles into file system - File cacheDirectory = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); - int cacheSize = 10 * 1024 * 1024; // 10 MB - Cache cache = new Cache(cacheDirectory, cacheSize); - builder.cache(cache); - } - OkHttpEngine.OkHttpFactory factory = new OkHttpEngine.OkHttpFactory(builder); - - UrlTileSource tileSource = MapilionMvtTileSource.builder() - .apiKey(API_KEY) - .httpFactory(factory) - //.locale("en") - .build(); - - VectorTileLayer l = mMap.setBaseMap(tileSource); - mMap.setTheme(VtmThemes.OPENMAPTILES); - - // Hillshading - UrlTileSource shadedTileSource = DefaultSources.MAPILION_HILLSHADE_2 - .apiKey(API_KEY) - .httpFactory(factory) - .build(); - mMap.layers().add(new BitmapTileLayer(mMap, shadedTileSource)); - - mMap.layers().add(new BuildingLayer(mMap, l)); - mMap.layers().add(new LabelLayer(mMap, l)); - - MapPosition pos = MapPreferences.getMapPosition(); - if (pos != null) - mMap.setMapPosition(pos); - } - - @Override - public void dispose() { - MapPreferences.saveMapPosition(mMap.getMapPosition()); - super.dispose(); - } - - public static void main(String[] args) { - GdxMapApp.init(); - GdxMapApp.run(new MapilionMvtTest()); - } -} diff --git a/vtm/src/org/oscim/tiling/source/bitmap/DefaultSources.java b/vtm/src/org/oscim/tiling/source/bitmap/DefaultSources.java index 477e2b830..df8fdda7a 100644 --- a/vtm/src/org/oscim/tiling/source/bitmap/DefaultSources.java +++ b/vtm/src/org/oscim/tiling/source/bitmap/DefaultSources.java @@ -19,7 +19,6 @@ package org.oscim.tiling.source.bitmap; import org.oscim.layers.tile.bitmap.BitmapTileLayer.FadeStep; -import org.oscim.map.Viewport; import org.oscim.tiling.source.bitmap.BitmapTileSource.Builder; /** @@ -64,20 +63,4 @@ public class DefaultSources { .url("https://tiles.wmflabs.org/hillshading") .tilePath("/{Z}/{X}/{Y}.png") .zoomMax(14); - - // Needs an API key - public static Builder MAPILION_HILLSHADE_1 = BitmapTileSource.builder() - .url("https://tiles.mapilion.com/hillshades/v1") - .tilePath("/{Z}/{X}/{Y}.png") - .zoomMin(1) - .zoomMax(12); - - // Needs an API key - public static Builder MAPILION_HILLSHADE_2 = BitmapTileSource.builder() - .url("https://tiles.mapilion.com/hillshades/v2") - .tilePath("/{Z}/{X}/{Y}.png") - .fadeSteps(new FadeStep[]{ - new FadeStep(0, Viewport.MAX_ZOOM_LEVEL, 1, 0.2f) - }) - .zoomMax(12); }