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

Last change on this file since 36 was 36, checked in by imi, 18 years ago

added Mercator projection

File size: 822 bytes
Line 
1package org.openstreetmap.josm.data.projection;
2
3import javax.swing.JComponent;
4
5import org.openstreetmap.josm.data.GeoPoint;
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°
12 * coordinate.
13 *
14 * @author imi
15 */
16public class Mercator extends Projection {
17
18 @Override
19 public void latlon2xy(GeoPoint p) {
20 p.x = p.lon*Math.PI/180;
21 p.y = Math.log(Math.tan(Math.PI/4+p.lat*Math.PI/360));
22 }
23
24 @Override
25 public void xy2latlon(GeoPoint p) {
26 p.lon = p.x*180/Math.PI;
27 p.lat = Math.atan(Math.sinh(p.y))*180/Math.PI;
28 }
29
30 @Override
31 public String toString() {
32 return "Mercator";
33 }
34
35 @Override
36 public JComponent getConfigurationPanel() {
37 return null;
38 }
39
40 @Override
41 public void commitConfigurationPanel() {
42 }
43}
Note: See TracBrowser for help on using the repository browser.