Last change
on this file since 1309 was 1309, checked in by stoecker, 16 years ago |
fixed texts, added EPSG codes to projection (to fix WMS access)
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Line | |
---|
1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.data.projection;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
7 | import 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 | * See also USGS Bulletin 1532
|
---|
17 | * (http://egsc.usgs.gov/isb/pubs/factsheets/fs08799.html)
|
---|
18 | *
|
---|
19 | * @author imi
|
---|
20 | */
|
---|
21 | public class Mercator implements Projection {
|
---|
22 |
|
---|
23 | public EastNorth latlon2eastNorth(LatLon p) {
|
---|
24 | return new EastNorth(
|
---|
25 | p.lon()*Math.PI/180,
|
---|
26 | Math.log(Math.tan(Math.PI/4+p.lat()*Math.PI/360)));
|
---|
27 | }
|
---|
28 |
|
---|
29 | public LatLon eastNorth2latlon(EastNorth p) {
|
---|
30 | return new LatLon(
|
---|
31 | Math.atan(Math.sinh(p.north()))*180/Math.PI,
|
---|
32 | p.east()*180/Math.PI);
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override public String toString() {
|
---|
36 | return tr("Mercator");
|
---|
37 | }
|
---|
38 |
|
---|
39 | public String toCode() {
|
---|
40 | return "EPSG:3785"; /* TODO: Check if that is correct */
|
---|
41 | }
|
---|
42 |
|
---|
43 | public String getCacheDirectoryName() {
|
---|
44 | return "mercator";
|
---|
45 | }
|
---|
46 |
|
---|
47 | public double scaleFactor() {
|
---|
48 | return 1/Math.PI/2;
|
---|
49 | }
|
---|
50 |
|
---|
51 | @Override public boolean equals(Object o) {
|
---|
52 | return o instanceof Mercator;
|
---|
53 | }
|
---|
54 |
|
---|
55 | @Override public int hashCode() {
|
---|
56 | return Mercator.class.hashCode();
|
---|
57 | }
|
---|
58 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.