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

Last change on this file since 2114 was 2114, checked in by stoecker, 15 years ago

see #3016 - patch by xeen - fixes some zooming issues

  • Property svn:eol-style set to native
File size: 1.6 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 public EastNorth latlon2eastNorth(LatLon p) {
25 return new EastNorth(
26 p.lon()*Math.PI/180,
27 Math.log(Math.tan(Math.PI/4+p.lat()*Math.PI/360)));
28 }
29
30 public LatLon eastNorth2latlon(EastNorth p) {
31 return new LatLon(
32 Math.atan(Math.sinh(p.north()))*180/Math.PI,
33 p.east()*180/Math.PI);
34 }
35
36 @Override public String toString() {
37 return tr("Mercator");
38 }
39
40 public String toCode() {
41 return "EPSG:3857"; /* TODO: Check if that is correct */
42 }
43
44 public String getCacheDirectoryName() {
45 return "mercator";
46 }
47
48 public Bounds getWorldBoundsLatLon()
49 {
50 return new Bounds(
51 new LatLon(-85.05112877980659, -180.0),
52 new LatLon(85.05112877980659, 180.0));
53 }
54
55 public double getDefaultZoomInPPD() {
56 // This will set the scale bar to about 100 km
57 return 0.000158;
58 }
59}
Note: See TracBrowser for help on using the repository browser.