/* * Copyright(c) 2008, Space Science and Engineering Center, UW-Madison * Refer to "McIDAS Software Acquisition and Distribution Policies" * in the file mcidas/data/license.txt */ /**** $Id: m0GenNavBlk.c,v 1.3 2012/03/08 21:49:36 russd Tst $ ****/ #include #include #include #include #include "mcidas.h" Fint ilalo_( float *); /* Name: ** m0GenNavBlk - make a McIDAS navigation block ** ** Interface: ** int m0GenNavBlk( char *projection, ** char *pole, ** float *parms, ** Fint *nav ** ) ** ** Input: ** projection projection name ** pole NORTH or SOUTH pole of planet ** parms navigation parameters ** ** Input and Output: ** none ** ** Output: ** nav navigation block ** ** Return values: ** 0 success ** -1 failed: invalid projection ** ** Remarks: ** valid projections are MERC ** ** Categories: ** adde ** image */ int m0GenNavBlk( char *projection, char *pole, float *parms, Fint *nav ) { /* internal variables */ char *nav_type; int i; int planet_radius = 6378137; int planet_eccentricity = 81819; static char trace_string[500]; /* print the input specifications */ (void *)sprintf(trace_string," m0GenNavBlk: NAV proj=%s pole=%s ",projection, pole ); M0sxtrce( trace_string ); for( i=0; i<10; i++ ) { (void *)sprintf(trace_string," parm[%d]=%f",i,parms[i]); M0sxtrce( trace_string ); } /* Mercator projection */ if( strncmp( projection, "MERC", 4 ) == 0 ) { nav_type = stralloc( "MERC", NULL ); memcpy( (void *)&nav[0], (void *)nav_type, 4); nav[1] = (int)parms[0]; nav[2] = (int)parms[1]; nav[3] = ilalo_( &parms[2] ); if( parms[4] < 1000.0 ) { nav[4] = (int)( parms[4]*1000.0 ); } else { nav[4] = (int)( parms[4]*.00057 ); } nav[5] = ilalo_( &parms[3] ); nav[6] = planet_radius; nav[7] = planet_eccentricity; (void *)sprintf(trace_string," nav[0]=MERC"); M0sxtrce( trace_string ); for( i=1; i<10; i++ ) { (void *)sprintf(trace_string," nav[%d]=%d",i,nav[i]); M0sxtrce( trace_string ); } /* Polar Sterographic projection */ } else if( strncmp( projection, "PS", 2 ) == 0 ) { nav_type = stralloc( "PS ", NULL ); memcpy( (void *)&nav[0], (void *)nav_type, 4); nav[1] = (int)parms[0]; nav[2] = (int)parms[1]; nav[3] = ilalo_( &parms[2] ); if( parms[4] < 1000.0 ) { nav[4] = (int)( parms[3]*1000.0 ); } else { nav[4] = (int)( parms[3]*.00057 ); } nav[5] = ilalo_( &parms[4] ); nav[6] = planet_radius; nav[7] = planet_eccentricity; nav[8] = 0; nav[9] = 0; nav[10]= 900000; (void *)sprintf(trace_string," nav[0]=PS"); M0sxtrce( trace_string ); for( i=1; i<12; i++ ) { (void *)sprintf(trace_string," nav[%d]=%d",i,nav[i]); M0sxtrce( trace_string ); } /* Lambert Conformal Conic projection */ } else if( strncmp( projection, "LAMB", 4 ) == 0 ) { nav_type = stralloc( "LAMB", NULL ); memcpy( (void *)&nav[0], (void *)nav_type, 4); nav[1] = (int)parms[0]; nav[2] = (int)parms[1]; nav[3] = ilalo_( &parms[2] ); nav[4] = ilalo_( &parms[3] ); if( parms[4] < 1000.0 ) { nav[5] = (int)( parms[4]*1000.0 ); } else { nav[5] = (int)( parms[4]*.00057 ); } nav[6] = ilalo_( &parms[5] ); nav[7] = planet_radius; nav[8] = planet_eccentricity; nav[9] = 0; nav[10] = 0; nav[11]= 900000; (void *)sprintf(trace_string," nav[0]=LAMB"); M0sxtrce( trace_string ); for( i=1; i<12; i++ ) { (void *)sprintf(trace_string," nav[%d]=%d",i,nav[i]); M0sxtrce( trace_string ); } /* Rectilinear projection */ } else if( strncmp( projection, "RECT", 4 ) == 0 ) { nav_type = stralloc( "RECT", NULL ); memcpy( (void *)&nav[0], (void *)nav_type, 4); nav[1] = (int)parms[0]; nav[2] = (int)(parms[1]*1000000.0); nav[3] = (int)parms[2]; nav[4] = (int)(parms[3]*1000000.0); nav[5] = (int)(parms[4]*100000000.0 +.5); nav[6] = (int)(parms[5]*100000000.0 +.5); nav[7] = planet_radius; nav[8] = planet_eccentricity; nav[9] = 0; nav[10] = 0; nav[11] = 6; nav[12] = 6; nav[13] = 8; nav[14] = 8; nav[15] = 3; nav[16] = 6; (void *)sprintf(trace_string," nav[0]=RECT"); M0sxtrce( trace_string ); for( i=1; i<=16; i++ ) { (void *)sprintf(trace_string," nav[%d]=%d",i,nav[i]); M0sxtrce( trace_string ); } /* Mollweide projection */ } else if( strncmp( projection, "MOLL", 4 ) == 0 ) { nav_type = stralloc( "MOLL", NULL ); memcpy( (void *)&nav[0], (void *)nav_type, 4); nav[1] = (int)parms[0]; nav[2] = (int)parms[1]; nav[3] = (int)parms[2]; nav[4] = (int)parms[3]; nav[6] = planet_radius; nav[7] = planet_eccentricity; nav_type = stralloc( "KMPP", NULL ); memcpy( (void *)&nav[14], (void *)nav_type, 4); (void *)sprintf(trace_string," nav[0]=MOLL"); M0sxtrce( trace_string ); for( i=1; i<15; i++ ) { (void *)sprintf(trace_string," nav[%d]=%d",i,nav[i]); M0sxtrce( trace_string ); } /* unsupported projection */ } else { return -1; } return 0; }