Changeset 5066 in josm for trunk/src/org/openstreetmap/josm/data/projection/proj/LambertConformalConic.java
- Timestamp:
- 2012-03-10T16:18:23+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/proj/LambertConformalConic.java
r5040 r5066 7 7 8 8 import org.openstreetmap.josm.data.projection.Ellipsoid; 9 import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; 9 10 10 11 /** … … 14 15 */ 15 16 public class LambertConformalConic implements Proj { 16 17 17 18 protected Ellipsoid ellps; 18 19 protected double e; 19 20 20 21 public static abstract class Parameters { 21 22 public final double latitudeOrigin; … … 24 25 } 25 26 }; 26 27 27 28 public static class Parameters1SP extends Parameters { 28 29 public Parameters1SP(double latitudeOrigin) { … … 42 43 43 44 private Parameters params; 44 45 45 46 /** 46 47 * projection exponent … … 52 53 protected double F; 53 54 /** 54 * radius of the parallel of latitude of the false origin (2SP) or at 55 * radius of the parallel of latitude of the false origin (2SP) or at 55 56 * natural origin (1SP) 56 57 */ 57 protected double r0; 58 58 protected double r0; 59 59 60 /** 60 61 * precision in iterative schema … … 62 63 protected static final double epsilon = 1e-12; 63 64 64 /** 65 * Constructor. 66 * Call one of the updateParameters... methods for initialization. 67 */ 68 public LambertConformalConic() { 65 @Override 66 public void initialize(ProjParameters params) throws ProjectionConfigurationException { 67 ellps = params.ellps; 68 e = ellps.e; 69 if (params.lcc_n != null && params.lcc_F != null && params.lcc_r0 != null) { 70 initializeDirect(params.lcc_n, params.lcc_F, params.lcc_r0); 71 } else { 72 if (params.lat_0 == null) 73 throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_0")); 74 if (params.lat_1 != null && params.lat_2 != null) { 75 initialize2SP(params.lat_0, params.lat_1, params.lat_2); 76 } else { 77 initialize1SP(params.lat_0); 78 } 79 } 69 80 } 70 81 71 82 /** 72 83 * Initialize for LCC with 2 standard parallels. 73 * 74 * @param ellps the ellipsoid 84 * 75 85 * @param lat_0 latitude of false origin (in degrees) 76 86 * @param lat_1 latitude of first standard parallel (in degrees) 77 87 * @param lat_2 latitude of second standard parallel (in degrees) 78 88 */ 79 p ublic void updateParameters2SP(Ellipsoid ellps,double lat_0, double lat_1, double lat_2) {89 private void initialize2SP(double lat_0, double lat_1, double lat_2) { 80 90 this.params = new Parameters2SP(lat_0, lat_1, lat_2); 81 this.ellps = ellps; 82 this.e = ellps.e; 83 91 84 92 final double m1 = m(toRadians(lat_1)); 85 93 final double m2 = m(toRadians(lat_2)); 86 94 87 95 final double t1 = t(toRadians(lat_1)); 88 96 final double t2 = t(toRadians(lat_2)); 89 97 final double tf = t(toRadians(lat_0)); 90 98 91 99 n = (log(m1) - log(m2)) / (log(t1) - log(t2)); 92 100 F = m1 / (n * pow(t1, n)); 93 101 r0 = F * pow(tf, n); 94 102 } 95 103 96 104 /** 97 105 * Initialize for LCC with 1 standard parallel. 98 * 99 * @param ellps the ellipsoid 106 * 100 107 * @param lat_0 latitude of natural origin (in degrees) 101 108 */ 102 p ublic void updateParameters1SP(Ellipsoid ellps,double lat_0) {109 private void initialize1SP(double lat_0) { 103 110 this.params = new Parameters1SP(lat_0); 104 this.ellps = ellps;105 this.e = ellps.e;106 111 final double lat_0_rad = toRadians(lat_0); 107 112 108 113 final double m0 = m(lat_0_rad); 109 114 final double t0 = t(lat_0_rad); 110 115 111 116 n = sin(lat_0_rad); 112 117 F = m0 / (n * pow(t0, n)); … … 116 121 /** 117 122 * Initialize LCC by providing the projection parameters directly. 118 * 119 * @param ellps the ellipsoid 123 * 120 124 * @param n see field n 121 125 * @param F see field F 122 126 * @param r0 see field r0 123 127 */ 124 p ublic void updateParametersDirect(Ellipsoid ellps,double n, double F, double r0) {128 private void initializeDirect(double n, double F, double r0) { 125 129 this.params = null; 126 this.ellps = ellps;127 this.e = ellps.e;128 130 this.n = n; 129 131 this.F = F; … … 145 147 return cos(lat_rad) / (sqrt(1 - e * e * pow(sin(lat_rad), 2))); 146 148 } 147 149 148 150 @Override 149 151 public String getName() { … … 166 168 return new double[] { X, Y }; 167 169 } 168 170 169 171 @Override 170 172 public double[] invproject(double east, double north) { … … 176 178 return new double[] { phi, lambda }; 177 179 } 178 180 179 181 public final Parameters getParameters() { 180 182 return params;
Note:
See TracChangeset
for help on using the changeset viewer.