105 using namespace MSP::CCS;
113 const double PI = 3.14159265358979323e0;
120 return coeff * (sin(x * latit));
129 Bonne::Bonne(
double ellipsoidSemiMajorAxis,
double ellipsoidFlattening,
double centralMeridian,
double originLatitude,
double falseEasting,
double falseNorthing ) :
132 es2( 0.0066943799901413800 ),
133 es4( 4.4814723452405e-005 ),
134 es6( 3.0000678794350e-007 ),
135 M1( 4984944.3782319 ),
136 m1( .70829317069372 ),
137 c0( .99832429845280 ),
138 c1( .0025146070605187 ),
139 c2( 2.6390465943377e-006 ),
140 c3( 3.4180460865959e-009 ),
141 a0( .0025188265843907 ),
142 a1( 3.7009490356205e-006 ),
143 a2( 7.4478137675038e-009 ),
144 a3( 1.7035993238596e-011 ),
145 Bonn_Origin_Long( 0.0 ),
146 Bonn_Origin_Lat( ((45 *
PI) / 180.0) ),
147 Bonn_False_Easting( 0.0 ),
148 Bonn_False_Northing( 0.0 ),
149 Sin_Bonn_Origin_Lat( .70710678118655 ),
150 Bonn_am1sin( 6388838.2901211 ),
151 Bonn_Max_Easting( 20027474.0 ),
152 Bonn_Min_Easting( -20027474.0 ),
153 Bonn_Delta_Northing( 20003932.0 )
174 double x,e1,e2,e3,e4;
176 double sin2lat, sin4lat, sin6lat, lat;
177 double inv_f = 1 / ellipsoidFlattening;
179 if (ellipsoidSemiMajorAxis <= 0.0)
183 if ((inv_f < 250) || (inv_f > 350))
191 if ((centralMeridian < -
PI) || (centralMeridian >
TWO_PI))
199 Bonn_Origin_Lat = originLatitude;
200 if (centralMeridian >
PI)
201 centralMeridian -=
TWO_PI;
202 Bonn_Origin_Long = centralMeridian;
203 Bonn_False_Northing = falseNorthing;
204 Bonn_False_Easting = falseEasting;
205 if (Bonn_Origin_Lat == 0.0)
207 if (Bonn_Origin_Long > 0)
209 Bonn_Max_Easting = 19926189.0;
210 Bonn_Min_Easting = -20037509.0;
212 else if (Bonn_Origin_Long < 0)
214 Bonn_Max_Easting = 20037509.0;
215 Bonn_Min_Easting = -19926189.0;
219 Bonn_Max_Easting = 20037509.0;
220 Bonn_Min_Easting = -20037509.0;
222 Bonn_Delta_Northing = 10001966.0;
228 Sin_Bonn_Origin_Lat = sin(Bonn_Origin_Lat);
233 j = 45.0 * es6 / 1024.0;
234 three_es4 = 3.0 * es4;
235 c0 = 1 - es2 / 4.0 - three_es4 / 64.0 - 5.0 * es6 / 256.0;
236 c1 = 3.0 * es2 / 8.0 + three_es4 / 32.0 + j;
237 c2 = 15.0 * es4 / 256.0 + j;
238 c3 = 35.0 * es6 / 3072.0;
240 clat = cos(Bonn_Origin_Lat);
241 m1 = bonnm(clat, Sin_Bonn_Origin_Lat);
243 lat = c0 * Bonn_Origin_Lat;
247 M1 = bonnM(lat, sin2lat, sin4lat, sin6lat);
249 x = sqrt (1.0 - es2);
250 e1 = (1.0 - x) / (1.0 + x);
254 a0 = 3.0 * e1 / 2.0 - 27.0 * e3 / 32.0;
255 a1 = 21.0 * e2 / 16.0 - 55.0 * e4 / 32.0;
256 a2 = 151.0 * e3 / 96.0;
257 a3 = 1097.0 * e4 / 512.0;
258 if (Sin_Bonn_Origin_Lat == 0.0)
263 Bonn_Max_Easting = 20027474.0;
264 Bonn_Min_Easting = -20027474.0;
265 Bonn_Delta_Northing = 20003932.0;
272 sinusoidal =
new Sinusoidal( *( b.sinusoidal ) );
288 Bonn_Origin_Long = b.Bonn_Origin_Long;
289 Bonn_Origin_Lat = b.Bonn_Origin_Lat;
290 Bonn_False_Easting = b.Bonn_False_Easting;
291 Bonn_False_Northing = b.Bonn_False_Northing;
292 Sin_Bonn_Origin_Lat = b.Sin_Bonn_Origin_Lat;
293 Bonn_am1sin = b.Bonn_am1sin;
294 Bonn_Max_Easting = b.Bonn_Max_Easting;
295 Bonn_Min_Easting = b.Bonn_Min_Easting;
296 Bonn_Delta_Northing = b.Bonn_Delta_Northing;
314 sinusoidal->operator=( *b.sinusoidal );
330 Bonn_Origin_Long = b.Bonn_Origin_Long;
331 Bonn_Origin_Lat = b.Bonn_Origin_Lat;
332 Bonn_False_Easting = b.Bonn_False_Easting;
333 Bonn_False_Northing = b.Bonn_False_Northing;
334 Sin_Bonn_Origin_Lat = b.Sin_Bonn_Origin_Lat;
335 Bonn_am1sin = b.Bonn_am1sin;
336 Bonn_Max_Easting = b.Bonn_Max_Easting;
337 Bonn_Min_Easting = b.Bonn_Min_Easting;
338 Bonn_Delta_Northing = b.Bonn_Delta_Northing;
387 double lat, sin2lat, sin4lat, sin6lat;
388 double easting, northing;
390 double longitude = geodeticCoordinates->
longitude();
391 double latitude = geodeticCoordinates->
latitude();
392 double clat = cos(latitude);
393 double slat = sin(latitude);
399 if ((longitude < -
PI) || (longitude >
TWO_PI))
404 if (Bonn_Origin_Lat == 0.0)
408 dlam = longitude - Bonn_Origin_Long;
417 if ((latitude - Bonn_Origin_Lat) == 0.0 && floatEq(fabs(latitude),
PI_OVER_2,.00001))
424 mm = bonnm(clat, slat);
429 MM = bonnM(lat, sin2lat, sin4lat, sin6lat);
431 rho = Bonn_am1sin + M1 - MM;
436 easting = rho * sin(EE) + Bonn_False_Easting;
437 northing = Bonn_am1sin - rho * cos(EE) + Bonn_False_Northing;
469 double sin2mu, sin4mu, sin6mu, sin8mu;
471 double longitude, latitude;
473 double easting = mapProjectionCoordinates->
easting();
474 double northing = mapProjectionCoordinates->
northing();
476 if ((easting < (Bonn_False_Easting + Bonn_Min_Easting))
477 || (easting > (Bonn_False_Easting + Bonn_Max_Easting)))
481 if ((northing < (Bonn_False_Northing - Bonn_Delta_Northing))
482 || (northing > (Bonn_False_Northing + Bonn_Delta_Northing)))
487 if (Bonn_Origin_Lat == 0.0)
491 dy = northing - Bonn_False_Northing;
492 dx = easting - Bonn_False_Easting;
493 am1sin_dy = Bonn_am1sin - dy;
494 rho = sqrt(dx * dx + am1sin_dy * am1sin_dy);
495 if (Bonn_Origin_Lat < 0.0)
497 MM = Bonn_am1sin + M1 - rho;
504 latitude = mu + sin2mu + sin4mu + sin6mu + sin8mu;
506 if (floatEq(fabs(latitude),
PI_OVER_2,.00001))
508 longitude = Bonn_Origin_Long;
512 clat = cos(latitude);
513 slat = sin(latitude);
514 mm = bonnm(clat, slat);
516 if (Bonn_Origin_Lat < 0.0)
519 am1sin_dy = -am1sin_dy;
521 longitude = Bonn_Origin_Long + rho * (atan2(dx, am1sin_dy)) /
537 else if (longitude < -
PI)
546 double Bonne::bonnm(
double coslat,
double sinlat )
548 return coslat/sqrt(1.0 - es2*sinlat*sinlat);
552 double Bonne::bonnM(
double c0lat,
double c1s2lat,
double c2s4lat,
double c3s6lat )
558 double Bonne::floatEq(
double x,
double v,
double epsilon )
560 return ((v - epsilon) < x) && (x < (v + epsilon));