Re: map projection display questions

Stuart-

Stuart Maclean wrote:
Yippee, so I have finally had some success adapting the
visad/examples/MapProjectionDisplay.java code.  I still don't understand
all of it, but oh well.

I defined my own GRIBCoordinateSystem, for a 150 cols x 126 rows grid I
have and an associated LambertConformalProjection.  works great.  The grid
is over the NE Pacific Ocean, and covers some US/Canada land, and is the
output of an MM5 weather model run here.

So then I added, via the jmet.BaseMapAdapter, the OUTLUSAM map file (from
the idv auxdata set).  This gives me nice coastlines and US state lines,
great.

BUT, I'd like the display to be 'clipped' at the 'box' boundary.  I can
see that the 'box' corresponds to the 'defaultMapArea' as returned by the
GRIB, and this is the whole grid of course (0,0,150,126).

So my question is, can the display be 'clipped' to the box?  I noted the
Display.SelectRange scalar map target from the tutorial, but this seems to
want me to set ranges for lat and lon, which are tricky.  I'd like to set
ranges on the grid values since these are known and constant, e.g 0-150
and 0-126.  Can this be done??

Any help very gratefully appreciated.

You can set the clipping using the DisplayRenderer's setClip
methods.  Here's an example from the IDV's MapProjectionDisplayJ3D:

    /**
     * Enable clipping of data at the box edges.
     *
     * @param  clip  true to turn clipping on, otherwise off
     */
    public void enableClipping(boolean clip) {
        DisplayRendererJ3D dr
            (DisplayRendererJ3D) getDisplay().getDisplayRenderer();
        try {
            dr.setClip(0, clip, 1.0f, 0.0f, 0.0f, -1.001f);
            dr.setClip(1, clip, -1.0f, 0.0f, 0.0f, -1.001f);
            dr.setClip(2, clip, 0.0f, 1.0f, 0.0f, -1.001f);
            dr.setClip(3, clip, 0.0f, -1.0f, 0.0f, -1.001f);
            // clipping on top and bottom of box - do not
            //dr.setClip(4, clip,  0.0f,  0.0f,  1.0f, -1.001f);
            //dr.setClip(5, clip,  0.0f,  0.0f, -1.0f, -1.001f);
        } catch (VisADException ve) {
            System.err.println("Couldn't set clipping " + ve);
        }
        super.enableClipping(clip);
    }

For 3D, you need to set the clipping separately on each side.

For a 2D display, you can use:

    public void enableClipping(boolean clip) {
        DisplayRendererJ2D dr2
            (DisplayRendererJ2D) getDisplay().getDisplayRenderer();
        if (clip) {
            dr2.setClip(-1.0f, 1.0f, -1.0f, 1.0f);
        }
        super.enableClipping(clip);
    }

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
"There's someone in my head, but it's not me"    Roger Waters
*************************************************************



  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: