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. | |
| 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 . | |||
| 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
|
0 |
| map
|
0 |
| map
|
elevInfo |
Notice that the initialization of map reverses the order of the rows in elevInfo.