示例#1
0
void vfgname ( int *iret )
/************************************************************************
 * vfgname                                                              *
 *                                                                      *
 * This function gets the station information for the anchor points.  	*
 *                                                                      *
 * vfgname ( iret )                                            		*
 *                                                                      *
 * Input parameters:                                                    *
 *                                                                      *
 * Output parameters:                                                   *
 *      *iret            int            Return Code                     *
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * A. Hardy/GSC          8/99   Created                                 *
 * A. Hardy/GSC         11/99   Removed unused variables		*
 * A. Hardy/GSC         01/00   Changed type from int to char           *
 * A. Hardy/GSC		 2/00   Extracted from SPCTXT                   *
 * A. Hardy/GSC		 5/00   Removed FILE declarations		*
 * A. Hardy/GSC		 5/01   Initialized iret to 0			*
 * R. Tian/SAIC		 7/03	Changed to call cst_gtag		*
 ***********************************************************************/
{
    char    stninfo[128];
    char    hunt[1], type[7];
    int     ier, nstns, maxlen, isrch;
/*-------------------------------------------------------------------*/
    *iret = 0;
    ier = 0;
    strcpy (type, "ANCHOR");
    hunt[0] = '\0';
    maxlen = sizeof(stninfo);
    isrch = 1;

    /*
     * Find the first point's information.
     */

    clo_init ( &ier );
    clo_findstn ( type, spcinfo.ancrpt.stn1, hunt, isrch, maxlen,
                  &nstns, stninfo, &ier ); 
    cst_gtag ( "NAME", stninfo, " ", spcinfo.ancrpt.stnnam1, &ier );
    cst_gtag ( "ST", stninfo, " ", spcinfo.ancrpt.stateid1, &ier );

    /*
     * Find the second point's information.
     */

    clo_findstn ( type, spcinfo.ancrpt.stn2, hunt, 1, maxlen,
                  &nstns, stninfo, &ier); 
    cst_gtag ( "NAME", stninfo, " ", spcinfo.ancrpt.stnnam2, &ier );
    cst_gtag ( "ST", stninfo, " ", spcinfo.ancrpt.stateid2, &ier );
}
示例#2
0
void shn_dfhr ( int *idst, float *rlat, float *rlon, int *idiff, int *iret )
/************************************************************************
 * shn_dfhr								*
 *									*
 * Given a location defined by a latitude/longitude pair, this function	*
 * determines the offset (in hours) between GMT and the local time at	*
 * that location.							*
 *									*
 * shn_dfhr ( *idst, *rlat, *rlon, *idiff, *iret )			*
 *									*
 * Input parameters:                                                    *
 *	*idst		int		Flag denoting whether the	*
 *					current	report date-time occurs	*
 *					during Daylight	Savings Time:	*
 *					   0 = No			*
 *					   1 = Yes			*
 *	*rlat		float		Latitude of location		*
 *	*rlon		float		Longitude of location		*
 *                                                                      *
 * Output parameters:                                                   *
 *	*idiff		int		Difference (in hours) determined*
 *					by subtracting GMT from the	*
 *					local time at the given location*
 *	*iret		int		Return code:			*
 *					   0 = normal return		*
 *					  -1 = a problem occurred	*
 **                                                                     *
 *  Log:                                                                *
 *  J. Ator/NCEP         04/05                                          *
 ***********************************************************************/
{
	char cbndtp[8] = "TZ_BNDS";
	char cwrkst[80];
	char info[128];

	int ier;

	*iret = -1;

	clo_tqbnd ( cbndtp, *rlat, *rlon, cwrkst, &ier );
	if ( ier != 0 ) {
	    LOG_ERROR(clo_tqbnd);
	    return;
	}

	clo_bginfo ( cbndtp, 0, info, &ier ); 
	if ( ier != 0 ) {
	    LOG_ERROR(clo_bginfo);
	    return;
	}

	if ( *idst ) {
	    cst_gtag ( "GMT_DST_OFFSET", (const char *) info, " ", cwrkst, &ier );
	}
	else {
	    cst_gtag ( "GMT_OFFSET"    , (const char *) info, " ", cwrkst, &ier );
	}
	if ( ier != 0 ) {
	    LOG_ERROR(cst_gtag);
	    return;
	}

	cst_numb ( cwrkst, idiff, &ier );
	if ( ier != 0 ) {
	    LOG_ERROR(cst_numb);
	    return;
	}

	*iret = 0;
	return;
}
示例#3
0
void clo_ddenc ( char *type, int format, float lat, float lon, char *str,
                 int *iret )
/************************************************************************
 * clo_ddenc                                                    	*
 *                                                                      *
 * This function returns gets the string for the seek and location      *
 * structure indicating which entry matches the input CLO name for the  *
 * given latitude and longitude. The format code is in a 4-5 digit      *
 * format (Eg. 5212 or 10212).  The columns are formatted as follows : 	*
 *					       				*
 *									*
 *   ROUNDING        UNITS        DIRECTION     DISPLAY			*
 *                                              			*
 *  5 - nearest 5    0 - omit     0 - omit      0 - degrees		*
 * 10 - nearest 10   1 - NM       1 - 16 point  1 - decimal/minutes   	*
 *                   2 - SM       2 - degrees   2 - 1st column		*
 *                   3 - KM             	4 - 3rd column		*
 *									*
 * For DISPLAY, the 1st column is usually the station id and the 3rd    *
 * column is the name of the station, city or county.			*
 *                                                                      *
 * clo_ddenc ( type, format, lat, lon, str, iret)                       *
 *                                                                      *
 * Input parameters:                                                    *
 *	*type		char		Name of CLO parameter		*
 *	format		int		Indicator of format to use      *
 *      lat            float            Latitude point                  *
 *      lon            float            Longitude point                 *
 *									*
 * Output parameters:                                                   *
 *	*str		char		Character string location       *
 *	*iret		int		Return value			*
 *					=  < 0 - String not created	*
 *									*
 **                                                                     *
 * Log:                                                                 *
 * A. Hardy/GSC		01/00	Create					*
 * A. Hardy/GSC		01/00	Added new format display option         *
 * A. Hardy/GSC		01/00	Added length chk of str;changed rounding*
 * A. Hardy/GSC		02/00	modified for all variations of formats  *
 * A. Hardy/GSC		02/00	reworked string display; city locations *
 * D.W.Plummer/NCEP	 8/00	changes for clo_ redesign		*
 * A. Hardy/GSC		 8/00   renamed from clo_format			*
 * T. Piper/GSC		 3/01	Fixed IRIX6 compiler warnings		*
 * D.W.Plummer/NCEP	 8/01	Repl clo_bqinfo w/ cst_gtag		*
 * D.W.Plummer/NCEP	 6/05	Tens digit sets # decimals for lat,lon	*
 ***********************************************************************/
{
    int		idist, icmp, nh, ier;
    int		ilat, ilon, imnt, imnn, isit, isin;
    char	stn[80], idx[80], *pidx, sdir[4];
    float	dist, dir;
    int         ione, itens, ihund, irnd, which, inlen;
    int         isln, iwidth, ilftovr;
    char        sdirc[5], sdist[5];
    char	info[128], fmt[20];
    /*---------------------------------------------------------------------*/
    *iret = 0;
    strcpy ( str, "NULL" );
    iwidth = 16;

    /*
     * Parse out format into it's components.
     */

    ione  = format % 10;
    itens = (int) (format/10) % 10;
    ihund = (int) (format/100) % 10;
    irnd  = format / 1000;

    /*
     * Check one's place for lat-lon or deg-min.
     */

    if ( ione == 0 ) {	/* show lat/lon */
        /*
         * Tens digit controls the number of decimal digits for the
         * lat,lon display. The default is 2 digits.
         */
        if ( itens == 0 )  itens = 2;
        sprintf(fmt,"%%.%df, %%.%df", itens, itens );
        sprintf(str, fmt, lat, lon);
    }
    else if ( ione == 1 ) {   /* show lat/lon as deg-min */
        isit = ( lat < 0.0F ) ? '-' : ' ';
        ilat = (int) G_ABS ( lat );
        imnt = G_NINT ( ( G_ABS(lat) - (float)ilat ) * 60.0F );
        if  ( imnt >= 60 )  {
            imnt = imnt % 60;
            ilat += 1;
        }

        isin = ( lon < 0.0F ) ? '-' : ' ';
        ilon = (int) G_ABS ( lon );
        imnn = G_NINT ( ( G_ABS(lon) - (float)ilon ) * 60.0F );
        if  ( imnn >= 60 )  {
            imnn = imnn % 60;
            ilon += 1;
        }

        sprintf ( str, "%c%3d:%02d, %c%3d:%02d",
                  isit, ilat, imnt, isin, ilon, imnn );
    }

    else {   /* show city/county/stn  */
        which = clo_which ( type );

        if ( clo.loc[which].format == 1 ) { 		/* show bound */

            clo_tqbnd ( type, lat, lon, idx, &ier);
            pidx = idx;

            /*
             *   Find and save the county FIPS id.
            */

            if ( ione == 2) {

                if (strcmp ( pidx,"-") != 0 ) {
                    clo_bginfo ( type, 0, info, &ier );
                    cst_gtag ( "FIPS", info, "?", str, &ier );
                }
                else {
                    cst_split (pidx, ' ', 14, str, &ier);
                }
            }
            if ( ione == 4) {  /* Save the bound name */
                cst_split (pidx, ' ', 14, str, &ier);
            }
        }


        else {
            if ( clo.loc[which].format == 0 ) { 	/* show station */

                /*
                 *  get station ID, distance and direction.
                 */
                clo_tdirect ( type, lat, lon, stn, &dist, &dir, &ier );

                if ( ione == 4 ) {
                    /*
                     *  Replace station ID w/ station name.
                     */
                    clo_tgnm ( type, 1, sizeof(stn), &nh, stn, &ier );
                }
            }

            if ( ihund == 0 ) {
                strcpy ( sdirc, "" );
            }
            else {
                if ( ihund == 1 ) {           /* get nautical miles */
                    dist *= M2NM;
                }
                else if ( ihund == 2 ) {      /* get statute miles */
                    dist *= M2SM;
                }
                else if ( ihund == 3 ) {      /* get kilometers */
                    dist /= 1000.0F;
                }

                if ( irnd > 0 ) {
                    idist = G_NINT ( dist / (float)irnd ) * irnd;
                    sprintf ( sdirc, "%i ", idist);
                }
                else if ( irnd < 0 ) {
                    irnd = 1;
                    idist = G_NINT ( dist / (float)irnd ) * irnd;
                    sprintf ( sdirc, "%i ", idist);
                }
                else if ( irnd == 0 ) {
                    strcpy ( sdirc, "" );
                }

            }

            if ( itens == 0 ) {  /* omit the direction */
                strcpy ( sdist, "" );
            }
            else {
                if ( itens == 1 ) {      /* use 16 point dir. */
                    clo_compass ( &dir, sdir, &icmp, &ier );
                    sprintf ( sdist, "%s", sdir );
                }
                else if  ( itens == 2 ) {      /* use degrees  */
                    sprintf ( sdist, "%.0f", dir );
                }
            }

            sprintf(str, "%s %s",sdirc, sdist);

            /*
             * If the stn name is longer than 4 chars, print
             */

            inlen = (int)strlen(stn);
            isln = (int)strlen(str);
            ilftovr = iwidth - isln;

            if (inlen > 4 )  {
                sprintf ( str, "%*s %.*s", isln, str, ilftovr, stn );
            }
            else {
                sprintf ( str, "%s %3s", str, stn );
            }

            if ( (ihund == 0 ) && ( itens == 0 ) ) {
                sprintf ( str, "%.*s", ilftovr, stn );
            }
        }
    }
    if ( strcmp ( str, "NULL") != 0 ) *iret = -1;
}
示例#4
0
void wbc_area ( char *locnam, char *vorstr, int len, char *areastr, 
                int *iret )
/************************************************************************
 * wbc_area                                                    		*
 *                                                                      *
 * This function converts the VOR stations string to the VOR watch area *
 * string,containing distance, direction, county names and state ids.	*
 *                                                                      *
 * Input example:							*
 *   17 WNW DEC;26 E FAM;26 WNW FAM;55 SSE COU;22 NNW UIN;47 ENE UIN;	*
 *                                                                      *
 * Output example:							*
 *   17 WNW OF DECATUR, IL..TO 26 E OF FARMINGTON, MO..TO 26 WNW OF 	*
 *   FARMINGTON, MO..TO 55 SSE OF COLUMBIA, MO..TO 22 NNW OF QUINCY, 	*
 *   IL..TO 47 ENE OF QUINCY, IL.					*
 *                                                                      *
 * wbc_area ( locnam, vorstr, len, areastr, iret )   			*
 *                                                                      *
 * Input parameters:                                                    *
 *	*locnam		char	Locator type				*
 *	*vorstr		char	Polygon text string			*
 *	len		int	Max length of 'areastr'			*
 *									*
 * Output parameters:                                                   *
 *	*areastr	char	Polygon area text string		*
 *	*iret		int	Return value				*
 *			           -5 = VORSTR too big 			*
 *									*
 **                                                                     *
 * Log:                                                                 *
 * A. Hardy/NCEP	 5/03   From VF_AREA				*
 ************************************************************************/
{
	int	ii, nstn, maxlen, nstr, np, icnt, ier, exp, max, len1;
	char    tmpstr[420], holdstr[200], qstate[1], pstn[180]; 
	char    arrgrp[15], **aryvor, county[30], state[3];
/*---------------------------------------------------------------------*/
    *iret = 0;
    np = 1;
    icnt = 1;
    max  = 6;
    exp  = 4;
    qstate[0] = '\0';
    tmpstr[0] = '\0';
    maxlen = sizeof(pstn);

    if ( strcmp ( locnam, "VOR") != 0 ) {
        *iret = -2;
        return;
    }
    cst_lstr ( vorstr, &len1, &ier );
    if ( len1 >= 400 ) {
        *iret = -5;
        return;
    }

   /*
    * Set up the memory space to break up the VOR area string.
    */

    clo_init ( &ier );

    aryvor = (char **) malloc(sizeof(char *) * 4);
    for ( ii = 0; ii < 4; ii++ ) {
        aryvor[ii] = (char *) malloc(6) ;
    }

   /*
    *  Get the city and state of the VOR station.
    */

    for ( ii = 0; ii < 6; ii++) {

        vorstr = (char *) cst_split ( vorstr, ';', 12, arrgrp, &ier);

        cst_clst ( arrgrp, ' ', " ", exp, max, aryvor, &nstr, &ier);

	if ( nstr == 3 ) {

            clo_findstn ( locnam, aryvor[2], qstate, np, maxlen,
                      &nstn, pstn, &ier);

	}
	else if ( nstr == 2) {
            clo_findstn ( locnam, aryvor[1], qstate, np, maxlen,
                      &nstn, pstn, &ier);
	}

	cst_gtag ( "NAME", pstn, " ", county, &ier );
	cst_gtag ( "ST", pstn, " ", state, &ier );
	cst_rnan (county, county, &ier);

       /*
        * Create the watch area string.
        */

        holdstr[0] = '\0';

	if ( icnt < 6 ) {
	    if ( strcmp ( aryvor[0], "..") != 0 ) {
	        sprintf( holdstr," %s %s OF %s, %s..TO ",aryvor[0], 
	                 aryvor[1], county, state);
	    }
	    else {
		/*
		 * Print string for zero distance and no direction.
		 */
	        sprintf( holdstr," %s, %s..TO ", county, state);
	    }
	}
	else {
	    if ( strcmp ( aryvor[0], "..") != 0 ) {
	        sprintf( holdstr," %s %s OF %s, %s.",aryvor[0], aryvor[1],
	             county, state);
	    }
	    else {
		/*
		 * Print string for zero distance and no direction.
		 */
	        sprintf( holdstr," %s, %s.", county, state);
	    }
	}
	icnt++;
        cst_ncat ( tmpstr, holdstr, &len1, &ier);
    }

    len1 = G_MIN ( len, (int)strlen(tmpstr) );
    cst_ncpy( areastr, tmpstr, len1, &ier);

   /*
    * Free memory space.
    */

    for ( ii = 0; ii < 4; ii++ ) {
        free ( aryvor[ii] );
    }
    free ( aryvor);
}
示例#5
0
int main ( int argc, char **argv )
/************************************************************************
 * mdp									*
 *                                                                      *
 * This program generates the mesoscale discussion latlon pairings.	*
 * Pairings will be written to a file whose filename is based on the	*
 * input filename (filename extension, if exists, is replaced w/ "mdp").*
 *                                                                      *
 * Example:								*
 * mdp input_vgf_file.vgf						*
 * Produces latlon pairings in the ASCII file				*
 * output_vgf_file.mdp							*
 *                                                                      *
 * main(argc, argv)                                                     *
 *                                                                      *
 * Input parameters:                                                    *
 *  argc   int      number of parameters of command line                *
 *  argv   char**   parameter array of command line                     *
 *                                                                      *
 * Output parameters:                                                   *
 * Return parameters:                                                   *
 *                      NONE                                            *
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * D.W.Plummer/NCEP	 6/02						*
 * D.W.Plummer/NCEP	 8/02	Bug fix for lons > 99.995 and < 100.0	*
 * G. Grosshans/SPC	11/02	Updated to decode multi-scalloped lines *
 * G. Grosshans/SPC	12/02	Updated to compute WFO/State		*
 * S. Jacobs/NCEP	 5/03	Clean up unused variables and headers	*
 * G. Grosshans/SPC     10/03   Updated for precision                   *
 * T. Piper/SAIC	12/05	Updated cst_wrap for CSC		*
 * J. Wu/SAIC		04/06	Added parameter in cst_wrap 		*
 * G. Grosshans/SPC	08/08	Updated for SCN 08-45 to add LAT...LON  *
 * 				and list first point as last point      *
 * 				to indicate a closed polygon.  Add      *
 *				word wrapping for ATTN...WFO...		*
 ***********************************************************************/
{
int		ii, ix, iy, ixfirst, iyfirst, pagflg, ne, ilen,
	        npts, ier, iret, nitems, more, curpos;

long		ifilesize;

float		x, y, flat[MAXLISTITEMS], flon[MAXLISTITEMS];

char		vg_class, vg_type, buffer[2048], bufferfinal[2048],
		bufferfinalwfo[2048],str[20], *cptr, errgrp[12], infile[128],
		ifname[128], outfile[128], info[2048], stpo[4],
		cstl_list[1000], cstl_liststate[1000],
		newLineStr[13]="            "; /* 13 spaces */

char		blank[2]={' '}, device[13], dfilnam[73], pro[80];
int		mode, istat, iunit, itype;
float		xsize, ysize, lllat, lllon, urlat, urlon,
		prjang1, prjang2, prjang3;

VG_DBStruct	el;

FILE		*ifptr, *ofptr;

const int line_len = 66;

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

    /* 
     * Set defaults for gsdeva and gsmprj
     */
    mode = 1;
    strcpy ( device, "GN" );
    iunit = 1;
    strcpy ( dfilnam, "MDPSPC" );
    itype = 1;
    xsize = 500.0F;
    ysize = 500.0F;
    lllat = 10.0F;
    lllon = -120.0F;
    urlat = 50.0F;
    urlon = -50.0F;
    strcpy ( pro, "str" );
    prjang1 =   90.0F;
    prjang2 = -105.0F;
    prjang3 =    0.0F;
    cstl_list[0] = '\0';
    cstl_liststate[0] = '\0';

    in_bdta ( &ier );
    ginitp ( &mode, &istat, &ier);
    gsdeva (device, &iunit, dfilnam, &itype, &xsize, &ysize, &iret,
	    strlen(device), strlen(dfilnam));
    gsmprj ( pro, &prjang1, &prjang2, &prjang3, 
	     &lllat, &lllon, &urlat, &urlon, &iret, strlen(pro));
    clo_init ( &ier );

    /*
     *  Check if number of input arguments is correct.
     */
    if ( argc < 2 )  {
	pagflg = G_FALSE;
	strcpy ( errgrp, "MDPSPC" );
        ip_help ( errgrp, &pagflg, &ier,
                  strlen(errgrp) );
	gendp (&mode, &ier);
	exit (0);
    }

    /*
     *  First input on command line is input vgf file name.
     */
    strcpy ( infile, argv[1] );
    cfl_inqr ( infile, NULL, &ifilesize, ifname, &ier );
    ifptr = (FILE *) cfl_ropn(ifname, "", &ier);
    if ( ier != 0 )  {
	printf("Error opening VGF file %s\n", infile );
	gendp (&mode, &ier);
	exit (0);
    }

    /*
     *  Output filename is input filename w/ "mdp" filename extension.
     */
    strcpy ( outfile, infile );
    cptr = strrchr( outfile, '.' );
    if ( cptr != (char *)NULL )  {
	cptr[0] = '\0';
    }
    strcat( outfile, ".mdp" );
    
    /*
     *  Loop through all the elements until a line is found.
     */
    ne = 0;
    more = G_TRUE;
    curpos = 0;
    buffer[0] = '\0';
    bufferfinal[0] = '\0';
    bufferfinalwfo[0] = '\0';
    strcat ( buffer, "LAT...LON   " );
    while ( ne < MAX_EDITABLE_ELEMS && more == G_TRUE )  {
	cvg_rdrecnoc( ifname, ifptr, curpos, &el, &ier );

	if ( ier < 0 )  {
	    more = G_FALSE;
	}
	else  {

	    curpos += el.hdr.recsz;

	    vg_class = el.hdr.vg_class;
	    vg_type  = el.hdr.vg_type;

            if ( ( (int)vg_class == CLASS_LINES ) &&
	    	 ( el.hdr.vg_type == SPLN_ELM ) &&
		 ( (int)el.elem.spl.info.spltyp == 3 ) )  {

		/*
		 *  Open output file.
		 */
		ofptr = (FILE *)cfl_wopn ( outfile, &ier );
		if ( ier != 0 )  {
		    printf("Error opening/creating output file %s\n",
		    	    outfile );
	            gendp (&mode, &ier);
		    exit (0);
    		}

	       /*
		* Find FIPS bounded by the closed line
		*/

		npts = el.elem.spl.info.numpts;

		/*  FIND WHAT STATES ARE IN MD AREA */

		clo_binpoly ( "CNTY_BNDS", npts, el.elem.spl.latlon,
                              &(el.elem.spl.latlon[npts]), &ier );
		clo_tgltln ( "CNTY_BNDS", MAXLISTITEMS, &nitems,
			      flat, flon, &ier);

		for ( ii = 0; ii < nitems; ii++ )  {
		  clo_bginfo( "CNTY_BNDS", ii, info, &ier );
		  cst_gtag( "STATE", info, "?", stpo, &ier);
		  
		  if (strstr(cstl_liststate, stpo)==NULL) {
		    strcat(cstl_liststate, stpo);
		    strcat(cstl_liststate, " ");		  
		  }
		}


		/*  FIND WHAT WFOs ARE IN MD AREA */
		clo_binpoly ( "CWA_BNDS", npts, el.elem.spl.latlon,
                              &(el.elem.spl.latlon[el.elem.spl.info.numpts]),
			      &ier );
		clo_tgltln ( "CWA_BNDS", MAXLISTITEMS, &nitems,
			      flat, flon, &ier);

		for ( ii = 0; ii < nitems; ii++ )  {
		  clo_bginfo( "CWA_BNDS", ii, info, &ier );
		  cst_gtag( "WFO", info, "?", stpo, &ier);
		  strcat(cstl_list, stpo);
		  strcat(cstl_list, "...");		  
		}

		/*
		 *  Format lats and lons into buffer.
		 */
		if ( (int)vg_type == LINE_ELM )  {
		    npts = el.elem.lin.info.numpts;
		}
		else if ( (int)vg_type == SPLN_ELM )  {
		    npts = el.elem.spl.info.numpts;
		}
		for ( ii = 0; ii < npts; ii++ )  {
		    if ( (int)vg_type == LINE_ELM )  {
		        x = el.elem.lin.latlon[ii];
		        y = -el.elem.lin.latlon[ii+npts];
		    }
		    else if ( (int)vg_type == SPLN_ELM )  {
		        x = el.elem.spl.latlon[ii];
		        y = -el.elem.spl.latlon[ii+npts];
		    }
		    /*
		     * Make sure lats and lons are rounded
		     * to 100ths of deg.
		     */
		    x = ((int)(x*100.0F)) / 100.0F;
		    y = ((int)(y*100.0F)) / 100.0F;
		    if ( y >= 100.0F )  y -= 100.0F;
		    ix = G_NINT(x*100.0F);
		    iy = G_NINT(y*100.0F);
		    sprintf( str, "%04d%04d ", ix, iy );
		    strcat ( buffer, str );
		    if ( ii == 0 ) {
                        ixfirst = ix;
			iyfirst = iy;
                    }
		}
		/*
		 *   Repeat first lat/lon point as last lat/lon point 
		 *   to indicate a closed polygon.
		 */


		sprintf( str, "%04d%04d ", ixfirst, iyfirst);
		strcat ( buffer, str );

		sprintf( str, "\n\n" );
		strcat ( buffer, str );

		/*
		 *  Wrap buffer such that only 6 pairs of lat,lons 
		 *  on one line.
		 *  ilen = 55;
		 *  cst_wrap( buffer, blank, &ilen, "\n", (char *)NULL, buffer, &ier );
		 */
		ilen = 66;
		cst_wrap( buffer, blank, &ilen, "\n", newLineStr, buffer, &ier );

	    }

	}
	ne++;
    }

    /*
     * wrap the ATTN...WFO... line
     */
    strcat ( bufferfinalwfo, "ATTN...WFO..." );
    strcat ( bufferfinalwfo, cstl_list );
    cst_wrap( bufferfinalwfo, "...", &line_len, "\n", (char *)NULL, bufferfinalwfo, &ier );

    /*
     * build the output file string and add the ATTN...WFO... string
     */
    strcat ( bufferfinal,"STATES=" );
    strcat ( bufferfinal, cstl_liststate );
    strcat ( bufferfinal, "\n\n" );
    strcat ( bufferfinal, bufferfinalwfo );
/*
    strcat ( bufferfinal,"ATTN...WFO..." );
    strcat ( bufferfinal, cstl_list );
*/
    strcat ( bufferfinal, "\n\n" );
    strcat ( bufferfinal, buffer );

    /*
     *  Write to output file.
     */
    cfl_writ ( ofptr, (int)strlen(bufferfinal),
    	       (unsigned char *)bufferfinal, &ier );

    /*
     *  close files and exit.
     */
    cfl_clos ( ifptr, &ier );
    cfl_clos ( ofptr, &ier );
    gendp (&mode, &ier);
    return(0);

}
示例#6
0
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 );

    }

}