1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.projection.proj;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.Bounds;
|
---|
7 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
8 | import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Oblique Mercator Projection. A conformal, oblique, cylindrical projection with the cylinder
|
---|
12 | * touching the ellipsoid (or sphere) along a great circle path (the central line). The
|
---|
13 | * {@linkplain Mercator} and {@linkplain TransverseMercator Transverse Mercator} projections can
|
---|
14 | * be thought of as special cases of the oblique mercator, where the central line is along the
|
---|
15 | * equator or a meridian, respectively. The Oblique Mercator projection has been used in
|
---|
16 | * Switzerland, Hungary, Madagascar, Malaysia, Borneo and the panhandle of Alaska.
|
---|
17 | * <p>
|
---|
18 | * The Oblique Mercator projection uses a (<var>U</var>,<var>V</var>) coordinate system, with the
|
---|
19 | * <var>U</var> axis along the central line. During the forward projection, coordinates from the
|
---|
20 | * ellipsoid are projected conformally to a sphere of constant total curvature, called the
|
---|
21 | * "aposphere", before being projected onto the plane. The projection coordinates are further
|
---|
22 | * convented to a (<var>X</var>,<var>Y</var>) coordinate system by rotating the calculated
|
---|
23 | * (<var>u</var>,<var>v</var>) coordinates to give output (<var>x</var>,<var>y</var>) coordinates.
|
---|
24 | * The rotation value is usually the same as the projection azimuth (the angle, east of north, of
|
---|
25 | * the central line), but some cases allow a separate rotation parameter.
|
---|
26 | * <p>
|
---|
27 | * There are two forms of the oblique mercator, differing in the origin of their grid coordinates.
|
---|
28 | * The Hotine Oblique Mercator (EPSG code 9812) has grid coordinates start at the intersection of
|
---|
29 | * the central line and the equator of the aposphere.
|
---|
30 | * The Oblique Mercator (EPSG code 9815) is the same, except the grid coordinates begin at the
|
---|
31 | * central point (where the latitude of center and central line intersect). ESRI separates these
|
---|
32 | * two case by appending {@code "Natural_Origin"} (for the {@code "Hotine_Oblique_Mercator"}) and
|
---|
33 | * {@code "Center"} (for the {@code "Oblique_Mercator"}) to the projection names.
|
---|
34 | * <p>
|
---|
35 | * Two different methods are used to specify the central line for the oblique mercator:
|
---|
36 | * 1) a central point and an azimuth, east of north, describing the central line and
|
---|
37 | * 2) two points on the central line. The EPSG does not use the two point method,
|
---|
38 | * while ESRI separates the two cases by putting {@code "Azimuth"} and {@code "Two_Point"}
|
---|
39 | * in their projection names. Both cases use the point where the {@code "latitude_of_center"}
|
---|
40 | * parameter crosses the central line as the projection's central point.
|
---|
41 | * The {@linkplain #centralMeridian central meridian} is not a projection parameter,
|
---|
42 | * and is instead calculated as the intersection between the central line and the
|
---|
43 | * equator of the aposphere.
|
---|
44 | * <p>
|
---|
45 | * For the azimuth method, the central latitude cannot be ±90.0 degrees
|
---|
46 | * and the central line cannot be at a maximum or minimum latitude at the central point.
|
---|
47 | * In the two point method, the latitude of the first and second points cannot be
|
---|
48 | * equal. Also, the latitude of the first point and central point cannot be
|
---|
49 | * ±90.0 degrees. Furthermore, the latitude of the first point cannot be 0.0 and
|
---|
50 | * the latitude of the second point cannot be -90.0 degrees. A change of
|
---|
51 | * 10<sup>-7</sup> radians can allow calculation at these special cases. Snyder's restriction
|
---|
52 | * of the central latitude being 0.0 has been removed, since the equations appear
|
---|
53 | * to work correctly in this case.
|
---|
54 | * <p>
|
---|
55 | * Azimuth values of 0.0 and ±90.0 degrees are allowed (and used in Hungary
|
---|
56 | * and Switzerland), though these cases would usually use a Mercator or
|
---|
57 | * Transverse Mercator projection instead. Azimuth values > 90 degrees cause
|
---|
58 | * errors in the equations.
|
---|
59 | * <p>
|
---|
60 | * The oblique mercator is also called the "Rectified Skew Orthomorphic" (RSO). It appears
|
---|
61 | * is that the only difference from the oblique mercator is that the RSO allows the rotation
|
---|
62 | * from the (<var>U</var>,<var>V</var>) to (<var>X</var>,<var>Y</var>) coordinate system to
|
---|
63 | * be different from the azimuth. This separate parameter is called
|
---|
64 | * {@code "rectified_grid_angle"} (or {@code "XY_Plane_Rotation"} by ESRI) and is also
|
---|
65 | * included in the EPSG's parameters for the Oblique Mercator and Hotine Oblique Mercator.
|
---|
66 | * The rotation parameter is optional in all the non-two point projections and will be
|
---|
67 | * set to the azimuth if not specified.
|
---|
68 | * <p>
|
---|
69 | * Projection cases and aliases implemented by the {@link ObliqueMercator} are:
|
---|
70 | * <ul>
|
---|
71 | * <li>{@code Oblique_Mercator} (EPSG code 9815)<br>
|
---|
72 | * grid coordinates begin at the central point,
|
---|
73 | * has {@code "rectified_grid_angle"} parameter.</li>
|
---|
74 | * <li>{@code Hotine_Oblique_Mercator_Azimuth_Center} (ESRI)<br>
|
---|
75 | * grid coordinates begin at the central point.</li>
|
---|
76 | * <li>{@code Rectified_Skew_Orthomorphic_Center} (ESRI)<br>
|
---|
77 | * grid coordinates begin at the central point,
|
---|
78 | * has {@code "rectified_grid_angle"} parameter.</li>
|
---|
79 | *
|
---|
80 | * <li>{@code Hotine_Oblique_Mercator} (EPSG code 9812)<br>
|
---|
81 | * grid coordinates begin at the interseciton of the central line and aposphere equator,
|
---|
82 | * has {@code "rectified_grid_angle"} parameter.</li>
|
---|
83 | * <li>{@code Hotine_Oblique_Mercator_Azimuth_Natural_Origin} (ESRI)<br>
|
---|
84 | * grid coordinates begin at the interseciton of the central line and aposphere equator.</li>
|
---|
85 | * <li>{@code Rectified_Skew_Orthomorphic_Natural_Origin} (ESRI)<br>
|
---|
86 | * grid coordinates begin at the interseciton of the central line and aposphere equator,
|
---|
87 | * has {@code "rectified_grid_angle"} parameter.</li>
|
---|
88 | *
|
---|
89 | * <li>{@code Hotine_Oblique_Mercator_Two_Point_Center} (ESRI)<br>
|
---|
90 | * grid coordinates begin at the central point.</li>
|
---|
91 | * <li>{@code Hotine_Oblique_Mercator_Two_Point_Natural_Origin} (ESRI)<br>
|
---|
92 | * grid coordinates begin at the interseciton of the central line and aposphere equator.</li>
|
---|
93 | * </ul>
|
---|
94 | * <p>
|
---|
95 | * This class has been derived from the implementation of the Geotools project;
|
---|
96 | * git 8cbf52d, org.geotools.referencing.operation.projection.ObliqueMercator
|
---|
97 | * at the time of migration.
|
---|
98 | * <p>
|
---|
99 | * Note that automatic calculation of bounds is very limited for this projection,
|
---|
100 | * since the central line can have any orientation.
|
---|
101 | * <p>
|
---|
102 | * <b>References:</b>
|
---|
103 | * <ul>
|
---|
104 | * <li>{@code libproj4} is available at
|
---|
105 | * <A HREF="http://members.bellatlantic.net/~vze2hc4d/proj4/">libproj4 Miscellanea</A><br>
|
---|
106 | * Relevent files are: {@code PJ_omerc.c}, {@code pj_tsfn.c},
|
---|
107 | * {@code pj_fwd.c}, {@code pj_inv.c} and {@code lib_proj.h}</li>
|
---|
108 | * <li>John P. Snyder (Map Projections - A Working Manual,
|
---|
109 | * U.S. Geological Survey Professional Paper 1395, 1987)</li>
|
---|
110 | * <li>"Coordinate Conversions and Transformations including Formulas",
|
---|
111 | * EPSG Guidence Note Number 7 part 2, Version 24.</li>
|
---|
112 | * <li>Gerald Evenden, 2004, <a href="http://members.verizon.net/~vze2hc4d/proj4/omerc.pdf">
|
---|
113 | * Documentation of revised Oblique Mercator</a></li>
|
---|
114 | * </ul>
|
---|
115 | *
|
---|
116 | * @author Gerald I. Evenden (for original code in Proj4)
|
---|
117 | * @author Rueben Schulz
|
---|
118 | *
|
---|
119 | * @see <A HREF="http://mathworld.wolfram.com/MercatorProjection.html">Oblique Mercator projection on MathWorld</A>
|
---|
120 | * @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/hotine_oblique_mercator.html">"hotine_oblique_mercator" on RemoteSensing.org</A>
|
---|
121 | * @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/oblique_mercator.html">"oblique_mercator" on RemoteSensing.org</A>
|
---|
122 | */
|
---|
123 | public class ObliqueMercator extends AbstractProj implements ICentralMeridianProvider {
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * Maximum difference allowed when comparing real numbers.
|
---|
127 | */
|
---|
128 | private static final double EPSILON = 1E-6;
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * Maximum difference allowed when comparing latitudes.
|
---|
132 | */
|
---|
133 | private static final double EPSILON_LATITUDE = 1E-10;
|
---|
134 |
|
---|
135 | //////
|
---|
136 | ////// Map projection parameters. The following are NOT used by the transformation
|
---|
137 | ////// methods, but are stored in order to restitute them in WKT formatting. They
|
---|
138 | ////// are made visible ('protected' access) for documentation purpose and because
|
---|
139 | ////// they are user-supplied parameters, not derived coefficients.
|
---|
140 | //////
|
---|
141 |
|
---|
142 | /**
|
---|
143 | * The azimuth of the central line passing throught the centre of the projection, in radians.
|
---|
144 | */
|
---|
145 | protected double azimuth;
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * The rectified bearing of the central line, in radians. This is equals to the
|
---|
149 | * {@linkplain #azimuth} if the parameter value is not set.
|
---|
150 | */
|
---|
151 | protected double rectifiedGridAngle;
|
---|
152 |
|
---|
153 | //////
|
---|
154 | ////// Map projection coefficients computed from the above parameters.
|
---|
155 | ////// They are the fields used for coordinate transformations.
|
---|
156 | //////
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Constants used in the transformation.
|
---|
160 | */
|
---|
161 | private double B, A, E;
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Convenience values equal to {@link #A} / {@link #B},
|
---|
165 | * {@link #A}×{@link #B}, and {@link #B} / {@link #A}.
|
---|
166 | */
|
---|
167 | private double ArB, AB, BrA;
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * <var>v</var> values when the input latitude is a pole.
|
---|
171 | */
|
---|
172 | private double v_pole_n, v_pole_s;
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Sine and Cosine values for gamma0 (the angle between the meridian
|
---|
176 | * and central line at the intersection between the central line and
|
---|
177 | * the Earth equator on aposphere).
|
---|
178 | */
|
---|
179 | private double singamma0, cosgamma0;
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Sine and Cosine values for the rotation between (U,V) and
|
---|
183 | * (X,Y) coordinate systems
|
---|
184 | */
|
---|
185 | private double sinrot, cosrot;
|
---|
186 |
|
---|
187 | /**
|
---|
188 | * <var>u</var> value (in (U,V) coordinate system) of the central point. Used in
|
---|
189 | * the oblique mercator case. The <var>v</var> value of the central point is 0.0.
|
---|
190 | */
|
---|
191 | private double u_c;
|
---|
192 |
|
---|
193 | /**
|
---|
194 | * Central longitude in <u>radians</u>. Default value is 0, the Greenwich meridian.
|
---|
195 | * This is called '<var>lambda0</var>' in Snyder.
|
---|
196 | */
|
---|
197 | protected double centralMeridian;
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * A reference point, which is known to be on the central line.
|
---|
201 | */
|
---|
202 | private LatLon referencePoint;
|
---|
203 |
|
---|
204 | @Override
|
---|
205 | public String getName() {
|
---|
206 | return tr("Oblique Mercator");
|
---|
207 | }
|
---|
208 |
|
---|
209 | @Override
|
---|
210 | public String getProj4Id() {
|
---|
211 | return "omerc";
|
---|
212 | }
|
---|
213 |
|
---|
214 | @Override
|
---|
215 | public void initialize(ProjParameters params) throws ProjectionConfigurationException {
|
---|
216 | super.initialize(params);
|
---|
217 | boolean twoPoint = params.alpha == null;
|
---|
218 |
|
---|
219 | double latCenter = 0;
|
---|
220 | if (params.lat0 != null) {
|
---|
221 | latCenter = Math.toRadians(params.lat0);
|
---|
222 | }
|
---|
223 |
|
---|
224 | final double com = Math.sqrt(1.0 - e2);
|
---|
225 | double sinph0 = Math.sin(latCenter);
|
---|
226 | double cosph0 = Math.cos(latCenter);
|
---|
227 | final double con = 1. - e2 * sinph0 * sinph0;
|
---|
228 | double temp = cosph0 * cosph0;
|
---|
229 | B = Math.sqrt(1.0 + e2 * (temp * temp) / (1.0 - e2));
|
---|
230 | A = B * com / con;
|
---|
231 | final double D = B * com / (cosph0 * Math.sqrt(con));
|
---|
232 | double F = D * D - 1.0;
|
---|
233 | if (F < 0.0) {
|
---|
234 | F = 0.0;
|
---|
235 | } else {
|
---|
236 | F = Math.sqrt(F);
|
---|
237 | if (latCenter < 0.0) {
|
---|
238 | F = -F;
|
---|
239 | }
|
---|
240 | }
|
---|
241 | E = F += D;
|
---|
242 | E = F * Math.pow(tsfn(latCenter, sinph0), B);
|
---|
243 |
|
---|
244 | /*
|
---|
245 | * Computes the constants that depend on the "twoPoint" vs "azimuth" case. In the
|
---|
246 | * two points case, we compute them from (LAT_OF_1ST_POINT, LONG_OF_1ST_POINT) and
|
---|
247 | * (LAT_OF_2ND_POINT, LONG_OF_2ND_POINT). For the "azimuth" case, we compute them
|
---|
248 | * from LONGITUDE_OF_CENTRE and AZIMUTH.
|
---|
249 | */
|
---|
250 | final double gamma0;
|
---|
251 | Double lonCenter = null;
|
---|
252 | if (twoPoint) {
|
---|
253 | if (params.lon1 == null)
|
---|
254 | throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lon_1"));
|
---|
255 | if (params.lat1 == null)
|
---|
256 | throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_1"));
|
---|
257 | if (params.lon2 == null)
|
---|
258 | throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lon_2"));
|
---|
259 | if (params.lat2 == null)
|
---|
260 | throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_2"));
|
---|
261 | referencePoint = new LatLon(params.lat1, params.lat2);
|
---|
262 | double lon1 = Math.toRadians(params.lon1);
|
---|
263 | double lat1 = Math.toRadians(params.lat1);
|
---|
264 | double lon2 = Math.toRadians(params.lon2);
|
---|
265 | double lat2 = Math.toRadians(params.lat2);
|
---|
266 |
|
---|
267 | if (Math.abs(lat1 - lat2) <= EPSILON ||
|
---|
268 | Math.abs(lat1) <= EPSILON ||
|
---|
269 | Math.abs(Math.abs(lat1) - Math.PI / 2) <= EPSILON ||
|
---|
270 | Math.abs(Math.abs(latCenter) - Math.PI / 2) <= EPSILON ||
|
---|
271 | Math.abs(Math.abs(lat2) - Math.PI / 2) <= EPSILON) {
|
---|
272 | throw new ProjectionConfigurationException(
|
---|
273 | tr("Unsuitable parameters ''{0}'' and ''{1}'' for two point method.", "lat_1", "lat_2"));
|
---|
274 | }
|
---|
275 | /*
|
---|
276 | * The coefficients for the "two points" case.
|
---|
277 | */
|
---|
278 | final double H = Math.pow(tsfn(lat1, Math.sin(lat1)), B);
|
---|
279 | final double L = Math.pow(tsfn(lat2, Math.sin(lat2)), B);
|
---|
280 | final double Fp = E / H;
|
---|
281 | final double P = (L - H) / (L + H);
|
---|
282 | double J = E * E;
|
---|
283 | J = (J - L * H) / (J + L * H);
|
---|
284 | double diff = lon1 - lon2;
|
---|
285 | if (diff < -Math.PI) {
|
---|
286 | lon2 -= 2.0 * Math.PI;
|
---|
287 | } else if (diff > Math.PI) {
|
---|
288 | lon2 += 2.0 * Math.PI;
|
---|
289 | }
|
---|
290 | centralMeridian = normalizeLon(0.5 * (lon1 + lon2) -
|
---|
291 | Math.atan(J * Math.tan(0.5 * B * (lon1 - lon2)) / P) / B);
|
---|
292 | gamma0 = Math.atan(2.0 * Math.sin(B * normalizeLon(lon1 - centralMeridian)) /
|
---|
293 | (Fp - 1.0 / Fp));
|
---|
294 | azimuth = Math.asin(D * Math.sin(gamma0));
|
---|
295 | rectifiedGridAngle = azimuth;
|
---|
296 | } else {
|
---|
297 | if (params.lonc == null)
|
---|
298 | throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lonc"));
|
---|
299 | if (params.lat0 == null)
|
---|
300 | throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_0"));
|
---|
301 | if (params.alpha == null)
|
---|
302 | throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "alpha"));
|
---|
303 | referencePoint = new LatLon(params.lat0, params.lonc);
|
---|
304 |
|
---|
305 | lonCenter = Math.toRadians(params.lonc);
|
---|
306 | azimuth = Math.toRadians(params.alpha);
|
---|
307 | if ((azimuth > -1.5*Math.PI && azimuth < -0.5*Math.PI) ||
|
---|
308 | (azimuth > 0.5*Math.PI && azimuth < 1.5*Math.PI)) {
|
---|
309 | throw new ProjectionConfigurationException(
|
---|
310 | tr("Illegal value for parameter ''{0}'': {1}", "alpha", Double.toString(params.alpha)));
|
---|
311 | }
|
---|
312 | if (params.gamma != null) {
|
---|
313 | rectifiedGridAngle = Math.toRadians(params.gamma);
|
---|
314 | } else {
|
---|
315 | rectifiedGridAngle = azimuth;
|
---|
316 | }
|
---|
317 | gamma0 = Math.asin(Math.sin(azimuth) / D);
|
---|
318 | // Check for asin(+-1.00000001)
|
---|
319 | temp = 0.5 * (F - 1.0 / F) * Math.tan(gamma0);
|
---|
320 | if (Math.abs(temp) > 1.0) {
|
---|
321 | if (Math.abs(Math.abs(temp) - 1.0) > EPSILON) {
|
---|
322 | throw new ProjectionConfigurationException(tr("error in initialization"));
|
---|
323 | }
|
---|
324 | temp = (temp > 0) ? 1.0 : -1.0;
|
---|
325 | }
|
---|
326 | centralMeridian = lonCenter - Math.asin(temp) / B;
|
---|
327 | }
|
---|
328 |
|
---|
329 | /*
|
---|
330 | * More coefficients common to all kind of oblique mercator.
|
---|
331 | */
|
---|
332 | singamma0 = Math.sin(gamma0);
|
---|
333 | cosgamma0 = Math.cos(gamma0);
|
---|
334 | sinrot = Math.sin(rectifiedGridAngle);
|
---|
335 | cosrot = Math.cos(rectifiedGridAngle);
|
---|
336 | ArB = A / B;
|
---|
337 | AB = A * B;
|
---|
338 | BrA = B / A;
|
---|
339 | v_pole_n = ArB * Math.log(Math.tan(0.5 * (Math.PI/2.0 - gamma0)));
|
---|
340 | v_pole_s = ArB * Math.log(Math.tan(0.5 * (Math.PI/2.0 + gamma0)));
|
---|
341 | boolean hotine = params.no_off != null && params.no_off;
|
---|
342 | if (hotine) {
|
---|
343 | u_c = 0.0;
|
---|
344 | } else {
|
---|
345 | if (Math.abs(Math.abs(azimuth) - Math.PI/2.0) < EPSILON_LATITUDE) {
|
---|
346 | // lonCenter == null in twoPoint, but azimuth cannot be 90 here (lat1 != lat2)
|
---|
347 | if (lonCenter == null) {
|
---|
348 | throw new ProjectionConfigurationException("assertion error");
|
---|
349 | }
|
---|
350 | u_c = A * (lonCenter - centralMeridian);
|
---|
351 | } else {
|
---|
352 | double u_c = Math.abs(ArB * Math.atan2(Math.sqrt(D * D - 1.0), Math.cos(azimuth)));
|
---|
353 | if (latCenter < 0.0) {
|
---|
354 | u_c = -u_c;
|
---|
355 | }
|
---|
356 | this.u_c = u_c;
|
---|
357 | }
|
---|
358 | }
|
---|
359 | }
|
---|
360 |
|
---|
361 | @Override
|
---|
362 | public double[] project(double y, double x) {
|
---|
363 | x = normalizeLon(x);
|
---|
364 | double u, v;
|
---|
365 | if (Math.abs(Math.abs(y) - Math.PI/2.0) > EPSILON) {
|
---|
366 | double Q = E / Math.pow(tsfn(y, Math.sin(y)), B);
|
---|
367 | double temp = 1.0 / Q;
|
---|
368 | double S = 0.5 * (Q - temp);
|
---|
369 | double V = Math.sin(B * x);
|
---|
370 | double U = (S * singamma0 - V * cosgamma0) / (0.5 * (Q + temp));
|
---|
371 | if (Math.abs(Math.abs(U) - 1.0) < EPSILON) {
|
---|
372 | v = 0; // this is actually an error and should be reported to the caller somehow
|
---|
373 | } else {
|
---|
374 | v = 0.5 * ArB * Math.log((1.0 - U) / (1.0 + U));
|
---|
375 | }
|
---|
376 | temp = Math.cos(B * x);
|
---|
377 | if (Math.abs(temp) < EPSILON_LATITUDE) {
|
---|
378 | u = AB * x;
|
---|
379 | } else {
|
---|
380 | u = ArB * Math.atan2((S * cosgamma0 + V * singamma0), temp);
|
---|
381 | }
|
---|
382 | } else {
|
---|
383 | v = y > 0 ? v_pole_n : v_pole_s;
|
---|
384 | u = ArB * y;
|
---|
385 | }
|
---|
386 | u -= u_c;
|
---|
387 | x = v * cosrot + u * sinrot;
|
---|
388 | y = u * cosrot - v * sinrot;
|
---|
389 | return new double[] {x, y};
|
---|
390 | }
|
---|
391 |
|
---|
392 | @Override
|
---|
393 | public double[] invproject(double x, double y) {
|
---|
394 | double v = x * cosrot - y * sinrot;
|
---|
395 | double u = y * cosrot + x * sinrot + u_c;
|
---|
396 | double Qp = Math.exp(-BrA * v);
|
---|
397 | double temp = 1.0 / Qp;
|
---|
398 | double Sp = 0.5 * (Qp - temp);
|
---|
399 | double Vp = Math.sin(BrA * u);
|
---|
400 | double Up = (Vp * cosgamma0 + Sp * singamma0) / (0.5 * (Qp + temp));
|
---|
401 | if (Math.abs(Math.abs(Up) - 1.0) < EPSILON) {
|
---|
402 | x = 0.0;
|
---|
403 | y = Up < 0.0 ? -Math.PI / 2.0 : Math.PI / 2.0;
|
---|
404 | } else {
|
---|
405 | y = Math.pow(E / Math.sqrt((1. + Up) / (1. - Up)), 1.0 / B); //calculate t
|
---|
406 | y = cphi2(y);
|
---|
407 | x = -Math.atan2((Sp * cosgamma0 - Vp * singamma0), Math.cos(BrA * u)) / B;
|
---|
408 | }
|
---|
409 | return new double[] {y, x};
|
---|
410 | }
|
---|
411 |
|
---|
412 | @Override
|
---|
413 | public Bounds getAlgorithmBounds() {
|
---|
414 | // The central line of this projection can be oriented in any direction.
|
---|
415 | // Moreover, the projection doesn't work too well very far off the central line.
|
---|
416 | // This makes it hard to choose proper bounds automatically.
|
---|
417 | //
|
---|
418 | // We return a small box around a reference point. This default box is
|
---|
419 | // probably too small for most applications. If this is the case, the
|
---|
420 | // bounds should be configured explicitly.
|
---|
421 | double lat = referencePoint.lat();
|
---|
422 | double dLat = 3.0;
|
---|
423 | double lon = referencePoint.lon() - Math.toDegrees(centralMeridian);
|
---|
424 | double dLon = 3.0;
|
---|
425 | return new Bounds(lat - dLat, lon - dLon, lat + dLat, lon + dLon, false);
|
---|
426 | }
|
---|
427 |
|
---|
428 | @Override
|
---|
429 | public double getCentralMeridian() {
|
---|
430 | return Math.toDegrees(centralMeridian);
|
---|
431 | }
|
---|
432 | }
|
---|