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.

Re: Mapping Problems

Hi Mathias,

> I have a dataset with MathType (index) -> (longitude, latitude, altitude, 
> temperature, ...) and I want to add a plane in my DisplayImplJ3D
> such that the plane is a rectangle with its vertices lets say in the outer 
> borders of the x-y-plane. Therefore I initialize the plane like
> 
> RealTupleType domainTupleType = new RealTupleType(RealType.Longitude, 
> RealType.Latitude);
> RealType valueRealType = realTypes[2];
> FunctionType functionType = new FunctionType(domainTupleType, valueRealType);
> visad.Set set = new Linear2DSet(domainTupleType, ranges[0][0], ranges[0][1], 
> 2, ranges[1][0], ranges[1][1], 2);
> layerField = new FlatField(functionType, set);
> layerField.setSamples(new double[][] { {ranges[2][0], ranges[2][0], 
> ranges[2][0], ranges[2][0]} });
> DataReference layerReference = new DataReferenceImpl("layer");
> layerReference.setData(layerField);
> 
> where RealType.Longitude is mapped to Display.XAxis and RealType.Latitude is 
> mapped to Display.YAxis and double[][] ranges holds the outer
> borders of the x-y-plane. This works very well if the Longitude borders are 
> within ]-180, 180[. But if I load a dataset with a point that has
> a Longitude value of -180 then the plane is invisible because the Longitude 
> value of -180 mapped to the XAxis is drawn at Longitude = 180
> instead of Longitude = -180. How can I prevent this? Is there a possibility 
> to avoid the wrapping of the Longitude-values?

I tried my own test of this with the attached Junk.java program
and did not get the problem you describe.

> I also add three points to handle the plane as a slicer that can make even 
> non x-y-plane-parallel slices. I add the points with
> ConstantMap(-/+1, Display.X/YAxis) and they always appear in the outer edges 
> of the x-y-plane. This seems not to be influenced by my dataset.
> Is the interpretation of a ConstantMap another than the interpretation of a 
> ScalarMap?

This is confusing. You would add points to the display
using DisplayImpl.addReference(), not with the ConstantMap
constructor.

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html
// import needed classes
import visad.*;
import visad.java3d.DisplayImplJ3D;
import visad.java2d.DisplayImplJ2D;
import visad.util.VisADSlider;
import visad.data.netcdf.Plain;
import java.rmi.RemoteException;
import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Junk {

  // type 'java Junk' to run this application
  public static void main(String args[])
         throws VisADException, RemoteException, IOException {

    RealTupleType earth
      new RealTupleType(RealType.Longitude, RealType.Latitude);

    Linear2DSet region = new Linear2DSet(earth, -180.0, 180.0, 2, -90.0, 90.0, 
2);
    RealType range = new RealType("range");
    FunctionType ftype = new FunctionType(earth, range);
    FlatField field = new FlatField(ftype, region);
    field.setSamples(new float[][] {{0.0f, 0.5f, 0.5f, 1.0f}});

    // create a DataReference for region
    final DataReference region_ref = new DataReferenceImpl("region");
    // region_ref.setData(region);
    region_ref.setData(field);

    // create a Display using Java3D
    // DisplayImpl display = new DisplayImplJ3D("image display");
    // create a Display using Java2D
    DisplayImpl display = new DisplayImplJ2D("image display");

    // map earth coordinates to display coordinates
    display.addMap(new ScalarMap(RealType.Longitude, Display.XAxis));
    display.addMap(new ScalarMap(RealType.Latitude, Display.YAxis));
    display.addMap(new ScalarMap(range, Display.Green));

    GraphicsModeControl mode = display.getGraphicsModeControl();
    mode.setScaleEnable(true);

    // link the Display to region_ref
    display.addReference(region_ref);

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("Junk VisAD Application");
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
    });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);
  }
}

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