j3d.org Code

org.j3d.loaders.dem
Class DEMParser

java.lang.Object
  extended by org.j3d.loaders.dem.DEMParser
All Implemented Interfaces:
HeightMapSource

public class DEMParser
extends java.lang.Object
implements HeightMapSource

A low-level parser for the DEM file format.

The output of this parser is the records as per the file and the option of a raw height array.

The definition of the file format can be found at: http://edcwww.cr.usgs.gov/glis/hyper/guide/1_dgr_dem

Version:
$Revision: 1.3 $
Author:
Justin Couch

Constructor Summary
DEMParser()
          Construct a new parser with no stream set.
DEMParser(java.io.InputStream is)
          Construct a new parser using the given stream to source the data from.
DEMParser(java.io.Reader rdr)
          Construct a new parser using the given reader to source the data from.
 
Method Summary
 void clear()
          Force a clear of the data that has been previous read by this parser.
 float[] getGridStep()
          Fetch information about the real-world stepping sizes that this grid uses.
 float[][] getHeights()
          Create a new height array from the pre-parsed values.
 DEMTypeARecord getTypeARecord()
          Get the header used to describe the last stream parsed.
 DEMTypeBRecord[] getTypeBRecords()
          Fetch all of the type B records that were registered in this file.
 DEMTypeCRecord getTypeCRecord()
          Get the type C record from the file.
 float[][] parse(boolean returnHeights)
          Do all the parsing work.
 void reset(java.io.InputStream is)
          Reset the parser to use the new stream.
 void reset(java.io.Reader rdr)
          Reset the parser to use the new stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DEMParser

public DEMParser()
Construct a new parser with no stream set.


DEMParser

public DEMParser(java.io.InputStream is)
Construct a new parser using the given stream to source the data from.

Parameters:
is - The stream to read data from

DEMParser

public DEMParser(java.io.Reader rdr)
Construct a new parser using the given reader to source the data from.

Parameters:
rdr - The stream to read data from
Method Detail

clear

public void clear()
Force a clear of the data that has been previous read by this parser.


reset

public void reset(java.io.InputStream is)
Reset the parser to use the new stream. After calling this method all header and height information is reset to empty.

Parameters:
is - The new stream to use

reset

public void reset(java.io.Reader rdr)
Reset the parser to use the new stream. After calling this method all header and height information is reset to empty.

Parameters:
rdr - The stream to read data from

getTypeARecord

public DEMTypeARecord getTypeARecord()
Get the header used to describe the last stream parsed. If no stream has been parsed yet, this will return null.

Returns:
The header for the last read stream or null

getTypeBRecords

public DEMTypeBRecord[] getTypeBRecords()
Fetch all of the type B records that were registered in this file. Will probably contain more than one record and is always non-null. The records will be in the order they were read from the file.

Returns:
The list of all the Type B records parsed

getTypeCRecord

public DEMTypeCRecord getTypeCRecord()
Get the type C record from the file. If none was provided, then this will return null.

Returns:
The type C record info or null

getHeights

public float[][] getHeights()
Create a new height array from the pre-parsed values. If there has not been any parsing prior to this point null will be returned. Each time this method is called a new array of values is generated.

Specified by:
getHeights in interface HeightMapSource
Returns:
The converted heights or null

getGridStep

public float[] getGridStep()
Fetch information about the real-world stepping sizes that this grid uses.

Specified by:
getGridStep in interface HeightMapSource
Returns:
The stepping information for width and depth

parse

public float[][] parse(boolean returnHeights)
                throws java.io.IOException
Do all the parsing work. Convenience method for all to call internally

Parameters:
returnHeights - true if this should return the array of height values
Returns:
An array of the heights if requested or null if not
Throws:
IncorrectFormatException - The file is not one our parser understands
ParsingErrorException - An error parsing the file
java.io.IOException

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org