예제 #1
0
void bounds_line(float *X, float *Y, int nsegs, int color, int ltype, int lwidth)
{
static char navigate[]="M";
int lhw = 0;
int whw = 0;

int iret;

      gsline (&ltype,&lhw,&lwidth,&whw,&iret);
      gscolr (&color,&iret);
      if(iret != 0) printf("iret 3 %d\n",iret);
      gline (navigate,&nsegs,X,Y,&iret,strlen(navigate));
}
예제 #2
0
void wgem_gscolr( int *icolr, int *iret )
/************************************************************************
 * wgem_gscolr             						*
 *									*
 * This function is a wrapper for gscolr.				*
 *									*
 * void wgem_gscolr( icolr, iret )					*
 *									*
 * Input parameters:							*
 *	*icolr		int	color number       			*
 *									*
 * Output parameters:							*
 *	*iret		int	return code				*
 **									*
 * Log:									*
 * E. Safford/SAIC	11/07	initial coding                          *
 ***********************************************************************/
{
    gscolr( icolr, iret );
}
예제 #3
0
void bounds_fill(float *X, float *Y, int nsegs, int color)
{
static char navigate[]="M";
float x1[LLMXPT],y1[LLMXPT];
int ltype,lhw,lwidth,whw,segc;
int i,iret;


   ltype = 1;
   lhw = 0; lwidth = 1; whw = 0;
   gsline (&ltype,&lhw,&lwidth,&whw,&iret);
   if(iret == 0)
      {
      gscolr (&color,&iret);
      /* gplt fill routine can only accept up to LLMXPT segments */
      if(nsegs > LLMXPT)
         {
         segc = LLMXPT;
         gfill (navigate,&segc,X,Y,&iret,strlen(navigate));
         while(segc < nsegs)
            {
            x1[0] = X[0]; y1[0] = Y[0];
            x1[1] = X[segc-1]; y1[1] = Y[segc-1];
            i = 2;
            while((i < LLMXPT)&&(segc < nsegs))
               {
               x1[i] = X[segc];
               y1[i] = Y[segc];
               i++;
               segc++;
               }
            gfill (navigate,&i,x1,y1,&iret,strlen(navigate));
            }
         }
      else
         gfill(navigate,&nsegs,X,Y,&iret,strlen(navigate));
      }
}
예제 #4
0
void gg_rtrk ( char *filtyp, char *filnam, char *stime, char *etime,
		int *itmclr, int *iskip, int *iret )
/************************************************************************
 * gg_rtrk								*
 *									*
 * This routine reads the data from a Altimeter Ground Track Prediction *
 * file and plots it.							*
 *									*
 * gg_rtrk ( filtyp, filnam, stime, etime, itmclr, iskip, iret )        *
 *									*
 *									*
 * Input parameters:							*
 *	*filtyp		char		Data type			*
 *	*filnam		char		Data file name			*
 *	*stime		char		Start time of data 		*
 *	*etime		char		End time of data 		*
 * 	*itmclr		int		Time stamp color		*
 *	*iskip		int		Skip value			*
 *									*
 * Output parameters:							*
 *	*iret		int		Return code			*
 **									*
 * Log:									*
 * G. McFadden/SAIC	12/08	Modeled after gg_qsrd			*
 * S. Jacobs/NCEP	 6/10	Removed underscore on function name	*
 ***********************************************************************/
{
	int	ier, incr, itarr[5], iyoff = 0,
		ixoff = -10, ntime, np2, pcount, gyear, ymd, hm;
	FILE    *fptr;
	char    buffer[256], textstr[8], final_ts[9], ymd_string[7], hm_string[5];
        char    gempak_dt[12];
        char    *cp, underscore[2];
	float   lat, lon, rotat = 0.0F;
	double	dlat, dlon, dalt;
        size_t  two = 2;
/*---------------------------------------------------------------------*/
/*
 *  Open the data file.
 */
	fptr = cfl_ropn ( filnam, NULL, &ier );
	if ( fptr == NULL  ||  ier != 0 )  {
	    *iret = -1;
	    return;
	}
	*iret = 0;

        underscore[0] = '_';
        underscore[1] = '\0';

/*
 * Set the skip factor.
 */
        if  ( *iskip <= 0 ) {
            incr = 1;
        }
        else {
            incr = *iskip + 1;
        }

        pcount = incr;
        while  ( ier == 0 )  {

/*
 *  Read this prediction's data.
 */
	    cfl_trln( fptr, 256, buffer, &ier );
	    if ( ier != 0 ) {
/*
 *  Bad read...close the file and exit.
 */
     		cfl_clos ( fptr, &ier );
		return;
	    }
/*
 *  Extract this prediction's data.
 */
	    sscanf( buffer, "%d %d %d %d %d %lf %lf %lf",
			&itarr[0], &itarr[1], &itarr[2], &itarr[3],
			&itarr[4], &dlat, &dlon, &dalt );

	    lat = (float)dlat;
            lon = (float)dlon;
/*
 *  Get the gempak date/time of this prediction
 */
            gyear = itarr[0] - 2000;
            ymd  = gyear * 10000 + itarr[1] * 100 + itarr[2];
            sprintf(ymd_string, "%6.6d", ymd );

            hm = itarr[3] * 100 + itarr[4];
            sprintf(hm_string, "%4.4d", hm );

            gempak_dt[0] = '\0';
            strcat(gempak_dt,ymd_string);
            strcat(gempak_dt,"/");
            strcat(gempak_dt,hm_string);

/*
 *  The longitude is stored as 0 -> 360.  PRNLON will correct the longitude to
 *  the range -180 -> 180.
 */
            np2 = 1;
            prnlon( &np2, &lon, &ier );

/*
 *  Plot the prediction if it is not skipped and if it is within the valid
 *  time range...plot "DD_HHMM" on the screen.
 */
            ntime = itarr[2] * 10000 + itarr[3] * 100 + itarr[4];
	    sprintf(textstr, "%6.6d", ntime);
            final_ts[0] = '\0';
            strncpy(final_ts,textstr,two);
            final_ts[2] = '\0';
            strcat(final_ts,underscore);
            cp = textstr + 2;
            strcat(final_ts,cp);
                 
	    gscolr ( itmclr, &ier);
            if ( pcount % incr == 0 && PathTimeCheck( gempak_dt, stime, etime) ) {
	       gtext  ( sys_M, &lat, &lon, final_ts, &rotat, &ixoff, &iyoff,
	                &ier, strlen(sys_M), strlen(final_ts) );
            }

            pcount++;

	}
/*
 *  Close the file.
 */
	cfl_clos ( fptr, &ier );
}
예제 #5
0
void cds_ccf ( VG_DBStruct *el, int indx, int *iret )
/************************************************************************
 * cds_ccf								*
 *									*
 * This function displays CCFs to the output device.			*
 *									*
 * cds_ccf (el, indx, iret)						*
 *									*
 * Input parameters:							*
 * 	*el		VG_DBStruct	Pointer to VG record structure	*
 *	indx		int		Index into user attribute table *
 *									*
 * Output parameters:							*
 *	*iret		int		Return code			*
 *									*
 **									*
 * Log:									*
 * D.W.Plummer/NCEP	 7/99	Copied from cds_sig			*
 * S. Law/GSC		02/00	added smoothing				*
 * S. Law/GSC		05/00	added fill, moved color setting to pgen	*
 * A. Hardy/GSC         11/00   renamed output coord. system declaration*
 * J. Wu/GSC            02/01   Modified 'unused1' in VG to 'smooth'	*
 * D.W.Plummer/NCEP	 5/01	Added check for cdsColor		*
 * M. Li/SAIC		01/03	delete vgstruct.h			*
 * H. Zeng/SAIC		02/05	assigned iftyp with a new value		*
 * L. Hinson/AWC        07/09   Add Setting/Uattrib tbl functionality   *
 *                              Add Connector, if needed, from text box *
 *                              to polygon.  Add motion vector/speed    *
 * L. Hinson/AWC        02/10   Fix uninitialized 'ifilled' on Lines    *
 ***********************************************************************/
{
    int		ii, np, ier, istyp, width, lintyp, lthw, lwhw;
    int         iltypx, ilthwx, iwidthx, iwhwx, icolrx, iftypx;
    int		ifilled, iftyp;
    float	szfilx, szfil, lat[MAX_SIGMET], lon[MAX_SIGMET];
    int idx;
    VG_DBStruct el_tmp;
    CCFType	*pccf;
    
    int npts, npls, *inout;
    float *xpt, *ypt, *xpl, *ypl;
    
    float areadir, areaspd, xcent, ycent, minangle, V1x, V1y, V2u, V2v;
    float angle, latmv[2], lonmv[2];
    int i, motionvertexnum, foundmotionvertex;
    char    textLayoutStr[256];
    Boolean textLayoutNIL = False;
    
/*---------------------------------------------------------------------*/

    *iret = 0;

    /*
     *  Save plot attributes.
     */
    gqcolr (&icolrx, &ier);
    gqline (&iltypx, &ilthwx, &iwidthx, &iwhwx, &ier);
    gqfill (&szfilx, &iftypx, &ier);
   
    /*
     * setup basic information
     */
    lintyp = 1;
    lthw  = 0;
    width = 3;
    lwhw  = 0;
    gsline (&lintyp, &lthw, &width, &lwhw, &ier);
    
    pccf  = &(el->elem.ccf);
    np    = pccf->info.npts;
    /*
     * Set the color for the feature.
     */
    if (cdsColor == 0) {
      if ( cdsUattr[indx].maj_col == 0 ) {
        if (pccf->info.prob == (CCFLVL_HIGH + 1)) { /*1 = High, 2= Low */
          gscolr ( &(el->hdr.maj_col), &ier);
	}
	else {
          gscolr ( &(el->hdr.min_col), &ier);
	}
      }
      else {
        /* Use the Uattrib table */
        if (pccf->info.prob == (CCFLVL_HIGH + 1)) {
          gscolr ( &cdsUattr[indx].maj_col, &ier);
          el->hdr.maj_col = cdsUattr[indx].maj_col; /* Colors everything else */
        } else {
          gscolr ( &cdsUattr[indx].min_col, &ier);
          el->hdr.maj_col = cdsUattr[indx].min_col;  /* Colors everything else */
        }
      }
    } else {
      gscolr ( &cdsColor, &ier);
    }

    /*
     *  Set the smoothing level_tmp
     */
    ii = (cdsUattr[indx].smooth == -1) ?
	 (int) el->hdr.smooth : cdsUattr[indx].smooth;
    istyp = (ii == 0) ? 0 : 2;
    gssmth (&istyp, &cdsSmthDens[ii], &ier);

    /*
     * If fill is set, fill the polygon.
     */
    ifilled=0;
    if (cdsUattr[indx].filled == 0) {
      ifilled = (int) el->hdr.filled;
    } else {
      if (pccf->info.subtype == SIGTYP_AREA) {      
        if (pccf->info.cover == CCFLVL_HIGH + 1) {
          ifilled =  cdsUattr[indx].info.ccf->fillhi;
        }
        if (pccf->info.cover == CCFLVL_MEDIUM + 1) {
          ifilled = cdsUattr[indx].info.ccf->fillmed;
        }
        if (pccf->info.cover == CCFLVL_LOW + 1) {
          ifilled = cdsUattr[indx].info.ccf->filllow;
        }
      }
    }
    
    if (ifilled >= 1 && cdsFill == 1) {
	iftyp = ifilled;
	szfil = 1.0F;
	gsfill (&szfil, &iftyp, &ier);

	gfill (sys_M, &np, pccf->latlon, &(pccf->latlon[np]),
	       &ier, strlen (sys_M));

	iftyp = 1;
	gsfill (&szfil, &iftyp, &ier);
    }
    
    if (cdsUattr[indx].info.ccf->linetype == 0) {
      lintyp = el->elem.ccf.info.linetype;
    } else {
      lintyp = cdsUattr[indx].info.ccf->linetype;
    }
        
    switch (pccf->info.subtype)  {

      case	SIGTYP_LINE_HIGH:		/* line		*/
        gsline (&lintyp, &lthw, &width, &lwhw, &ier);
	for (ii = 0; ii < np; ii++)  {
	    lat[ii] = pccf->latlon[ii];
	    lon[ii] = pccf->latlon[ii+np];
	}

	gline (sys_M, &np, lat, lon, &ier, strlen (sys_M));

	break;

      case      SIGTYP_LINE_MED:               /* line         */
        gsline (&lintyp, &lthw, &width, &lwhw, &ier);
        for (ii = 0; ii < np; ii++)  {
	    lat[ii] = pccf->latlon[ii];
	    lon[ii] = pccf->latlon[ii+np];
	}

	gline (sys_M, &np, lat, lon, &ier, strlen (sys_M));

        break;
        
      case	SIGTYP_AREA:		/* area		*/
        gsline (&lintyp, &lthw, &width, &lwhw, &ier);

	for ( ii = 0; ii < np; ii++ )  {
	    lat[ii] = pccf->latlon[ii];
	    lon[ii] = pccf->latlon[ii+np];
	}
	lat[np] = pccf->latlon[0];
	lon[np] = pccf->latlon[np];
	np++;

	gline (sys_M, &np, lat, lon, &ier, strlen (sys_M));

	break;

    }
    
    /* Check to see if textLayoutString for CCF Text contains NIL */
    /* If so, set the variable textLayoutNIL to TRUE. */
    
    if ( cdsUattr[indx].info.ccf->textLayout[0] == '\0' ) {
      strcpy(textLayoutStr, el->elem.ccf.textLayout);
    } else {
      strcpy(textLayoutStr, cdsUattr[indx].info.ccf->textLayout);
    }
    if (strstr(textLayoutStr, "NIL") != NULL) {
      textLayoutNIL = True;
    }

    /*
     * Reset smooth level to 0
     */
    if (istyp > 0) {
	istyp = 0;
	gssmth (&istyp, &cdsSmthDens[0], &ier);
    }
    
    /*
     *  Restore the saved plot attribute values
     */
    gsline ( &iltypx, &ilthwx, &iwidthx, &iwhwx, &ier );
    gscolr ( &icolrx, &ier );
    gsfill (&szfilx, &iftypx, &ier);
        
    if (! (pccf->info.subtype == SIGTYP_LINE_HIGH || pccf->info.subtype == SIGTYP_LINE_MED)) {
      /* Create an arrow if the text box is outside the CCF polygon*/
      cds_getinx( el, &idx, &ier);  /* Get the idx to the arrow size */
      npts = 1;
      G_MALLOC( xpt, float, npts, "cds_ccf: xpt" );
      G_MALLOC( ypt, float, npts, "cds_ccf: ypt" );
      G_MALLOC( inout, int, npts, "cds_ccf: inout" );
      xpt[0] = el->elem.ccf.info.textlat;
      ypt[0] = el->elem.ccf.info.textlon;
      npls = el->elem.ccf.info.npts;
      G_MALLOC( xpl, float, npls, "cds_ccf: xpl" );
      G_MALLOC( ypl, float, npls, "cds_ccf: ypl" );
      for ( ii = 0; ii < npls; ii++ ) {
          xpl[ii] = el->elem.ccf.latlon[ii];
          ypl[ii] = el->elem.ccf.latlon[ii+npls];
      }
      cgr_inpoly ( sys_M, &npts, xpt, ypt, sys_M, &npls, xpl, ypl, inout, &ier );
      /*
       * If the center of the text box is outside of GFA polygon, and TextLayoutNIL
       * not set display an arrowed line.
       */
      if ( inout[0] == 0  && textLayoutNIL == False) {
        el_tmp.hdr.delete   = 0;
        el_tmp.hdr.vg_type  = SPLN_ELM;
        el_tmp.hdr.vg_class = (char)CLASS_LINES;
        el_tmp.hdr.filled   = 0;
        el_tmp.hdr.closed   = 0;
        el_tmp.hdr.smooth   = 0;
        el_tmp.hdr.version  = 0;
        el_tmp.hdr.grptyp   = 0;
        el_tmp.hdr.grpnum   = 0;
        el_tmp.hdr.maj_col  = el->hdr.maj_col;
        el_tmp.hdr.min_col  = el->hdr.min_col;
        el_tmp.hdr.recsz    = 0;
        el_tmp.hdr.range_min_lat = 0;
        el_tmp.hdr.range_min_lon = 0;
        el_tmp.hdr.range_max_lat = 0;
        el_tmp.hdr.range_max_lon = 0;

        el_tmp.elem.spl.info.numpts = 2;
        el_tmp.elem.spl.info.spltyp = 4;
        el_tmp.elem.spl.info.splstr = 0.5;
        el_tmp.elem.spl.info.spldir = 1;
        el_tmp.elem.spl.info.splsiz = 1.0;
        el_tmp.elem.spl.info.splsiz = el->elem.ccf.info.szarrow;
        /* Set the Arrow Size from the settings table... */
        if ( fabs (cdsUattr[idx].info.ccf->szarrow < 0.01) ) {
          el_tmp.elem.spl.info.splsiz = el->elem.ccf.info.szarrow;
        } else {
          el_tmp.elem.spl.info.splsiz = cdsUattr[idx].info.ccf->szarrow;
        }
                        
        el_tmp.elem.spl.latlon[0] = el->elem.ccf.info.textlat;
        el_tmp.elem.spl.latlon[1] = el->elem.ccf.info.arrowlat;
        el_tmp.elem.spl.latlon[2] = el->elem.ccf.info.textlon;
        el_tmp.elem.spl.latlon[3] = el->elem.ccf.info.arrowlon;
        el_tmp.elem.spl.info.splwid = 3;
        el_tmp.hdr.maj_col = el_tmp.hdr.min_col = 31;        
        cds_dspelm(&el_tmp, &ier);
        el_tmp.elem.spl.info.splwid = 1;
        el_tmp.hdr.maj_col = el_tmp.hdr.min_col = 32;
        cds_dspelm(&el_tmp, &ier);

      }
예제 #6
0
void radar_info(rad_struct RADARS[], int NEXSTNS)
{
int i,j,np=1,iret;
float x,y,sped,drct;
float rotat=0;
float rwmrk, rhmrk, rwtxt, rhtxt, rwbrb, rhbrb;
int ixoff=0,iyoff=0;
char plotstr[8];

float nx[1], ny[1], gx[1], gy[1]; 

char gcord[]="G", ncord[]="N";
char NEstr[] = "NE";
char OMstr[] = "OM";
char NAstr[] = "NA";
cntr_struct *next_cntr;
int *dataptr;

gqsysz ( &rwmrk, &rhmrk, &rwtxt, &rhtxt, &rwbrb, &rhbrb, &iret);

if(radinfo_col > 0) 
   {
   gscolr(&radinfo_col,&iret);
   for(i=0;i<NEXSTNS;i++)
      {
      get_xy(RADARS[i].stnlat,RADARS[i].stnlon,&x,&y);
      if(RADARS[i].mode == MDNE)
         gtext(gcord,&x,&y,NEstr,&rotat,&ixoff,&iyoff,&iret, strlen(gcord),strlen(NEstr));
      else if(RADARS[i].mode == MDOM)
         gtext(gcord,&x,&y,OMstr,&rotat,&ixoff,&iyoff,&iret, strlen(gcord),strlen(OMstr));
      else if(RADARS[i].mode == MDNA)
         gtext(gcord,&x,&y,NAstr,&rotat,&ixoff,&iyoff,&iret, strlen(gcord),strlen(NAstr));
      }
   }

if(cntr_col > 0)
   {
   gscolr(&cntr_col,&iret);
   gsbarb(&cntr_sz,&cntr_wid,&cntr_type,&iret);

   filter_init();

   for(i=0;i<NEXSTNS;i++)
      {
      for(j=0;j<RADARS[i].ncntr;j++)
         {
         get_xy4(RADARS[i].stnlat,RADARS[i].stnlon,RADARS[i].cntr[j].ggg,&x,&y);
         gx[0] = x + .125; gy[0] = y - .125;         
         gtrans ( gcord, ncord, &np, gx, gy, nx, ny, &iret,
            strlen(gcord),strlen(ncord));

	 if((nx[0] >= 0)&&(nx[0] <= 1)&&(ny[0] >= 0)&&(ny[0] <= 1))
	    n_filter (np, nx, ny, rhbrb, rwbrb, cntr_filter, &(RADARS[i].cntr[j]));

         } 
      }

   filter_set_head();
   while(filter_retrieve((void *)(&next_cntr), &x, &y))
      {
      sped = next_cntr->spd;
      drct = next_cntr->dir;
      gbarb(ncord,&np,&x,&y,&sped,&drct,&iret,strlen(ncord));
      } 
   }

if(maxtop_col > 0)
   {
   gscolr(&maxtop_col,&iret);

   filter_init();

   for(i=0;i<NEXSTNS;i++)
      {
      if(RADARS[i].maxtop > 0)
         {
         get_xy4(RADARS[i].stnlat,RADARS[i].stnlon,RADARS[i].maxtop_ggg,&x,&y);

	 gx[0] = x + .125; gy[0] = y - .125;
         gtrans ( gcord, ncord, &np, gx, gy, nx, ny, &iret,
            strlen(gcord),strlen(ncord));
         /* char string is 3 characters */
	 if((nx[0] >= 0)&&(nx[0] <= 1)&&(ny[0] >= 0)&&(ny[0] <= 1))
	    n_filter (np, nx, ny, rhtxt, rwtxt*2.7, maxtop_filter, &(RADARS[i].maxtop) );
         }
      }
   ixoff = 0; iyoff = 0; rotat = 0;
   filter_set_head();
   while(filter_retrieve((void *)(&dataptr), &x, &y))
      {
      sprintf(plotstr,"%03d\0",*dataptr);
      gtextc(ncord,&x,&y,plotstr,&rotat,&ixoff,&iyoff,&iret,
            strlen(ncord),strlen(plotstr));
      }
   }

if(meso_col > 0)
   {
   gscolr(&meso_col,&iret);
   gsmrkr(&meso_mark,&meso_hw,&meso_sz,&meso_wid,&iret);

   filter_init();

   for(i=0;i<NEXSTNS;i++)
      {
      for(j=0;j<RADARS[i].nmeso;j++)
         {
         get_xy4(RADARS[i].stnlat,RADARS[i].stnlon,RADARS[i].meso[j].ggg,&x,&y);

	 gx[0] = x + .125; gy[0] = y - .125;
         gtrans ( gcord, ncord, &np, gx, gy, nx, ny, &iret,
            strlen(gcord),strlen(ncord));
	 if((nx[0] >= 0)&&(nx[0] <= 1)&&(ny[0] >= 0)&&(ny[0] <= 1))
	    n_filter (np, nx, ny, rhmrk, rwmrk, meso_filter, NULL);
         RADARS[i].meso[j].nx = nx[0];
         RADARS[i].meso[j].ny = ny[0];
         }
      }
   filter_set_head();
   while(filter_retrieve((void *)(&dataptr), &x, &y))
      {
      gmark(ncord,&np,&x,&y,&iret,strlen(ncord));
      }
   }

if(tvs_col > 0)
   {
   gscolr(&tvs_col,&iret);
   gsmrkr(&tvs_mark,&tvs_hw,&tvs_sz,&tvs_wid,&iret);

   filter_init();

   for(i=0;i<NEXSTNS;i++)
      {
      for(j=0;j<RADARS[i].ntvs;j++)
         {
         get_xy4(RADARS[i].stnlat,RADARS[i].stnlon,RADARS[i].tvs[j].ggg,&x,&y);
         gx[0] = x + .125; gy[0] = y - .125;
         gtrans ( gcord, ncord, &np, gx, gy, nx, ny, &iret,
            strlen(gcord),strlen(ncord));
	 if((nx[0] >= 0)&&(nx[0] <= 1)&&(ny[0] >= 0)&&(ny[0] <= 1))
            n_filter (np, nx, ny, rhmrk, rwmrk, tvs_filter, NULL);
         RADARS[i].tvs[j].nx = nx[0];
         RADARS[i].tvs[j].ny = ny[0];
         }
      }
   filter_set_head();
   while(filter_retrieve((void *)(&dataptr), &x, &y))
      {
      gmark(ncord,&np,&x,&y,&iret,strlen(ncord));
      }
   }

}
예제 #7
0
void cds_sig ( VG_DBStruct *el, int indx, int *iret )
/************************************************************************
 * cds_sig								*
 *									*
 * This function displays SIGMETs to the output device.			*
 *									*
 * cds_sig (el, indx, iret)						*
 *									*
 * Input parameters:							*
 * 	*el		VG_DBStruct	Pointer to VG record structure	*
 *	indx		int		Index into user attribute table *
 *									*
 * Output parameters:							*
 *	*iret		int		Return code			*
 *									*
 **									*
 * Log:									*
 * D.W.Plummer/NCEP	 7/99	Copied from cds_line			*
 * D.W.Plummer/NCEP	 9/99	Compute circle from element distance;	*
 *				Compute line extension area		*
 * H. Zeng/EAI           9/99   Preserve plot attributes                *
 * F. J. Yen/NCEP 	10/99   Handled user attribute table            *
 * M. Li/GSC		10/99	Modified clo_direct and clo_dltln codes	*
 * D.W.Plummer/NCEP	12/99	Added plotting of sequence number	*
 * M. Li/GSC		 1/00	Used string variables in gtrans		*
 * S. Law/GSC		05/00	changed to use MAX_SIGMET for lat/lon	*
 * H. Zeng/EAI          06/00   increased the sizes of lat&lon arrays   *
 * A. Hardy/GSC         11/00   renamed coordinate system declarations	*
 * M. Li/SAIC           01/03   delete vgstruct.h                       *
 * T. Piper/SAIC        12/05   redone with new Setting_t structure     *
 ***********************************************************************/
{
    int		ii, kk, npts, np, intrsct, ier;
    int		mtype, color, width, lintyp, lthw, lwhw, mkhw, two;
    int         iltypx, ilthwx, iwidthx, iwhwx, icolrx, imarkx, imkhwx, imkwidx;
    char	str[4];
    float	lat[MAX_SIGMET*2+3], lon[MAX_SIGMET*2+3];
    float	size, dist, dir, ang1, ang2;
    float	dirs[]={ 0.0F, 180.0F, 90.0F, 270.0F };
    float	s1lat[2], s1lon[2], s2lat[2], s2lon[2];
    float	x1[2], y1[2], x2[2], y2[2];
    float	xint, yint;
    float       szmarkx;
    float	lbllat, lbllon, rotat=0.0F;
    int		ixoff=0, iyoff=2;
    int		itxfn_s, itxhw_s, itxwid_s, ibrdr_s, irrotn_s, ijust_s;
    float	sztext_s;
    int		itxfn, itxhw, itxwid, ibrdr, irrotn, ijust;
    float	sztext;
    SigmetType	*psig;
/*---------------------------------------------------------------------*/

    *iret = 0;

    /*
     *  Save plot attributes.
     */
    gqcolr ( &icolrx, &ier );
    gqline ( &iltypx, &ilthwx, &iwidthx, &iwhwx, &ier );
    gqmrkr ( &imarkx, &imkhwx, &szmarkx, &imkwidx, &ier );
   
    /*
     * setup basic information
     */
    psig  = &(el->elem.sig);
    width =  (int) (( (  cdsUattr[indx].info.sig->linwid == 0 ) ?
		(float)psig->info.linwid :
		(float)cdsUattr[indx].info.sig->linwid) * cdsLineWdth);
    lintyp = (  cdsUattr[indx].info.sig->lintyp == 0 ) ?
		psig->info.lintyp : cdsUattr[indx].info.sig->lintyp;

    lthw  = 0;
    lwhw  = 0;
    mtype = 1;
    mkhw  = 0;
    size  = 1.0F;
    np    = psig->info.npts;

    gsline (&lintyp, &lthw, &width, &lwhw, &ier);

    color = (cdsColor == 0) ? 
       	 ( ( cdsUattr[indx].maj_col == 0 ) ?
	     el->hdr.maj_col : cdsUattr[indx].maj_col ) : cdsColor;
    gscolr (&color, &ier);

    switch ( psig->info.subtype )  {

      case	SIGTYP_ISOL:		/* isolated	*/

	/*
	 *  Plot marker w/ surrounding circle
	 */

        lat[0] = psig->latlon[0];
        lon[0] = psig->latlon[np];
        gsmrkr ( &mtype, &mkhw, &size, &width, &ier );
        gmark ( sys_M, &np, lat, lon, &ier, strlen(sys_M) );

	if ( !G_DIFF(psig->info.distance, 0.0F ) )  {

            dir = ( lat[0] >= 0.F ) ? 180.F : 0.F;
	    dist = psig->info.distance * NM2M;
	    clo_dltln ( &lat[0], &lon[0], &dist, &dir, &(lat[1]), &(lon[1]), &ier );
            np = 18;
            gcircl ( sys_M, lat, lon, &(lat[1]), &(lon[1]), &np, 
		     &ier, strlen(sys_M) );

	}

	break;

      case	SIGTYP_LINE:		/* line		*/

	for ( ii = 0; ii < np; ii++ )  {
	    lat[ii] = psig->latlon[ii];
	    lon[ii] = psig->latlon[ii+np];
	}

	gline ( sys_M, &np, lat, lon, &ier, strlen(sys_M) );

	if ( !G_DIFF(psig->info.distance, 0.0F) )  {

	    lintyp = 2;
    	    gsline (&lintyp, &lthw, &width, &lwhw, &ier);

	    dist = psig->info.distance * NM2M;

	    switch ( psig->info.sol )  {

		case	SIGLINE_NOF:
		case	SIGLINE_SOF:
		case	SIGLINE_EOF:
		case	SIGLINE_WOF:

		    npts = 1;
		    for ( ii = 0; ii < np; ii++ )  {
			clo_dltln ( &(psig->latlon[ii]), &(psig->latlon[ii+np]),
				    &dist, &(dirs[psig->info.sol-1]),
				    &(lat[npts]), &(lon[npts]), &ier );
			npts++;
		    }
		    lat[npts] = psig->latlon[np-1];
		    lon[npts] = psig->latlon[2*np-1];
		    npts++;

		    gline ( sys_M, &npts, lat, lon, &ier, strlen(sys_M) );

		break;

		case	SIGLINE_ESOL:

		    lat[0] = psig->latlon[0];
		    lon[0] = psig->latlon[np];

		    clo_direct ( &(psig->latlon[1]), &(psig->latlon[np+1]),
				 &(psig->latlon[0]), &(psig->latlon[np  ]),
				 &ang1, &ier );

		    ang1 -= 90.0F;
		    clo_dltln ( &(psig->latlon[0]), &(psig->latlon[np]), &dist, 
				&ang1, &(lat[2*np+1]), &(lon[2*np+1]), &ier );
		    ang1 = ang1 - 180.0F;
		    clo_dltln ( &(psig->latlon[0]), &(psig->latlon[np]), &dist, 
				&ang1, &(lat[1]), &(lon[1]), &ier );

		    ang2 = ang1;

		    two = 2;
		    for ( ii = 1; ii < np-1; ii++ )  {

		     clo_direct ( &(psig->latlon[ii-1]), &(psig->latlon[np+ii-1]),
				  &(psig->latlon[ii]), &(psig->latlon[np+ii]), 
				  &ang1, &ier );
		     ang1 = (float)fmod ( ((double)ang1+270.0), 360.0);
		     clo_dltln ( &(psig->latlon[ii]), &(psig->latlon[np+ii]), 
				 &dist, &ang1, &(s1lat[1]), &(s1lon[1]), &ier );
		     clo_direct ( &(psig->latlon[ii+1]), &(psig->latlon[np+ii+1]),
				  &(psig->latlon[ii]), &(psig->latlon[np+ii]),
				  &ang2, &ier );
		     ang2 = (float)fmod ( ((double)ang2+90.0), 360.0);
		     clo_dltln ( &(psig->latlon[ii]), &(psig->latlon[np+ii]), 
				 &dist, &ang2, &(s2lat[0]), &(s2lon[0]), &ier );

		     if ( G_ABS(ang1-ang2) > 1.F )  {

		       clo_dltln ( &(psig->latlon[ii-1]), &(psig->latlon[np+ii-1]), 
				   &dist, &ang1, &(s1lat[0]), &(s1lon[0]), &ier );
		       clo_dltln ( &(psig->latlon[ii+1]), &(psig->latlon[np+ii+1]), 
				   &dist, &ang2, &(s2lat[1]), &(s2lon[1]), &ier );

		       gtrans ( sys_M, sys_N, &two, s1lat, s1lon, x1, y1, 
		                &ier, strlen(sys_M), strlen(sys_N) );
		       gtrans ( sys_M, sys_N, &two, s2lat, s2lon, x2, y2, 
		                &ier, strlen(sys_M), strlen(sys_N) );
		       cgr_segint( sys_N, x1, y1, sys_N, x2, y2,
			           sys_M, &xint, &yint, &intrsct, &ier );

		     }
		     else  {

		       xint = (s1lat[1] + s2lat[0]) / 2.0F;
		       yint = (s1lon[1] + s2lon[0]) / 2.0F;

		     }

		     kk = ii + 1;
		     lat[kk] = xint;
		     lon[kk] = yint;

		     ang1 = (float)fmod ( ((double)ang1+180.0), 360.0 );
		     ang2 = (float)fmod ( ((double)ang2+180.0), 360.0 );

		     clo_dltln ( &(psig->latlon[ii]), &(psig->latlon[np+ii]), 
				 &dist, &ang1, &(s1lat[1]), &(s1lon[1]), &ier );
		     clo_dltln ( &(psig->latlon[ii]), &(psig->latlon[np+ii]), 
				 &dist, &ang2, &(s2lat[0]), &(s2lon[0]), &ier );

		     if ( G_ABS(ang1-ang2) > 1.F )  {

		       clo_dltln ( &(psig->latlon[ii-1]), &(psig->latlon[np+ii-1]), 
				   &dist, &ang1, &(s1lat[0]), &(s1lon[0]), &ier );
		       clo_dltln ( &(psig->latlon[ii+1]), &(psig->latlon[np+ii+1]), 
				   &dist, &ang2, &(s2lat[1]), &(s2lon[1]), &ier );

		       gtrans ( sys_M, sys_N, &two, s1lat, s1lon, x1, y1, 
		                &ier, strlen(sys_M), strlen(sys_N) );
		       gtrans ( sys_M, sys_N, &two, s2lat, s2lon, x2, y2, 
		                &ier, strlen(sys_M), strlen(sys_N) );
		       cgr_segint( sys_N, x1, y1, sys_N, x2, y2,
			           sys_M, &xint, &yint, &intrsct, &ier );

		     }
		     else  {

		       xint = (s1lat[1] + s2lat[0]) / 2.0F;
		       yint = (s1lon[1] + s2lon[0]) / 2.0F;

		     }

		     kk = 2*np - ii + 1;
		     lat[kk] = xint;
		     lon[kk] = yint;

		     ang1 = (float)fmod ( ((double)ang1+180.0), 360.0 );
		     ang2 = (float)fmod ( ((double)ang2+180.0), 360.0 );

		     ang1 = ang2;

		    }

		    clo_direct ( &(psig->latlon[np-2]), &(psig->latlon[2*np-2]),
				 &(psig->latlon[np-1]), &(psig->latlon[2*np-1]),
				 &ang2, &ier );

		    ang2 -= 90.0F;
		    clo_dltln ( &(psig->latlon[np-1]), &(psig->latlon[2*np-1]), 
				&dist, &ang2, &(lat[np]), &(lon[np]), &ier );

		    ang2 = (float)fmod ( ((double)ang2+180.0), 360.0);
		    clo_dltln ( &(psig->latlon[np-1]), &(psig->latlon[2*np-1]), 
				&dist, &ang2, &(lat[np+2]), &(lon[np+2]), &ier );

		    lat[np+1] = psig->latlon[np-1];
		    lon[np+1] = psig->latlon[2*np-1];

		    lat[2*np+2] = lat[0];
		    lon[2*np+2] = lon[0];

		    npts = 2*np + 3;
		    gline ( sys_M, &npts, lat, lon, &ier, strlen(sys_M) );

		break;

	    }

	}

	break;

      case	SIGTYP_AREA:		/* area		*/

	for ( ii = 0; ii < np; ii++ )  {
	    lat[ii] = psig->latlon[ii];
	    lon[ii] = psig->latlon[ii+np];
	}
	lat[np] = psig->latlon[0];
	lon[np] = psig->latlon[np];
	np++;

	gline ( sys_M, &np, lat, lon, &ier, strlen(sys_M) );

	break;

    }

    if ( el->hdr.vg_type == SIGCONV_ELM || el->hdr.vg_type == SIGOUTL_ELM )  {

	if ( el->hdr.vg_type == SIGCONV_ELM ) 
	    sprintf( str, "%d%c", psig->info.seqnum, psig->info.msgid[0] );
	else if ( el->hdr.vg_type == SIGOUTL_ELM )
	    sprintf( str, "%d", psig->info.seqnum );

	np = psig->info.npts;
	lbllat = psig->latlon[0];
	lbllon = psig->latlon[np];
	for ( ii = 1; ii < np; ii++ )  {
	    if ( psig->latlon[ii] > lbllat )  {
	        lbllat = psig->latlon[ii];
	        lbllon = psig->latlon[ii+np];
	    }
	}

	gqtext( &itxfn_s, &itxhw_s, &sztext_s, &itxwid_s, &ibrdr_s, 
		&irrotn_s, &ijust_s, &ier );
	itxfn  = 0;
	itxhw  = 0;
	sztext = 1.5F;
	itxwid = 0;
	ibrdr  = 0;
	irrotn = 0;
	ijust  = 2;
	gstext( &itxfn, &itxhw, &sztext, &itxwid, &ibrdr, &irrotn, &ijust, &ier );
	gtext( sys_M, &lbllat, &lbllon, str, &rotat, &ixoff, &iyoff, &ier, 
	       strlen(sys_M), strlen(str) );
	gstext( &itxfn_s, &itxhw_s, &sztext_s, &itxwid_s, &ibrdr_s, 
		&irrotn_s, &ijust_s, &ier );

    }

    /*
     *  Restore the saved plot attribute values
     */
    gsmrkr ( &imarkx, &imkhwx, &szmarkx, &imkwidx, &ier );
    gsline ( &iltypx, &ilthwx, &iwidthx, &iwhwx, &ier );
    gscolr ( &icolrx, &ier );

}