GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-9b28d7b83c
wr_cellhd.c
Go to the documentation of this file.
1 /*!
2  * \file lib/gis/wr_cellhd.c
3  *
4  * \brief GIS Library - Write Cell Header functions.
5  *
6  * (C) 2001-2014 by the GRASS Development Team
7  *
8  * This program is free software under the GNU General Public License
9  * (>=v2). Read the file COPYING that comes with GRASS for details.
10  *
11  * \author GRASS GIS Development Team
12  *
13  * \date 1999-2014
14  */
15 
16 #include <stdio.h>
17 #include <grass/gis.h>
18 
19 /**
20  * \brief Write cell header or window.
21  *
22  * \param[in,out] fd header file
23  * \param[in] cellhd pointed to cell header structure
24  * \param[in] is_cellhd 1 cell header; 0 window
25  * \return
26  */
27 
28 void G__write_Cell_head(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
29 {
30  char buf[1024];
31  int fmt;
32 
33  fmt = cellhd->proj;
34 
35  fprintf(fd, "proj: %d\n", cellhd->proj);
36  fprintf(fd, "zone: %d\n", cellhd->zone);
37 
38  G_format_northing(cellhd->north, buf, fmt);
39  fprintf(fd, "north: %s\n", buf);
40 
41  G_format_northing(cellhd->south, buf, fmt);
42  fprintf(fd, "south: %s\n", buf);
43 
44  G_format_easting(cellhd->east, buf, fmt);
45  fprintf(fd, "east: %s\n", buf);
46 
47  G_format_easting(cellhd->west, buf, fmt);
48  fprintf(fd, "west: %s\n", buf);
49 
50  fprintf(fd, "cols: %d\n", cellhd->cols);
51  fprintf(fd, "rows: %d\n", cellhd->rows);
52 
53  G_format_resolution(cellhd->ew_res, buf, fmt);
54  fprintf(fd, "e-w resol: %s\n", buf);
55 
56  G_format_resolution(cellhd->ns_res, buf, fmt);
57  fprintf(fd, "n-s resol: %s\n", buf);
58 
59  if (is_cellhd) {
60  fprintf(fd, "format: %d\n", cellhd->format);
61  fprintf(fd, "compressed: %d\n", cellhd->compressed);
62  }
63 }
64 
65 /**
66  * \brief Write 3D cell header or window.
67  *
68  * \param[in,out] fd header file
69  * \param[in] cellhd pointer to cell header structure
70  * \param[in] is_cellhd 1 cell header; 0 window
71  * \return
72  */
73 
74 void G__write_Cell_head3(FILE *fd, const struct Cell_head *cellhd,
75  int is_cellhd)
76 {
77  char buf[1024];
78  int fmt;
79 
80  fmt = cellhd->proj;
81 
82  G__write_Cell_head(fd, cellhd, is_cellhd);
83 
84  fprintf(fd, "top: %.15f\n", cellhd->top);
85  fprintf(fd, "bottom: %.15f\n", cellhd->bottom);
86 
87  fprintf(fd, "cols3: %d\n", cellhd->cols3);
88  fprintf(fd, "rows3: %d\n", cellhd->rows3);
89  fprintf(fd, "depths: %d\n", cellhd->depths);
90 
91  G_format_resolution(cellhd->ew_res3, buf, fmt);
92  fprintf(fd, "e-w resol3: %s\n", buf);
93 
94  G_format_resolution(cellhd->ns_res3, buf, fmt);
95  fprintf(fd, "n-s resol3: %s\n", buf);
96 
97  G_format_resolution(cellhd->tb_res, buf, -1);
98  fprintf(fd, "t-b resol: %s\n", buf);
99 }
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
void G_format_northing(double, char *, int)
Northing to ASCII.
Definition: wind_format.c:29
2D/3D raster map header (used also for region)
Definition: gis.h:437
int cols3
Number of columns for 3D data.
Definition: gis.h:458
double ew_res
Resolution - east to west cell size for 2D data.
Definition: gis.h:473
double north
Extent coordinates (north)
Definition: gis.h:483
double bottom
Extent coordinates (bottom) - 3D data.
Definition: gis.h:493
int compressed
Compression mode (raster header only)
Definition: gis.h:450
int format
Max number of bytes per raster data value minus 1 (raster header only)
Definition: gis.h:443
int zone
Projection zone (UTM)
Definition: gis.h:471
int depths
number of depths for 3D data
Definition: gis.h:460
double east
Extent coordinates (east)
Definition: gis.h:487
double ew_res3
Resolution - east to west cell size for 3D data.
Definition: gis.h:475
double ns_res
Resolution - north to south cell size for 2D data.
Definition: gis.h:477
double ns_res3
Resolution - north to south cell size for 3D data.
Definition: gis.h:479
double top
Extent coordinates (top) - 3D data.
Definition: gis.h:491
int rows3
Number of rows for 3D data.
Definition: gis.h:454
int rows
Number of rows for 2D data.
Definition: gis.h:452
int cols
Number of columns for 2D data.
Definition: gis.h:456
int proj
Projection code.
Definition: gis.h:469
double south
Extent coordinates (south)
Definition: gis.h:485
double tb_res
Resolution - top to bottom cell size for 3D data.
Definition: gis.h:481
double west
Extent coordinates (west)
Definition: gis.h:489
void G__write_Cell_head(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
Write cell header or window.
Definition: wr_cellhd.c:28
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:74