source: josm/trunk/src/org/openstreetmap/josm/data/projection/Mercator.java@ 1722

Last change on this file since 1722 was 1722, checked in by stoecker, 15 years ago

Large rework in projection handling - now allows only switching and more specific projections
TODO:

  • allow subprojections (i.e. settings for projections)
  • setup preferences for subprojections
  • better support of the new projection depending world bounds (how to handle valid data outside of world)
  • do not allow to zoom out of the world - zoom should stop when whole world is displayed
  • fix Lambert and SwissGrid to handle new OutOfWorld style and subprojections
  • fix new UTM projection
  • handle layers with fixed projection on projection change
  • allow easier projection switching (e.g. in menu)

NOTE:
This checkin very likely will cause problems. Please report or fix them. Older plugins may have trouble. The SVN plugins
have been fixed but may have problems nevertheless. This is a BIG change, but will make JOSMs internal structure much cleaner
and reduce lots of projection related problems.

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.projection;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import org.openstreetmap.josm.data.coor.EastNorth;
7import org.openstreetmap.josm.data.coor.LatLon;
8import org.openstreetmap.josm.data.Bounds;
9import 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 */
23public 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 @Override public boolean equals(Object o) {
50 return o instanceof Mercator;
51 }
52
53 public ProjectionBounds getWorldBounds()
54 {
55 Bounds b = getWorldBoundsLatLon();
56 return new ProjectionBounds(latlon2eastNorth(b.min), latlon2eastNorth(b.max));
57 }
58
59 public Bounds getWorldBoundsLatLon()
60 {
61 return new Bounds(
62 new LatLon(-85.05112877980659, -180.0),
63 new LatLon(85.05112877980659, 180.0));
64 }
65}
Note: See TracBrowser for help on using the repository browser.