Test-Case GriddedTo2DSet

Hi Ugo and others,

I attached a test case where I am creating a Gridded2DSet.
The structure of the points is the following:

                .
            . . .
        . . . . .
    . . . . . . .
. . . . . . . . .

points are arounf 245m and missing points around 200m.
Look at the result, the grid has not as many points as I expected.
I don't know how to display a wireframe in VisAD.
What is wrong, where I am loosing my points!

Thanks for your help in advance, and many thanks for your help sofar Ugo.

Desiree

oooooooooooooooooooooooooooooooooooooooooooooooo
Desiree Hilbring

Institut fuer Photogrammetrie und Fernerkundung  
Universitaet Karlsruhe, Germany
email: hilbring@xxxxxxxxxxxxxxxxxxxx             
# 0721 6083676                                   
oooooooooooooooooooooooooooooooooooooooooooooooo


/*
VisAD Tutorial
Copyright (C) 2000 Ugo Taddei
*/

// Import needed classes

import visad.*;
import visad.java2d.DisplayImplJ2D;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import visad.java3d.DisplayImplJ3D;

  /**
  VisAD Tutorial example 3_09
  We have the functions altitude = h(latitude, longitude)
                        temperature = f(latitude, longitude)
                        
  represented by the MathType 
  ( (latitude, longitude) -> (altitude, temperature ) )
  Map the altitude to IsoContour and temperature to RGB
  Run program with "java P3_09" 
 */
  


public class DGM1{

    // Declare variables
    // The domain quantities longitude and latitude
    // and the dependent quantities altitude, temperature
        
    private RealType eastValues,northValues;
    private RealType heightValues;
    
    // Two Tuples: one to pack longitude and latitude together, as the domain
    // and the other for the range (altitude, temperature)    
    private RealTupleType domain_tuple;
    
    // The function (domain_tuple -> range_tuple )
    private FunctionType func_en_h;

    // Our Data values for the domain are represented by the Set
    private Set domain_set;
  
    // The Data class FlatField
    private FlatField vals_ff;  
  
    // The DataReference from data to display
    private DataReferenceImpl data_ref;

    // The 2D display, and its the maps
    private DisplayImpl display;
    private ScalarMap eastMap, northMap, heightMap;
  
    public DGM1(String []args)
        throws RemoteException, VisADException {

        float[] eastNaN = 
{3479991.5f,3479991.5f,3479991.5f,3479991.5f,3479991.5f,
                           
3479992.5f,3479992.5f,3479992.5f,3479992.5f,3479992.5f,
                           
3479993.5f,3479993.5f,3479993.5f,3479993.5f,3479993.5f,
                           
3479994.5f,3479994.5f,3479994.5f,3479994.5f,3479994.5f,
                           
3479995.5f,3479995.5f,3479995.5f,3479995.5f,3479995.5f,
                           
3479996.5f,3479996.5f,3479996.5f,3479996.5f,3479996.5f,
                           
3479997.5f,3479997.5f,3479997.5f,3479997.5f,3479997.5f,
                           
3479998.5f,3479998.5f,3479998.5f,3479998.5f,3479998.5f,
                           
3479999.5f,3479999.5f,3479999.5f,3479999.5f,3479999.5f};
        float[] northNaN = 
{5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
                            
5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
                            
5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
                            
5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
                            
5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
                            
5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
                            
5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
                            
5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
                            
5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f};
        float[] heightNaN = {245.65f,200.0f,200.0f,200.0f,200.0f,
                             245.65f,200.0f,200.0f,200.0f,200.0f,
                             245.68f,245.66f,200.0f,200.0f,200.0f,
                             245.64f,245.64f,200.0f,200.0f,200.0f,
                             245.63f,245.65f,245.63f,200.0f,200.0f,
                             245.62f,245.65f,245.63f,200.0f,200.0f,
                             245.60f,245.62f,245.63f,245.59f,200.0f,
                             245.60f,245.62f,245.63f,245.59f,200.0f,
                             245.58f,245.57f,245.62f,245.64f,245.54f};



        int nCols = 9;
        int nRows = 5;
        double[][] coords = new double[2][nCols*nRows]; 
        for (int i=0;i<(nCols*nRows);i++) {
            coords[0][i]=eastNaN[i];
            coords[1][i]=northNaN[i];
        }
        
        
        // Create the quantities
        // Use RealType(String name);   
        eastValues = new RealType("eastValues");
        northValues = new RealType("northValues");
        
        domain_tuple = new RealTupleType(eastValues,northValues);
    
        heightValues = new RealType("heightValues");
    
        // Create a FunctionType (domain_tuple -> range_tuple )
        // Use FunctionType(MathType domain, MathType range)    
        func_en_h = new FunctionType(domain_tuple, heightValues);
    
        domain_set = new Gridded2DDoubleSet(domain_tuple,coords,nRows,nCols); 

        // Get the Set samples to facilitate the calculations
        float[][] set_samples = domain_set.getSamples( true );
        
        // We create another array, with the same number of elements of
        // altitude and temperature, but organized as 
        float[][] flat_samples = new float[1][nCols*nRows]; 
    
        // ...and then we fill our 'flat' array with the generated values
        // by looping over NCOLS and NROWS     
        // specifiy height
        for(int c = 0; c < nCols; c++){
            for(int r = 0; r < nRows; r++){     
                //flat_samples[0][c*nRows+r] = height[c*nRows+r]; 
                flat_samples[0][c*nRows+r] = heightNaN[c*nRows+r];
            }
        }
        /*
        for(int c = 0; c < NCOLS; c++)    
            for(int r = 0; r < NROWS; r++){     
                flat_samples[0][c*NROWS+r] = heightNaN[c*NROWS+r];              
     
                //System.out.println("height "+height[c*NROWS+r]);
            }
        */
    
      
        // Create a FlatField  
        // Use FlatField(FunctionType type, Set domain_set)    
        vals_ff = new FlatField( func_en_h, domain_set);
    
        // ...and put the values above into it
        // Note the argument false, meaning that the array won't be copied 
        vals_ff.setSamples( flat_samples , false ); 
     
        // Create Display and its maps    
        // A 2D display    
        display = new DisplayImplJ3D("display1");    
        
        // Create the ScalarMaps: latitude to XAxis, longitude to YAxis and
        // altitude to RGB and temperature to IsoContour
        // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar) 
        eastMap = new ScalarMap( eastValues,    Display.YAxis );
        northMap = new ScalarMap( northValues, Display.XAxis );
        heightMap = new ScalarMap(heightValues,Display.ZAxis);  
   
        // Add maps to display
        display.addMap( eastMap );
        display.addMap( northMap );    
        display.addMap( heightMap );

        /*
        eastMap.setRange(-1.0, 1.0);
        northMap.setRange(-1.0, 1.0);
        heightMap.setRange(-1.0, 1.0);
        */

        //eastMap.setRange(3532000,3533000);
        //northMap.setRange(5379000,5380000);
        //heightMap.setRange(600,700);
        heightMap.setRange(200,300);
        //heightMap.setRange(-1.0,1.0);
  
        // Create a data reference and set the FlatField as our data 
        data_ref = new DataReferenceImpl("data_ref");
        data_ref.setData( vals_ff );
    
        // Add reference to display
        display.addReference( data_ref );
    
    
        // Create application window and add display to window
        JFrame jframe = new JFrame("VisAD Tutorial example DGM1");
        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 DGM1(args);
    }

} //end of Visad Tutorial Program 3_09
  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: