GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
sigfile.c
Go to the documentation of this file.
1 /*!
2  \file lib/imagery/sigfile.c
3 
4  \brief Imagery Library - Signature file functions (statistics for i.maxlik).
5 
6  (C) 2001-2008, 2013 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 USA CERL
12 */
13 
14 #include <string.h>
15 #include <grass/imagery.h>
16 
17 /*!
18  \brief Create signature file
19 
20  \param group group name
21  \param subgroup subgroup name in given group
22  \param name signature filename
23 
24  \return pointer to FILE*
25  \return NULL on error
26 */
27 FILE *I_fopen_signature_file_new(const char *group,
28  const char *subgroup, const char *name)
29 {
30  char element[GPATH_MAX];
31  char group_name[GNAME_MAX], group_mapset[GMAPSET_MAX];
32  FILE *fd;
33 
34  if (!G_name_is_fully_qualified(group, group_name, group_mapset)) {
35  strcpy(group_name, group);
36  }
37 
38  /* create sigset directory */
39  sprintf(element, "%s/subgroup/%s/sig", group_name, subgroup);
40  G__make_mapset_element_misc("group", element);
41 
42  sprintf(element, "subgroup/%s/sig/%s", subgroup, name);
43 
44  fd = G_fopen_new_misc("group", element, group_name);
45 
46  return fd;
47 }
48 
49 /*!
50  \brief Open existing signature file
51 
52  \param group group name (may be fully qualified)
53  \param subgroup subgroup name in given group
54  \param name signature filename
55 
56  \return pointer to FILE*
57  \return NULL on error
58 */
59 FILE *I_fopen_signature_file_old(const char *group,
60  const char *subgroup, const char *name)
61 {
62  char element[GPATH_MAX];
63  char group_name[GNAME_MAX], group_mapset[GMAPSET_MAX];
64  FILE *fd;
65 
66  G_unqualified_name(group, NULL, group_name, group_mapset);
67  sprintf(element, "subgroup/%s/sig/%s", subgroup, name);
68 
69  fd = G_fopen_old_misc("group", element, group_name, group_mapset);
70 
71  return fd;
72 }
#define GMAPSET_MAX
Definition: gis.h:168
int G_unqualified_name(const char *, const char *, char *, char *)
Returns unqualified map name (without @ mapset)
Definition: nme_in_mps.c:134
int G__make_mapset_element_misc(const char *, const char *)
Create misc element in the current mapset.
Definition: mapset_msc.c:112
#define NULL
Definition: ccmath.h:32
Definition: lidar.h:86
FILE * G_fopen_old_misc(const char *, const char *, const char *, const char *)
open a database file for reading
Definition: open_misc.c:210
FILE * I_fopen_signature_file_old(const char *group, const char *subgroup, const char *name)
Open existing signature file.
Definition: sigfile.c:59
#define GPATH_MAX
Definition: gis.h:170
FILE * I_fopen_signature_file_new(const char *group, const char *subgroup, const char *name)
Create signature file.
Definition: sigfile.c:27
FILE * G_fopen_new_misc(const char *, const char *, const char *)
open a new database file
Definition: open_misc.c:182
#define GNAME_MAX
Definition: gis.h:167
const char * name
Definition: named_colr.c:7
int G_name_is_fully_qualified(const char *, char *, char *)
Check if map name is fully qualified (map @ mapset)
Definition: nme_in_mps.c:36