Changeset 26249 in osm for applications/viewer/jmapviewer/src
- Timestamp:
- 2011-07-02T17:56:16+02:00 (13 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java
r25798 r26249 12 12 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 13 13 14 public abstract class AbstractOsmTileSource implements TileSource { 15 16 protected String name; 17 protected String baseUrl; 18 protected String attrImgUrl; 19 14 public abstract class AbstractOsmTileSource extends AbstractTSMTileSource { 20 15 public AbstractOsmTileSource(String name, String base_url) { 21 this(name, base_url, null);16 super(name, base_url); 22 17 } 23 18 24 19 public AbstractOsmTileSource(String name, String base_url, String attr_img_url) { 25 this.name = name; 26 this.baseUrl = base_url; 27 if(baseUrl.endsWith("/")) { 28 baseUrl = baseUrl.substring(0,baseUrl.length()-1); 29 } 30 attrImgUrl = attr_img_url; 20 super(name, base_url, attr_img_url); 31 21 } 32 33 public String getName() {34 return name;35 }36 37 22 public int getMaxZoom() { 38 return 21; 39 } 40 41 public int getMinZoom() { 42 return 0; 43 } 44 45 public String getExtension() { 46 return "png"; 47 } 48 49 /** 50 * @throws IOException when subclass cannot return the tile URL 51 */ 52 public String getTilePath(int zoom, int tilex, int tiley) throws IOException { 53 return "/" + zoom + "/" + tilex + "/" + tiley + "." + getExtension(); 54 } 55 56 public String getBaseUrl() { 57 return this.baseUrl; 58 } 59 60 public String getTileUrl(int zoom, int tilex, int tiley) throws IOException { 61 return this.getBaseUrl() + getTilePath(zoom, tilex, tiley); 23 return 18; 62 24 } 63 25 64 26 @Override 65 public String toString() {66 return getName();67 }68 69 public String getTileType() {70 return "png";71 }72 73 public int getTileSize() {74 return 256;75 }76 77 public Image getAttributionImage() {78 if (attrImgUrl != null)79 return new ImageIcon(attrImgUrl).getImage();80 else81 return null;82 }83 84 27 public boolean requiresAttribution() { 85 28 return false; 86 29 } 87 30 31 @Override 88 32 public String getAttributionText(int zoom, Coordinate topLeft, Coordinate botRight) { 89 throw new UnsupportedOperationException("no attribution"); 90 //return "\u00a9 OpenStreetMap contributors, CC-BY-SA "; 33 return "\u00a9 OpenStreetMap contributors, CC-BY-SA "; 91 34 } 92 35 36 @Override 93 37 public String getAttributionLinkURL() { 94 throw new UnsupportedOperationException("no attribution"); 95 //return "http://openstreetmap.org/"; 38 return "http://openstreetmap.org/"; 96 39 } 97 40 41 @Override 98 42 public String getTermsOfUseURL() { 99 throw new UnsupportedOperationException("no attribution"); 100 //return "http://www.openstreetmap.org/copyright"; 101 } 102 103 public double latToTileY(double lat, int zoom) { 104 double l = lat / 180 * Math.PI; 105 double pf = Math.log(Math.tan(l) + (1 / Math.cos(l))); 106 return Math.pow(2.0, zoom - 1) * (Math.PI - pf) / Math.PI; 107 } 108 109 public double lonToTileX(double lon, int zoom) { 110 return Math.pow(2.0, zoom - 3) * (lon + 180.0) / 45.0; 111 } 112 113 public double tileYToLat(int y, int zoom) { 114 return Math.atan(Math.sinh(Math.PI - (Math.PI * y / Math.pow(2.0, zoom - 1)))) * 180 / Math.PI; 115 } 116 117 public double tileXToLon(int x, int zoom) { 118 return x * 45.0 / Math.pow(2.0, zoom - 3) - 180.0; 43 return "http://www.openstreetmap.org/copyright"; 119 44 } 120 45 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
r26085 r26249 30 30 import org.xml.sax.SAXException; 31 31 32 public class BingAerialTileSource extends Abstract OsmTileSource {32 public class BingAerialTileSource extends AbstractTSMTileSource { 33 33 private static String API_KEY = "Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU"; 34 34 private static Future<List<Attribution>> attributions; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java
r26234 r26249 11 11 } 12 12 13 @Override14 public int getMaxZoom() {15 return 18;16 }17 18 13 public TileUpdate getTileUpdate() { 19 14 return TileUpdate.IfNoneMatch; 20 15 } 21 22 16 } 23 17 … … 49 43 return TileUpdate.LastModified; 50 44 } 51 52 45 } 53 46 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
r25577 r26249 5 5 import org.openstreetmap.gui.jmapviewer.OsmMercator; 6 6 7 public class ScanexTileSource extends Abstract OsmTileSource {7 public class ScanexTileSource extends AbstractTSMTileSource { 8 8 private static String API_KEY = "4018C5A9AECAD8868ED5DEB2E41D09F7"; 9 9 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
r26235 r26249 2 2 3 3 4 public class TMSTileSource extends Abstract OsmTileSource {4 public class TMSTileSource extends AbstractTSMTileSource { 5 5 protected int maxZoom; 6 6 protected int minZoom = 0;
Note:
See TracChangeset
for help on using the changeset viewer.