diff --git a/src/org/oscim/layers/tile/bitmap/NaturalEarth.java b/src/org/oscim/layers/tile/bitmap/NaturalEarth.java new file mode 100644 index 00000000..5ba269e7 --- /dev/null +++ b/src/org/oscim/layers/tile/bitmap/NaturalEarth.java @@ -0,0 +1,61 @@ +/* + * 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 NaturalEarth extends AbstractTileSource { + public static final NaturalEarth INSTANCE = new NaturalEarth("city.informatik.uni-bremen.de", 80); + private static final int PARALLEL_REQUESTS_LIMIT = 4; + private static final String PROTOCOL = "http"; + private static final int ZOOM_LEVEL_MAX = 6; + private static final int ZOOM_LEVEL_MIN = 0; + + public NaturalEarth(String hostName, int port) { + super(hostName, port); + } + + @Override + public int getParallelRequestsLimit() { + return PARALLEL_REQUESTS_LIMIT; + } + + @Override + public URL getTileUrl(Tile tile) throws MalformedURLException { + StringBuilder stringBuilder = new StringBuilder(32); + stringBuilder.append("/osci/ne_image2/"); + stringBuilder.append(tile.zoomLevel); + stringBuilder.append('/'); + stringBuilder.append(tile.tileX); + stringBuilder.append('/'); + stringBuilder.append((1 << tile.zoomLevel) - tile.tileY - 1); + stringBuilder.append(".png"); + + return new URL(PROTOCOL, this.hostName, this.port, stringBuilder.toString()); + } + + @Override + public byte getZoomLevelMax() { + return ZOOM_LEVEL_MAX; + } + + @Override + public byte getZoomLevelMin() { + return ZOOM_LEVEL_MIN; + } +}