source: josm/trunk/src/org/openstreetmap/josm/data/projection/LambertEST.java@ 1849

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

some projection and zoom cleanups - projection classes still need better handling of outside-world coordinates

File size: 4.5 KB
Line 
1//License: GPL. For details, see LICENSE file.
2//Thanks to Johan Montagnat and its geoconv java converter application
3//(http://www.i3s.unice.fr/~johan/gps/ , published under GPL license)
4//from which some code and constants have been reused here.
5package org.openstreetmap.josm.data.projection;
6
7import static org.openstreetmap.josm.tools.I18n.tr;
8
9import org.openstreetmap.josm.data.coor.EastNorth;
10import org.openstreetmap.josm.data.coor.LatLon;
11import org.openstreetmap.josm.data.Bounds;
12import org.openstreetmap.josm.data.ProjectionBounds;
13
14public class LambertEST implements Projection {
15
16 public static final double ef = 500000; //Easting at false origin = 5000000 m
17 public static final double nf = 6375000; //Northing at false origin = 6375000 m
18 public static final double lat1 = Math.toRadians(59 + 1.0/3.0); //Latitude of 1st standard parallel = 59o20`0`` N
19 public static final double lat2 = Math.toRadians( 58);//Latitude of 2nd standard parallel = 58o0`0`` N
20 public static final double latf = Math.toRadians(57.517553930555555555555555555556);//'Latitude of false origin = 57o31`3,19415`` N
21 public static final double lonf = Math.toRadians( 24.0);
22 public static final double a = 6378137;
23 public static final double ee = 0.081819191042815792;
24 public static final double m1 = Math.cos(lat1) / (Math.sqrt(1 - ee *ee * Math.pow(Math.sin(lat1), 2)));
25 public static final double m2 = Math.cos(lat2) / (Math.sqrt(1 - ee *ee * Math.pow(Math.sin(lat2), 2)));
26 public static final double t1 = Math.tan(Math.PI / 4.0 - lat1 / 2.0)
27 / Math.pow(( (1.0 - ee * Math.sin(lat1)) / (1.0 + ee * Math.sin(lat1))) ,(ee / 2.0));
28 public static final double t2 = Math.tan(Math.PI / 4.0 - lat2 / 2.0)
29 / Math.pow(( (1.0 - ee * Math.sin(lat2)) / (1.0 + ee * Math.sin(lat2))) ,(ee / 2.0));
30 public static final double tf = Math.tan(Math.PI / 4.0 - latf / 2.0)
31 / Math.pow(( (1.0 - ee * Math.sin(latf)) / (1.0 + ee * Math.sin(latf))) ,(ee / 2.0));
32 public static final double n = (Math.log(m1) - Math.log(m2))
33 / (Math.log(t1) - Math.log(t2));
34 public static final double f = m1 / (n * Math.pow(t1, n));
35 public static final double rf = a * f * Math.pow(tf, n);
36
37 /**
38 * precision in iterative schema
39 */
40 public static final double epsilon = 1e-11;
41
42 /**
43 * @param p WGS84 lat/lon (ellipsoid GRS80) (in degree)
44 * @return eastnorth projection in Lambert Zone (ellipsoid GRS80)
45 */
46 public EastNorth latlon2eastNorth(LatLon p)
47 {
48
49 double t = Math.tan(Math.PI / 4.0 - Math.toRadians(p.lat()) / 2.0)
50 / Math.pow(( (1.0 - ee * Math.sin(Math.toRadians(p.lat()))) / (1.0
51 + ee * Math.sin(Math.toRadians(p.lat())))) ,(ee / 2.0));
52 double r = a * f * Math.pow(t, n);
53 double theta = n * (Math.toRadians(p.lon()) - lonf);
54
55 double x = ef + r * Math.sin(theta); //587446.7
56 double y = nf + rf - r * Math.cos(theta); //6485401.6
57
58 return new EastNorth(x,y);
59 }
60
61 public static double IterateAngle(double e, double t)
62 {
63 double a1 = 0.0;
64 double a2 = 3.1415926535897931;
65 double a = 1.5707963267948966;
66 double b = 1.5707963267948966 - (2.0 * Math.atan(t * Math.pow((1.0
67 - (e * Math.sin(a))) / (1.0 + (e * Math.sin(a))), e / 2.0)));
68 while (Math.abs(a-b) > epsilon)
69 {
70 a = a1 + ((a2 - a1) / 2.0);
71 b = 1.5707963267948966 - (2.0 * Math.atan(t * Math.pow((1.0
72 - (e * Math.sin(a))) / (1.0 + (e * Math.sin(a))), e / 2.0)));
73 if (a1 == a2)
74 {
75 return 0.0;
76 }
77 if (b > a)
78 a1 = a;
79 else
80 a2 = a;
81 }
82 return b;
83 }
84
85 public LatLon eastNorth2latlon(EastNorth p)
86 {
87 double r = Math.sqrt(Math.pow((p.getX() - ef), 2.0) + Math.pow((rf
88 - p.getY() + nf), 2.0) ) * Math.signum(n);
89 double T = Math.pow((r / (a * f)), (1.0/ n)) ;
90 double theta = Math.atan((p.getX() - ef) / (rf - p.getY() + nf));
91 double y = (theta / n + lonf) ;
92 double x = (IterateAngle(ee, T)) ;
93 return new LatLon(Math.toDegrees(x),Math.toDegrees(y));
94 }
95
96 @Override
97 public String toString() {
98 return tr("Lambert Zone (Estonia)");
99 }
100
101 public String toCode() {
102 return "EPSG:3301";
103 }
104
105 public String getCacheDirectoryName() {
106 return "lambertest";
107 }
108
109 public Bounds getWorldBoundsLatLon()
110 {
111 return new Bounds(
112 new LatLon(-90.0, -180.0),
113 new LatLon(90.0, 180.0));
114 }
115}
Note: See TracBrowser for help on using the repository browser.