source: josm/trunk/src/org/openstreetmap/josm/data/projection/Mercator.java@ 3922

Last change on this file since 3922 was 3922, checked in by stoecker, 14 years ago

correct mercator projection scaling factor

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.projection;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import org.openstreetmap.josm.data.Bounds;
7import org.openstreetmap.josm.data.coor.EastNorth;
8import org.openstreetmap.josm.data.coor.LatLon;
9
10/**
11 * Implement Mercator Projection code, coded after documentation
12 * from wikipedia.
13 *
14 * The center of the mercator projection is always the 0 grad
15 * coordinate.
16 *
17 * See also USGS Bulletin 1532
18 * (http://egsc.usgs.gov/isb/pubs/factsheets/fs08799.html)
19 *
20 * @author imi
21 */
22public class Mercator implements Projection {
23
24 final double radius = 6378137.0;
25
26 public EastNorth latlon2eastNorth(LatLon p) {
27 return new EastNorth(
28 p.lon()*Math.PI/180*radius,
29 Math.log(Math.tan(Math.PI/4+p.lat()*Math.PI/360))*radius);
30 }
31
32 public LatLon eastNorth2latlon(EastNorth p) {
33 return new LatLon(
34 Math.atan(Math.sinh(p.north()/radius))*180/Math.PI,
35 p.east()/radius*180/Math.PI);
36 }
37
38 @Override public String toString() {
39 return tr("Mercator");
40 }
41
42 public String toCode() {
43 return "EPSG:3857"; /* initially they used 3785 but that has been superseded, see http://www.epsg-registry.org/ */
44 }
45
46 @Override
47 public int hashCode() {
48 return getClass().getName().hashCode(); // we have no variables
49 }
50
51 public String getCacheDirectoryName() {
52 return "mercator";
53 }
54
55 public Bounds getWorldBoundsLatLon()
56 {
57 return new Bounds(
58 new LatLon(-85.05112877980659, -180.0),
59 new LatLon(85.05112877980659, 180.0));
60 }
61
62 public double getDefaultZoomInPPD() {
63 // This will set the scale bar to about 100 km
64 return 1000.0;/*0.000158*/
65 }
66}
Note: See TracBrowser for help on using the repository browser.