GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
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 }
2D/3D raster map header (used also for region)
Definition: gis.h:412
double west
Extent coordinates (west)
Definition: gis.h:464
int format
Max number of bytes per raster data value minus 1 (raster header only)
Definition: gis.h:418
void G_format_northing(double, char *, int)
Northing to ASCII.
Definition: wind_format.c:29
void G_format_resolution(double, char *, int)
Resolution to ASCII.
Definition: wind_format.c:69
void G_format_easting(double, char *, int)
Easting to ASCII.
Definition: wind_format.c:49
int cols3
Number of columns for 3D data.
Definition: gis.h:433
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:466
int compressed
Compression mode (raster header only)
Definition: gis.h:425
double north
Extent coordinates (north)
Definition: gis.h:458
double ns_res3
Resolution - north to south cell size for 3D data.
Definition: gis.h:454
int rows3
Number of rows for 3D data.
Definition: gis.h:429
double south
Extent coordinates (south)
Definition: gis.h:460
int zone
Projection zone (UTM)
Definition: gis.h:446
double bottom
Extent coordinates (bottom) - 3D data.
Definition: gis.h:468
int depths
number of depths for 3D data
Definition: gis.h:435
int proj
Projection code.
Definition: gis.h:444
int cols
Number of columns for 2D data.
Definition: gis.h:431
double ns_res
Resolution - north to south cell size for 2D data.
Definition: gis.h:452
double east
Extent coordinates (east)
Definition: gis.h:462
double ew_res
Resolution - east to west cell size for 2D data.
Definition: gis.h:448
double tb_res
Resolution - top to bottom cell size for 3D data.
Definition: gis.h:456
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:427
double ew_res3
Resolution - east to west cell size for 3D data.
Definition: gis.h:450