|
Last change
on this file since 1823 was 1823, checked in by stoecker, 16 years ago |
|
some projection and zoom cleanups - projection classes still need better handling of outside-world coordinates
|
-
Property svn:eol-style
set to
native
|
|
File size:
1.5 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 | import org.openstreetmap.josm.data.Bounds;
|
|---|
| 9 | import org.openstreetmap.josm.data.ProjectionBounds;
|
|---|
| 10 |
|
|---|
| 11 | /**
|
|---|
| 12 | * Implement Mercator Projection code, coded after documentation
|
|---|
| 13 | * from wikipedia.
|
|---|
| 14 | *
|
|---|
| 15 | * The center of the mercator projection is always the 0 grad
|
|---|
| 16 | * coordinate.
|
|---|
| 17 | *
|
|---|
| 18 | * See also USGS Bulletin 1532
|
|---|
| 19 | * (http://egsc.usgs.gov/isb/pubs/factsheets/fs08799.html)
|
|---|
| 20 | *
|
|---|
| 21 | * @author imi
|
|---|
| 22 | */
|
|---|
| 23 | public class Mercator implements Projection {
|
|---|
| 24 |
|
|---|
| 25 | public EastNorth latlon2eastNorth(LatLon p) {
|
|---|
| 26 | return new EastNorth(
|
|---|
| 27 | p.lon()*Math.PI/180,
|
|---|
| 28 | Math.log(Math.tan(Math.PI/4+p.lat()*Math.PI/360)));
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | public LatLon eastNorth2latlon(EastNorth p) {
|
|---|
| 32 | return new LatLon(
|
|---|
| 33 | Math.atan(Math.sinh(p.north()))*180/Math.PI,
|
|---|
| 34 | p.east()*180/Math.PI);
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | @Override public String toString() {
|
|---|
| 38 | return tr("Mercator");
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | public String toCode() {
|
|---|
| 42 | return "EPSG:3857"; /* TODO: Check if that is correct */
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | public String getCacheDirectoryName() {
|
|---|
| 46 | return "mercator";
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | public Bounds getWorldBoundsLatLon()
|
|---|
| 50 | {
|
|---|
| 51 | return new Bounds(
|
|---|
| 52 | new LatLon(-85.05112877980659, -180.0),
|
|---|
| 53 | new LatLon(85.05112877980659, 180.0));
|
|---|
| 54 | }
|
|---|
| 55 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.