next up previous contents
Next: The .trl File Up: Program Execution & Data Previous: main()
Go to: SmartForest Home Printer-friendly: sf-impl.pdf


The .elev File

Parsing the .elev file begins in the function named read_DEMFile. read_DEMFile first calls elevReader where the actual reading of the file occurs. After the file is read by elevReader, control returns to read_DEMFile. read_DEMFile continues by setting some global (yuck) variables based on the data read from the .elev file.

The elevReader function utilizes the scanner provided in tokenizer.c. It creates an encapsulated variable called elev. elev's contents are accessible using the accessor functions provided in elevReader.c. The first six values comprise the header of the .elev file. elev is formatted as follows:

Never Data Field Purpose
Used Type Name  
  int nCols The number of columns in the DEM file.
  int nRows The number of rows in the DEM file.
  int xllCorner The x-component of the south-west corner.
  int yllCorner The y-component of the south-west corner.
  int cellSize The width and height of each grid. The value is often 30. (Meters)
  int noDataVal The value used to represent ``No Data''
  float[][] elevInfo The elevation information. Each datum represents the height
      of the sample. The units are not specified but are likely feet.
      The data is read from the file in row-major order.

Once elev is initialized, its values are used to initialize the global variables that are actually used by the application. In this light, elev may be viewed solely as an interface to the contents of the file while the global variables are the data abstractions used by the application. The variables are as follows:

Global Variable Name (Application Abstraction) Initialized by elev Field (File Interface)
columnCount nCols
rowCount nRows
x_sw xllCorner
y_sw yllCorner
x_ave cellSize * nRows
y_ave cellSize * nCols
map $[col][nRows - row - 1][0]$ 0
map $[col][nRows - row - 1][1]$ 0
map $[col][nRows - row - 1][2]$ elevInfo$[col][row]$

Notice that the initialization of map reverses the order of the rows in elevInfo.


next up previous contents
Next: The .trl File Up: Program Execution & Data Previous: main()
Matthew S. Davis
2002-08-07