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

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

removed usage of tab stops

  • Property svn:eol-style set to native
File size: 1.2 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.coor.EastNorth;
7import org.openstreetmap.josm.data.coor.LatLon;
8
9/**
10 * Implement Mercator Projection code, coded after documentation
11 * from wikipedia.
12 *
13 * The center of the mercator projection is always the 0 grad
14 * coordinate.
15 *
16 * @author imi
17 */
18public class Mercator implements Projection {
19
20 public EastNorth latlon2eastNorth(LatLon p) {
21 return new EastNorth(
22 p.lon()*Math.PI/180,
23 Math.log(Math.tan(Math.PI/4+p.lat()*Math.PI/360)));
24 }
25
26 public LatLon eastNorth2latlon(EastNorth p) {
27 return new LatLon(
28 Math.atan(Math.sinh(p.north()))*180/Math.PI,
29 p.east()*180/Math.PI);
30 }
31
32 @Override public String toString() {
33 return tr("Mercator");
34 }
35
36 public String getCacheDirectoryName() {
37 return "mercator";
38 }
39
40 public double scaleFactor() {
41 return 1/Math.PI/2;
42 }
43
44 @Override public boolean equals(Object o) {
45 return o instanceof Mercator;
46 }
47
48 @Override public int hashCode() {
49 return Mercator.class.hashCode();
50 }
51}
Note: See TracBrowser for help on using the repository browser.