Changeset 32025 in osm for applications/viewer/jmapviewer/src/org/openstreetmap/gui
- Timestamp:
- 2016-01-24T23:10:45+01:00 (9 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java
r31791 r32025 9 9 * Abstract class for OSM Tile sources 10 10 */ 11 public abstract class AbstractOsmTileSource extends AbstractTMSTileSource {12 11 public abstract class AbstractOsmTileSource extends TMSTileSource { 12 13 13 /** 14 * The OSM attribution. Must be always in line with 14 * The OSM attribution. Must be always in line with 15 15 * <a href="https://www.openstreetmap.org/copyright/en">https://www.openstreetmap.org/copyright/en</a> 16 16 */ 17 17 public static final String DEFAULT_OSM_ATTRIBUTION = "\u00a9 OpenStreetMap contributors"; 18 18 19 19 /** 20 20 * Constructs a new OSM tile source -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
r32024 r32025 11 11 import java.util.Map.Entry; 12 12 13 import org.openstreetmap.gui.jmapviewer.Coordinate;14 13 import org.openstreetmap.gui.jmapviewer.OsmMercator; 15 14 import org.openstreetmap.gui.jmapviewer.Tile; … … 32 31 private final Map<String, String> metadataHeaders; 33 32 protected int tileSize; 34 protected OsmMercator osmMercator;35 33 36 34 /** … … 50 48 this.metadataHeaders = info.getMetadataHeaders(); 51 49 this.tileSize = info.getTileSize(); 52 this.osmMercator = new OsmMercator(this.getTileSize());53 50 } 54 51 … … 128 125 129 126 @Override 130 public double getDistance(double lat1, double lon1, double lat2, double lon2) {131 return osmMercator.getDistance(lat1, lon1, lat2, lon2);132 }133 134 @Override135 public Point latLonToXY(double lat, double lon, int zoom) {136 return new Point(137 (int) osmMercator.lonToX(lon, zoom),138 (int) osmMercator.latToY(lat, zoom)139 );140 }141 142 @Override143 127 public Point latLonToXY(ICoordinate point, int zoom) { 144 128 return latLonToXY(point.getLat(), point.getLon(), zoom); … … 151 135 152 136 @Override 153 public ICoordinate xyToLatLon(int x, int y, int zoom) {154 return new Coordinate(155 osmMercator.yToLat(y, zoom),156 osmMercator.xToLon(x, zoom)157 );158 }159 160 @Override161 public TileXY latLonToTileXY(double lat, double lon, int zoom) {162 return new TileXY(163 osmMercator.lonToX(lon, zoom) / getTileSize(),164 osmMercator.latToY(lat, zoom) / getTileSize()165 );166 }167 168 @Override169 137 public TileXY latLonToTileXY(ICoordinate point, int zoom) { 170 138 return latLonToTileXY(point.getLat(), point.getLon(), zoom); … … 179 147 public ICoordinate tileXYToLatLon(Tile tile) { 180 148 return tileXYToLatLon(tile.getXtile(), tile.getYtile(), tile.getZoom()); 181 }182 183 @Override184 public ICoordinate tileXYToLatLon(int x, int y, int zoom) {185 return new Coordinate(186 osmMercator.yToLat(y * getTileSize(), zoom),187 osmMercator.xToLon(x * getTileSize(), zoom)188 );189 149 } 190 150 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
r31855 r32025 37 37 import org.xml.sax.SAXException; 38 38 39 public class BingAerialTileSource extends AbstractTMSTileSource {39 public class BingAerialTileSource extends TMSTileSource { 40 40 41 41 private static final String API_KEY = "Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU"; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
r31790 r32025 1 1 // License: GPL. For details, see Readme.txt file. 2 2 package org.openstreetmap.gui.jmapviewer.tilesources; 3 4 import java.awt.Point; 5 6 import org.openstreetmap.gui.jmapviewer.Coordinate; 7 import org.openstreetmap.gui.jmapviewer.OsmMercator; 8 import org.openstreetmap.gui.jmapviewer.TileXY; 9 import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 3 10 4 11 public class TMSTileSource extends AbstractTMSTileSource { … … 6 13 protected int maxZoom; 7 14 protected int minZoom; 15 protected OsmMercator osmMercator; 8 16 9 17 public TMSTileSource(TileSourceInfo info) { … … 11 19 minZoom = info.getMinZoom(); 12 20 maxZoom = info.getMaxZoom(); 21 this.osmMercator = new OsmMercator(this.getTileSize()); 13 22 } 14 23 … … 22 31 return (maxZoom == 0) ? super.getMaxZoom() : maxZoom; 23 32 } 33 @Override 34 public double getDistance(double lat1, double lon1, double lat2, double lon2) { 35 return osmMercator.getDistance(lat1, lon1, lat2, lon2); 36 } 37 38 @Override 39 public Point latLonToXY(double lat, double lon, int zoom) { 40 return new Point( 41 (int) osmMercator.lonToX(lon, zoom), 42 (int) osmMercator.latToY(lat, zoom) 43 ); 44 } 45 46 @Override 47 public ICoordinate xyToLatLon(int x, int y, int zoom) { 48 return new Coordinate( 49 osmMercator.yToLat(y, zoom), 50 osmMercator.xToLon(x, zoom) 51 ); 52 } 53 54 @Override 55 public TileXY latLonToTileXY(double lat, double lon, int zoom) { 56 return new TileXY( 57 osmMercator.lonToX(lon, zoom) / getTileSize(), 58 osmMercator.latToY(lat, zoom) / getTileSize() 59 ); 60 } 61 62 @Override 63 public ICoordinate tileXYToLatLon(int x, int y, int zoom) { 64 return new Coordinate( 65 osmMercator.yToLat(y * getTileSize(), zoom), 66 osmMercator.xToLon(x * getTileSize(), zoom) 67 ); 68 } 24 69 }
Note:
See TracChangeset
for help on using the changeset viewer.