From 915046fb9a3a288a9b68749cd8dfa1661e5a55c2 Mon Sep 17 00:00:00 2001 From: Emux <devemux86@gmail.com> Date: Thu, 7 Jul 2016 21:06:11 +0300 Subject: [PATCH] Samples: various improvements, #32 --- .../src/org/oscim/test/PathLayerTest.java | 37 +++++++++++++----- .../src/org/oscim/test/S3DBLayerTest.java | 26 +++++++++---- .../src/org/oscim/test/VectorLayerTest.java | 39 ++++++++++++------- 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/vtm-playground/src/org/oscim/test/PathLayerTest.java b/vtm-playground/src/org/oscim/test/PathLayerTest.java index 80e06179..7894ff8d 100644 --- a/vtm-playground/src/org/oscim/test/PathLayerTest.java +++ b/vtm-playground/src/org/oscim/test/PathLayerTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * 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 + * 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 <http://www.gnu.org/licenses/>. + */ package org.oscim.test; import java.util.ArrayList; @@ -9,13 +25,16 @@ import org.oscim.core.MapPosition; import org.oscim.event.Event; import org.oscim.gdx.GdxMapApp; import org.oscim.layers.JtsPathLayer; -import org.oscim.map.Map; +import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.map.Map.UpdateListener; +import org.oscim.tiling.source.bitmap.DefaultSources; public class PathLayerTest extends GdxMapApp { @Override public void createLayers() { + mMap.setBaseMap(new BitmapTileLayer(mMap, DefaultSources.STAMEN_TONER.build())); + createLayers(1, true); mMap.setMapPosition(0, 0, 1 << 2); @@ -23,24 +42,24 @@ public class PathLayerTest extends GdxMapApp { mMap.events.bind(new UpdateListener() { @Override public void onMapEvent(Event e, MapPosition mapPosition) { - if (e == Map.UPDATE_EVENT) { - long t = System.currentTimeMillis(); - float pos = t % 20000 / 10000f - 1f; - createLayers(pos, false); - mMap.updateMap(true); - } + //if (e == Map.UPDATE_EVENT) { + long t = System.currentTimeMillis(); + float pos = t % 20000 / 10000f - 1f; + createLayers(pos, false); + mMap.updateMap(true); + //} } }); } - ArrayList<JtsPathLayer> mPathLayers = new ArrayList<JtsPathLayer>(); + ArrayList<JtsPathLayer> mPathLayers = new ArrayList<>(); void createLayers(float pos, boolean init) { int i = 0; for (double lat = -90; lat <= 90; lat += 5) { - List<GeoPoint> pts = new ArrayList<GeoPoint>(); + List<GeoPoint> pts = new ArrayList<>(); for (double lon = -180; lon <= 180; lon += 2) { //pts.add(new GeoPoint(lat, lon)); diff --git a/vtm-playground/src/org/oscim/test/S3DBLayerTest.java b/vtm-playground/src/org/oscim/test/S3DBLayerTest.java index c26381c6..aba72547 100644 --- a/vtm-playground/src/org/oscim/test/S3DBLayerTest.java +++ b/vtm-playground/src/org/oscim/test/S3DBLayerTest.java @@ -1,21 +1,33 @@ +/* + * Copyright 2016 devemux86 + * + * 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 + * 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 <http://www.gnu.org/licenses/>. + */ package org.oscim.test; import org.oscim.gdx.GdxMapApp; -import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.buildings.S3DBLayer; +import org.oscim.theme.VtmThemes; import org.oscim.tiling.TileSource; -import org.oscim.tiling.source.bitmap.DefaultSources; import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; public class S3DBLayerTest extends GdxMapApp { @Override public void createLayers() { - - //VectorTileLayer l = mMap.setBaseMap(new OSciMap4TileSource()); - //mMap.setTheme(VtmThemes.DEFAULT); - - mMap.setBaseMap(new BitmapTileLayer(mMap, DefaultSources.STAMEN_TONER.build())); + mMap.setBaseMap(new OSciMap4TileSource()); + mMap.setTheme(VtmThemes.DEFAULT); TileSource ts = OSciMap4TileSource .builder() diff --git a/vtm-playground/src/org/oscim/test/VectorLayerTest.java b/vtm-playground/src/org/oscim/test/VectorLayerTest.java index dea93575..0910b2f2 100644 --- a/vtm-playground/src/org/oscim/test/VectorLayerTest.java +++ b/vtm-playground/src/org/oscim/test/VectorLayerTest.java @@ -1,22 +1,39 @@ +/* + * Copyright 2016 devemux86 + * + * 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 + * 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 <http://www.gnu.org/licenses/>. + */ package org.oscim.test; import org.oscim.backend.canvas.Color; import org.oscim.gdx.GdxMapApp; +import org.oscim.layers.TileGridLayer; import org.oscim.layers.vector.VectorLayer; import org.oscim.layers.vector.geometries.PointDrawable; import org.oscim.layers.vector.geometries.Style; -import org.oscim.map.Map; +import org.oscim.theme.VtmThemes; +import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; import org.oscim.utils.ColorUtil; public class VectorLayerTest extends GdxMapApp { @Override public void createLayers() { - Map map = getMap(); + mMap.setBaseMap(new OSciMap4TileSource()); + mMap.setTheme(VtmThemes.DEFAULT); - //VectorTileLayer tileLayer = map.setBaseMap(new OSciMap4TileSource()); - - VectorLayer vectorLayer = new VectorLayer(map); + VectorLayer vectorLayer = new VectorLayer(mMap); // vectorLayer.add(new PointDrawable(0, 180, Style.builder() // .setBuffer(10) @@ -38,8 +55,6 @@ public class VectorLayerTest extends GdxMapApp { .fillColor(Color.RED) .fillAlpha(0.2); - Style style = sb.fillAlpha(0.2).build(); - // int tileSize = 5; // for (int x = -180; x < 200; x += tileSize) { // for (int y = -90; y < 90; y += tileSize) { @@ -54,7 +69,7 @@ public class VectorLayerTest extends GdxMapApp { // } for (int i = 0; i < 1000; i++) { - style = sb.buffer(Math.random() * 1) + Style style = sb.buffer(Math.random() * 1) .fillColor(ColorUtil.setHue(Color.RED, Math.random())) .fillAlpha(0.5) @@ -66,12 +81,10 @@ public class VectorLayerTest extends GdxMapApp { } - map.layers().add(vectorLayer); + mMap.layers().add(vectorLayer); + mMap.layers().add(new TileGridLayer(mMap, 0xff222222, 1.2f, 1)); - //map.layers().add(new LabelLayer(map, tileLayer)); - //map.setTheme(VtmThemes.DEFAULT); - - map.setMapPosition(0, 0, 1 << 2); + mMap.setMapPosition(0, 0, 1 << 2); } public static void main(String[] args) {