Scaling?

Hi Bill and others,

do you remember? You helped me last year in using the
Delaunay-Triangulation of VisAD to create a Java3D Shape3D terrain.
Now, I am trying something similar. I just want to create a terrain
struxture out of a regular raster.
I used a Linear2DSet in the example and I am getting a shape, but I don't
want any scaling in my result. I tried setting

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

which you suggested last year. But then the Shape is not longer displayed.
The example program is attached.

Thanks in advance 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 TerrainGridDes{

    // 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 TerrainGridDes(String []args)
        throws RemoteException, VisADException {

        // Data from ascii-file
        /*
        float[] east = {100,100,100,100,150,150,150,150,200,200,200,200};
        float[] north = {100,150,200,250,100,150,200,250,100,150,200,200};
        float[] height = {50,310,99,445,120,310,810,99,100,601,702,109};
        */

        float[] east = {3532500,3532500,3532500,3532550,3532550,3532550};
        float[] north = {5379500,5379550,5379600,5379500,5379550,5379600};
        float[] height = {688.8f,688.6f,688.4f,688.3f,688.4f,688.5f};

        
        // Create the quantities
        // Use RealType(String name);   
        eastValues = new RealType("eastValues");
        northValues = new RealType("northValues");
        
        domain_tuple = new RealTupleType(northValues,eastValues);
    
        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);
    
        // Create the domain Set
        // Use LinearDSet(MathType type, double first1, double last1, int 
lengthX, 
        //                               double first2, double last2, int 
lengthY) 
        int NCOLS = 2;
        int NROWS = 3;
            
        //domain_set = new Linear2DSet(domain_tuple, 100, 250, NROWS,
        //                           100, 200, NCOLS);          
        
        System.out.println("nCols "+NCOLS);
        System.out.println("nRows "+NROWS);
        System.out.println("5379000, 5380000, 3532000, 3533000");
        domain_set = new 
Linear2DSet(domain_tuple,5379000,5380000,NROWS,3532000, 3533000, 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];              
                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);
        */
  
        // 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 TerrainGridDes");
        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 TerrainGridDes(args);
    }

} //end of Visad Tutorial Program 3_09
  • Follow-Ups:
    • Re: Scaling?
      • From: From: Bill Hibbard <hibbard@xxxxxxxxxxxxxxxxx>
  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: