diff options
| author | rsudev <rsudev@googlemail.com> | 2013-01-17 17:48:26 +0100 |
|---|---|---|
| committer | rsudev <rsudev@googlemail.com> | 2013-01-17 17:48:26 +0100 |
| commit | 150b956f209d95ed9077e44ea655bdbfb5d88721 (patch) | |
| tree | 667170024df626e7f25e9a18d22810679e5d9eb4 /tests/src/cgeo/geocaching/connector | |
| parent | 821bec6b5e14c0ffd4adf977074c5b84421e99c0 (diff) | |
| download | cgeo-150b956f209d95ed9077e44ea655bdbfb5d88721.zip cgeo-150b956f209d95ed9077e44ea655bdbfb5d88721.tar.gz cgeo-150b956f209d95ed9077e44ea655bdbfb5d88721.tar.bz2 | |
Extend zoom calculation to nxm tilesets
Previously tile sets generated for the live map where fixed to max 2x2 tiles. In order to enhance the flexibility of the live-map algorithms, now the generation of more fine-grained tile sets or even a lower bound for the zoom level to use is supported.
Diffstat (limited to 'tests/src/cgeo/geocaching/connector')
| -rw-r--r-- | tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java b/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java index 234ff26..fb49949 100644 --- a/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java @@ -1,6 +1,9 @@ package cgeo.geocaching.connector.gc; import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.geopoint.Viewport; + +import java.util.Set; import junit.framework.TestCase; @@ -10,16 +13,58 @@ public class AutoZoomTest extends TestCase { Geopoint bottomLeft = new Geopoint(49.3, 8.3); Geopoint topRight = new Geopoint(49.4, 8.4); - int zoom = Tile.calcZoomLat(bottomLeft, topRight); + int zoom = Tile.calcZoomLat(bottomLeft, topRight, 2); assertTrue(Math.abs(new Tile(bottomLeft, zoom).getY() - new Tile(topRight, zoom).getY()) == 1); assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getY() - new Tile(topRight, zoom + 1).getY()) > 1); - zoom = Tile.calcZoomLon(bottomLeft, topRight); + zoom = Tile.calcZoomLon(bottomLeft, topRight, 2); assertTrue(new Tile(bottomLeft, zoom).getX() + 1 == new Tile(topRight, zoom).getX()); assertTrue(new Tile(bottomLeft, zoom + 1).getX() + 1 < new Tile(topRight, zoom + 1).getX()); } + public static void testZoom2() { + Geopoint bottomLeft = new Geopoint(49.3, 8.3); + Geopoint topRight = new Geopoint(49.4, 8.4); + + int zoom = Tile.calcZoomLat(bottomLeft, topRight, 3); + + assertTrue(Math.abs(new Tile(bottomLeft, zoom).getY() - new Tile(topRight, zoom).getY()) >= 2); + assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getY() - new Tile(topRight, zoom + 1).getY()) > 2); + + zoom = Tile.calcZoomLon(bottomLeft, topRight, 3); + + assertTrue(Math.abs(new Tile(bottomLeft, zoom).getX() - new Tile(topRight, zoom).getX()) >= 2); + assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getX() - new Tile(topRight, zoom + 1).getX()) > 2); + + } + + public static void testTiles1x2() { + Geopoint bottomLeft = new Geopoint(49.3, 8.3); + Geopoint topRight = new Geopoint(49.4, 8.4); + + Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight)); + + assertEquals(2, tiles.size()); + } + + public static void testTiles2x3() { + Geopoint bottomLeft = new Geopoint(49.3, 8.3); + Geopoint topRight = new Geopoint(49.4, 8.4); + + Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, Tile.ZOOMLEVEL_MIN); + + assertEquals(6, tiles.size()); + } + + public static void testTilesZoom13() { + Geopoint bottomLeft = new Geopoint(49.3, 8.3); + Geopoint topRight = new Geopoint(49.4, 8.4); + + Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, 13); + + assertEquals(16, tiles.size()); + } } |
