diff --git a/vtm/src/org/oscim/layers/tile/bitmap/OpenStreetMap.java b/vtm/src/org/oscim/layers/tile/bitmap/OpenStreetMap.java new file mode 100644 index 00000000..a16cf37b --- /dev/null +++ b/vtm/src/org/oscim/layers/tile/bitmap/OpenStreetMap.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010, 2011, 2012 mapsforge.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 . + */ +package org.oscim.layers.tile.bitmap; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.oscim.core.Tile; + +public class OpenStreetMap extends AbstractTileSource { + public static final OpenStreetMap INSTANCE = new OpenStreetMap(".tile.openstreetmap.org", + 80); + + private static final int PARALLEL_REQUESTS_LIMIT = 8; + private static final String PROTOCOL = "http"; + private static final int ZOOM_LEVEL_MAX = 18; + private static final int ZOOM_LEVEL_MIN = 0; + + public OpenStreetMap(String hostName, int port) { + super(hostName, port); + } + + @Override + public int getParallelRequestsLimit() { + return PARALLEL_REQUESTS_LIMIT; + } + + private char[] subdomains = { 'a', 'b', 'c', 'd' }; + private int curDomain = 0; + + @Override + public URL getTileUrl(Tile tile) throws MalformedURLException { + StringBuilder stringBuilder = new StringBuilder(32); + + //stringBuilder.append("/osm/osm/"); + stringBuilder.append("/"); + stringBuilder.append(tile.zoomLevel); + stringBuilder.append('/'); + stringBuilder.append(tile.tileX); + stringBuilder.append('/'); + stringBuilder.append(tile.tileY); + stringBuilder.append(".png"); + + String host; + synchronized (this) { + curDomain = (curDomain++) % 4; + host = subdomains[curDomain] + hostName; + } + + return new URL(PROTOCOL, host, port, stringBuilder.toString()); + } + + @Override + public byte getZoomLevelMax() { + return ZOOM_LEVEL_MAX; + } + + @Override + public byte getZoomLevelMin() { + return ZOOM_LEVEL_MIN; + } +} diff --git a/vtm/src/org/oscim/layers/tile/bitmap/OpenStreetMapTransport.java b/vtm/src/org/oscim/layers/tile/bitmap/OpenStreetMapTransport.java new file mode 100644 index 00000000..0c72a7a6 --- /dev/null +++ b/vtm/src/org/oscim/layers/tile/bitmap/OpenStreetMapTransport.java @@ -0,0 +1,77 @@ +/* + * Copyright 2010, 2011, 2012 mapsforge.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 . + */ +package org.oscim.layers.tile.bitmap; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.oscim.core.Tile; + +public class OpenStreetMapTransport extends AbstractTileSource { + //http://tile.thunderforest.com/transport/3/3/3.png + + public static final OpenStreetMapTransport INSTANCE = + new OpenStreetMapTransport(".tile.thunderforest.com", 80); + + private static final int PARALLEL_REQUESTS_LIMIT = 8; + private static final String PROTOCOL = "http"; + private static final int ZOOM_LEVEL_MAX = 18; + private static final int ZOOM_LEVEL_MIN = 0; + + public OpenStreetMapTransport(String hostName, int port) { + super(hostName, port); + } + + @Override + public int getParallelRequestsLimit() { + return PARALLEL_REQUESTS_LIMIT; + } + + private char[] subdomains = { 'a', 'b', 'c', 'd' }; + private int curDomain = 0; + + @Override + public URL getTileUrl(Tile tile) throws MalformedURLException { + StringBuilder stringBuilder = new StringBuilder(32); + + //stringBuilder.append("/transport/"); + stringBuilder.append("/outdoors/"); + //stringBuilder.append("/landscape/"); + stringBuilder.append(tile.zoomLevel); + stringBuilder.append('/'); + stringBuilder.append(tile.tileX); + stringBuilder.append('/'); + stringBuilder.append(tile.tileY); + stringBuilder.append(".png"); + + String host; + synchronized (this) { + curDomain = (curDomain++) % 4; + host = subdomains[curDomain] + hostName; + } + + return new URL(PROTOCOL, host, port, stringBuilder.toString()); + } + + @Override + public byte getZoomLevelMax() { + return ZOOM_LEVEL_MAX; + } + + @Override + public byte getZoomLevelMin() { + return ZOOM_LEVEL_MIN; + } +} diff --git a/vtm/src/org/oscim/layers/tile/bitmap/StamenTonerTiles.java b/vtm/src/org/oscim/layers/tile/bitmap/StamenTonerTiles.java new file mode 100644 index 00000000..374a5f93 --- /dev/null +++ b/vtm/src/org/oscim/layers/tile/bitmap/StamenTonerTiles.java @@ -0,0 +1,67 @@ +/* + * Copyright 2010, 2011, 2012 mapsforge.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 . + */ +package org.oscim.layers.tile.bitmap; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.oscim.core.Tile; + +public class StamenTonerTiles extends AbstractTileSource { + public static final StamenTonerTiles INSTANCE = new StamenTonerTiles(".tile.stamen.com", 80); + private static final int PARALLEL_REQUESTS_LIMIT = 8; + private static final String PROTOCOL = "http"; + private static final int ZOOM_LEVEL_MAX = 16; + private static final int ZOOM_LEVEL_MIN = 0; + + public StamenTonerTiles(String hostName, int port) { + super(hostName, port); + } + + @Override + public int getParallelRequestsLimit() { + return PARALLEL_REQUESTS_LIMIT; + } + + private char[] subdomains = { 'a', 'b', 'c', 'd' }; + private int curDomain = 0; + + @Override + public URL getTileUrl(Tile tile) throws MalformedURLException { + StringBuilder stringBuilder = new StringBuilder(32); + + stringBuilder.append("/toner/"); + stringBuilder.append(tile.zoomLevel); + stringBuilder.append('/'); + stringBuilder.append(tile.tileX); + stringBuilder.append('/'); + stringBuilder.append(tile.tileY); + stringBuilder.append(".png"); + + curDomain = (curDomain++) % 4; + + return new URL(PROTOCOL, subdomains[curDomain] + hostName, port, stringBuilder.toString()); + } + + @Override + public byte getZoomLevelMax() { + return ZOOM_LEVEL_MAX; + } + + @Override + public byte getZoomLevelMin() { + return ZOOM_LEVEL_MIN; + } +}