Changeset 9230 in josm for trunk/src/org/openstreetmap/josm/tools
 Timestamp:
 20151231T16:37:24+01:00 (5 years ago)
 Location:
 trunk/src/org/openstreetmap/josm/tools
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r9227 r9230 437 437 /** 438 438 * Sets whether not to set header {@code Connection=close} 439 * <p />439 * <p> 440 440 * This might fix #7640, see 441 441 * <a href='https://web.archive.org/web/20140118201501/http://www.tikalk.com/java/forums/httpurlconnectiondisablekeepalive'>here</a>. 
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r9062 r9230 12 12 import org.openstreetmap.josm.data.Bounds; 13 13 import org.openstreetmap.josm.data.coor.LatLon; 14 import org.openstreetmap.josm.data.projection.Ellipsoid; 14 15 15 16 public final class OsmUrlToBounds { … … 188 189 } 189 190 190 /** radius of the earth */191 public static final double R = 6378137.0;192 193 191 public static Bounds positionToBounds(final double lat, final double lon, final int zoom) { 194 192 int tileSizeInPixels = 256; … … 207 205 width = 640; 208 206 } 209 double scale = (1 << zoom) * tileSizeInPixels / (2 * Math.PI * R);207 double scale = (1 << zoom) * tileSizeInPixels / (2 * Math.PI * Ellipsoid.WGS84.a); 210 208 double deltaX = width / 2.0 / scale; 211 209 double deltaY = height / 2.0 / scale; 212 double x = Math.toRadians(lon) * R;210 double x = Math.toRadians(lon) * Ellipsoid.WGS84.a; 213 211 double y = mercatorY(lat); 214 return new Bounds(invMercatorY(y  deltaY), Math.toDegrees(x  deltaX) / R, invMercatorY(y + deltaY), Math.toDegrees(x + deltaX) / R); 212 return new Bounds( 213 invMercatorY(y  deltaY), Math.toDegrees(x  deltaX) / Ellipsoid.WGS84.a, 214 invMercatorY(y + deltaY), Math.toDegrees(x + deltaX) / Ellipsoid.WGS84.a); 215 215 } 216 216 217 217 public static double mercatorY(double lat) { 218 return Math.log(Math.tan(Math.PI/4 + Math.toRadians(lat)/2)) * R;218 return Math.log(Math.tan(Math.PI/4 + Math.toRadians(lat)/2)) * Ellipsoid.WGS84.a; 219 219 } 220 220 221 221 public static double invMercatorY(double north) { 222 return Math.toDegrees(Math.atan(Math.sinh(north / R)));222 return Math.toDegrees(Math.atan(Math.sinh(north / Ellipsoid.WGS84.a))); 223 223 } 224 224
Note: See TracChangeset
for help on using the changeset viewer.