diff --git a/vtm-android-example/AndroidManifest.xml b/vtm-android-example/AndroidManifest.xml index 8333e816..dfdbd783 100644 --- a/vtm-android-example/AndroidManifest.xml +++ b/vtm-android-example/AndroidManifest.xml @@ -112,6 +112,9 @@ + @@ -130,6 +133,9 @@ + diff --git a/vtm-android-example/build.gradle b/vtm-android-example/build.gradle index e3242a52..967725e1 100644 --- a/vtm-android-example/build.gradle +++ b/vtm-android-example/build.gradle @@ -9,6 +9,7 @@ configurations.all { dependencies { implementation project(':vtm-android') + implementation project(':vtm-extras') implementation project(':vtm-http') implementation project(':vtm-jeo') implementation project(':vtm-json') diff --git a/vtm-android-example/res/layout/activity_shadow.xml b/vtm-android-example/res/layout/activity_shadow.xml new file mode 100644 index 00000000..08dd2511 --- /dev/null +++ b/vtm-android-example/res/layout/activity_shadow.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vtm-android-example/res/values/strings.xml b/vtm-android-example/res/values/strings.xml index c3e1c64f..fa0a4521 100644 --- a/vtm-android-example/res/values/strings.xml +++ b/vtm-android-example/res/values/strings.xml @@ -24,5 +24,6 @@ Search \'*\' or OSM key void or value + Now diff --git a/vtm-android-example/src/org/oscim/android/test/OverpassActivity.java b/vtm-android-example/src/org/oscim/android/test/OverpassActivity.java new file mode 100644 index 00000000..210343c0 --- /dev/null +++ b/vtm-android-example/src/org/oscim/android/test/OverpassActivity.java @@ -0,0 +1,72 @@ +/* + * Copyright 2019 Gustl22 + * + * 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.Bundle; + +import org.oscim.layers.tile.bitmap.BitmapTileLayer; +import org.oscim.layers.tile.buildings.BuildingLayer; +import org.oscim.layers.tile.buildings.S3DBLayer; +import org.oscim.layers.tile.vector.VectorTileLayer; +import org.oscim.layers.tile.vector.labeling.LabelLayer; +import org.oscim.map.Viewport; +import org.oscim.theme.VtmThemes; +import org.oscim.tiling.TileSource; +import org.oscim.tiling.source.OkHttpEngine; +import org.oscim.tiling.source.bitmap.DefaultSources; +import org.oscim.tiling.source.overpass.OverpassTileSource; + +/** + * Use Overpass API data for vector layer. + * Only for developing as can be error-prone. + * Take care of overpass provider licenses. + */ +public class OverpassActivity extends MapActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + TileSource tileSource = OverpassTileSource.builder() + .httpFactory(new OkHttpEngine.OkHttpFactory()) + .zoomMin(15) + .zoomMax(17) + .build(); + VectorTileLayer l = mMap.setBaseMap(tileSource); + + TileSource bitmapTileSource = DefaultSources.OPENSTREETMAP + .httpFactory(new OkHttpEngine.OkHttpFactory()) + .zoomMax(15) + .fadeSteps(new BitmapTileLayer.FadeStep[]{ + new BitmapTileLayer.FadeStep(15, 16, 1f, 0f), + new BitmapTileLayer.FadeStep(16, Viewport.MAX_ZOOM_LEVEL, 0f, 0f) + }) + .build(); + mMap.layers().add(new BitmapTileLayer(mMap, bitmapTileSource)); + + BuildingLayer.RAW_DATA = true; + mMap.layers().add(new S3DBLayer(mMap, l)); + mMap.layers().add(new LabelLayer(mMap, l)); + + mMap.setTheme(VtmThemes.DEFAULT); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + + BuildingLayer.RAW_DATA = false; + } +} 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 4fa4abc0..b6bdfa08 100644 --- a/vtm-android-example/src/org/oscim/android/test/Samples.java +++ b/vtm-android-example/src/org/oscim/android/test/Samples.java @@ -2,8 +2,12 @@ * Copyright 2010, 2011, 2012, 2013 mapsforge.org * Copyright 2013 Hannes Janetzek * Copyright 2016-2018 devemux86 + * Copyright 2016 mar-v-in + * Copyright 2016 Mathieu de Brito * Copyright 2017-2018 Longri * Copyright 2017 nebular + * Copyright 2018 boldtrn + * Copyright 2018-2019 Gustl22 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -108,6 +112,7 @@ public class Samples extends Activity { linearLayout.addView(createButton(MapsforgeS3DBActivity.class)); linearLayout.addView(createButton(AtlasThemeActivity.class)); linearLayout.addView(createButton(POTTextureActivity.class)); + linearLayout.addView(createButton(ShadowActivity.class)); linearLayout.addView(createLabel("Raster Maps")); linearLayout.addView(createButton(BitmapTileActivity.class)); @@ -136,5 +141,6 @@ public class Samples extends Activity { linearLayout.addView(createButton(ThemeStylerActivity.class)); linearLayout.addView(createButton(JeoIndoorActivity.class)); linearLayout.addView(createButton(GdxPoi3DActivity.class)); + linearLayout.addView(createButton(OverpassActivity.class)); } } diff --git a/vtm-android-example/src/org/oscim/android/test/ShadowActivity.java b/vtm-android-example/src/org/oscim/android/test/ShadowActivity.java new file mode 100644 index 00000000..544da3f3 --- /dev/null +++ b/vtm-android-example/src/org/oscim/android/test/ShadowActivity.java @@ -0,0 +1,80 @@ +/* + * Copyright 2019 Gustl22 + * + * 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.Bundle; +import android.view.View; +import android.widget.SeekBar; +import android.widget.ToggleButton; + +import org.oscim.layers.tile.buildings.BuildingLayer; +import org.oscim.renderer.ExtrusionRenderer; +import org.oscim.renderer.light.Sun; + +public class ShadowActivity extends SimpleMapActivity implements SeekBar.OnSeekBarChangeListener { + + public ShadowActivity() { + super(R.layout.activity_shadow); + } + + private SeekBar mSeekBar; + + @Override + public void onCreate(Bundle savedInstanceState) { + BuildingLayer.SHADOW = true; + + super.onCreate(savedInstanceState); + mSeekBar = findViewById(R.id.seekBarShadow); + mSeekBar.setOnSeekBarChangeListener(this); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + + BuildingLayer.SHADOW = false; + } + + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + int id = seekBar.getId(); + if (id == R.id.seekBarShadow) { + Sun sun = mBuildingLayer.getExtrusionRenderer().getSun(); + sun.setProgress(progress / 1000f); + sun.updatePosition(); + sun.updateColor(); + + mMap.updateMap(true); + } + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + + public void onToggleCurrentSun(View view) { + boolean isCurrentSun = ((ToggleButton) view).isChecked(); + mSeekBar.setEnabled(!isCurrentSun); + ExtrusionRenderer extrusionRenderer = mBuildingLayer.getExtrusionRenderer(); + extrusionRenderer.enableCurrentSunPos(isCurrentSun); + extrusionRenderer.getSun().update(); + mSeekBar.setProgress((int) (extrusionRenderer.getSun().getProgress() * 1000)); + mMap.updateMap(true); + } +} diff --git a/vtm-android-example/src/org/oscim/android/test/SimpleMapActivity.java b/vtm-android-example/src/org/oscim/android/test/SimpleMapActivity.java index d2fc81e8..6c843f86 100644 --- a/vtm-android-example/src/org/oscim/android/test/SimpleMapActivity.java +++ b/vtm-android-example/src/org/oscim/android/test/SimpleMapActivity.java @@ -1,6 +1,7 @@ /* * Copyright 2013 Hannes Janetzek * Copyright 2016-2018 devemux86 + * Copyright 2019 Gustl22 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -39,6 +40,17 @@ import org.oscim.theme.VtmThemes; public class SimpleMapActivity extends BaseMapActivity { private DefaultMapScaleBar mapScaleBar; + BuildingLayer mBuildingLayer; + LabelLayer mLabelLayer; + + public SimpleMapActivity(int contentView) { + super(contentView); + } + + public SimpleMapActivity() { + super(); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -48,8 +60,10 @@ public class SimpleMapActivity extends BaseMapActivity { void createLayers() { GroupLayer groupLayer = new GroupLayer(mMap); - groupLayer.layers.add(new BuildingLayer(mMap, mBaseLayer)); - groupLayer.layers.add(new LabelLayer(mMap, mBaseLayer)); + mBuildingLayer = new BuildingLayer(mMap, mBaseLayer); + groupLayer.layers.add(mBuildingLayer); + mLabelLayer = new LabelLayer(mMap, mBaseLayer); + groupLayer.layers.add(mLabelLayer); mMap.layers().add(groupLayer); mapScaleBar = new DefaultMapScaleBar(mMap); diff --git a/vtm-playground/src/org/oscim/test/MapsforgeTest.java b/vtm-playground/src/org/oscim/test/MapsforgeTest.java index 7c5022a2..2e1620f4 100644 --- a/vtm-playground/src/org/oscim/test/MapsforgeTest.java +++ b/vtm-playground/src/org/oscim/test/MapsforgeTest.java @@ -68,6 +68,7 @@ public class MapsforgeTest extends GdxMapApp { VectorTileLayer l = mMap.setBaseMap(tileSource); loadTheme(null); + BuildingLayer.SHADOW = SHADOWS; BuildingLayer buildingLayer = s3db ? new S3DBLayer(mMap, l) : new BuildingLayer(mMap, l); mMap.layers().add(buildingLayer); @@ -116,6 +117,9 @@ public class MapsforgeTest extends GdxMapApp { @Override public void dispose() { + if (SHADOWS) + BuildingLayer.SHADOW = false; + MapPreferences.saveMapPosition(mMap.getMapPosition()); super.dispose(); }