Last change
on this file since 864 was 627, checked in by framm, 16 years ago |
|
-
Property svn:eol-style
set to
native
|
File size:
1.1 KB
|
Line | |
---|
1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.data.projection;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
5 | import 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 | */
|
---|
16 | public 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 |
|
---|
42 | @Override public boolean equals(Object o) {
|
---|
43 | return o instanceof Mercator;
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Override public int hashCode() {
|
---|
47 | return Mercator.class.hashCode();
|
---|
48 | }
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.