GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
wr_cellhd.c
Go to the documentation of this file.
1 
2 /*!
3  * \file lib/gis/wr_cellhd.c
4  *
5  * \brief GIS Library - Write Cell Header functions.
6  *
7  * (C) 2001-2014 by the GRASS Development Team
8  *
9  * This program is free software under the GNU General Public License
10  * (>=v2). Read the file COPYING that comes with GRASS for details.
11  *
12  * \author GRASS GIS Development Team
13  *
14  * \date 1999-2014
15  */
16 
17 #include <stdio.h>
18 #include <grass/gis.h>
19 
20 
21 /**
22  * \brief Write cell header or window.
23  *
24  * \param[in,out] fd header file
25  * \param[in] cellhd pointed to cell header structure
26  * \param[in] is_cellhd 1 cell header; 0 window
27  * \return
28  */
29 
30 void G__write_Cell_head(FILE * fd,
31  const struct Cell_head *cellhd, int is_cellhd)
32 {
33  char buf[1024];
34  int fmt;
35 
36  fmt = cellhd->proj;
37 
38  fprintf(fd, "proj: %d\n", cellhd->proj);
39  fprintf(fd, "zone: %d\n", cellhd->zone);
40 
41  G_format_northing(cellhd->north, buf, fmt);
42  fprintf(fd, "north: %s\n", buf);
43 
44  G_format_northing(cellhd->south, buf, fmt);
45  fprintf(fd, "south: %s\n", buf);
46 
47  G_format_easting(cellhd->east, buf, fmt);
48  fprintf(fd, "east: %s\n", buf);
49 
50  G_format_easting(cellhd->west, buf, fmt);
51  fprintf(fd, "west: %s\n", buf);
52 
53  fprintf(fd, "cols: %d\n", cellhd->cols);
54  fprintf(fd, "rows: %d\n", cellhd->rows);
55 
56  G_format_resolution(cellhd->ew_res, buf, fmt);
57  fprintf(fd, "e-w resol: %s\n", buf);
58 
59  G_format_resolution(cellhd->ns_res, buf, fmt);
60  fprintf(fd, "n-s resol: %s\n", buf);
61 
62  if (is_cellhd) {
63  fprintf(fd, "format: %d\n", cellhd->format);
64  fprintf(fd, "compressed: %d\n", cellhd->compressed);
65  }
66 }
67 
68 
69 /**
70  * \brief Write 3D cell header or window.
71  *
72  * \param[in,out] fd header file
73  * \param[in] cellhd pointer to cell header structure
74  * \param[in] is_cellhd 1 cell header; 0 window
75  * \return
76  */
77 
78 void G__write_Cell_head3(FILE * fd,
79  const struct Cell_head *cellhd, int is_cellhd)
80 {
81  char buf[1024];
82  int fmt;
83 
84  fmt = cellhd->proj;
85 
86  G__write_Cell_head(fd, cellhd, is_cellhd);
87 
88  fprintf(fd, "top: %.15f\n", cellhd->top);
89  fprintf(fd, "bottom: %.15f\n", cellhd->bottom);
90 
91  fprintf(fd, "cols3: %d\n", cellhd->cols3);
92  fprintf(fd, "rows3: %d\n", cellhd->rows3);
93  fprintf(fd, "depths: %d\n", cellhd->depths);
94 
95  G_format_resolution(cellhd->ew_res3, buf, fmt);
96  fprintf(fd, "e-w resol3: %s\n", buf);
97 
98  G_format_resolution(cellhd->ns_res3, buf, fmt);
99  fprintf(fd, "n-s resol3: %s\n", buf);
100 
101  G_format_resolution(cellhd->tb_res, buf, -1);
102  fprintf(fd, "t-b resol: %s\n", buf);
103 }
void G_format_easting(double east, char *buf, int projection)
Easting to ASCII.
Definition: wind_format.c:49
2D/3D raster map header (used also for region)
Definition: gis.h:390
double west
Extent coordinates (west)
Definition: gis.h:442
void G_format_resolution(double res, char *buf, int projection)
Resolution to ASCII.
Definition: wind_format.c:69
void G_format_northing(double north, char *buf, int projection)
Northing to ASCII.
Definition: wind_format.c:29
int format
Max number of bytes per raster data value minus 1 (raster header only)
Definition: gis.h:396
fd
Definition: d/range.c:69
int cols3
Number of columns for 3D data.
Definition: gis.h:411
void G__write_Cell_head(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
Write cell header or window.
Definition: wr_cellhd.c:30
double top
Extent coordinates (top) - 3D data.
Definition: gis.h:444
int compressed
Compression mode (raster header only)
Definition: gis.h:403
double north
Extent coordinates (north)
Definition: gis.h:436
double ns_res3
Resolution - north to south cell size for 3D data.
Definition: gis.h:432
int rows3
Number of rows for 3D data.
Definition: gis.h:407
double south
Extent coordinates (south)
Definition: gis.h:438
int zone
Projection zone (UTM)
Definition: gis.h:424
double bottom
Extent coordinates (bottom) - 3D data.
Definition: gis.h:446
int depths
number of depths for 3D data
Definition: gis.h:413
int proj
Projection code.
Definition: gis.h:422
int cols
Number of columns for 2D data.
Definition: gis.h:409
double ns_res
Resolution - north to south cell size for 2D data.
Definition: gis.h:430
double east
Extent coordinates (east)
Definition: gis.h:440
double ew_res
Resolution - east to west cell size for 2D data.
Definition: gis.h:426
double tb_res
Resolution - top to bottom cell size for 3D data.
Definition: gis.h:434
void G__write_Cell_head3(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
Write 3D cell header or window.
Definition: wr_cellhd.c:78
int rows
Number of rows for 2D data.
Definition: gis.h:405
double ew_res3
Resolution - east to west cell size for 3D data.
Definition: gis.h:428