Changeset 8715


Ignore:
Timestamp:
06/24/11 14:15:04 (14 years ago)
Author:
jschierm
Message:

Extract defaults from Xy2llx and Ll2xyx into separate functions (and fix reformatting).

Location:
issm/trunk/src/c/modules
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.cpp

    r8706 r8715  
    2222%                               -1 : south latitude (default is mer=0  lat=71)
    2323*/
    24         double  delta,slat;
    25         bool    flag=true;
     24        double  central_meridian,standard_parallel;
    2625
    27         /*  Get central_meridian and standard_parallel depending on hemisphere  */
    28         if (sgn ==  1) {
    29                 delta= 45;
    30                 slat = 70;
    31                 _printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).\n");
    32         }
    33         else if (sgn == -1) {
    34                 delta= 0;
    35                 slat = 71;
    36                 _printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).\n");
    37         }
    38         else _error_("Sign should be either +1 or -1.\n");
     26        Ll2xydef(&central_meridian,&standard_parallel,sgn);
    3927
    40         return(Ll2xyx(x,y, lat,lon,ncoord, sgn,delta,slat));
     28        return(Ll2xyx(x,y,lat,lon,ncoord,sgn,central_meridian,standard_parallel));
    4129}
    4230
     
    5947        int     i,iret=0;
    6048        double  delta,slat;
    61         double  cde,re,ex2,ex,pi;
     49        double  cde,re,ex2,ex;
    6250        double  latitude,longitude;
    6351        double  T,rho,sl,tc,mc;
     
    10593        return(iret);
    10694}
     95
     96void Ll2xydef(double* pdelta, double* pslat, int sgn){
     97/*  This is a cpp conversion of the following:
     98%LL2XY - converts lat long to polar stereographic
     99%
     100%   Converts from geodetic latitude and longitude to Polar
     101%   Stereographic (X,Y) coordinates for the polar regions.
     102%   Author: Michael P. Schodlok, December 2003 (map2ll)
     103%
     104%   Usage:
     105%      [x,y] = ll2xy(lat,lon,sgn)
     106%      [x,y] = ll2xy(lat,lon,sgn,central_meridian,standard_parallel)
     107%
     108%      - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70)
     109%                               -1 : south latitude (default is mer=0  lat=71)
     110*/
     111        bool    flag=true;
     112
     113        /*  Get central_meridian and standard_parallel depending on hemisphere  */
     114        if (sgn ==  1) {
     115                *pdelta= 45;
     116                *pslat = 70;
     117                _printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).\n");
     118        }
     119        else if (sgn == -1) {
     120                *pdelta= 0;
     121                *pslat = 71;
     122                _printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).\n");
     123        }
     124        else _error_("Sign should be either +1 or -1.\n");
     125
     126        return;
     127}
  • issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.h

    r8698 r8715  
    99int Ll2xyx(double* x, double* y, double* lat, double* lon, int ncoord, int sgn);
    1010int Ll2xyx(double* x, double* y, double* lat, double* lon, int ncoord, int sgn, double central_meridian, double standard_parallel);
     11void Ll2xydef(double* pdelta, double* pslat, int sgn);
    1112
    1213#endif  /* _LL2XYX_H */
  • issm/trunk/src/c/modules/Xy2llx/Xy2llx.cpp

    r8698 r8715  
    2323%                               -1 : south latitude (default is mer=0  lat=71)
    2424*/
     25        double  central_meridian,standard_parallel;
    2526
    26         double  delta,slat;
    27         bool    flag=true;
     27        Xy2lldef(&central_meridian,&standard_parallel,sgn);
    2828
    29         /*  Get central_meridian and standard_parallel depending on hemisphere  */
    30         if (sgn == 1) {
    31                 delta= 45;
    32                 slat = 70;
    33                 _printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).\n");
    34         }
    35         else if (sgn == -1) {
    36                 delta= 0;
    37                 slat = 71;
    38                 _printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).\n");
    39         }
    40         else _error_("Sign should be either +1 or -1.\n");
    41 
    42         return(Xy2llx(lat,lon,x,y,ncoord,sgn,delta,slat));
     29        return(Xy2llx(lat,lon,x,y,ncoord,sgn,central_meridian,standard_parallel));
    4330}
    4431
     
    6249        int     i,iret=0;
    6350        double  delta,slat;
    64         double  cde,re,ex2,ex,pi;
     51        double  cde,re,ex2,ex;
    6552        double  sl,rho,cm,T,chi;
    6653
     
    10693                }
    10794
    108                 lon[i] = lon[i] * 180. / pi;
    109                 lat[i] = lat[i] * 180. / pi;
     95                lon[i] = lon[i] * 180. / PI;
     96                lat[i] = lat[i] * 180. / PI;
    11097                lon[i] = lon[i] - delta;
    11198        }
     
    113100        return(iret);
    114101}
     102
     103void Xy2lldef(double* pdelta, double* pslat, int sgn){
     104/*  This is a cpp conversion of the following:
     105%XY2LL - converts xy to lat long
     106%
     107%   Converts Polar  Stereographic (X,Y) coordinates for the polar regions to
     108%   latitude and longitude Stereographic (X,Y) coordinates for the polar
     109%   regions.
     110%   Author: Michael P. Schodlok, December 2003 (map2xy.m)
     111%
     112%   Usage:
     113%      [lat,lon] = xy2ll(x,y,sgn);
     114%      [lat,lon] = xy2ll(x,y,sgn,central_meridian,standard_parallel);
     115%
     116%      - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70)
     117%                               -1 : south latitude (default is mer=0  lat=71)
     118*/
     119        bool    flag=true;
     120
     121        /*  Get central_meridian and standard_parallel depending on hemisphere  */
     122        if (sgn == 1) {
     123                *pdelta= 45;
     124                *pslat = 70;
     125                _printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).\n");
     126        }
     127        else if (sgn == -1) {
     128                *pdelta= 0;
     129                *pslat = 71;
     130                _printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).\n");
     131        }
     132        else _error_("Sign should be either +1 or -1.\n");
     133
     134        return;
     135}
  • issm/trunk/src/c/modules/Xy2llx/Xy2llx.h

    r8698 r8715  
    99int Xy2llx(double* lat, double* lon, double* x, double* y, int ncoord, int sgn);
    1010int Xy2llx(double* lat, double* lon, double* x, double* y, int ncoord, int sgn, double central_meridian, double standard_parallel);
     11void Xy2lldef(double* pdelta, double* pslat, int sgn);
    1112
    1213#endif  /* _XY2LLX_H */
Note: See TracChangeset for help on using the changeset viewer.