1      SUBROUTINE MAPLAB (XP,YP,FLPT,LCODE,LONLAB)<C_TITLE  MAPLAB  Plots the numerical labels on the map grid.C_ARGUMENTS@	REAL XP  	 ![I] The X world coord. of the number to be plotted.>	REAL YP		 ![I] The Y world coord. of the number to be plotted9	REAL FLPT	 ![I] The floating point number to be plotted.R	INTEGER LCODE(2) ![I] The line type of the long., lat. to be plotted (see MAPROJ)J	LOGICAL LONLAB   ![I] A flag indicating which axis is currently plotting.PC_DESCRIPTION Subroutine MAPLAB plots the numerical labels on a map grid.  This MC module determines the locations of the labels to be plotted dependent upon MC lOngitude and latitude grid line increment.  This routine also examines theKC line type of the projection (lines are classified into 3 different types,8C straight, circular, and neither straight or circular).C	C_VARIABLES%      INCLUDE 'RAD$INC:GRID.INC/LIST'.C				Uses: RLON, YLATMIN, YLATMAX, DLON, DLAT,)C			              KPROJ.  Modifies: None.$      INCLUDE 'RAD$INC:LAB.INC/LIST'1C				Uses: LONSP, LATSP, IDX, IDY, ORIENT, ISIZE,GC	                              LOGICAL LCHECK,OFFSET.  Modifies: none.0C_CALLS  CONV FNDFRST FRSTPT LCHECK MAPROJ PWRIT"C_HISTORY  84NOV28  R.GURULE  USGSC_PAUSE      LOGICAL LCHECK,OFFSET!      CHARACTER*14 CNUM, PCHAR *1$      COMMON /CC/CNUM,IPT,IDEC,NCHAR7      DATA XBORD,YBORD/.FALSE.,.FALSE./,ISFLG/0/,IOR/0/      DATA PCHAR/'.'/      CLON = CENT(1)      CLAT = CENT(2)      PNMBR = FLPT+      CALL MAPROJ(1,LLON,YLATMIN,XMIN,YMIN)+      CALL MAPROJ(1,RLON,YLATMAX,XMAX,YMAX)L!----Convert the delta x, delta y into World coordinates. Since all plotting&!    takes place in world coordinates.P!-----Set XBORD or YBORD appropiately, True if plotting interior labels, and notM!     just the border labels.  ISFLG is zero first time through here, else 1.M!     find the difference in longitudes and determine the longitudinal range.H!     Check for the special case when KPROJ = Polar, set longitude range!     to 360.0.      IF( ISFLG .EQ. 0)THEN4        A1 = ABS((LLON - CLON)) + ABS((RLON - CLON))	IF(KPROJ.EQ.3)A1 = 360.0        NXLINES = A1 / LONSP/     	NYLINES = (YLATMAX - YLATMIN) / LATSP + 1&        IF(NXLINES.GT.2)XBORD = .TRUE.&        IF(NYLINES.GT.2)YBORD = .TRUE.        ISFLG = 1      ENDIF      %!-----Encode the label to be plotted.      	5      ENCODE(12,100,CNUM)FLPT                         100  FORMAT(F12.1)      IST=1
      IEND=12      CALL FNDFRST(CNUM,IPT)M      IDEC= INDEX(CNUM, PCHAR)                                                     NCHAR= (IDEC - IPT)4!-----Plot the mercator and cylindrical coordinates.,!     Specific params for long, or lat axes.D!     Plot the proper coordinates for lambert and polar coordinates.        IF(LONLAB)THEN	#          IF(LCODE(2).EQ.2)THEN 		 C!---------Swap the y min and max if the latitude is less than zero.	    IF(YLATMIN.GE.0.0)THEN3              CALL MAPROJ( 1,FLPT,YLATMIN,XP,YP)   3              CALL MAPROJ( 1,FLPT,YLATMAX,XP1,YP1) !	    ELSE IF(YLATMAIN.LE.0.0)THEN3              CALL MAPROJ( 1,FLPT,YLATMAX,XP,YP)   3              CALL MAPROJ( 1,FLPT,YLATMIN,XP1,YP1) 
	    ENDIF3          ELSE IF(LCODE(2).EQ.1.AND.KPROJ.NE.5)THEN            XP1= XP            YP1= YMAX            XP = XP            YP = YMIN          ELSE +            CALL MAPROJ(1,FLPT, CLAT,XP,YP)-            CALL MAPROJ(1,FLPT, CLAT,XP1,YP1)          ENDIF%        ELSE					!Params for latitude"          IF( LCODE(2) .EQ. 2)THEN+            CALL MAPROJ(1, LLON,FLPT,XP,YP)-            CALL MAPROJ(1, RLON,FLPT,XP1,YP1)E          ELSE IF(LCODE(2).EQ.3)THEN		!Plot along clon the lat label.+            CALL MAPROJ(1, CLON,FLPT,XP,YP)          ELSE             XP = XMIN             YP = YP             YP1= YP             XP1= XMAX          ENDIF
        ENDIFF!-----Set ICODE appropiately..indicating ICODE=1, then plot meridians,!     else parallels.      IF(LONLAB)THEN        ICODE =1
      ELSE        ICODE =2      ENDIF                                IF(XBORD .OR. YBORD)THEN&         IF( LCHECK(ICODE,FLPT) )THEN	9           CALL CONV(XP,YP,IXP,IYP,LONLAB,FLPT,LCODE(1))            CALL FRSTPT(IXP,IYP)H           CALL PWRIT(IXP,IYP,%REF(CNUM(IPT:IDEC)), NCHAR,ISIZE,IOR,0)  7!------If plotting circles only plot maximum latitudes.         IF(KPROJ.EQ.5)RETURN7         IF(LCODE(2) .EQ. 3  .AND.(.NOT.LONLAB))RETURN	0         IF(LCODE(2) .EQ. 2 .AND. LONLAB) RETURNE         IF((KPROJ .EQ. 3).AND.(.NOT.LONLAB))RETURN                  :           CALL CONV(XP1,YP1,IXP,IYP,LONLAB,FLPT,LCODE(1))           CALL FRSTPT(IXP,IYP)F           CALL PWRIT(IXP,IYP,%REF(CNUM(IPT:IDEC)), NCHAR,ISIZE,IOR,0)         ENDIF       ELSEE           IF(FLPT .EQ. LLON .OR. FLPT .EQ. RLON .OR. FLPT.EQ.YLATMIN#     1	   .OR. FLPT.EQ.YLATMAX)THEN:             CALL CONV(XP,YP,IXP,IYP,LONLAB,FLPT,LCODE(1))G             CALL PWRIT(IXP,IYP,%REF(CNUM(IPT:IDEC)),NCHAR,ISIZE,IOR,0)5             IF( LCODE(2) .EQ. 2 .AND. LONLAB) RETURN6             IF(KPROJ.EQ.3 .AND. (.NOT. LONLAB))RETURN=             CALL CONV(XP1,YP1, IXP,IYP,LONLAB,FLPT,LCODE(1))G             CALL PWRIT(IXP,IYP,%REF(CNUM(IPT:IDEC)),NCHAR,ISIZE,IOR,0) 	   ENDIF         
        ENDIF      RETURN	      END*      LOGICAL FUNCTION LCHECK (ICODE,FLPT)FC_TITLE  LCHECK  Logical function decides if a label is to be plotted.C_ARGUMENTSIC	INTEGER ICODE  ![I]If ICODE=1, longitude checking; else latitude check.=C	REAL FLPT      ![I]The floating point number to be plotted.C_VAR      INCLUDE 'RAD$INC:LAB.INC')C				Uses: LONSP, LATSP.  Modifies: none.       INCLUDE 'RAD$INC:GRID.INC'.C				Uses: RLON, LLON, YLATMIN, YLATMAX, DLON,!C				      DLAT.  Modifies: none.
C_DESCRIPTIONGC The logical function LCHECK indicates whether or not a label is to beIC plotted on either the latitude or longitude grid line.  Determines if aHC label is to be plotted by examining the line type and projection type.HC This module examines the delta longitude, and delta latitude incrementIC to decide whether the grid interval is such that a label is required as(C specified by the input user arguments.C_PAUSE      DATA DLT,DLN/2*0.0/      CLON = CENT(1)      GO TO (100,200) ICODE      '!-----Check for longitude label or not.       100 IF(XBORD)THEN			P!--We want to plot even multiples of long, check for case of first or last Long.M!  If first or ending longitude isn't a multiple of dlon, and we want to plot.!  interior grid lines, then set lcheck false.(       REM = ABS( AMOD(FLPT, ABS(DLON)))2       IF( FLPT .EQ. LLON .OR. FLPT .EQ. RLON)THEN         IF (REM .NE. 0.0)THEN           LCHECK = .FALSE.
         ELSE           LCHECK =.TRUE.         ENDIF         GO TO 999       ELSEN!---Increment our DLN counter, check to see if equal to or long. label spacing!   If so then plot the label.         DLN = DLN + DLON$         IF(ABS(DLN) .EQ. LONSP)THEN            DLN= 0.0            LCHECK = .TRUE.
         ELSE            LCHECK = .FALSE.         ENDIF
        ENDIF      ELSE		M!- Plot only starting and ending longs, we don't care about any intermediate 2!- labels, because there aren't any at this lonsp.8         IF(( FLPT .EQ. LLON) .OR. (FLPT .EQ. RLON))THEN            LCHECK = .TRUE.
         ELSE            LCHECK = .FALSE.         ENDIF      ENDIF      GO TO 999      &!-----Check for Latitude label or not.8  200 IF(YBORD)THEN			!we want to plot even multiples of0         				!DLat, IF = to first or ending then&      					!return w/out incr counter.#       REM = ABS( AMOD(FLPT, DLAT))9        IF( FLPT .EQ. YLATMIN .OR. FLPT .EQ. YLATMAX)THEN7           IF( ABS (AMOD (FLPT, ABS(DLAT))).NE.0.0)THEN             LCHECK = .FALSE.           ELSE             LCHECK = .TRUE.           ENDIF         RETURN        ELSE       	 DLT = DLT + DLAT$         IF(ABS(DLT) .EQ. LATSP)THEN            DLT= 0.0            LCHECK = .TRUE.
         ELSE            LCHECK = .FALSE.         ENDIF       ENDIF2      ELSE				!PLOT ONLY STARTING AND ENDING Lats.;       IF((FLPT .EQ. YLATMIN) .OR. (FLPT .EQ. YLATMAX))THEN          LCHECK = .TRUE.       ELSE                    LCHECK = .FALSE.       ENDIF                  ENDIF 999   CONTINUE      RETURN	      END      .	SUBROUTINE CONV (X,Y,IX,IY,LONLAB,FLPT,LCODE)AC_TITLE  CONV  Adds an offset to a label in the X or Y direction.C_ARGUMENTS#	REAL X	    ![I] X-axis coordinate.$	REAL Y      ![I] Y-axis coordinate.<	INTEGER IX  ![O] X coordinate with the appropriate delta X.<	INTEGER IY  ![O] Y coordinate with the appropriate delta Y.B	LOGICAL LONLAB  ![I] Logical variable, if true we are plotting a B                       ! longitude, otherwise plotting a latitude.G	REAL FLPT       ![I] The floating point number to be plotted, aids in P                      !deciding if we are plotting the rlon, or bottom latitude.F	INTEGER LCODE(2) ![I] The line type of the long., lat. to be plotted.
C_DESCRIPTIONKC  The subroutine CONV will add an offset to the X or Y plotting coordinateKC  depending on the latitude or longitude to be plotted.  Conv will add an IC  x and/or y offset to a label if it is too close to an already existing	C  label.C_VARIABLES              A      INCLUDE 'RAD$INC:GRID.INC'    !Uses:  RLON,YLATMIN,YLATMAX,5                                    !Modifies:  NONE.?      INCLUDE 'RAD$INC:LAB.INC'     !Uses:  IDX,IDY,ISIZE,CENT.5                                    !Modifies:  NONE.9C_HISTORY  R.Gurule  84Nov28  U.S.G.S Flagstaff, Az.86001C_END      CHARACTER*14 CNUM      INTEGER OLDX,OLDY      DIMENSION IWIDTH(4)$      COMMON /CC/CNUM,IPT,IDEC,NCHAR?      DATA IWIDTH/8,12,16,24/,OLDX,OLDY/-20000, -20000/,LONE/1/      CLON = CENT(1)&      IF(OLDX.EQ.-20000)IS = ISIZE + 1      ICHARSIZ= IWIDTH(IS)      L!-----Assume Mercator and Simple Cylindrical, calculate XMIN,XMAX,YMIN,YMAX.      IF(LONLAB)THEN,        CALL MAPROJ(1,FLPT,YLATMIN,XPT,YMIN),        CALL MAPROJ(1,FLPT,YLATMAX,XPT,YMAX)
      ELSE)        CALL MAPROJ(1,LLON,FLPT,XMIN,YPT))        CALL MAPROJ(1,RLON,FLPT,XMAX,YPT)      ENDIFQ        IF(LCODE(1).EQ.3.AND.LCODE(2).EQ.3)THEN !CHECK FOR LONGITUDINAL LABELING ;         CLON=CENT(1)				!ONLY PLOT ALONG NEAREST LATITUDE	F       	 CLAT=CENT(2)		        	!IF VIEW, SET DELAT,DELON AS CENTER OF        ENDIF					!PROJ.G!-----Preset the latitude to plot longitudinal labels on, if LCODE(1)=3/        IF(LCODE(1).EQ.3.AND.LCODE(2).EQ.1)THEN7          IF(YLATMIN.LT.0.0 .AND. YLATMAX .GT. 0.0)THEN            CLAT = 0.0            CLON = CLON          ELSE            CLAT = YLATMIN            CLON = CLON          ENDIF
        ENDIF!---- Check for line type = 3.      IF(LCODE(1) .EQ. 3) THEND        IF( LONLAB )THEN		    ! If longitudinal labeling, then plot L          CALL MAPROJ(1,FLPT,CLAT,XPT,YPT)  ! the longitude labels along the.      	ELSE	  			    ! central latidude (CLAT)*          CALL MAPROJ(1,CLON,FLPT,XPT,YPT)3  	ENDIF				    ! Place latitude labels along Along      					    ! CLON'!--Take care of line type = 2 (circle).N!  If longitudinal label plotting then send the longitude label to be plotted,K!  and the minimum latitude to be plotted, else if plotting latitude labelsI!  send the right longitude and the corresponding latitude to be plotted.&       ELSE IF(LCODE(2).EQ.2)THEN             IF(LONLAB)THEN4          IF(KPROJ.NE.3.AND.FLPT.NE.360.0)THEN      4            CALL MAPROJ(1, FLPT, YLATMIN, XPT, YMIN)	  ENDIF        ELSE3          CALL MAPROJ(1, RLON, FLPT, XMAX, YPT)    
        ENDIF        ANG = ATAN2D(Y , X)        DY =  IDY  * COSD (ANG)"        DX =  -(IDX  * SIND (ANG))        IDELY = JIFIX(DX)        IDELX = JIFIX(DY)           IF (.NOT. LONLAB)THEN          IDELY = IDEL1           IF(DY .LE. 0.0)THEN            IDELX = DX          ELSE             IDELX = -DX          ENDIF        ENDIF      F!-----Case of a rectangular grid. (e.g.  MERCATOR, SIMPLE CYLINDRICAL):      ELSE IF((LCODE(1) .EQ. 1) .AND. LCODE(2) .EQ. 1)THEN%!-----Test for latitude or longitude.        IF(LONLAB) THEN<          IF(Y .EQ. YMIN)THEN		!If plotting longitudes, then8            IDELY = IDY  		!offset in neg. direction for8            IDELX = 0	                !minimum latitude.          ELSE            IDELY = IDY * -1          ENDIFH        ELSE                            !Then we are plotting latitudes,O                                        !Multiplying by a negative 1 alternates(          LONE = LONE * -1		!this value.          IDELX = IDX * LONE          IDELY = 0
        ENDIF      ENDIF      $!-----Convert to screen coordinates.      CALL FL2INT(X,Y,MX,MY))      IX = (MX * 1024.0)/ 32767.0 + IDELX)      IY = (MY * 1024.0)/ 32767.0 + IDELY?!-----Implies first time this routine is called if oldx= -20000      IF(OLDX.EQ.-20000)THEN2         OLDX= IX + IDELX + ((NCHAR+1) * ICHARSIZ)2         OLDY= IY + IDELY + ((NCHAR+1) * ICHARSIZ)         RETURN      ENDIFL!-----Check and make sure that the new label doesn't over run the old label.      IYDELT= JIABS(OLDY-IY)      IXDELT= JIABS(OLDX-IX)F!      IF(IXDELTA.LE.ICHARSIZ.AND.IYDELT.LE.ICHARSIZ.AND.(LONLAB))THEN!        IPT = 1!        IDEC = 1!        NCHAR = 1!        CNUM(1:1) = ' '!      ELSE*!        OLDX = IX + ( (NCHAR) * ICHARSIZ)*!        OLDY = IY + ( (NCHAR) * ICHARSIZ)!      ENDIF      RETURN	      END