Last change
on this file since 51 was 51, checked in by imi, 18 years ago |
- fixed server rounding problem
- fixed bug, that save with filter does not add extension
- fixed modified flag for data from server vs. data from disk
- hacked "ConcurrentModifyException" (need to do this better)
|
File size:
830 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 | // round values to maximum server precision
|
---|
25 | p.lon = Math.round(p.lon*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;
|
---|
26 | p.lat = Math.round(p.lat*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public String toString() {
|
---|
31 | return "Mercator";
|
---|
32 | }
|
---|
33 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.