GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
group.c File Reference
#include <string.h>
#include <stdlib.h>
#include <grass/imagery.h>
Include dependency graph for group.c:

Go to the source code of this file.

Functions

int I_get_group (char *group)
 
int I_put_group (const char *group)
 
int I_get_subgroup (const char *group, char *subgroup)
 
int I_put_subgroup (const char *group, const char *subgroup)
 
int I_get_group_ref (const char *group, struct Ref *ref)
 read group REF file More...
 
int I_get_group_ref2 (const char *group, const char *mapset, struct Ref *ref)
 read group REF file More...
 
int I_get_subgroup_ref (const char *group, const char *subgroup, struct Ref *ref)
 read subgroup REF file More...
 
int I_get_subgroup_ref2 (const char *group, const char *subgroup, const char *mapset, struct Ref *ref)
 read subgroup REF file More...
 
int I_init_ref_color_nums (struct Ref *ref)
 
int I_put_group_ref (const char *group, const struct Ref *ref)
 write group REF file More...
 
int I_put_subgroup_ref (const char *group, const char *subgroup, const struct Ref *ref)
 write subgroup REF file More...
 
int I_add_file_to_group_ref (const char *name, const char *mapset, struct Ref *ref)
 add file name to Ref structure More...
 
int I_transfer_group_ref_file (const struct Ref *ref2, int n, struct Ref *ref1)
 copy Ref lists More...
 
int I_init_group_ref (struct Ref *ref)
 initialize Ref structure More...
 
int I_free_group_ref (struct Ref *ref)
 free Ref structure More...
 

Function Documentation

◆ I_add_file_to_group_ref()

int I_add_file_to_group_ref ( const char *  name,
const char *  mapset,
struct Ref ref 
)

add file name to Ref structure

This routine adds the file name and mapset to the list contained in the ref structure, if it is not already in the list. The ref structure must have been properly initialized. This routine is used by programs, such as i.maxlik, to add to the group new raster maps created from files already in the group. Returns the index into the file array within the ref structure for the file after insertion; see Imagery_Library_Data_Structures.

Parameters
name
mapset
ref
Returns
int

Definition at line 396 of file group.c.

References Ref::file, G_malloc, G_realloc, Ref_Files::mapset, Ref_Files::name, and Ref::nfiles.

Referenced by I_transfer_group_ref_file().

◆ I_free_group_ref()

int I_free_group_ref ( struct Ref ref)

free Ref structure

This routine frees memory allocated to the ref structure.

Parameters
ref
Returns
int

Definition at line 502 of file group.c.

References Ref::file, free(), and Ref::nfiles.

Referenced by I_iclass_init_group().

◆ I_get_group()

int I_get_group ( char *  group)

Definition at line 38 of file group.c.

References G_fopen_old(), G_mapset(), G_suppress_warnings(), GROUPFILE, and NULL.

◆ I_get_group_ref()

int I_get_group_ref ( const char *  group,
struct Ref ref 
)

read group REF file

Reads the contents of the REF file for the specified group into the ref structure. Returns 1 if successful; 0 otherwise (but no error messages are printed).

Parameters
group
ref
Returns
int

Definition at line 114 of file group.c.

Referenced by I_iclass_init_group().

◆ I_get_group_ref2()

int I_get_group_ref2 ( const char *  group,
const char *  mapset,
struct Ref ref 
)

read group REF file

Reads the contents of the REF file for the specified group into the ref structure. Returns 1 if successful; 0 otherwise (but no error messages are printed).

Parameters
group
mapset
ref
Returns
int

Definition at line 133 of file group.c.

◆ I_get_subgroup()

int I_get_subgroup ( const char *  group,
char *  subgroup 
)

Definition at line 68 of file group.c.

References G_suppress_warnings(), I_find_group(), I_fopen_group_file_old(), NULL, and SUBGROUPFILE.

◆ I_get_subgroup_ref()

int I_get_subgroup_ref ( const char *  group,
const char *  subgroup,
struct Ref ref 
)

read subgroup REF file

Reads the contents of the REF file for the specified subgroup of the specified group into the ref structure. Returns 1 if successful; 0 otherwise (but no error messages are printed).

Parameters
group
subgroup
ref
Returns
int

Definition at line 153 of file group.c.

Referenced by I_iclass_init_group().

◆ I_get_subgroup_ref2()

int I_get_subgroup_ref2 ( const char *  group,
const char *  subgroup,
const char *  mapset,
struct Ref ref 
)

read subgroup REF file

Reads the contents of the REF file for the specified subgroup of the specified group into the ref structure. Returns 1 if successful; 0 otherwise (but no error messages are printed).

Parameters
group
subgroup
mapset
ref
Returns
int

Definition at line 174 of file group.c.

◆ I_init_group_ref()

int I_init_group_ref ( struct Ref ref)

initialize Ref structure

This routine initializes the ref structure for other library calls which require a Ref structure. This routine must be called before any use of the structure can be made. Note. The routines I_get_group_ref and I_get_subgroup_ref call this routine automatically.

Parameters
ref
Returns
int

Definition at line 483 of file group.c.

References Ref::blu, Ref_Color::n, Ref::nfiles, NULL, and Ref_Color::table.

Referenced by I_iclass_init_group().

◆ I_init_ref_color_nums()

int I_init_ref_color_nums ( struct Ref ref)

Definition at line 260 of file group.c.

References Ref::blu, Ref_Color::index, Ref_Color::n, Ref::nfiles, NULL, and Ref_Color::table.

◆ I_put_group()

int I_put_group ( const char *  group)

Definition at line 55 of file group.c.

References G_fopen_new(), GROUPFILE, and NULL.

◆ I_put_group_ref()

int I_put_group_ref ( const char *  group,
const struct Ref ref 
)

write group REF file

Writes the contents of the ref structure to the REF file for the specified group. Returns 1 if successful; 0 otherwise (and prints a diagnostic error). Note. This routine will create the group, if it does not already exist.

Parameters
group
ref
Returns
int

Definition at line 318 of file group.c.

◆ I_put_subgroup()

int I_put_subgroup ( const char *  group,
const char *  subgroup 
)

Definition at line 87 of file group.c.

References I_find_group(), I_fopen_group_file_new(), NULL, and SUBGROUPFILE.

◆ I_put_subgroup_ref()

int I_put_subgroup_ref ( const char *  group,
const char *  subgroup,
const struct Ref ref 
)

write subgroup REF file

Writes the contents of the ref structure into the REF file for the specified subgroup of the specified group. Returns 1 if successful; 0 otherwise (and prints a diagnostic error). Note. This routine will create the subgroup, if it does not already exist.

Parameters
group
subgroup
ref
Returns
int

Definition at line 340 of file group.c.

◆ I_transfer_group_ref_file()

int I_transfer_group_ref_file ( const struct Ref ref2,
int  n,
struct Ref ref1 
)

copy Ref lists

This routine is used to copy file names from one Ref structure to another. The name and mapset for file n from the src structure are copied into the dst structure (which must be properly initialized). For example, the following code copies one Ref structure to another:

struct Ref src,dst;
int n;
// some code to get information into <b>src</b>
...
I_init_group_ref (&dst);
for (n = 0; n < src.nfiles; n++)

This routine is used by g.gui.gcp to create the REF file for a subgroup.

Parameters
src
n
dst
Returns
int

Definition at line 448 of file group.c.

References Ref::blu, Ref::file, I_add_file_to_group_ref(), Ref_Files::mapset, Ref_Color::n, and Ref_Files::name.