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

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