NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

rangeControl with McIdas Map outlines

Hi Folks,

I am trying to display McIdas map outlines within a 3D bounding box
using VisAD and the BaseMapAdapter class.  I am running into
difficulties when I try to select a longitude range that extends beyond
+/-180 degrees (for example, a map outline over the Pacific Ocean
between -240 and -60 degrees longitude).

I can successfully select this range and display the desired map
outlines using the ScalarMap setRange methods.  However, this results
in a display with the correct map outlines within the 3D bounding box,
but the rest of the entire world map also extends outside the 3D
bounding box.

I then added code to generate a rangeControl so that the map outlines
outside of the bounding box would be eliminated.  However, when this
code is added, the map outlines that extend beyond +/-180 degrees
longitude no longer display inside the 3D bounding box.  This approach
works fine as long as I stay withing +/-180 degrees longitude, but, if
I want a map outline over the Pacific Ocean, for example, I am unable
to display the outlines beyond -180 degrees longitude.

I am appending some sample code that demonstrates this problem. 

Any suggestions for a way around this or a better approach to take for
displaying map outlines?

Thanks!

Tim Scheitlin
National Center For Atmospheric Research
scheitln@xxxxxxxx


/* CCLI MapTest Class */

/* 
   This class is responsible for reading a McIdas Map database and
   drawing a map.
*/

// Import needed classes

import visad.*;
import java.rmi.RemoteException;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.*;
import visad.ColorControl;
import visad.CoordinateSystem;
import visad.ConstantMap;
import visad.Data;
import visad.DataReference;
import visad.DataReferenceImpl;
import visad.Display;
import visad.DisplayImpl;
import visad.RealTupleType;
import visad.RealType;
import visad.ScalarMap;
import visad.data.mcidas.BaseMapAdapter;
import visad.java3d.DisplayImplJ3D;
import visad.RangeControl;

public class MapTest
{
   public static ScalarMap latMap;     // latitude  -> YAxis
   public static ScalarMap lonMap;     // longitude -> XAxis
   public static ScalarMap lonRangeMap;
   public static ScalarMap latRangeMap;
   public static DataReference maplinesRef;
   public static ConstantMap[] maplinesConstantMap = new ConstantMap[4];
   public static DisplayImplJ3D display;


    public MapTest(String mapFile)
    {
        try
        {
            //  Read in the map file
            BaseMapAdapter baseMapAdapter;
            baseMapAdapter = new BaseMapAdapter(mapFile);

            // Set ScalarMaps for X and Y axes
            latMap = new ScalarMap(RealType.Latitude, Display.YAxis);
            lonMap = new ScalarMap(RealType.Longitude, Display.XAxis);

            // Remove any prior data references
            display.removeAllReferences();

            // Add the lat/lon maps
            display.addMap(latMap);
            display.addMap(lonMap);

            // Set the lat/lon range within the 3D bounding box
            latMap.setRange(-30.0, 30.0);
            lonMap.setRange(-240.0, -60.0);

// In this next code section I am trying to create a RangeControl so that
// only the desired world map outlines between longitude -240 to -60 and 
// latitude -30 to 30 are displayed in the 3D bounding box.
// However, when this code is added, the map outlines between -240 and -180
// degrees Longitude do not display.  If the code is commented out, as below,
// all the correct map outlines appear within the 3D bounding box.  However,
// the rest of the world map also appears outside of the bounding box.
// How do I get all the desired map outlines within the 3D bounding box 
// without having the rest of the world map appear outside the bounding box?

//      lonRangeMap = new ScalarMap(RealType.Longitude,Display.SelectRange);
//      display.addMap(lonRangeMap);
//      RangeControl lonRangeControl = (RangeControl) lonRangeMap.getControl();
//      latRangeMap = new ScalarMap(RealType.Latitude,Display.SelectRange);
//      display.addMap(latRangeMap);
//      RangeControl latRangeControl = (RangeControl) latRangeMap.getControl();
//      float[] nlonRange = { -240.0f, -60.0f };
//      float[] nlatRange = { -30.0f, 30.0f };
//      lonRangeControl.setRange ( nlonRange );
//      latRangeControl.setRange ( nlatRange );

            // create a reference for the map lines
            maplinesRef = new DataReferenceImpl("MapTest");
            maplinesRef.setData(baseMapAdapter.getData());

            // set the attributes of the map lines (color, location)
            maplinesConstantMap[0] = new ConstantMap(0., Display.Blue);
            maplinesConstantMap[1] = new ConstantMap(1., Display.Red);
            maplinesConstantMap[2] = new ConstantMap(0., Display.Green);
            maplinesConstantMap[3] = new ConstantMap(1.001, Display.Radius); 
            display.addReference (maplinesRef, maplinesConstantMap);
        }
        catch (Exception ne)
        {
            ne.printStackTrace(); System.exit(1);
        }

    }

  public static void main(String[] args)
        throws RemoteException, VisADException
  {

    display = new DisplayImplJ3D("display1");
    MapTest mapLines = new MapTest("../OUTLSUPW");
    JFrame jframe = new JFrame();
    jframe.setContentPane( (JPanel) display.getComponent() );
    jframe.setSize(400,400);
    jframe.setVisible(true);
    
  }

}


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