98 using namespace MSP::CCS;
106 const double PI = 3.14159265358979323e0;
113 return coeff * sin(x * latit);
117 double floatEq(
double x,
double v,
double epsilon )
119 return ((v - epsilon) < x) && (x < (v + epsilon));
128 Sinusoidal::Sinusoidal(
double ellipsoidSemiMajorAxis,
double ellipsoidFlattening,
double centralMeridian,
double falseEasting,
double falseNorthing ) :
130 es2( 0.0066943799901413800 ),
131 es4( 4.4814723452405e-005 ),
132 es6( 3.0000678794350e-007 ),
133 c0( .99832429845280 ),
134 c1( .0025146070605187 ),
135 c2( 2.6390465943377e-006 ),
136 c3( 3.4180460865959e-009 ),
137 a0( .0025188265843907 ),
138 a1( 3.7009490356205e-006 ),
139 a2( 7.4478137675038e-009 ),
140 a3( 1.7035993238596e-011 ),
141 Sinu_Origin_Long( 0.0 ),
142 Sinu_False_Easting( 0.0 ),
143 Sinu_False_Northing( 0.0 ),
144 Sinu_Max_Easting( 20037509.0 ),
145 Sinu_Min_Easting( -20037509.0 ),
146 Sinu_Delta_Northing( 10001966.0 )
165 double One_MINUS_es2, Sqrt_One_MINUS_es2, e1, e2, e3, e4;
166 double inv_f = 1 / ellipsoidFlattening;
168 if (ellipsoidSemiMajorAxis <= 0.0)
172 if ((inv_f < 250) || (inv_f > 350))
176 if ((centralMeridian < -
PI) || (centralMeridian >
TWO_PI))
187 j = 45.0 * es6 / 1024.0;
188 c0 = 1.0 - es2 / 4.0 - 3.0 * es4 / 64.0 - 5.0 * es6 / 256.0;
189 c1 = 3.0 * es2 / 8.0 + 3.0 * es4 / 32.0 + j;
190 c2 = 15.0 * es4 / 256.0 + j;
191 c3 = 35.0 * es6 / 3072.0;
192 One_MINUS_es2 = 1.0 - es2;
193 Sqrt_One_MINUS_es2 = sqrt(One_MINUS_es2);
194 e1 = (1.0 - Sqrt_One_MINUS_es2) / (1.0 + Sqrt_One_MINUS_es2);
198 a0 = 3.0 * e1 / 2.0 - 27.0 * e3 / 32.0 ;
199 a1 = 21.0 * e2 / 16.0 - 55.0 * e4 / 32.0;
200 a2 = 151.0 * e3 / 96.0;
201 a3 = 1097.0 * e4 / 512.0;
202 if (centralMeridian >
PI)
203 centralMeridian -=
TWO_PI;
204 Sinu_Origin_Long = centralMeridian;
205 Sinu_False_Northing = falseNorthing;
206 Sinu_False_Easting = falseEasting;
208 if (Sinu_Origin_Long > 0)
210 Sinu_Max_Easting = 19926189.0;
211 Sinu_Min_Easting = -20037509.0;
213 else if (Sinu_Origin_Long < 0)
215 Sinu_Max_Easting = 20037509.0;
216 Sinu_Min_Easting = -19926189.0;
220 Sinu_Max_Easting = 20037509.0;
221 Sinu_Min_Easting = -20037509.0;
241 Sinu_Origin_Long = s.Sinu_Origin_Long;
242 Sinu_False_Easting = s.Sinu_False_Easting;
243 Sinu_False_Northing = s.Sinu_False_Northing;
244 Sinu_Max_Easting = s.Sinu_Max_Easting;
245 Sinu_Min_Easting = s.Sinu_Min_Easting;
246 Sinu_Delta_Northing = s.Sinu_Delta_Northing;
272 Sinu_Origin_Long = s.Sinu_Origin_Long;
273 Sinu_False_Easting = s.Sinu_False_Easting;
274 Sinu_False_Northing = s.Sinu_False_Northing;
275 Sinu_Max_Easting = s.Sinu_Max_Easting;
276 Sinu_Min_Easting = s.Sinu_Min_Easting;
277 Sinu_Delta_Northing = s.Sinu_Delta_Northing;
304 Sinu_False_Northing );
324 double sin2lat, sin4lat, sin6lat;
329 double longitude = geodeticCoordinates->
longitude();
330 double latitude = geodeticCoordinates->
latitude();
331 double slat = sin(latitude);
337 if ((longitude < -
PI) || (longitude >
TWO_PI))
342 dlam = longitude - Sinu_Origin_Long;
351 mm = sqrt(1.0 - es2 * slat * slat);
356 MM =
semiMajorAxis * (c0 * latitude - sin2lat + sin4lat - sin6lat);
358 double easting =
semiMajorAxis * dlam * cos(latitude) / mm + Sinu_False_Easting;
359 double northing = MM + Sinu_False_Northing;
383 double sin2mu, sin4mu, sin6mu, sin8mu;
385 double longitude, latitude;
387 double easting = mapProjectionCoordinates->
easting();
388 double northing = mapProjectionCoordinates->
northing();
390 if ((easting < (Sinu_False_Easting + Sinu_Min_Easting))
391 || (easting > (Sinu_False_Easting + Sinu_Max_Easting)))
395 if ((northing < (Sinu_False_Northing - Sinu_Delta_Northing))
396 || (northing > (Sinu_False_Northing + Sinu_Delta_Northing)))
401 dy = northing - Sinu_False_Northing;
402 dx = easting - Sinu_False_Easting;
409 latitude = mu + sin2mu + sin4mu + sin6mu + sin8mu;
417 longitude = Sinu_Origin_Long;
420 sin_lat = sin(latitude);
421 longitude = Sinu_Origin_Long + dx * sqrt(1.0 - es2 *
432 else if (longitude < -
PI)