Last change
on this file since 52 was 52, checked in by imi, 18 years ago |
- fixed data merge (sometime set modified unnecessary)
- fixed rounding (now compare with epsilon instead of round everything)
- Fix: upload does not clear all changes if only some thing got uploaded
|
File size:
642 bytes
|
Line | |
---|
1 | package org.openstreetmap.josm.data.projection;
|
---|
2 |
|
---|
3 | import org.openstreetmap.josm.data.GeoPoint;
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * Implement Mercator Projection code, coded after documentation
|
---|
7 | * from wikipedia.
|
---|
8 | *
|
---|
9 | * The center of the mercator projection is always the 0 grad
|
---|
10 | * coordinate.
|
---|
11 | *
|
---|
12 | * @author imi
|
---|
13 | */
|
---|
14 | public class Mercator implements Projection {
|
---|
15 |
|
---|
16 | public void latlon2xy(GeoPoint p) {
|
---|
17 | p.x = p.lon*Math.PI/180;
|
---|
18 | p.y = Math.log(Math.tan(Math.PI/4+p.lat*Math.PI/360));
|
---|
19 | }
|
---|
20 |
|
---|
21 | public void xy2latlon(GeoPoint p) {
|
---|
22 | p.lon = p.x*180/Math.PI;
|
---|
23 | p.lat = Math.atan(Math.sinh(p.y))*180/Math.PI;
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public String toString() {
|
---|
28 | return "Mercator";
|
---|
29 | }
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.