Changeset 11858 in josm for trunk/src/org/openstreetmap/josm/data/imagery/AbstractWMSTileSource.java
- Timestamp:
- 2017-04-09T11:08:10+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/AbstractWMSTileSource.java
r11830 r11858 11 11 import org.openstreetmap.gui.jmapviewer.tilesources.TMSTileSource; 12 12 import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo; 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.Bounds; 15 14 import org.openstreetmap.josm.data.ProjectionBounds; … … 32 31 private double[] degreesPerTile; 33 32 private static final float SCALE_DENOMINATOR_ZOOM_LEVEL_1 = 559082264.0287178f; 33 private Projection tileProjection; 34 34 35 35 /** 36 36 * Constructs a new {@code AbstractWMSTileSource}. 37 37 * @param info tile source info 38 * @param tileProjection the tile projection 38 39 */ 39 public AbstractWMSTileSource(TileSourceInfo info ) {40 public AbstractWMSTileSource(TileSourceInfo info, Projection tileProjection) { 40 41 super(info); 42 this.tileProjection = tileProjection; 41 43 } 42 44 … … 48 50 } 49 51 52 public void setTileProjection(Projection tileProjection) { 53 this.tileProjection = tileProjection; 54 initProjection(); 55 } 56 57 public Projection getTileProjection() { 58 return this.tileProjection; 59 } 60 50 61 /** 51 62 * Initializes class with current projection in JOSM. This call is needed every time projection changes. 52 63 */ 53 64 public void initProjection() { 54 initProjection( Main.getProjection());65 initProjection(this.tileProjection); 55 66 } 56 67 … … 99 110 @Override 100 111 public ICoordinate tileXYToLatLon(int x, int y, int zoom) { 101 return Main.getProjection().eastNorth2latlon(getTileEastNorth(x, y, zoom)).toCoordinate();112 return tileProjection.eastNorth2latlon(getTileEastNorth(x, y, zoom)).toCoordinate(); 102 113 } 103 114 … … 112 123 @Override 113 124 public TileXY latLonToTileXY(double lat, double lon, int zoom) { 114 EastNorth enPoint = Main.getProjection().latlon2eastNorth(new LatLon(lat, lon));125 EastNorth enPoint = tileProjection.latlon2eastNorth(new LatLon(lat, lon)); 115 126 return eastNorthToTileXY(enPoint, zoom); 116 127 } … … 144 155 public Point latLonToXY(double lat, double lon, int zoom) { 145 156 double scale = getDegreesPerTile(zoom) / getTileSize(); 146 EastNorth point = Main.getProjection().latlon2eastNorth(new LatLon(lat, lon));157 EastNorth point = tileProjection.latlon2eastNorth(new LatLon(lat, lon)); 147 158 return new Point( 148 159 (int) Math.round((point.east() - anchorPosition.east()) / scale), … … 164 175 public ICoordinate xyToLatLon(int x, int y, int zoom) { 165 176 double scale = getDegreesPerTile(zoom) / getTileSize(); 166 Projection proj = Main.getProjection();167 177 EastNorth ret = new EastNorth( 168 178 anchorPosition.east() + x * scale, 169 179 anchorPosition.north() - y * scale 170 180 ); 171 return proj.eastNorth2latlon(ret).toCoordinate();181 return tileProjection.eastNorth2latlon(ret).toCoordinate(); 172 182 } 173 183 … … 197 207 @Override 198 208 public String getServerCRS() { 199 return Main.getProjection().toCode();209 return this.tileProjection.toCode(); 200 210 } 201 211 }
Note:
See TracChangeset
for help on using the changeset viewer.