GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
raster_metadata.c File Reference

Raster library - Functions to read and write raster "units", "semantic label" and "vertical datum" meta-data info. More...

#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
Include dependency graph for raster_metadata.c:

Go to the source code of this file.

Functions

char * Rast_read_units (const char *name, const char *mapset)
 Get a raster map's units metadata string. More...
 
void Rast_write_units (const char *name, const char *str)
 Write a string to a raster map's units metadata file. More...
 
char * Rast_read_vdatum (const char *name, const char *mapset)
 Get a raster map's vertical datum metadata string. More...
 
void Rast_write_vdatum (const char *name, const char *str)
 Write a string into a raster's vertical datum metadata file. More...
 
char * Rast_read_semantic_label (const char *name, const char *mapset)
 Get a raster map semantic label metadata string. More...
 
char * Rast_get_semantic_label_or_name (const char *name, const char *mapset)
 Get a raster map semantic label or fall back to its name. More...
 
void Rast_write_semantic_label (const char *name, const char *str)
 Write a string into a rasters semantic label metadata file. More...
 
bool Rast_legal_semantic_label (const char *semantic_label)
 Check for legal semantic label. More...
 

Detailed Description

Raster library - Functions to read and write raster "units", "semantic label" and "vertical datum" meta-data info.

(C) 2007-2009, 2021 by Hamish Bowman, Maris Nartiss, and the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Hamish Bowman

Definition in file raster_metadata.c.

Function Documentation

◆ Rast_get_semantic_label_or_name()

char* Rast_get_semantic_label_or_name ( const char *  name,
const char *  mapset 
)

Get a raster map semantic label or fall back to its name.

Use this function if a semantic label is needed but not mandated.

Parameters
nameraster map name
mapsetmapset name
Returns
string representing semantic label or map name

Definition at line 110 of file raster_metadata.c.

References G_store(), name, and Rast_read_semantic_label().

Referenced by I_iclass_init_signatures(), I_sort_signatures_by_semantic_label(), and I_SortSigSetBySemanticLabel().

◆ Rast_legal_semantic_label()

bool Rast_legal_semantic_label ( const char *  semantic_label)

Check for legal semantic label.

Legal semantic label must be a legal GRASS file name. Semantic labels are capped in length to GNAME_MAX.

This function will return false if provided semantic label is not considered to be valid. This function does not check if semantic label maps to any entry in metadata files of semantic labels as not all semantic labels have files with extra metadata.

The function prints a warning on error.

Parameters
semanticlabel reference to check
Returns
true success
false failure

Definition at line 153 of file raster_metadata.c.

◆ Rast_read_semantic_label()

char* Rast_read_semantic_label ( const char *  name,
const char *  mapset 
)

Get a raster map semantic label metadata string.

Read raster semantic label metadata file and put string in to str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing semantic label on success
NULL on error

Definition at line 95 of file raster_metadata.c.

Referenced by Rast_get_semantic_label_or_name().

◆ Rast_read_units()

char* Rast_read_units ( const char *  name,
const char *  mapset 
)

Get a raster map's units metadata string.

Read the raster's units metadata file and put string in str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing units on success
NULL on error

Definition at line 37 of file raster_metadata.c.

◆ Rast_read_vdatum()

char* Rast_read_vdatum ( const char *  name,
const char *  mapset 
)

Get a raster map's vertical datum metadata string.

Read the raster's vertical datum metadata file and put string in str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing vertical datum on success
NULL on error

Definition at line 66 of file raster_metadata.c.

◆ Rast_write_semantic_label()

void Rast_write_semantic_label ( const char *  name,
const char *  str 
)

Write a string into a rasters semantic label metadata file.

Raster map must exist in the current mapset.

It is up to the caller to validate semantic label string in advance with Rast_legal_semantic_label().

Parameters
nameraster map name
strstring containing data to be written

Definition at line 129 of file raster_metadata.c.

◆ Rast_write_units()

void Rast_write_units ( const char *  name,
const char *  str 
)

Write a string to a raster map's units metadata file.

Raster map must exist in the current mapset.

Parameters
nameraster map name
strstring containing data to be written

Definition at line 50 of file raster_metadata.c.

◆ Rast_write_vdatum()

void Rast_write_vdatum ( const char *  name,
const char *  str 
)

Write a string into a raster's vertical datum metadata file.

Raster map must exist in the current mapset.

Parameters
nameraster map name
strstring containing data to be written

Definition at line 79 of file raster_metadata.c.