コード例 #1
0
void nmp_rstrproj ( int lp, int *iret )
/************************************************************************
 * nmp_rstrproj                                                         *
 *                                                                      *
 * This function sets the projection for the specified loop.         	*
 *                                                                      *
 * void nmp_rstrproj( lp, iret )                                   	*
 *                                                                      *
 * Input parameters:                                                    *
 *  lp                  int	loop index                      	*
 *                                                                      *
 * Output parameters:                                                   *
 *  *iret		int	return code				*
 *				  -1 = invalid loop			*
 *                                                                      *
 * Return parameters:                                                   *
 *                      NONE                                            *
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * M. Li/GSC            03/01   Created                                 *
 ***********************************************************************/
{
int    	drpflg, which, ier;
/*---------------------------------------------------------------------*/

    if (lp < 0 || lp >= MAX_LOOP) {
	*iret = -1;
	return;
    }

    *iret = 0;
   
    if (strlen(maps[lp].garea[1]) > (size_t)0 ) {
        which = 1;
    }
    else {
	which = 0;
    }
    
    gg_maps( maps[lp].proj, maps[lp].garea[which], maps[lp].imgfile, 
    		&drpflg, &ier, 
		strlen(maps[lp].proj), strlen(maps[lp].garea[which]),
                strlen(maps[lp].imgfile) );

    if ( ier != G_NORMAL ) {
        NxmErr_update();
        *iret = ier;
    }

}
コード例 #2
0
void wgem_gg_maps( char *proj, char *garea, char *imgfil, int *idrpfl, int *iret )
/************************************************************************
 * wgem_gg_maps              						*
 *									*
 * This function is a wrapper for gg_maps.				*
 *									*
 * void wgem_gg_maps( proj, garea, imgfil, idrpfl, iret )		*
 *									*
 * Input parameters:							*
 *	*proj		char	map projection   			*
 *	*garea		char	graphics area 				*
 *	*imgfil		char	image (sat/rad) file name		*
 *									*
 * Output parameters:							*
 *	*idrpfl		int	flag to drop the image 			*
 *	*iret		int	return code				*
 **									*
 * Log:									*
 * E. Safford/SAIC	12/07	initial coding                          *
 ***********************************************************************/
{
    gg_maps( proj, garea, imgfil, idrpfl, iret,
             strlen( proj ), strlen( garea ), strlen( imgfil ) );
}
コード例 #3
0
ファイル: readimghdr.c プロジェクト: mjames-upc/garp
int readimghdr ( MetObjectType *mot )
{

	char			tmpstr [132];
	int			i, dropflg, iret;
	int			len;
	GeoRefObjectType	*geo;	
	AnyImageObjectType	*iot;


	iot = (AnyImageObjectType *) mot->metObjectContent;
	geo = GetGeoRefObject( GetActiveWindowObject() );

/*
 *	Read the image header
 */
	gg_maps ( geo->proj, geo->garea, mot->filename, &dropflg, &iret,
		  strlen (geo->proj), strlen (geo->garea), strlen (mot->filename) );

	if ( iret != 0 ) return 0;

	im_rtbl ( &iret );

/*
 *	Get everything from the GEMPAK image common block and save in
 *	the object.
 */
	iot->imgCmn.imftyp = getimgcomint ( "imftyp", strlen("imftyp"));
	iot->imgCmn.imbank = getimgcomint ( "imbank", strlen("imbank"));
	iot->imgCmn.imdoff = getimgcomint ( "imdoff", strlen("imdoff"));
	iot->imgCmn.imldat = getimgcomint ( "imldat", strlen("imldat"));
	iot->imgCmn.imnpix = getimgcomint ( "imnpix", strlen("imnpix"));
	iot->imgCmn.imnlin = getimgcomint ( "imnlin", strlen("imnlin"));
	iot->imgCmn.imdpth = getimgcomint ( "imdpth", strlen("imdpth"));
	iot->imgCmn.rmxres = (float) getimgcomflt ( "rmxres", strlen("rmxres"));
	iot->imgCmn.rmyres = (float) getimgcomflt ( "rmyres", strlen("rmyres"));
	iot->imgCmn.imleft = getimgcomint ( "imleft", strlen("imleft"));
	iot->imgCmn.imtop  = getimgcomint ( "imtop ", strlen("imtop "));
	iot->imgCmn.imrght = getimgcomint ( "imrght", strlen("imrght"));
	iot->imgCmn.imbot  = getimgcomint ( "imbot",  strlen("imbot") );
	iot->imgCmn.rmxysc = (float) getimgcomflt ( "rmxysc", strlen("rmxysc"));
	iot->imgCmn.imbswp = getimgcomint ( "imbswp", strlen("imbswp"));
	iot->imgCmn.imnchl = getimgcomint ( "imnchl", strlen("imnchl"));
	iot->imgCmn.imprsz = getimgcomint ( "imprsz", strlen("imprsz"));
	iot->imgCmn.imdcsz = getimgcomint ( "imdcsz", strlen("imdcsz"));
	iot->imgCmn.imclsz = getimgcomint ( "imclsz", strlen("imclsz"));
	iot->imgCmn.imlvsz = getimgcomint ( "imlvsz", strlen("imlvsz"));
	iot->imgCmn.imvald = getimgcomint ( "imvald", strlen("imvald"));
	iot->imgCmn.imrdfl = getimgcomint ( "imrdfl", strlen("imrdfl"));
	iot->imgCmn.immnpx = getimgcomint ( "immnpx", strlen("immnpx"));
	iot->imgCmn.immxpx = getimgcomint ( "immxpx", strlen("immxpx"));
	iot->imgCmn.imsorc = getimgcomint ( "imsorc", strlen("imsorc"));
	iot->imgCmn.imtype = getimgcomint ( "imtype", strlen("imtype"));
	iot->imgCmn.imradf = getimgcomint ( "imradf", strlen("imradf"));
	iot->imgCmn.rmbelv = (float) getimgcomflt ( "rmbelv", strlen("rmbelv"));
	iot->imgCmn.imdate = getimgcomint ( "imdate", strlen("imdate"));
	iot->imgCmn.imtime = getimgcomint ( "imtime", strlen("imtime"));
	iot->imgCmn.imndlv = getimgcomint ( "imndlv", strlen("imndlv"));

/*
 *	Strings need to be null-terminated
 */
	for ( i = 1; i <= 256; i++ ) {
	    len = getimgcomstr ( "cmblev", &i, tmpstr, strlen("cmblev"), sizeof(tmpstr) );
	    tmpstr [len] = '\0'; 
	    strcpy (iot->imgCmn.cmblev[i-1], tmpstr);
	}
 
	len = getimgcomstr ( "cmbunt", &i, tmpstr, strlen("cmbunt"), sizeof(tmpstr) );
	tmpstr [len] = '\0'; 
	strcpy (iot->imgCmn.cmbunt, tmpstr);

	len = getimgcomstr ( "cmsorc", &i, tmpstr, strlen("cmsorc"), sizeof(tmpstr) );
	tmpstr [len] = '\0';
	strcpy (iot->imgCmn.cmsorc, tmpstr);

	len = getimgcomstr ( "cmtype", &i, tmpstr, strlen("cmtype"), sizeof(tmpstr) );
	tmpstr [len] = '\0';
	strcpy (iot->imgCmn.cmtype, tmpstr);

	len = getimgcomstr ( "cmlutf", &i, tmpstr, strlen("cmlutf"), sizeof(tmpstr) );
	tmpstr [len] = '\0';
	strcpy (iot->imgCmn.cmlutf, tmpstr);

	len = getimgcomstr ( "cmfile", &i, tmpstr, strlen("cmfile"), sizeof(tmpstr) );
	tmpstr [len] = '\0';
	strcpy (iot->imgCmn.cmfile, tmpstr);

	len = getimgcomstr ( "cmcalb", &i, tmpstr, strlen("cmcalb"), sizeof(tmpstr) );
	tmpstr [len] = '\0';
	strcpy (iot->imgCmn.cmcalb, tmpstr);

/*
 *	Pass the GEMPAK image common block down through GPLT to the XW code.
 *	(This is necessary before we read the image data.)
 */
	gsicmn ( &iret );

	if ( GetVerboseLevel() > VERBOSE_1 ) {
	    printf ("readimghdr() source: %d, ", iot->imgCmn.imsorc);
	    printf (" type: %d, ", iot->imgCmn.imtype);
	    printf (" depth (or raw flag): %d\n", iot->imgCmn.imdpth);
	}
	

	return 1;

}
コード例 #4
0
ファイル: testnsn.c プロジェクト: ArielleBassanelli/gempak
int main ( void )
/************************************************************************
 * TESTNSN								*
 *									*
 * This program test the NSN library of routines.			*
 *									*
 **									*
 * Log:									*
 * S. Jacobs/NCEP	 6/99	Created					*
 * M. Li/GSC		 7/00	Added nsn_save and nsn_rest		*
 * T. Lee/SAIC		 8/03	Add time interval to nsn_gtim, nsn_dspl	*
 * T. Lee/SAIC		 2/04	Add reference time flag to nsn_gtim	*
 * T. Lee/SAIC		 4/04	Added delta reference time to nsn_gtim	*
 * T. Lee/SAIC		10/04	Added bin hours				*
 * T. Piper/SAIC        01/08   Added GD_INIT; removed from IN_BDTA     *
 * F. J. Yen/NCEP	04/08   Insert new parms for nsn_dspl (CSC).	*
 *				Request input for bin hours.		*
 ***********************************************************************/
{
	int	cont, ier, iret, numsub, id;
	char	ergrp[4], erstr[81], select[LLSCRN];

	int	iindex, jindex, knt, ntime, match, ititl, idelta,
		mode, istat, minute, isbcat, mrange, intrvl,
		ibfr, iaftr, mbfr, maftr, mstrct;
	char	alias[81], cycle[81], parms[81], color[81],
		level[81], vcord[81], filter[81], txtatt[81],
		garea[81], proj[5], panel[81], dattim[21], device[81],
		map[21], ltln[21], ans[9];
	unsigned int	jflag;
	Boolean	iflag;
	dttms_t	endtim, timarr[2000];

	char	blank[] = " ";

/*---------------------------------------------------------------------*/

	in_bdta ( &ier );
	gd_init ( &ier );

	mode = 1;
	ginitp ( &mode, &istat, &ier );

	printf ( "Enter full DEVICE string:\n" );
	scanf ( " %s", device );

	gg_sdev ( device, &ier, strlen ( device ) );

	strcpy ( ergrp, "NSN" );

	cont = G_TRUE;

	while ( cont ) {
	    printf ( "\n\n" );
	    printf ( "   1 = NSN_INIT   2 = NSN_SATT   3 = NSN_QATT\n" );
	    printf ( "   4 = NSN_GTIM   5 = NSN_DSPL   6 = NSN_SAVE\n" );
	    printf ( "   7 = NSN_REST\n\n" );
	    printf ( "  20 = Change device\n\n" );
	    printf ( "\n" );
	    printf ( "Select a subroutine number or type EXIT: " );
	    scanf ( " %s", select );
	    switch ( select[0] ) {
		case 'e':
		case 'E':
			cont = G_FALSE;
		default:
			numsub = atoi ( select );
			break;
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 1 )  {
		nsn_init ( &iret );

		printf ( "iret = %d\n", iret );

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 2 )  {
		printf ( "Enter index number:\n" );
		scanf  ( " %d", &iindex );
		printf ( "Enter the data alias (e.g., UAIR):\n" );
		scanf  ( " %s", alias );
		printf ( "Enter data subcategory number:\n" );
		scanf  ( " %d", &isbcat );
		printf ( "Enter the cycle date/time or NONE:\n" );
		scanf  ( " %s", cycle );
		printf ( "Enter the parm list:\n" );
		scanf  ( " %s", parms );
		printf ( "Enter the color list:\n" );
		scanf  ( " %s", color );
		printf ( "Enter the level:\n" );
		scanf  ( " %s", level );
		printf ( "Enter the vertical coordinate:\n" );
		scanf  ( " %s", vcord );
		printf ( "Enter the filter:\n" );
		scanf  ( " %s", filter );
		printf ( "Enter the text attributes string:\n" );
		scanf  ( " %s", txtatt );

		nsn_satt ( iindex, alias, isbcat, cycle, parms, color,
			   level, vcord, filter, txtatt, &jindex,
			   &iret );

		printf ( "iret   = %d\n", iret );
		printf ( "jindex = %d\n", jindex );

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 3 )  {
		printf ( "Enter index number:\n" );
		scanf  ( " %d", &iindex );

		nsn_qatt ( iindex, alias, &isbcat, cycle, parms, color,
			   level, vcord, filter, txtatt, &iret );

		printf ( "iret   = %d\n", iret );
		printf ( "alias  = %s\n", alias );
		printf ( "isbcat = %d\n", isbcat );
		printf ( "cycle  = %s\n", cycle );
		printf ( "parms  = %s\n", parms );
		printf ( "color  = %s\n", color );
		printf ( "level  = %s\n", level );
		printf ( "vcord  = %s\n", vcord );
		printf ( "filter = %s\n", filter );
		printf ( "txtatt = %s\n", txtatt );

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 4 )  {
		printf ( "Enter index number:\n" );
		scanf  ( " %d", &iindex );
                printf ( "Enter end time for range:\n" );
		scanf  ( " %s", endtim );
		printf ( "Enter time range in minutes:\n" );
		scanf  ( " %d", &mrange );
		printf ( "Enter time interval in minutes:\n" );
		scanf  ( " %d", &intrvl );
		printf ( "Enter reference time flag:\n" );
		scanf  ( " %u", &jflag );
		iflag = (Boolean) jflag;
		printf ( "Enter delta reference time in minutes:\n" );
		scanf  ( " %d", &idelta );


		nsn_gtim ( iindex, endtim, mrange, intrvl, iflag, 
			   &idelta, &ntime, timarr, &iret );

		printf ( "idelta = %d\n", idelta );
		printf ( "iret   = %d\n", iret );
		printf ( "ntime  = %d\n", ntime );
		if  ( ntime > 0 )  {
		    for ( knt = 0; knt < ntime; knt++ ) {
			printf ( "Times: timarr[%d] = %s\n",
				 knt, timarr[knt] );
		    }
		}

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 5 )  {
		printf ( "Enter index number:\n" );
		scanf  ( " %d", &iindex );

		nsn_qatt ( iindex, alias, &isbcat, cycle, parms, color,
			   level, vcord, filter, txtatt, &iret );

		printf ( "Enter GAREA:\n" );
		scanf  ( " %s", garea );

		printf ( "Default projection? (y/n)\n" );
		scanf  ( " %s", ans );
		if  ( ans[0] == 'N' || ans[0] == 'n' )  {
		    printf ( "Enter PROJ:\n" );
		    scanf  ( " %s", proj );
		}
		else {
		    strcpy ( proj, blank );
		}

		printf ( "Enter PANEL:\n" );
		scanf  ( " %s", panel );
		printf ( "Enter DATTIM:\n" );
		scanf  ( " %s", dattim );

                printf ( "Enter end time for range:\n" );
		scanf  ( " %s", endtim );
		printf ( "Enter the time range in minutes:\n" );
		scanf  ( " %d", &mrange );
		printf ( "Enter the time interval in minutes:\n" );
		scanf  ( " %d", &intrvl );

		printf ( "Enter time match type:\n" );
		scanf  ( " %d", &match );
		printf ( "Enter minutes for difference match:\n" );
		scanf  ( " %d", &minute );
		printf ( "Enter title line:\n" );
		scanf  ( " %d", &ititl );
                printf ( "Enter binning time before current time: hh mm:\n" );
                scanf  ( " %d %d", &ibfr, &mbfr );
                printf ( "Enter binning time after current time: hh mm:\n" );
                scanf  ( " %d %d", &iaftr, &maftr );
                printf ( "Enter most recent only flag (0 for no; 1 for yes)\n" );
                scanf  ( " %d", &mstrct );

		gg_maps ( proj, garea, blank, &id, &ier,
			  strlen ( proj ), strlen ( garea ),
			  strlen ( blank ) );

		gclear ( &ier );

		strcpy ( map, "1" );
		gg_map ( map, &ier, strlen ( map ) );

		strcpy ( ltln, "2" );
		gg_ltln ( ltln, &ier, strlen ( ltln ) );

		nsn_dspl ( panel, dattim, alias, &isbcat, cycle, parms,
			   color, level, vcord, filter, txtatt,       
			   endtim, &mrange, &intrvl, &match, &minute, 
			   &ititl, &ibfr, &mbfr, &iaftr, &maftr,
			   &mstrct, &iret,
			   strlen ( panel ), strlen ( dattim ),
			   strlen ( alias ), strlen ( cycle ),
			   strlen ( parms ), strlen ( color ),
			   strlen ( level ), strlen ( vcord ),
			   strlen ( filter ), strlen ( txtatt ),
			   strlen ( endtim ) );

		geplot ( &ier );

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
            if  ( numsub == 6 )  {
                nsn_save ( &iret );

                printf ( "iret = %d\n", iret );

                if  ( iret != 0 )  {
                    strcpy ( erstr, " " );
                    er_wmsg ( ergrp, &iret, erstr, &ier,
                              strlen ( ergrp ), strlen ( erstr ) );
                }
            }

/*---------------------------------------------------------------------*/
            if  ( numsub == 7 )  {
                nsn_rest ( &iret );

                printf ( "iret = %d\n", iret );

                if  ( iret != 0 )  {
                    strcpy ( erstr, " " );
                    er_wmsg ( ergrp, &iret, erstr, &ier,
                              strlen ( ergrp ), strlen ( erstr ) );
                }
            }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 10 )  {
		dumpcmn ( &iret );
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 20 )  {
		printf ( "Enter full DEVICE string:\n" );
		scanf ( " %s", device );

		gg_sdev ( device, &ier, strlen ( device ) );
	    }

	}
	return(0);
}
コード例 #5
0
ファイル: ncwsproj.c プロジェクト: ArielleBassanelli/gempak
void ncw_sproj ( const char *source )
/************************************************************************
 * ncw_sproj                                                          	*
 *                                                                      *
 * This function sets the projection information for the computational	*
 * window. The computational window usage may be specified in the 	*
 * 'prefs.tbl' table using the boolean keyword 'COMP_WINDOW'. The	*
 * projection to be employed is specified in 'source', a tagged string.	*
 * For example:								*
 * '<PROJ>str/90;-97;0<GAREA>19.00;-119.00;47.00;-56.00'                *
 * A default projection and geographical area may be specified in the 	*
 * 'prefs.tbl' with 'COMP_PROJ'	and 'COMP_GAREA'.  			*
 * If any of the provided projection information cannot be decoded - 	*
 * either through 'source' or the 'prefs.tbl' table - then an error is	*
 * set and whatever projection is in the main window will be used.	*
 *                                                                      *
 * void ncw_sproj( char *source )                                     	*
 *                                                                      *
 * Input parameters:                                                    *
 *  source	const char	projection information string		*
 *                                                                      *
 * Output parameters:                                                   *
 *                      NONE                                            *
 *                                                                      *
 * Return parameters:                                                   *
 *                      NONE                                            *
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * D.W.Plummer/NCEP	12/06						*
 ***********************************************************************/
{
int	p, ier, ier1, ier2, mone, idrpfl;
char 	*src, PROJ[32], GAREA[32];
Boolean	qcomp;

/*---------------------------------------------------------------------*/

    ctb_pfbool ( "COMP_WINDOW", &qcomp, &ier );

    if ( qcomp )  {

    G_MALLOC ( src, char, strlen(source)+1, 
	    "ncw_sproj: Error allocating src" );
    strcpy ( src, source );

    p = G_TRUE;

    if ( strcmp ( src, "PREFS" ) != 0 )  {

	/*
	 * If user input is not exactly 'PREFS' (meaning get the projection 
	 * info from 'prefs.tbl'), then try to find 'PROJ' and 'GAREA' 
	 * tags and parse/process that info.
	 */
	cst_gtag (  "PROJ", src, "",  PROJ, &ier1 );
	cst_gtag ( "GAREA", src, "", GAREA, &ier2 );

	if ( ier1 != 0 || ier2 != 0 )  {

	    /*
	     * If tags cannot be found, then process as if 'PREFS' was
	     * specified.
	     */
	    strcpy ( src, "PREFS" );

	}
    }

    if ( strcmp ( src, "PREFS" ) == 0 )  {

	/*
	 * Get the projection specs from 'prefs.tbl'.
	 * If not found, set error and use main window projection.
	 */
	ctb_pfstr ( "COMP_PROJ", PROJ, &ier1 );
	ctb_pfstr ( "COMP_GAREA", GAREA, &ier2 );

	if ( ier1 != 0 || ier2 != 0 )  {
	    p = G_FALSE;
	}
	
    }

    if ( p )  {

	gg_maps ( PROJ, GAREA, "", &idrpfl, &ier, 
		strlen(PROJ), strlen(GAREA), strlen("") );

	if ( ier != 0 )  {
	    p = G_FALSE;
	}

    }

    if ( !p )  {
	ncw_unset ();
	mone = -1;
	er_wmsg ( "NCW", &mone, NULL, &ier, strlen("NCW"), 0 );
	NxmErr_update ();
    }

    G_FREE ( src, char );

    }

}