Changeset 18211 in osm
- Timestamp:
- 2009-10-18T21:02:12+02:00 (15 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
r13036 r18211 57 57 } catch (Exception e) { 58 58 tile.setImage(Tile.ERROR_IMAGE); 59 tile.error = true; 59 60 listener.tileLoadingFinished(tile, false); 60 61 if (input == null) -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileSource.java
r15039 r18211 6 6 7 7 public static final String MAP_MAPNIK = "http://tile.openstreetmap.org"; 8 public static final String MAP_OSMA = "http://tah.openstreetmap.org/Tiles /tile";8 public static final String MAP_OSMA = "http://tah.openstreetmap.org/Tiles"; 9 9 10 protected static abstract class AbstractOsmTileSource implements TileSource { 10 public static abstract class AbstractOsmTileSource implements TileSource { 11 protected String NAME; 12 protected String BASE_URL; 13 public AbstractOsmTileSource(String name, String base_url) 14 { 15 NAME = name; 16 BASE_URL = base_url; 17 } 18 19 public String getName() { 20 return NAME; 21 } 11 22 12 23 public int getMaxZoom() { … … 18 29 } 19 30 31 public String getTilePath(int zoom, int tilex, int tiley) { 32 return "/" + zoom + "/" + tilex + "/" + tiley + ".png"; 33 } 34 35 public String getBaseUrl() { 36 return this.BASE_URL; 37 } 38 20 39 public String getTileUrl(int zoom, int tilex, int tiley) { 21 return "/" + zoom + "/" + tilex + "/" + tiley + ".png";40 return this.getBaseUrl() + getTilePath(zoom, tilex, tiley); 22 41 } 23 42 … … 34 53 35 54 public static class Mapnik extends AbstractOsmTileSource { 36 37 public static String NAME = "Mapnik"; 38 39 public String getName() { 40 return NAME; 41 } 42 43 @Override 44 public String getTileUrl(int zoom, int tilex, int tiley) { 45 return MAP_MAPNIK + super.getTileUrl(zoom, tilex, tiley); 55 public Mapnik() { 56 super("Mapnik", MAP_MAPNIK); 46 57 } 47 58 … … 54 65 public static class CycleMap extends AbstractOsmTileSource { 55 66 56 private static final String PATTERN = "http://%s.andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png"; 57 public static String NAME = "OSM Cycle Map"; 67 private static final String PATTERN = "http://%s.andy.sandbox.cloudmade.com/tiles/cycle"; 58 68 59 69 private static final String[] SERVER = { "a", "b", "c" }; … … 61 71 private int SERVER_NUM = 0; 62 72 73 public CycleMap() { 74 super("OSM Cycle Map", PATTERN); 75 } 76 63 77 @Override 64 public String get TileUrl(int zoom, int tilex, int tiley) {65 String url = String.format( PATTERN, new Object[] { SERVER[SERVER_NUM], zoom, tilex, tiley});78 public String getBaseUrl() { 79 String url = String.format(this.BASE_URL, new Object[] { SERVER[SERVER_NUM] }); 66 80 SERVER_NUM = (SERVER_NUM + 1) % SERVER.length; 67 81 return url; … … 72 86 } 73 87 74 public String getName() {75 return NAME;76 }77 78 88 public TileUpdate getTileUpdate() { 79 89 return TileUpdate.LastModified; … … 82 92 } 83 93 84 public static class TilesAtHome extends AbstractOsmTileSource { 85 86 public static String NAME = "TilesAtHome"; 94 public static abstract class OsmaSource extends AbstractOsmTileSource { 95 String osmaSuffix; 96 public OsmaSource(String name, String osmaSuffix) { 97 super(name, MAP_OSMA); 98 this.osmaSuffix = osmaSuffix; 99 } 87 100 88 101 public int getMaxZoom() { … … 90 103 } 91 104 92 public String getName() {93 return NAME;94 }95 96 105 @Override 97 public String get TileUrl(int zoom, int tilex, int tiley) {98 return MAP_OSMA + super.getTileUrl(zoom, tilex, tiley);106 public String getBaseUrl() { 107 return MAP_OSMA + "/" + osmaSuffix; 99 108 } 100 109 … … 103 112 } 104 113 } 114 public static class TilesAtHome extends OsmaSource { 115 public TilesAtHome() { 116 super("TilesAtHome", "tile"); 117 } 118 } 119 public static class Maplint extends OsmaSource { 120 public Maplint() { 121 super("Maplint", "maplint"); 122 } 123 } 105 124 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java
r18179 r18211 47 47 protected boolean loaded = false; 48 48 protected boolean loading = false; 49 protected boolean error = false; 49 50 public static final int SIZE = 256; 50 51 … … 225 226 if (this.loaded) 226 227 status = "loaded"; 228 if (this.error) 229 status = "error"; 227 230 return status; 228 231 } 232 public boolean hasError() { 233 return error; 234 } 229 235 230 236 }
Note:
See TracChangeset
for help on using the changeset viewer.