GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
init_head.c
Go to the documentation of this file.
1 /*!
2  \file lib/vector/Vlib/init_head.c
3 
4  \brief Vector library - init header of vector maps
5 
6  Higher level functions for reading/writing/manipulating vectors.
7 
8  Initialize Head structure. To make sure that we are not writing out
9  garbage to a file.
10 
11  (C) 2001-2009 by the GRASS Development Team
12 
13  This program is free software under the GNU General Public License
14  (>=v2). Read the file COPYING that comes with GRASS for details.
15 
16  \author Original author CERL, probably Dave Gerdes or Mike Higgins.
17  \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
18  \author Various updates by Martin Landa <landa.martin gmail.com>, 2009
19 */
20 
21 #include <string.h>
22 #include <grass/vector.h>
23 
24 /*!
25  \brief Initialize Map_info head structure (dig_head)
26 
27  \param[in,out] Map pointer to Map_info structure
28  */
29 void Vect__init_head(struct Map_info *Map)
30 {
31  char buf[64];
32 
33  G_zero(&(Map->head), sizeof(struct dig_head));
34 
35  /* organization */
36  Vect_set_organization(Map, "");
37 
38  /* date */
39  Vect_set_date(Map, "");
40 
41  /* user name */
42  sprintf(buf, "%s", G_whoami());
43  Vect_set_person(Map, buf);
44 
45  /* map name */
46  Vect_set_map_name(Map, "");
47 
48  /* source date */
49  sprintf(buf, "%s", G_date());
50  Vect_set_map_date(Map, buf);
51 
52  /* comments */
53  Vect_set_comment(Map, "");
54 
55  /* scale, threshold */
56  Vect_set_scale(Map, 1);
57  Vect_set_thresh(Map, 0.0);
58 
59  /* proj, zone */
60  Vect_set_proj(Map, -1);
61  Vect_set_zone(Map, -1);
62 
63  /* support variables */
64  Map->plus.Spidx_built = FALSE;
65  Map->plus.release_support = FALSE;
66  Map->plus.update_cidx = FALSE;
67 }
68 
69 /*!
70  \brief Copy header data from one to another map
71 
72  \param from target vector map
73  \param[out] to destination vector map
74 
75  \return 0
76  */
77 int Vect_copy_head_data(const struct Map_info *from, struct Map_info *to)
78 {
80  Vect_set_date(to, Vect_get_date(from));
85 
86  Vect_set_scale(to, Vect_get_scale(from));
87  Vect_set_zone(to, Vect_get_zone(from));
89 
90  return 0;
91 }
int Vect_set_map_name(struct Map_info *, const char *)
Set map name in map header.
int Vect_set_comment(struct Map_info *, const char *)
Set comment or other info string in map header.
const char * G_whoami(void)
Gets user&#39;s name.
Definition: gis/whoami.c:35
int Vect_set_thresh(struct Map_info *, double)
Set threshold used for digitization in map header.
int release_support
Release memory occupied by support structures (topo, spatial, category)
Definition: dig_structs.h:838
int Vect_set_map_date(struct Map_info *, const char *)
Set date when the source map was originally produced in map header.
double Vect_get_thresh(const struct Map_info *)
Get threshold used for digitization from map header.
int Spidx_built
Spatial index built?
Definition: dig_structs.h:1053
int Vect_get_zone(const struct Map_info *)
Get projection zone from map header.
const char * Vect_get_map_date(const struct Map_info *)
Get date when the source map was originally produced from map header.
int Vect_set_proj(struct Map_info *, int)
Set projection in map header.
Vector map header data.
Definition: dig_structs.h:294
#define FALSE
Definition: gis.h:63
int Vect_set_date(struct Map_info *, const char *)
Set date of digitization in map header.
struct Plus_head plus
Plus info (topology, version, ...)
Definition: dig_structs.h:1286
const char * Vect_get_organization(const struct Map_info *)
Get organization string from map header.
struct dig_head head
Header info.
Definition: dig_structs.h:1403
const char * Vect_get_map_name(const struct Map_info *)
Get map name from map header.
Vector map info.
Definition: dig_structs.h:1259
const char * Vect_get_date(const struct Map_info *)
Get date of digitization from map header.
int Vect_copy_head_data(const struct Map_info *from, struct Map_info *to)
Copy header data from one to another map.
Definition: init_head.c:77
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
Definition: gis/zero.c:23
const char * Vect_get_comment(const struct Map_info *)
Get comment or other info string from map header.
int Vect_set_person(struct Map_info *, const char *)
Set name of user who digitized the map in map header.
int Vect_get_scale(const struct Map_info *)
Get map scale from map header.
int update_cidx
Update category index if vector is modified.
Definition: dig_structs.h:1136
void Vect__init_head(struct Map_info *Map)
Initialize Map_info head structure (dig_head)
Definition: init_head.c:29
int Vect_set_organization(struct Map_info *, const char *)
Set organization string in map header.
int Vect_set_zone(struct Map_info *, int)
Set projection zone in map header.
const char * G_date(void)
Current date and time.
Definition: date.c:26
int Vect_set_scale(struct Map_info *, int)
Set map scale in map header.
const char * Vect_get_person(const struct Map_info *)
Get user name string who digitized the map from map header.