Changeset 12669 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-08-27T00:17:49+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java
r12375 r12669 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.coor; 3 4 import org.openstreetmap.gui.jmapviewer.JMapViewer;5 import org.openstreetmap.gui.jmapviewer.Projected;6 import org.openstreetmap.gui.jmapviewer.interfaces.IProjected;7 3 8 4 /** … … 29 25 public EastNorth(double east, double north) { 30 26 super(east, north); 31 }32 33 /**34 * Constructs a new {@code EastNorth} from {@link IProjected}.35 * @param p projected coordinates36 */37 public EastNorth(IProjected p) {38 super(p.getEast(), p.getNorth());39 27 } 40 28 … … 188 176 } 189 177 190 /**191 * Converts this to a {@link IProjected} instance to be used in the {@link JMapViewer}192 * @return The projected193 */194 public IProjected toProjected() {195 return new Projected(east(), north());196 }197 198 178 @Override 199 179 public String toString() { -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r12620 r12669 23 23 import java.util.regex.Pattern; 24 24 25 import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;26 25 import org.openstreetmap.josm.Main; 27 26 import org.openstreetmap.josm.data.Bounds; … … 294 293 } 295 294 296 /**297 * Constructs a new object for the given coordinate298 * @param coor the coordinate299 */300 public LatLon(ICoordinate coor) {301 this(coor.getLat(), coor.getLon());302 }303 304 295 @Override 305 296 public double lat() { … … 566 557 return Double.compare(that.x, x) == 0 && 567 558 Double.compare(that.y, y) == 0; 568 }569 570 /**571 * Converts this latitude/longitude to an instance of {@link ICoordinate}.572 * @return a {@link ICoordinate} instance of this latitude/longitude573 */574 public ICoordinate toCoordinate() {575 return new org.openstreetmap.gui.jmapviewer.Coordinate(lat(), lon());576 559 } 577 560 -
trunk/src/org/openstreetmap/josm/data/imagery/AbstractWMSTileSource.java
r11858 r12669 110 110 @Override 111 111 public ICoordinate tileXYToLatLon(int x, int y, int zoom) { 112 return tileProjection.eastNorth2latlon(getTileEastNorth(x, y, zoom)) .toCoordinate();112 return CoordinateConversion.llToCoor(tileProjection.eastNorth2latlon(getTileEastNorth(x, y, zoom))); 113 113 } 114 114 … … 179 179 anchorPosition.north() - y * scale 180 180 ); 181 return tileProjection.eastNorth2latlon(ret) .toCoordinate();181 return CoordinateConversion.llToCoor(tileProjection.eastNorth2latlon(ret)); 182 182 } 183 183 -
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r12620 r12669 808 808 TileMatrix matrix = getTileMatrix(zoom); 809 809 if (matrix == null) { 810 return tileProjection.getWorldBoundsLatLon().getCenter() .toCoordinate();810 return CoordinateConversion.llToCoor(tileProjection.getWorldBoundsLatLon().getCenter()); 811 811 } 812 812 double scale = matrix.scaleDenominator * this.crsScale; 813 813 EastNorth ret = new EastNorth(matrix.topLeftCorner.east() + x * scale, matrix.topLeftCorner.north() - y * scale); 814 return tileProjection.eastNorth2latlon(ret) .toCoordinate();814 return CoordinateConversion.llToCoor(tileProjection.eastNorth2latlon(ret)); 815 815 } 816 816 … … 1014 1014 } 1015 1015 1016 private EastNorth tileToEastNorth(int x, int y, int z) { 1017 return CoordinateConversion.projToEn(this.tileXYtoProjected(x, y, z)); 1018 } 1019 1016 1020 private ProjectionBounds getTileProjectionBounds(Tile tile) { 1017 ProjectionBounds pb = new ProjectionBounds(new EastNorth( 1018 this.tileXYtoProjected(tile.getXtile(), tile.getYtile(), tile.getZoom()))); 1019 pb.extend(new EastNorth(this.tileXYtoProjected(tile.getXtile() + 1, tile.getYtile() + 1, tile.getZoom()))); 1021 ProjectionBounds pb = new ProjectionBounds(tileToEastNorth(tile.getXtile(), tile.getYtile(), tile.getZoom())); 1022 pb.extend(tileToEastNorth(tile.getXtile() + 1, tile.getYtile() + 1, tile.getZoom())); 1020 1023 return pb; 1021 1024 } … … 1025 1028 ProjectionBounds pbInner = getTileProjectionBounds(inner); 1026 1029 ProjectionBounds pbOuter = getTileProjectionBounds(outer); 1027 // a little tolerance, for when inner tile touches the border of the 1028 // outer tile 1030 // a little tolerance, for when inner tile touches the border of the outer tile 1029 1031 double epsilon = 1e-7 * (pbOuter.maxEast - pbOuter.minEast); 1030 1032 return pbOuter.minEast <= pbInner.minEast + epsilon && -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r12630 r12669 80 80 import org.openstreetmap.josm.data.coor.EastNorth; 81 81 import org.openstreetmap.josm.data.coor.LatLon; 82 import org.openstreetmap.josm.data.imagery.CoordinateConversion; 82 83 import org.openstreetmap.josm.data.imagery.ImageryInfo; 83 84 import org.openstreetmap.josm.data.imagery.OffsetBookmark; … … 1135 1136 1136 1137 private ICoordinate getShiftedCoord(EastNorth en) { 1137 return getShiftedLatLon(en) .toCoordinate();1138 return CoordinateConversion.llToCoor(getShiftedLatLon(en)); 1138 1139 } 1139 1140 … … 1284 1285 return new TileSet(); 1285 1286 TileXY t1, t2; 1287 IProjected topLeftUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMin()); 1288 IProjected botRightUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMax()); 1286 1289 if (coordinateConverter.requiresReprojection()) { 1287 1290 Projection projServer = Projections.getProjectionByCode(tileSource.getServerCRS()); 1288 1291 ProjectionBounds projBounds = new ProjectionBounds( 1289 new EastNorth(coordinateConverter.shiftDisplayToServer(bounds.getMin())),1290 new EastNorth(coordinateConverter.shiftDisplayToServer(bounds.getMax())));1292 CoordinateConversion.projToEn(topLeftUnshifted), 1293 CoordinateConversion.projToEn(botRightUnshifted)); 1291 1294 ProjectionBounds bbox = projServer.getEastNorthBoundsBox(projBounds, Main.getProjection()); 1292 t1 = tileSource.projectedToTileXY(bbox.getMin() .toProjected(), zoom);1293 t2 = tileSource.projectedToTileXY(bbox.getMax() .toProjected(), zoom);1295 t1 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(bbox.getMin()), zoom); 1296 t2 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(bbox.getMax()), zoom); 1294 1297 } else { 1295 IProjected topLeftUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMin());1296 IProjected botRightUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMax());1297 1298 t1 = tileSource.projectedToTileXY(topLeftUnshifted, zoom); 1298 1299 t2 = tileSource.projectedToTileXY(botRightUnshifted, zoom); … … 1745 1746 for (LatLon point: points) { 1746 1747 TileXY minTile = tileSource.latLonToTileXY(point.lat() - bufferY, point.lon() - bufferX, currentZoomLevel); 1747 TileXY curTile = tileSource.latLonToTileXY( point.toCoordinate(), currentZoomLevel);1748 TileXY curTile = tileSource.latLonToTileXY(CoordinateConversion.llToCoor(point), currentZoomLevel); 1748 1749 TileXY maxTile = tileSource.latLonToTileXY(point.lat() + bufferY, point.lon() + bufferX, currentZoomLevel); 1749 1750 -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java
r12630 r12669 11 11 import org.openstreetmap.josm.data.ProjectionBounds; 12 12 import org.openstreetmap.josm.data.coor.EastNorth; 13 import org.openstreetmap.josm.data.imagery.CoordinateConversion; 13 14 import org.openstreetmap.josm.data.projection.Projection; 14 15 import org.openstreetmap.josm.data.projection.Projections; … … 95 96 this.anchor = null; 96 97 this.maxZoomReached = false; 98 } 99 100 private EastNorth tileToEastNorth(int x, int y, int z) { 101 return CoordinateConversion.projToEn(source.tileXYtoProjected(x, y, z)); 97 102 } 98 103 … … 118 123 Projection projCurrent = Main.getProjection(); 119 124 Projection projServer = Projections.getProjectionByCode(source.getServerCRS()); 120 EastNorth en00Server = newEastNorth(source.tileXYtoProjected(xtile, ytile, zoom));121 EastNorth en11Server = newEastNorth(source.tileXYtoProjected(xtile + 1, ytile + 1, zoom));125 EastNorth en00Server = tileToEastNorth(xtile, ytile, zoom); 126 EastNorth en11Server = tileToEastNorth(xtile + 1, ytile + 1, zoom); 122 127 ProjectionBounds pbServer = new ProjectionBounds(en00Server); 123 128 pbServer.extend(en11Server); -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java
r11961 r12669 17 17 import org.openstreetmap.josm.data.coor.EastNorth; 18 18 import org.openstreetmap.josm.data.coor.LatLon; 19 import org.openstreetmap.josm.data.imagery.CoordinateConversion; 19 20 import org.openstreetmap.josm.data.projection.Projecting; 20 21 import org.openstreetmap.josm.data.projection.ShiftedProjecting; … … 46 47 47 48 private MapViewPoint pos(ICoordinate ll) { 48 return mapView.getState().getPointFor( new LatLon(ll)).add(settings.getDisplacement());49 return mapView.getState().getPointFor(CoordinateConversion.coorToLL(ll)).add(settings.getDisplacement()); 49 50 } 50 51 51 52 private MapViewPoint pos(IProjected p) { 52 return mapView.getState().getPointFor( new EastNorth(p)).add(settings.getDisplacement());53 return mapView.getState().getPointFor(CoordinateConversion.projToEn(p)).add(settings.getDisplacement()); 53 54 } 54 55 … … 60 61 */ 61 62 public IProjected shiftDisplayToServer(EastNorth en) { 62 return en.subtract(settings.getDisplacement()) .toProjected();63 return CoordinateConversion.enToProj(en.subtract(settings.getDisplacement())); 63 64 } 64 65 … … 102 103 if (requiresReprojection()) { 103 104 LatLon ll = getProjecting().eastNorth2latlonClamped(mapView.getEastNorth(sx, sy)); 104 return tileSource.latLonToTileXY( ll.toCoordinate(), zoom);105 return tileSource.latLonToTileXY(CoordinateConversion.llToCoor(ll), zoom); 105 106 } else { 106 107 IProjected p = shiftDisplayToServer(mapView.getEastNorth(sx, sy)); … … 165 166 LatLon topLeft = mapView.getLatLon(0, 0); 166 167 LatLon botRight = mapView.getLatLon(mapView.getWidth(), mapView.getHeight()); 167 t1 = tileSource.latLonToTileXY( topLeft.toCoordinate(), zoom);168 t2 = tileSource.latLonToTileXY( botRight.toCoordinate(), zoom);168 t1 = tileSource.latLonToTileXY(CoordinateConversion.llToCoor(topLeft), zoom); 169 t2 = tileSource.latLonToTileXY(CoordinateConversion.llToCoor(botRight), zoom); 169 170 } else { 170 171 EastNorth topLeftEN = mapView.getEastNorth(0, 0); 171 172 EastNorth botRightEN = mapView.getEastNorth(mapView.getWidth(), mapView.getHeight()); 172 t1 = tileSource.projectedToTileXY(topLeftEN .toProjected(), zoom);173 t2 = tileSource.projectedToTileXY(botRightEN .toProjected(), zoom);173 t1 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(topLeftEN), zoom); 174 t2 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(botRightEN), zoom); 174 175 } 175 176 int screenPixels = mapView.getWidth()*mapView.getHeight();
Note:
See TracChangeset
for help on using the changeset viewer.