1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| static int LambertConformalConic_Sphere_Geo_to_Rect(
double radius,
double lat_1,
double lat_2,
double lat_0,
double long_0,
double latitude,
double longitude,
double *x,
double *y,
double *h_scale,
double *k_scale)
{
double
delta_long,
Ro,Ro_0,
Theta,
F,n,
tmp,
Lat1, Lat2, Lat0,Long0,Lat,Long;
Long0 = long_0 ;
Lat0 = lat_0 ;
Lat1 = lat_1 ;
Lat2 = lat_2 ;
Lat = latitude ;
Long = longitude ;
validate_longitude(&Long0);
validate_longitude(&Long);
validate_latitude(&Lat);
validate_latitude(&Lat0);
validate_latitude(&Lat1);
validate_latitude(&Lat2);
delta_long = Long - Long0;
Long0 *= DEGREE_TO_RADIAN;
Lat0 *= DEGREE_TO_RADIAN;
Lat1 *= DEGREE_TO_RADIAN;
Lat2 *= DEGREE_TO_RADIAN;
Long *= DEGREE_TO_RADIAN;
Lat *= DEGREE_TO_RADIAN;
delta_long *= DEGREE_TO_RADIAN;
/* Calculate n, formula 15-3 */
if ( fabs(lat_1 - lat_2) < ACCURACY_DOUBLE )
{
/* Then only one standard parallel */
n = sin(Lat1);
}
else
{
tmp = tan( PI_DIV_4 + (Lat1/2.0));
tmp = tan( PI_DIV_4 + (Lat2/2.0)) / tmp;
tmp = log(tmp);
n = log(cos(Lat1) / cos(Lat2)) / tmp ;
}
tmp = tan(PI_DIV_4 + (Lat1/2.0));
tmp = cos(Lat1) * pow(tmp,n);
F = tmp / n; /* formula 15-2 */
tmp = tan(PI_DIV_4 + (Lat0/2.0));
Ro_0 = (radius * F) / pow(tmp , n); /* formula 15-1a */
Theta = n * delta_long; /* formula 14-4 */
tmp = tan(PI_DIV_4 + (Lat / 2.0) ) ;
Ro = (radius * F) / pow(tmp , n); /* formula 15-1 */
*x = Ro * sin(Theta); /* formula 14-1 */
*y = Ro_0 - (Ro * cos(Theta)); /* formula 14-2 */
tmp = tan(PI_DIV_4 + (Lat/2.0));
tmp = cos(Lat) * pow(tmp,n);
*h_scale = cos(Lat1) * pow(tan(PI_DIV_4 + (Lat1/2.0)), n)/ tmp;
*k_scale = *h_scale; /* formula 15-4 */
return NO_ERROR;
} /* end LambertConformalConic_Sphere_Geo_to_Rect */ |
Partager