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

Last change on this file since 298 was 298, checked in by imi, 17 years ago
  • added license description to head of each source file
File size: 956 bytes
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.projection;
3
4import org.openstreetmap.josm.data.coor.EastNorth;
5import org.openstreetmap.josm.data.coor.LatLon;
6
7/**
8 * Implement Mercator Projection code, coded after documentation
9 * from wikipedia.
10 *
11 * The center of the mercator projection is always the 0 grad
12 * coordinate.
13 *
14 * @author imi
15 */
16public class Mercator implements Projection {
17
18 public EastNorth latlon2eastNorth(LatLon p) {
19 return new EastNorth(
20 p.lon()*Math.PI/180,
21 Math.log(Math.tan(Math.PI/4+p.lat()*Math.PI/360)));
22 }
23
24 public LatLon eastNorth2latlon(EastNorth p) {
25 return new LatLon(
26 Math.atan(Math.sinh(p.north()))*180/Math.PI,
27 p.east()*180/Math.PI);
28 }
29
30 @Override public String toString() {
31 return "Mercator";
32 }
33
34 public String getCacheDirectoryName() {
35 return "mercator";
36 }
37
38 public double scaleFactor() {
39 return 1/Math.PI/2;
40 }
41}
Note: See TracBrowser for help on using the repository browser.