Re: Problem filling just ...

From: Dave Kennison (kennison AT unknown)
Date: Thu Jun 15 1995 - 15:12:08 MDT


Jeffrey Jonas wrote:

> I have on a number of occasions had to generate B&W contour images
> over a world map. To get especially nice looking images I fill
> the world map with gray instead of drawing the continential
> outlines. This has been working out well until now. I want to
> do basically the same thing except instead of filling-up a gray
> world-map area, I want to only use part of the world-map, North
> America. I have tinkered around with this for a couple of days
> in an attempt to narrow down the problem, but I simply keep
> getting bad results (if any). It is obvious that there is some-
> thing I am missing in my understanding of how this works.
>
> Basically what I was doing that did not work was ...
>
> call mapstc('OU','PO')
> call maproj('CE',0.0,0.0,0.0)
> call mapset('MA',P1,P2,P3,P4) <-- P1-4 arrays of 0.'s
> call arinam(MAP,LMAP)
> call mapint
> call cpset('SET',0)
> call set(0.06, 0.94, 0.602, 0.139,
> * -150., -50., 20., 60., 1)
> call mapbla(MAP)
>
> However this works with the full world-map ....
> call set(0.013, 0.988, 0.27, 0.512,
> * -180., 180., -90., 90., 1)
>
> Any ideas or suggestions would be appreciated, thanx !!!

Attached below is a working program incorporating code fragments from above.
Following are the important changes:

  1) In the call to MAPSTC, I changed 'PO' to 'CO' so as to get just the
     outlines separating land from ocean.

  2) I arranged to color the land grey and the ocean cyan.

  3) I put in a "CALL MAPPOS (.06,.94,.139,.491)" to tell EZMAP what part
     of the plotter frame to use.

  4) I changed the MAPSET call to "CALL MAPSET ('CO',P1,P2,P3,P4)" to tell
     EZMAP to use the CORNERS method of determing the map limits and I made
     the contents of P1 through P4 be "20.,0.,-150.,0.,60.,0.,-50.,0.".
     The net effect of this is to tell EZMAP to display that subset of the
     globe as viewed in cylindrical-equidistant projection which has the
     lower left corner (20N,150W) and upper right corner (60N,50W).

  5) I took out the call to SET, which was overriding the one done by
     MAPINT. (I note in passing that the SET call had arguments 3 and
     4 in the wrong order; I assume this was a typo.)

Note that the user-system window defined by the MAPSET call has the same
aspect ratio as the fractional-system viewport defined by the MAPPOS call
(that is to say, that (.491-.139)/(.94-.06) = (60.-20.)/(-50.-(-150.)) = .4).
This ensures that portion of the map chosen for viewing will exactly fit in
specified viewport. (EZMAP shows you that portion of the map defined by the
call to MAPSET, but maintains its natural aspect ratio; this may leave a
portion of the viewport defined by the call to MAPPOS unfilled.)

There *are* times when you want to do your own call to SET after a call to
MAPINT has done one; this is true *only* when you really want to override
the natural aspect ratio of the map. In such cases, you should put lines
like

     CALL GETSET (OVPL,OVPR,OVPB,OVPT,WNDL,WNDR,WNDB,WNDT,LNLG)
     CALL SET (YVPL,YVPR,YVPB,YVPT,WNDL,WNDR,WNDB,WNDT,LNLG)

after the call to MAPINT, thus substituting your own viewport limits (YVPL,
YVPR, YVPB, and YVPT) for the original ones picked by EZMAP (OVPL, OVPR, OVPB,
and OVPT), but leaving the window limits (WNDL, WNDR, WNDB, and WNDT) as
determined by the values of the arguments of MAPSET and the linear/log flag
unchanged. I have put such code in (following the comment "Override the SET
call done by MAPINT."), but commented it out; you can run the program with
this code commented out and then with it back in and observe the effect.

Program follows:

      PROGRAM TESTIT
C
C Define the length of the area map.
C
        PARAMETER (LMAP=750000)
C
C Declare argument arrays for MAPSET.
C
        DIMENSION P1(2),P2(2),P3(2),P4(2)
C
C Declare area-map array, X and Y coordinate arrays, and area- and
C group-identifier arrays.
C
        DIMENSION IMAP(LMAP),XCRA(10000),YCRA(10000),IAAI(10),IAGI(10)
C
C Tell the compiler that COLRIT is a routine, not a variable.
C
        EXTERNAL COLRIT
C
C Define contents of argument arrays for MAPSET.
C
        DATA P1,P2,P3,P4 / 20.,0.,-150.,0.,60.,0.,-50.,0. /
C
C Open GKS.
C
        CALL OPNGKS
C
C Turn off clipping by GKS.
C
        CALL GSCLIP (0)
C
C Select solid fill by GKS.
C
        CALL GSFAIS (1)
C
C Define color indices 2 (cyan) and 3 (gray).
C
        CALL GSCR (1,2,0.,1.,1.)
        CALL GSCR (1,3,.5,.5,.5)
C
C Tell EZMAP to use continental-outline dataset.
C
        CALL MAPSTC ('OU','CO')
C
C Tell EZMAP to use a cylindrical equidistant projection.
C
        CALL MAPROJ ('CE',0.,0.,0.)
C
C Tell EZMAP what part of the plotter frame to use.
C
        CALL MAPPOS (.06,.94,.139,.491)
C
C Tell EZMAP to show only that portion of the map defined by two
C corner points.
C
        CALL MAPSET ('CO',P1,P2,P3,P4)
C
C Initialize the area map.
C
        CALL ARINAM (IMAP,LMAP)
C
C Initialize EZMAP.
C
        CALL MAPINT
C
C Override the SET call done by MAPINT.
C
C CALL GETSET (OVPL,OVPR,OVPB,OVPT,WNDL,WNDR,WNDB,WNDT,LNLG)
C CALL SET ( .06, .94,.139,.791,WNDL,WNDR,WNDB,WNDT,LNLG)
C
C Send outline data to the area map.
C
        CALL MAPBLA (IMAP)
C
C Recover the areas defined by the area map and let COLRIT color them.
C
        CALL ARSCAM (IMAP,XCRA,YCRA,10000,IAAI,IAGI,10,COLRIT)
C
C Advance the frame.
C
        CALL FRAME
C
C Close GKS.
C
        CALL CLSGKS
C
C Done.
C
        STOP
C
      END

      SUBROUTINE COLRIT (XCRA,YCRA,NCRA,IAAI,IAGI,NAID)
C
C This routine colors the polygon defined by the X and Y coordinates
C in the arrays XCRA and YCRA as implied by the area-identifier info
C in the arrays IAAI and IAGI.
C
        DIMENSION XCRA(NCRA),YCRA(NCRA),IAAI(NAID),IAGI(NAID)
C
C Recover the area identifier relative to group 1.
C
        IAG1=-1
C
        DO 101 I=1,NAID
          IF (IAGI(I).EQ.1) IAG1=IAAI(I)
  101 CONTINUE
C
C Color the area only if its area identifier relative to group 1 is
C greater than zero and the color suggested by the EZMAP routine
C MAPACI, plus 1, is a two or a three.
C
        IF (IAG1.GT.0) THEN
          ICLR=MAPACI(IAG1)+1
          IF (ICLR.GE.2.AND.ICLR.LE.3) THEN
            CALL GSFACI (ICLR)
            CALL GFA (NCRA-1,XCRA,YCRA)
          END IF
        END IF
C
C Done.
C
        RETURN
C
      END



This archive was generated by hypermail 2b29 : Wed Jun 28 2000 - 09:40:25 MDT