Tuples with reals cause an exception

I've been wanting to get some data like (n)->(lat, lon, name) onto the
screen, but I'm having trouble.

I've observed that I can write a program with:

1. RealType->RealType it does work.
2. RealType->(RealType, RealType) it does not work!
3. RealType->(TextType, RealType) it does work.

In all these cases the domain type is mapped to Display.XAxis and one
of the range types is mapped to Display.Text

Attached is my program that implements number 2 above, I would
appreciate
help getting this to work.

The output looks like:
java.lang.ClassCastException: visad.Tuple
        at visad.FieldImpl.getRangeCoordinateSystem(FieldImpl.java,
Compiled Code)
...

thanks,

Andrew.

-- 
 Andrew Donaldson                                           
 Email:   A.Donaldson@xxxxxxxxxx                Bureau of Meteorology
 Phone:   +61 3 9669 4537            P.O. Box. 1289K/150 Lonsdale St,
 Fax:     +61 3 9669 4128                       Melbourne, Australia.
import visad.*;
import visad.java2d.DisplayImplJ2D;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;


public class simple
{
        public simple (String []args)
                throws RemoteException, VisADException
        {
                RealType time = new RealType("time");
                RealType height = new RealType("height");
    
                DisplayImpl display = new DisplayImplJ2D("display1");
    
                // Maps
                display.addMap(new ScalarMap(Display.Latitude, Display.XAxis));
                display.addMap(new ScalarMap(Display.Longitude, Display.YAxis));
                display.addMap(new ScalarMap(height, Display.Text));

                /*
                 * Load up the data
                 */
                RealType cnameType = height;
        
                RealType[] rangeTypes = {
                        RealType.Latitude,
                        RealType.Longitude,
                        cnameType
                };
                RealTupleType rangeTupleType = new RealTupleType(rangeTypes);

                FunctionType function = new FunctionType(time, rangeTupleType);

                // Domain
                int ntimes = 1;
                Set timeSet = new Linear1DSet(RealType.Generic, 0.0,
                        (double) (ntimes - 1.0), ntimes);

                FieldImpl field = new FieldImpl(function, timeSet);
        
                // Store the range data
                Data[] data = {
                        new Real(RealType.Latitude, 33.5),
                        new Real(RealType.Longitude, 33.5),
                        new Real(cnameType, 33.5)
                };
                Tuple rangeTuple = new Tuple(rangeTupleType, data);
                field.setSample(0, rangeTuple);
    
                DataReferenceImpl data_ref = new DataReferenceImpl("data_ref");
                data_ref.setData( field );

                display.addReference( data_ref );
    
                // Create application window, put display into it 
                JFrame jframe = new JFrame("My first VisAD application");
                jframe.getContentPane().add(display.getComponent());
    
                // Set window size and make it visible
                jframe.setSize(300, 300);
                jframe.setVisible(true);
        }
  
        public static void main(String[] args)
                throws RemoteException, VisADException
        {
                new simple(args);
        }
}

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