forked from jontodd/r.refine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.h
executable file
·110 lines (95 loc) · 2.54 KB
/
grid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* ************************************************************
*
* MODULE: r.refine
*
* Authors: Jon Todd <[email protected]>, Laura Toma <[email protected]>
* Bowdoin College, USA
*
* Purpose: convert grid data to TIN
*
* COPYRIGHT:
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
*
************************************************************ */
/******************************************************************************
*
* grid.h contains functions for reading in and outputing arc-ascii
* grids (rasters)
*
* AUTHOR(S): Jonathan Todd - <[email protected]>
*
* UPDATED: jt 2005-08-15
*
* COMMENTS:
*
*****************************************************************************/
#ifndef __grid_h
#define __grid_h
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include "point.h"
//
// grid structure
//
typedef struct grid_t {
char*name; // File name (path)
ELEV_TYPE **data; // Data
unsigned long ncols; // Number of columns
unsigned long nrows; // Number of rows
double x; // x lat lon corner
double y; // y lat lon corner
double cellsize; // Cell size
ELEV_TYPE nodata; // No data value
ELEV_TYPE max; // Max elevation
ELEV_TYPE min; // Min elevation
} GRID;
//
// tiled grid structure with file pointers instead of data in memory
//
typedef struct tiled_grid {
char*name; // File name (path)
FILE ***files; // Tiled set of files
unsigned long ncols; // Number of columns
unsigned long nrows; // Number of rows
double x; // x lat lon corner
double y; // y lat lon corner
double cellsize; // Cell size
ELEV_TYPE nodata; // No data value
ELEV_TYPE max; // Max elevation
ELEV_TYPE min; // Min elevation
unsigned int TL;
} TILED_GRID;
//
// Write an elevation value to a file
//
void writeElevToTile(FILE *fp,ELEV_TYPE z);
//
// Read a arc-ascii grid file into a set of tile files. This way we
// don't read the data into memory but instead seperate it into tile
// which we can work on one by one
//
TILED_GRID *readGrid2Tile(char *path, unsigned int TL);
//
// bring grid file into an array
//
GRID *importGrid(char *path);
//
// write grid structure to file path
//
void writeGrid(GRID *g,char *path);
//
// Print the grid info
//
void printGrid(GRID *g);
//
// free memory from grid
//
void freeGrid(GRID *g);
#endif