Re: FieldImpl with different types

Hi Cameron,

> I am trying to create a FieldImpl which contains a combination of
> RealTypes and Text Types.
> Is this possible? and How is it done?

The range samples of the FieldImpl would be Tuple objects,
whose components are Real and Text objects.  And the range
type of the FieldImpl would be a TupleType whose components
are RealTypes and TextTypes.  You can use the FieldImpl
methods:

  public void setSamples(Data[] range, boolean copy)

or:

  public void setSample(int index, Data range)

to set the range Tuple objects in the FieldImpl.

> More specifically - I am reading a netCDF file which has variables of
> char type.  I seem to be successfully reading this into a FieldImpl but
> cannot get the text data out again?

Yes, hopefully the visad.data.netcdf.Plain adapter will
construct the appropriate FieldImpl for you (VisAD's Text
objects have not been used extensively yet, so please let
us know if you encounter bugs).

To retrieve a range sample from a FieldImpl use the method:

  public Data getSample(int index)

Then cast the Data result as a Tuple, and invoke its method:

  public Data getComponent(int i)

to get its Real and Text components (which also must be cast
from Data).

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

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