GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
defs/gis.h File Reference
#include <grass/config.h>
#include <stdarg.h>
#include <stdio.h>
#include <setjmp.h>
#include <sys/types.h>
#include <sys/stat.h>
Include dependency graph for defs/gis.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define G_alloca(n)   G_malloc(n)
 
#define G_freea(p)   G_free(p)
 
#define RELDIR   "?"
 
#define G_incr_void_ptr(ptr, size)    ((void *)((const unsigned char *)(ptr) + (size)))
 
#define G_malloc(n)   G__malloc(RELDIR "/" __FILE__, __LINE__, (n))
 
#define G_calloc(m, n)   G__calloc(RELDIR "/" __FILE__, __LINE__, (m), (n))
 
#define G_realloc(p, n)   G__realloc(RELDIR "/" __FILE__, __LINE__, (p), (n))
 

Functions

void G_adjust_Cell_head (struct Cell_head *, int, int)
 Adjust cell header. More...
 
void G_adjust_Cell_head3 (struct Cell_head *, int, int, int)
 Adjust cell header for 3D values. More...
 
int G_adjust_window_ll (struct Cell_head *cellhd)
 Adjust window for lat/lon. More...
 
void * G__malloc (const char *, int, size_t)
 Memory allocation. More...
 
void * G__calloc (const char *, int, size_t, size_t)
 Memory allocation. More...
 
void * G__realloc (const char *, int, void *, size_t)
 Memory reallocation. More...
 
void G_free (void *)
 Free allocated memory. More...
 
int G_begin_cell_area_calculations (void)
 Begin cell area calculations. More...
 
double G_area_of_cell_at_row (int)
 Cell area in specified row. More...
 
int G_begin_polygon_area_calculations (void)
 Begin polygon area calculations. More...
 
double G_area_of_polygon (const double *, const double *, int)
 Area in square meters of polygon. More...
 
void G_begin_zone_area_on_ellipsoid (double, double, double)
 Begin area calculations for ellipsoid. More...
 
double G_darea0_on_ellipsoid (double)
 Calculate integral for area between two latitudes. More...
 
double G_area_for_zone_on_ellipsoid (double, double)
 Calculates area between latitudes. More...
 
void G_begin_ellipsoid_polygon_area (double, double)
 Begin area calculations. More...
 
double G_ellipsoid_polygon_area (const double *, const double *, int)
 Area of lat-long polygon. More...
 
double G_planimetric_polygon_area (const double *, const double *, int)
 Calculates planimetric polygon area. More...
 
void G_begin_zone_area_on_sphere (double, double)
 Initialize calculations for sphere. More...
 
double G_darea0_on_sphere (double)
 Calculates integral for area between two latitudes. More...
 
double G_area_for_zone_on_sphere (double, double)
 Calculates area between latitudes. More...
 
void G_ascii_check (char *)
 Removes non-ascii characters from buffer. More...
 
int G_vasprintf (char **, const char *, va_list)
 Safe replacement for asprintf(). More...
 
int G_asprintf (char **, const char *,...) __attribute__((format(printf
 
int int G_rasprintf (char **, size_t *, const char *,...) __attribute__((format(printf
 
int int int G_aprintf (const char *,...)
 Adjust the width of string specifiers to the display space instead of the number of bytes for wide characters and print them formatted using the adjusted display width. More...
 
int G_faprintf (FILE *, const char *,...)
 fprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_saprintf (char *, const char *,...)
 sprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_snaprintf (char *, size_t, const char *,...)
 snprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_vaprintf (const char *, va_list)
 vprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_vfaprintf (FILE *, const char *, va_list)
 vfprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_vsaprintf (char *, const char *, va_list)
 vsprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_vsnaprintf (char *, size_t, const char *, va_list)
 vsnprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
size_t G_strlcat (char *, const char *, size_t)
 Size-bounded string concatenation. More...
 
size_t G_strlcpy (char *, const char *, size_t)
 Safe string copy function. More...
 
char * G_basename (char *, const char *)
 Truncates filename to the base part (before the last '.') if it matches the extension, otherwise leaves it unchanged. More...
 
size_t G_get_num_decimals (const char *)
 Get number of decimals from a string. More...
 
char * G_double_to_basename_format (double, size_t, size_t)
 Convert a double to a string substituting the dot with underscore 12.3456 => '12_3456'. More...
 
char * G_get_basename_separator (void)
 Return the environmental basename variable or the default value. More...
 
char * G_join_basename_strings (const char **, size_t)
 join an array of strings using the basename separator More...
 
char * G_generate_basename (const char *, double, size_t, size_t)
 Generate the format string. More...
 
void G_bresenham_line (int, int, int, int, int(*)(int, int))
 Bresenham line algorithm. More...
 
void G_clicker (void)
 
char * G_color_rules_options (void)
 Get list of color rules for Option->options. More...
 
char * G_color_rules_descriptions (void)
 Get color rules description for Option->descriptions. More...
 
char * G_color_rules_description_type (void)
 Get color rules description for Option->descriptions. More...
 
void G_list_color_rules (FILE *)
 Print color rules. More...
 
void G_list_color_rules_description_type (FILE *, char *)
 Print color rules with description and type. More...
 
int G_find_color_rule (const char *)
 Check if color rule is defined. More...
 
int G_num_standard_colors (void)
 Get number of named colors (RGB triplets) More...
 
int G_insert_commas (char *)
 Inserts commas into a number string. More...
 
void G_remove_commas (char *)
 Removes commas from number string. More...
 
int G_compressor_number (char *)
 
char * G_compressor_name (int)
 
int G_default_compressor (void)
 
int G_check_compressor (int)
 
int G_write_compressed (int, unsigned char *, int, int)
 
int G_write_unompressed (int, unsigned char *, int)
 
int G_read_compressed (int, int, unsigned char *, int, int)
 
int G_compress_bound (int, int)
 
int G_compress (unsigned char *, int, unsigned char *, int, int)
 
int G_expand (unsigned char *, int, unsigned char *, int, int)
 
int G_no_compress (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_no_expand (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_rle_compress (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_rle_expand (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_zlib_compress (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_zlib_expand (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_lz4_compress (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_lz4_expand (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_bz2_compress (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_bz2_expand (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_zstd_compress (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_zstd_expand (unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
 
int G_recursive_copy (const char *, const char *)
 Copy recursively source directory to destination directory. More...
 
int G_copy_file (const char *, const char *)
 Copies one file to another. More...
 
int G_is_initialized (int *)
 
void G_initialize_done (int *)
 
void G_init_counter (struct Counter *, int)
 
int G_counter_next (struct Counter *)
 
const char * G_date (void)
 Current date and time. More...
 
int G_get_datum_by_name (const char *)
 
const char * G_datum_name (int)
 
const char * G_datum_description (int)
 
const char * G_datum_ellipsoid (int)
 
int G_get_datumparams_from_projinfo (const struct Key_Value *, char *, char *)
 
void G_read_datum_table (void)
 
void G_init_debug (void)
 Initiate debugging. More...
 
int G_debug (int, const char *,...) __attribute__((format(printf
 
int int G_begin_distance_calculations (void)
 Begin distance calculations. More...
 
double G_distance (double, double, double, double)
 Returns distance in meters. More...
 
double G_distance_between_line_segments (double, double, double, double, double, double, double, double)
 Returns distance between two line segments in meters. More...
 
double G_distance_point_to_line_segment (double, double, double, double, double, double)
 Returns distance between a point and line segment in meters. More...
 
void G_done_msg (const char *,...) __attribute__((format(printf
 
void int G_is_little_endian (void)
 Tests for little ENDIAN. More...
 
void G_init_env (void)
 Initialize variables. More...
 
const char * G_getenv (const char *)
 Get environment variable. More...
 
const char * G_getenv2 (const char *, int)
 Get variable from specific place. More...
 
const char * G_getenv_nofatal (const char *)
 Get environment variable. More...
 
const char * G_getenv_nofatal2 (const char *, int)
 Get environment variable from specific place. More...
 
void G_setenv (const char *, const char *)
 Set environment variable (updates .gisrc) More...
 
void G_setenv2 (const char *, const char *, int)
 Set environment variable from specific place (updates .gisrc) More...
 
void G_setenv_nogisrc (const char *, const char *)
 Set environment name to value (doesn't update .gisrc) More...
 
void G_setenv_nogisrc2 (const char *, const char *, int)
 Set environment name to value from specific place (doesn't update .gisrc) More...
 
void G_unsetenv (const char *)
 Remove name from environment. More...
 
void G_unsetenv2 (const char *, int)
 Remove name from environment from specific place. More...
 
const char * G_get_env_name (int)
 Get variable name for index n. More...
 
void G_set_gisrc_mode (int)
 Set where to find/store variables. More...
 
int G_get_gisrc_mode (void)
 Get info where variables are stored. More...
 
void G_create_alt_env (void)
 Set up alternative environment variables. More...
 
void G_switch_env (void)
 Switch environments. More...
 
void G__read_mapset_env (void)
 Force to read the mapset environment file VAR. More...
 
void G__read_gisrc_env (void)
 Force to read the GISRC environment file. More...
 
void G__read_gisrc_path (void)
 Read or read again the GISRC (session) environment variable. More...
 
jmp_buf * G_fatal_longjmp (int)
 
int G_info_format (void)
 Get current message format. More...
 
void G_message (const char *,...) __attribute__((format(printf
 
void void G_verbose_message (const char *,...) __attribute__((format(printf
 
void void void G_important_message (const char *,...) __attribute__((format(printf
 
void void void void G_fatal_error (const char *,...) __attribute__((format(printf
 
void void void void __attribute__ ((noreturn))
 
void G_warning (const char *,...) __attribute__((format(printf
 
void int G_suppress_warnings (int)
 Suppress printing a warning message to stderr. More...
 
int G_sleep_on_error (int)
 Turn on/off no_sleep flag. More...
 
void G_set_error_routine (int(*)(const char *, int))
 Establishes error_routine as the routine that will handle the printing of subsequent error messages. More...
 
void G_unset_error_routine (void)
 After this call subsequent error messages will be handled in the default method. More...
 
void G_init_logging (void)
 
char * G_file_name (char *, const char *, const char *, const char *)
 Builds full path names to GIS data files. More...
 
char * G_file_name_misc (char *, const char *, const char *, const char *, const char *)
 Builds full path names to GIS misc data files. More...
 
char * G_file_name_tmp (char *, const char *, const char *, const char *)
 Builds full path names to GIS data files in temporary directory (for internal use only) More...
 
char * G_file_name_basedir (char *, const char *, const char *, const char *, const char *)
 Builds full path names to GIS data files in temporary directory (for internal use only) More...
 
const char * G_find_file (const char *, char *, const char *)
 Searches for a file from the mapset search list or in a specified mapset. More...
 
const char * G_find_file2 (const char *, const char *, const char *)
 Searches for a file from the mapset search list or in a specified mapset. (look but don't touch) More...
 
const char * G_find_file_misc (const char *, const char *, char *, const char *)
 Searches for a misc file from the mapset search list or in a specified mapset. More...
 
const char * G_find_file2_misc (const char *, const char *, const char *, const char *)
 Searches for a misc file from the mapset search list or in a specified mapset. (look but don't touch) More...
 
char * G_find_etc (const char *)
 searches for a file from the etc search list in GRASS_ADDON_ETC returns the full path to where the file was found. More...
 
const char * G_find_raster (char *, const char *)
 Find a raster map. More...
 
const char * G_find_raster2 (const char *, const char *)
 Find a raster map (look but don't touch) More...
 
const char * G_find_raster3d (const char *, const char *)
 Search for a 3D raster map in current search path or in a specified mapset. More...
 
const char * G_find_vector (char *, const char *)
 Finds a vector map. More...
 
const char * G_find_vector2 (const char *, const char *)
 Find a vector map (look but don't touch) More...
 
int G_begin_geodesic_equation (double, double, double, double)
 
double G_geodesic_lat_from_lon (double)
 
void G_begin_geodesic_distance (double, double)
 Begin geodesic distance. More...
 
void G_set_geodesic_distance_lat1 (double)
 Sets geodesic distance lat1. More...
 
void G_set_geodesic_distance_lat2 (double)
 Sets geodesic distance lat2. More...
 
double G_geodesic_distance_lon_to_lon (double, double)
 Calculates geodesic distance. More...
 
double G_geodesic_distance (double, double, double, double)
 Calculates geodesic distance. More...
 
int G_get_ellipsoid_parameters (double *, double *)
 get ellipsoid parameters More...
 
int G_get_spheroid_by_name (const char *, double *, double *, double *)
 Get spheroid parameters by name. More...
 
int G_get_ellipsoid_by_name (const char *, double *, double *)
 Get ellipsoid parameters by name. More...
 
const char * G_ellipsoid_name (int)
 Get ellipsoid name. More...
 
const char * G_ellipsoid_description (int)
 Get description for nth ellipsoid. More...
 
int G_read_ellipsoid_table (int)
 Read ellipsoid table. More...
 
struct Key_ValueG_get_projunits (void)
 Gets units information for location. More...
 
struct Key_ValueG_get_projinfo (void)
 Gets projection information for location. More...
 
struct Key_ValueG_get_projepsg (void)
 Gets EPSG information for the current location. More...
 
char * G_get_projwkt (void)
 Get WKT information for the current location. More...
 
char * G_get_projsrid (void)
 Get srid (spatial reference id) for the current location. More...
 
void G_get_window (struct Cell_head *)
 Get the current region. More...
 
void G_get_default_window (struct Cell_head *)
 Get the default region. More...
 
void G_get_element_window (struct Cell_head *, const char *, const char *, const char *)
 Get region for selected element (raster, vector, window, etc.) More...
 
int G_getl (char *, int, FILE *)
 Gets a line of text from a file. More...
 
int G_getl2 (char *, int, FILE *)
 Gets a line of text from a file of any pedigree. More...
 
const char * G_gisbase (void)
 Get full path name of the top level module directory. More...
 
const char * G_gisdbase (void)
 Get name of top level database directory. More...
 
void G__gisinit (const char *, const char *)
 Initialize GIS Library and ensures a valid mapset is available. More...
 
void G__no_gisinit (const char *)
 Initialize GIS Library. More...
 
void G_init_all (void)
 Initialize environment. More...
 
void G_add_error_handler (void(*)(void *), void *)
 Add new error handler. More...
 
void G_remove_error_handler (void(*)(void *), void *)
 Remove existing error handler. More...
 
const char * G_home (void)
 Get user's home directory. More...
 
const char * G_config_path (void)
 Get user's config path directory. More...
 
void G_init_ilist (struct ilist *)
 Init an integer list and free allocated memory. More...
 
void G_free_ilist (struct ilist *)
 Free allocated memory of an integer list. More...
 
struct ilistG_new_ilist (void)
 Return a new integer list. More...
 
void G_ilist_add (struct ilist *, int)
 Add item to ilist. More...
 
int G_intersect_line_segments (double, double, double, double, double, double, double, double, double *, double *, double *, double *)
 
int G_is_gisbase (const char *)
 Test if specified directory is GISBASE. More...
 
int G_is_location (const char *)
 Test if specified directory is location. More...
 
int G_is_mapset (const char *)
 Test if specified directory is mapset. More...
 
struct Key_ValueG_create_key_value (void)
 Allocate and initialize Key_Value structure. More...
 
void G_set_key_value (const char *, const char *, struct Key_Value *)
 Set value for given key. More...
 
const char * G_find_key_value (const char *, const struct Key_Value *)
 Find given key (case sensitive) More...
 
void G_free_key_value (struct Key_Value *)
 Free allocated Key_Value structure. More...
 
int G_fwrite_key_value (FILE *, const struct Key_Value *)
 Write key/value pairs to file. More...
 
struct Key_ValueG_fread_key_value (FILE *)
 Read key/values pairs from file. More...
 
void G_write_key_value_file (const char *, const struct Key_Value *)
 Write key/value pairs to file. More...
 
struct Key_ValueG_read_key_value_file (const char *)
 Read key/values pairs from file. More...
 
void G_update_key_value_file (const char *, const char *, const char *)
 Update file, set up value for given key. More...
 
int G_lookup_key_value_from_file (const char *, const char *, char[], int)
 Look up for key in file. More...
 
int G_legal_filename (const char *)
 Check for legal database file name. More...
 
int G_check_input_output_name (const char *, const char *, int)
 Check input and output file names. More...
 
void G_set_distance_to_line_tolerance (double)
 
double G_distance2_point_to_line (double, double, double, double, double, double)
 
void G_list_element (const char *, const char *, const char *, int(*)(const char *, const char *, char *))
 General purpose list function. More...
 
char ** G_list (int, const char *, const char *, const char *)
 List specified type of elements. Application must release the allocated memory. More...
 
void G_free_list (char **)
 Free list. More...
 
void G_lat_format (double, char *)
 
const char * G_lat_format_string (void)
 
void G_lon_format (double, char *)
 
const char * G_lon_format_string (void)
 
void G_llres_format (double, char *)
 
const char * G_llres_format_string (void)
 
void G_lat_parts (double, int *, int *, double *, char *)
 
void G_lon_parts (double, int *, int *, double *, char *)
 
int G_lat_scan (const char *, double *)
 
int G_lon_scan (const char *, double *)
 
int G_llres_scan (const char *, double *)
 
const char * G_location (void)
 Get current location name. More...
 
char * G_location_path (void)
 Get current location UNIX-like path. More...
 
void G_srand48 (long)
 Seed the pseudo-random number generator. More...
 
long G_srand48_auto (void)
 Seed the pseudo-random number generator from the time and PID. More...
 
long G_lrand48 (void)
 Generate an integer in the range [0, 2^31) More...
 
long G_mrand48 (void)
 Generate an integer in the range [-2^31, 2^31) More...
 
double G_drand48 (void)
 Generate a floating-point value in the range [0,1) More...
 
void G_set_ls_filter (int(*)(const char *, void *), void *)
 
void G_set_ls_exclude_filter (int(*)(const char *, void *), void *)
 
char ** G_ls2 (const char *, int *)
 Stores a sorted directory listing in an array. More...
 
void G_ls (const char *, FILE *)
 Prints a directory listing to a stream, in prettified column format. More...
 
void G_ls_format (char **, int, int, FILE *)
 Prints a listing of items to a stream, in prettified column format. More...
 
void * G_ls_regex_filter (const char *, int, int, int)
 
void * G_ls_glob_filter (const char *, int, int)
 
void G_free_ls_filter (void *)
 
int G_make_location (const char *, struct Cell_head *, const struct Key_Value *, const struct Key_Value *)
 Create a new location. More...
 
int G_make_location_epsg (const char *, struct Cell_head *, const struct Key_Value *, const struct Key_Value *, const struct Key_Value *)
 Create a new location. More...
 
int G_make_location_crs (const char *, struct Cell_head *, const struct Key_Value *, const struct Key_Value *, const char *, const char *)
 Create a new location. More...
 
int G_write_projsrid (const char *, const char *)
 Write srid (spatial reference id) to file. More...
 
int G_write_projwkt (const char *, const char *)
 Write WKT definition to file. More...
 
int G_compare_projections (const struct Key_Value *, const struct Key_Value *, const struct Key_Value *, const struct Key_Value *)
 Compare projections including units. More...
 
int G_make_mapset (const char *, const char *, const char *)
 Create a new mapset. More...
 
char * G_tolcase (char *)
 convert string to lower case More...
 
char * G_toucase (char *)
 convert string to upper case More...
 
const char * G_mapset (void)
 Get current mapset name. More...
 
char * G_mapset_path (void)
 Get current mapset UNIX-like path. More...
 
int G_make_mapset_element (const char *)
 Create element in the current mapset. More...
 
int G_make_mapset_element_tmp (const char *)
 Create element in the temporary directory. More...
 
int G_make_mapset_object_group (const char *)
 Create directory for group of elements of a given type. More...
 
int G_make_mapset_dir_object (const char *, const char *)
 Create directory for an object of a given type. More...
 
int G_make_mapset_object_group_tmp (const char *)
 Create directory for type of objects in the temporary directory. More...
 
int G_make_mapset_object_group_basedir (const char *, const char *)
 Create directory for type of objects in the temporary directory. More...
 
int G__make_mapset_element_misc (const char *, const char *)
 Create misc element in the current mapset. More...
 
int G_mapset_permissions (const char *)
 Check for user mapset permission. More...
 
int G_mapset_permissions2 (const char *, const char *, const char *)
 Check for user mapset permission. More...
 
const char * G_get_mapset_name (int)
 Get name of the n'th mapset from the current mapset search path. More...
 
void G_create_alt_search_path (void)
 Define alternative mapset search path. More...
 
void G_switch_search_path (void)
 Switch mapset search path. More...
 
void G_reset_mapsets (void)
 Reset number of mapsets. More...
 
char ** G_get_available_mapsets (void)
 Get list of available mapsets for current location. More...
 
void G_add_mapset_to_search_path (const char *)
 Add mapset to the list of mapsets in search path. More...
 
int G_is_mapset_in_search_path (const char *)
 Check if given mapset is in search path. More...
 
char * G_myname (void)
 Returns location title. More...
 
int G_color_values (const char *, float *, float *, float *)
 
const char * G_color_name (int)
 
void G_newlines_to_spaces (char *)
 
int G_name_is_fully_qualified (const char *, char *, char *)
 Check if map name is fully qualified (map @ mapset) More...
 
char * G_fully_qualified_name (const char *, const char *)
 Get fully qualified element name. More...
 
int G_unqualified_name (const char *, const char *, char *, char *)
 Returns unqualified map name (without @ mapset) More...
 
int G_set_omp_num_threads (struct Option *)
 Set the number of threads for OpenMP The intended usage is at the beginning of a C tool when parameters are processed, namely the G_OPT_M_NPROCS standard option. More...
 
int G_open_new (const char *, const char *)
 Open a new database file. More...
 
int G_open_old (const char *, const char *, const char *)
 Open a database file for reading. More...
 
int G_open_update (const char *, const char *)
 Open a database file for update. More...
 
FILE * G_fopen_new (const char *, const char *)
 Open a new database file. More...
 
FILE * G_fopen_old (const char *, const char *, const char *)
 Open a database file for reading. More...
 
FILE * G_fopen_append (const char *, const char *)
 Open a database file for update (append mode) More...
 
FILE * G_fopen_modify (const char *, const char *)
 Open a database file for update (r+ mode) More...
 
int G_open_new_misc (const char *, const char *, const char *)
 open a new database misc file More...
 
int G_open_old_misc (const char *, const char *, const char *, const char *)
 open a database misc file for reading More...
 
int G_open_update_misc (const char *, const char *, const char *)
 open a database misc file for update More...
 
FILE * G_fopen_new_misc (const char *, const char *, const char *)
 open a new database misc file More...
 
FILE * G_fopen_old_misc (const char *, const char *, const char *, const char *)
 open a database misc file for reading More...
 
FILE * G_fopen_append_misc (const char *, const char *, const char *)
 
FILE * G_fopen_modify_misc (const char *, const char *, const char *)
 
int G_check_overwrite (int argc, char **argv)
 Check for overwrite mode. More...
 
FILE * G_open_pager (struct Popen *)
 
void G_close_pager (struct Popen *)
 
FILE * G_open_mail (struct Popen *)
 
void G_close_mail (struct Popen *)
 
void G_disable_interactive (void)
 Disables the ability of the parser to operate interactively. More...
 
struct GModuleG_define_module (void)
 Initializes a new module. More...
 
struct FlagG_define_flag (void)
 Initializes a Flag struct. More...
 
struct OptionG_define_option (void)
 Initializes an Option struct. More...
 
struct OptionG_define_standard_option (int)
 Create standardised Option structure. More...
 
struct FlagG_define_standard_flag (int)
 Create standardised Flag structure. More...
 
int G_parser (int, char **)
 Parse command line. More...
 
void G_usage (void)
 Command line help/usage message. More...
 
char * G_recreate_command (void)
 Creates command to run non-interactive. More...
 
void G_add_keyword (const char *)
 Add keyword to the list. More...
 
void G_set_keywords (const char *)
 Set keywords from the string. More...
 
int G_get_overwrite (void)
 Get overwrite value. More...
 
char * G_option_to_separator (const struct Option *)
 Get separator string from the option. More...
 
FILE * G_open_option_file (const struct Option *)
 Get an input/output file pointer from the option. If the file name is omitted or '-', it returns either stdin or stdout based on the gisprompt. More...
 
void G_close_option_file (FILE *)
 Close an input/output file returned by G_open_option_file(). If the file pointer is stdin, stdout, or stderr, nothing happens. More...
 
void G_option_rule (int, int, void **)
 Set generic option rule. More...
 
void G_option_exclusive (void *,...)
 Sets the options to be mutually exclusive. More...
 
void G_option_required (void *,...)
 Sets the options to be required. More...
 
void G_option_requires (void *,...)
 Define a list of options from which at least one option is required if first option is present. More...
 
void G_option_requires_all (void *,...)
 Define additionally required options for an option. More...
 
void G_option_excludes (void *,...)
 Exclude selected options. More...
 
void G_option_collective (void *,...)
 Sets the options to be collective. More...
 
int G_mkdir (const char *)
 Creates a new directory. More...
 
int G_is_dirsep (char)
 Checks if a specified character is a valid directory separator character on the host system. More...
 
int G_is_absolute_path (const char *)
 Checks if a specified path looks like an absolute path on the host system. More...
 
char * G_convert_dirseps_to_host (char *)
 Converts directory separator characters in a string to the native host separator character (/ on Unix, \ on Windows) More...
 
char * G_convert_dirseps_from_host (char *)
 Converts directory separator characters in a string from the native host character to the GRASS separator character (/) More...
 
int G_lstat (const char *, struct stat *)
 Get file status. More...
 
int G_stat (const char *, struct stat *)
 Get file status. More...
 
int G_owner (const char *)
 Get owner id of path. More...
 
void G_percent (long, long, int)
 Print percent complete messages. More...
 
void G_percent_reset (void)
 Reset G_percent() to 0%; do not add newline. More...
 
void G_progress (long, int)
 Print progress info messages. More...
 
void G_set_percent_routine (int(*)(int))
 Establishes percent_routine as the routine that will handle the printing of percentage progress messages. More...
 
void G_unset_percent_routine (void)
 After this call subsequent percentage progress messages will be handled in the default method. More...
 
void G_popen_clear (struct Popen *)
 
FILE * G_popen_write (struct Popen *, const char *, const char **)
 
FILE * G_popen_read (struct Popen *, const char *, const char **)
 
void G_popen_close (struct Popen *)
 
void G_setup_plot (double, double, double, double, int(*)(int, int), int(*)(int, int))
 Initialize plotting routines. More...
 
void G_setup_fill (int)
 Set row_fill routine to row_solid_fill or row_dotted_fill. More...
 
void G_plot_where_xy (double, double, int *, int *)
 Converts east,north to x,y. More...
 
void G_plot_where_en (int, int, double *, double *)
 Converts x,y to east,north. More...
 
void G_plot_point (double, double)
 Plot point. More...
 
void G_plot_line (double, double, double, double)
 Plot line between latlon coordinates (fastline) More...
 
void G_plot_line2 (double, double, double, double)
 Plot line between latlon coordinates (slowline) More...
 
int G_plot_polygon (const double *, const double *, int)
 Plot filled polygon with n vertices. More...
 
int G_plot_area (double *const *, double *const *, int *, int)
 Plot multiple polygons. More...
 
void G_plot_fx (double(*)(double), double, double)
 Plot f(east1) to f(east2) More...
 
int G_pole_in_polygon (const double *, const double *, int)
 Check if pole is in polygon. More...
 
const char * G_program_name (void)
 Return module name. More...
 
const char * G_original_program_name (void)
 Return original path of the executed program. More...
 
void G_set_program_name (const char *)
 Set program name. More...
 
int G_projection (void)
 Query cartographic projection. More...
 
int G_projection_units (int)
 Get projection units code (for internal use only) More...
 
const char * G_projection_name (int)
 Get projection name. More...
 
const char * G_database_unit_name (int)
 Get units (localized) name for the current location. More...
 
int G_database_unit (void)
 Get units id for the current location. More...
 
const char * G_database_projection_name (void)
 Query cartographic projection for the current location. More...
 
const char * G_database_datum_name (void)
 Get datum name for the current location. More...
 
const char * G_database_ellipse_name (void)
 Get ellipsoid name for the current location. More...
 
double G_database_units_to_meters_factor (void)
 Conversion to meters. More...
 
const char * G_database_epsg_code (void)
 Get EPGS code for the current location. More...
 
int G_put_window (const struct Cell_head *)
 Writes the region (window) More...
 
int G_put_element_window (const struct Cell_head *, const char *, const char *)
 Write the region. More...
 
void G_putenv (const char *, const char *)
 Sets the UNIX environment variable name to value. More...
 
double G_meridional_radius_of_curvature (double, double, double)
 Meridional radius of curvature. More...
 
double G_transverse_radius_of_curvature (double, double, double)
 Transverse radius of curvature. More...
 
double G_radius_of_conformal_tangent_sphere (double, double, double)
 Radius of conformal tangent sphere. More...
 
void G__read_Cell_head (FILE *, struct Cell_head *)
 Read cell header (for internal use only) More...
 
void G__read_Cell_head_array (char **, struct Cell_head *)
 Read window from NULL terminated array of strings (for internal use only) More...
 
int G_remove (const char *, const char *)
 Remove a database file. More...
 
int G_remove_misc (const char *, const char *, const char *)
 Remove a database misc file. More...
 
int G_recursive_remove (const char *)
 Recursively remove all files in given directory. More...
 
int G_rename_file (const char *, const char *)
 Rename a file or a directory in the filesystem. More...
 
int G_rename (const char *, const char *, const char *)
 Rename a database file. More...
 
int G_begin_rhumbline_equation (double, double, double, double)
 Start rhumbline calculations. More...
 
double G_rhumbline_lat_from_lon (double)
 Calculates rhumbline latitude. More...
 
void G_rotate_around_point (double, double, double *, double *, double)
 Rotate point (double version) More...
 
void G_rotate_around_point_int (int, int, int *, int *, double)
 Rotate point (int version) More...
 
off_t G_ftell (FILE *)
 Get the current file position of the stream. More...
 
void G_fseek (FILE *, off_t, int)
 Change the file position of the stream. More...
 
void G_get_set_window (struct Cell_head *)
 Get the current working window (region) More...
 
void G_set_window (struct Cell_head *)
 Establishes window as the current working window (region). More...
 
void G_unset_window (void)
 Unset current region. More...
 
void G_shortest_way (double *, double *)
 Shortest way between two eastings. More...
 
void G_sleep (unsigned int)
 
int G_snprintf (char *, size_t, const char *,...) __attribute__((format(printf
 
int int G_strcasecmp (const char *, const char *)
 String compare ignoring case (upper or lower) More...
 
int G_strncasecmp (const char *, const char *, int)
 String compare ignoring case (upper or lower) - limited number of characters. More...
 
char * G_store (const char *)
 Copy string to allocated memory. More...
 
char * G_store_upper (const char *)
 Copy string to allocated memory and convert copied string to upper case. More...
 
char * G_store_lower (const char *)
 Copy string to allocated memory and convert copied string to lower case. More...
 
char * G_strchg (char *, char, char)
 Replace all occurrences of character in string bug with new. More...
 
char * G_str_replace (const char *, const char *, const char *)
 Replace all occurrences of old_str in buffer with new_str. More...
 
char * G_str_concat (const char **, int, const char *, int)
 String concatenation. More...
 
void G_strip (char *)
 Removes all leading and trailing white space from string. More...
 
char * G_chop (char *)
 Chop leading and trailing white spaces. More...
 
void G_str_to_upper (char *)
 Convert string to upper case. More...
 
void G_str_to_lower (char *)
 Convert string to lower case. More...
 
int G_str_to_sql (char *)
 Make string SQL compliant. More...
 
void G_squeeze (char *)
 Remove superfluous white space. More...
 
char * G_strcasestr (const char *, const char *)
 Finds the first occurrence of the sub-string in the null-terminated string ignoring case (upper or lower) More...
 
void G_init_tempfile (void)
 Initialize environment for creating tempfiles. More...
 
char * G_tempfile (void)
 Returns a temporary file name. More...
 
char * G_tempfile_basedir (const char *)
 Returns a temporary file name. More...
 
char * G_tempfile_pid (int)
 Create tempfile from process id. More...
 
char * G_tempfile_pid_basedir (int, const char *)
 Create tempfile from process id in given base directory. More...
 
void G_temp_element (char *)
 Populates element with a path string. More...
 
void G__temp_element (char *, int)
 Populates element with a path string (internal use only!) More...
 
void G__temp_element_basedir (char *, const char *)
 Populates element with a path string (internal use only!) More...
 
char * G_mktemp (char *)
 Opens a temporary file. More...
 
int G_mkstemp (char *, int, int)
 Returns a file descriptor. More...
 
FILE * G_mkstemp_fp (char *, int, int)
 Returns a file descriptor. More...
 
void G_init_timestamp (struct TimeStamp *)
 Initialize timestamp structure. More...
 
void G_set_timestamp (struct TimeStamp *, const struct DateTime *)
 
void G_set_timestamp_range (struct TimeStamp *, const struct DateTime *, const struct DateTime *)
 
int G_write_timestamp (FILE *, const struct TimeStamp *)
 Output TimeStamp structure to a file as a formatted string. More...
 
void G_get_timestamps (const struct TimeStamp *, struct DateTime *, struct DateTime *, int *)
 Copy TimeStamp into [two] Datetimes structs. More...
 
int G_format_timestamp (const struct TimeStamp *, char *)
 Create text string from TimeStamp structure. More...
 
int G_scan_timestamp (struct TimeStamp *, const char *)
 Fill a TimeStamp structure from a datetime string. More...
 
int G_has_raster_timestamp (const char *, const char *)
 Check if timestamp for raster map exists. More...
 
int G_read_raster_timestamp (const char *, const char *, struct TimeStamp *)
 Read timestamp from raster map. More...
 
int G_write_raster_timestamp (const char *, const struct TimeStamp *)
 Write timestamp of raster map. More...
 
int G_remove_raster_timestamp (const char *)
 Remove timestamp from raster map. More...
 
int G_has_vector_timestamp (const char *, const char *, const char *)
 Check if timestamp for vector map exists. More...
 
int G_read_vector_timestamp (const char *, const char *, const char *, struct TimeStamp *)
 Read timestamp from vector map. More...
 
int G_write_vector_timestamp (const char *, const char *, const struct TimeStamp *)
 Write timestamp of vector map. More...
 
int G_remove_vector_timestamp (const char *, const char *)
 Remove timestamp from vector map. More...
 
int G_has_raster3d_timestamp (const char *, const char *)
 Check if timestamp for 3D raster map exists. More...
 
int G_read_raster3d_timestamp (const char *, const char *, struct TimeStamp *)
 Read timestamp from 3D raster map. More...
 
int G_remove_raster3d_timestamp (const char *)
 Remove timestamp from 3D raster map. More...
 
int G_write_raster3d_timestamp (const char *, const struct TimeStamp *)
 Write timestamp of 3D raster map. More...
 
char ** G_tokenize (const char *, const char *)
 Tokenize string. More...
 
char ** G_tokenize2 (const char *, const char *, const char *)
 Tokenize string. More...
 
int G_number_of_tokens (char **)
 Return number of tokens. More...
 
void G_free_tokens (char **)
 Free memory allocated to tokens. More...
 
void G_trim_decimal (char *)
 Removes trailing zeros from decimal number. More...
 
double G_meters_to_units_factor (int)
 Units conversion from meters to units. More...
 
double G_meters_to_units_factor_sq (int)
 Units conversion from square meters to square units. More...
 
const char * G_get_units_name (int, int, int)
 Get localized units name. More...
 
int G_units (const char *)
 Get units code by name. More...
 
int G_is_units_type_spatial (int)
 Check if the unit is of spatial type. More...
 
int G_is_units_type_temporal (int)
 Check if the unit is of temporal type. More...
 
char * G_rc_path (const char *, const char *)
 Returns path to element and item. More...
 
int G_verbose (void)
 Get current verbosity level. More...
 
int G_verbose_min (void)
 Get min verbosity level. More...
 
int G_verbose_std (void)
 Get standard verbosity level. More...
 
int G_verbose_max (void)
 Get max verbosity level. More...
 
int G_set_verbose (int)
 Set verbosity level. More...
 
void G_3dview_warning (int)
 Turns 3D View warnings on and off. More...
 
int G_get_3dview_defaults (struct G_3dview *, struct Cell_head *)
 Sets default for v based on w. More...
 
int G_put_3dview (const char *, const struct G_3dview *, const struct Cell_head *)
 Saves info to a 3d.view file in the current mapset. More...
 
int G_get_3dview (const char *, const char *, struct G_3dview *)
 Gets a 3D View. More...
 
const char * G_whoami (void)
 Gets user's name. More...
 
void G_adjust_window_to_box (const struct Cell_head *, struct Cell_head *, int, int)
 Adjusts window to a rectangular box. More...
 
void G_format_northing (double, char *, int)
 Northing to ASCII. More...
 
void G_format_easting (double, char *, int)
 Easting to ASCII. More...
 
void G_format_resolution (double, char *, int)
 Resolution to ASCII. More...
 
int G_point_in_region (double, double)
 Returns TRUE if coordinate is within the current region settings. More...
 
int G_point_in_window (double, double, const struct Cell_head *)
 Returns TRUE if coordinate is within the given map region. More...
 
int G_limit_east (double *, int)
 
int G_limit_west (double *, int)
 
int G_limit_north (double *, int)
 Limit north (y) coordinate. More...
 
int G_limit_south (double *, int)
 Limit south (y) coordinate. More...
 
int G_window_overlap (const struct Cell_head *, double, double, double, double)
 Determines if a box overlays a map window. More...
 
double G_window_percentage_overlap (const struct Cell_head *, double, double, double, double)
 Determines percentage of box is contained in the window. More...
 
int G_scan_northing (const char *, double *, int)
 ASCII northing to double. More...
 
int G_scan_easting (const char *, double *, int)
 ASCII easting to double. More...
 
int G_scan_resolution (const char *, double *, int)
 ASCII resolution to double. More...
 
double G_adjust_east_longitude (double, double)
 Adjust east longitude. More...
 
double G_adjust_easting (double, const struct Cell_head *)
 Returns east not smaller than west. More...
 
void G__init_window (void)
 Initialize window (region). More...
 
void G_begin_execute (void(*func)(void *), void *, void **, int)
 
void G_end_execute (void **)
 
void G_init_workers (void)
 
void G_finish_workers (void)
 
void G__write_Cell_head (FILE *, const struct Cell_head *, int)
 Write cell header or window. More...
 
void G__write_Cell_head3 (FILE *, const struct Cell_head *, int)
 Write 3D cell header or window. More...
 
void G_write_zeros (int, size_t)
 Writes n bytes of zero to file descriptor fd More...
 
void G_xdr_get_int (int *, const void *)
 
void G_xdr_put_int (void *, const int *)
 
void G_xdr_get_float (float *, const void *)
 
void G_xdr_put_float (void *, const float *)
 
void G_xdr_get_double (double *, const void *)
 
void G_xdr_put_double (void *, const double *)
 
void G_zero (void *, int)
 Zero out a buffer, buf, of length i. More...
 
int G_zone (void)
 Query cartographic zone. More...
 

Macro Definition Documentation

◆ G_alloca

#define G_alloca (   n)    G_malloc(n)

Definition at line 57 of file defs/gis.h.

◆ G_calloc

#define G_calloc (   m,
 
)    G__calloc(RELDIR "/" __FILE__, __LINE__, (m), (n))

Definition at line 95 of file defs/gis.h.

◆ G_freea

#define G_freea (   p)    G_free(p)

Definition at line 58 of file defs/gis.h.

◆ G_incr_void_ptr

#define G_incr_void_ptr (   ptr,
  size 
)     ((void *)((const unsigned char *)(ptr) + (size)))

Definition at line 81 of file defs/gis.h.

◆ G_malloc

#define G_malloc (   n)    G__malloc(RELDIR "/" __FILE__, __LINE__, (n))

Definition at line 94 of file defs/gis.h.

◆ G_realloc

#define G_realloc (   p,
 
)    G__realloc(RELDIR "/" __FILE__, __LINE__, (p), (n))

Definition at line 96 of file defs/gis.h.

◆ RELDIR

#define RELDIR   "?"

Definition at line 72 of file defs/gis.h.

Function Documentation

◆ __attribute__()

void void void void __attribute__ ( (noreturn)  )

◆ G_3dview_warning()

void G_3dview_warning ( int  b)

Turns 3D View warnings on and off.

If Suppress_warn is 0, a warning will be printed if less than 95% of the window when the view was saved overlaps the current window.

Parameters
[in]b
Returns

Definition at line 45 of file view.c.

◆ G__calloc()

void* G__calloc ( const char *  file,
int  line,
size_t  m,
size_t  n 
)

Memory allocation.

Allocates a properly aligned block of memory n*m bytes in length, initializes the allocated memory to zero, and returns a pointer to the allocated block of memory.

Dies with error message on memory allocation fail.

Note: Allocating memory for reading and writing raster maps is discussed in Allocating Raster I/O Buffers.

Parameters
filefine name
lineline number
melement size
nnumber of elements

Definition at line 73 of file gis/alloc.c.

◆ G__gisinit()

void G__gisinit ( const char *  version,
const char *  pgm 
)

Initialize GIS Library and ensures a valid mapset is available.

Parameters
version
pgmprogram (module) name
Returns
always returns 0 on success
G_fatal_error() is called on error

Definition at line 43 of file gisinit.c.

◆ G__init_window()

void G__init_window ( void  )

Initialize window (region).

Definition at line 76 of file gis/window_map.c.

References G_get_window(), G_initialize_done(), G_is_initialized(), G__::window, and G__::window_set.

Referenced by G_init_all(), and Rast__init_window().

◆ G__make_mapset_element_misc()

int G__make_mapset_element_misc ( const char *  dir,
const char *  name 
)

Create misc element in the current mapset.

Parameters
dirdirectory path (e.g., cell_misc)
nameelement to be created in mapset (e.g., elevation)
Returns
0 no element defined
1 on success

Definition at line 260 of file mapset_msc.c.

References G_make_mapset_dir_object(), and name.

Referenced by I_fopen_subgroup_file_append(), I_fopen_subgroup_file_new(), Rast__close_null(), and Rast__quant_export().

◆ G__malloc()

void* G__malloc ( const char *  file,
int  line,
size_t  n 
)

Memory allocation.

Allocates a block of memory at least n bytes which is aligned properly for all data types. A pointer to the aligned block is returned.

Dies with error message on memory allocation fail.

Parameters
filefile name
lineline number
nnumber of elements

Definition at line 32 of file gis/alloc.c.

◆ G__no_gisinit()

void G__no_gisinit ( const char *  version)

Initialize GIS Library.

Initializes GIS engine, but does not check for a valid mapset.

Definition at line 98 of file gisinit.c.

◆ G__read_Cell_head()

void G__read_Cell_head ( FILE *  fd,
struct Cell_head cellhd 
)

Read cell header (for internal use only)

Parameters
fpfile descriptor
[out]cellhdpointer to Cell_head structure

Definition at line 56 of file rd_cellhd.c.

References count, G__read_Cell_head_array(), G_calloc, G_debug(), G_free(), G_fseek(), G_getl(), and G_store().

Referenced by Rast_get_cellhd().

◆ G__read_Cell_head_array()

void G__read_Cell_head_array ( char **  array,
struct Cell_head cellhd 
)

Read window from NULL terminated array of strings (for internal use only)

Parameters
arrayarray of strings
[out]cellhdpointer to Cell_head structure

Definition at line 96 of file rd_cellhd.c.

Referenced by G__read_Cell_head().

◆ G__read_gisrc_env()

void G__read_gisrc_env ( void  )

Force to read the GISRC environment file.

The GISRC file will be read into memory, ignoring if it was readed before. Existing values will be overwritten, new values appended.

Returns

Definition at line 112 of file env.c.

◆ G__read_gisrc_path()

void G__read_gisrc_path ( void  )

Read or read again the GISRC (session) environment variable.

The GISRC environment variable will be read and its value stored, ignoring if it was read before.

Calls G_fatal_error when the GISRC variable is not set.

Definition at line 125 of file env.c.

References _, G_fatal_error(), and st.

◆ G__read_mapset_env()

void G__read_mapset_env ( void  )

Force to read the mapset environment file VAR.

The mapset specific VAR file of the mapset set with G_setenv() will be read into memory, ignoring if it was readed before. Existing values will be overwritten, new values appended.

Returns

Definition at line 98 of file env.c.

◆ G__realloc()

void* G__realloc ( const char *  file,
int  line,
void *  buf,
size_t  n 
)

Memory reallocation.

Changes the size of a previously allocated block of memory at ptr and returns a pointer to the new block of memory. The size may be larger or smaller than the original size. If the original block cannot be extended "in place", then a new block is allocated and the original block copied to the new block.

Note: If buf is NULL, then this routine simply allocates a block of n bytes else buf must point to memory that has been dynamically allocated by G_malloc(), G_calloc(), G_realloc(), malloc(3), alloc(3), or realloc(3).. This routine works around broken realloc() routines, which do not handle a NULL buf.

Parameters
filefile name
lineline number
[in,out]bufbuffer holding original data
[in]narray size

Definition at line 119 of file gis/alloc.c.

◆ G__temp_element()

void G__temp_element ( char *  element,
int  tmp 
)

Populates element with a path string (internal use only!)

Parameters
[out]elementelement name
tmpTRUE to use G_make_mapset_element_tmp() instead of G_make_mapset_element()

Definition at line 159 of file tempfile.c.

Referenced by G_temp_element(), and Vect__get_path().

◆ G__temp_element_basedir()

void G__temp_element_basedir ( char *  element,
const char *  basedir 
)

Populates element with a path string (internal use only!)

Parameters
[out]elementelement name
tmpTRUE to use G_make_mapset_element_tmp() instead of G_make_mapset_element()

Definition at line 185 of file tempfile.c.

References G__machine_name(), G_debug(), G_make_mapset_object_group(), G_make_mapset_object_group_basedir(), NULL, and strcpy.

Referenced by G_tempfile_pid_basedir().

◆ G__write_Cell_head()

void G__write_Cell_head ( FILE *  fd,
const struct Cell_head cellhd,
int  is_cellhd 
)

Write cell header or window.

Parameters
[in,out]fdheader file
[in]cellhdpointed to cell header structure
[in]is_cellhd1 cell header; 0 window
Returns

Definition at line 28 of file wr_cellhd.c.

References Cell_head::cols, Cell_head::compressed, Cell_head::east, Cell_head::ew_res, Cell_head::format, G_format_easting(), G_format_northing(), G_format_resolution(), Cell_head::north, Cell_head::ns_res, Cell_head::proj, Cell_head::rows, Cell_head::south, Cell_head::west, and Cell_head::zone.

Referenced by G__write_Cell_head3(), and Rast_put_cellhd().

◆ G__write_Cell_head3()

void G__write_Cell_head3 ( FILE *  fd,
const struct Cell_head cellhd,
int  is_cellhd 
)

Write 3D cell header or window.

Parameters
[in,out]fdheader file
[in]cellhdpointer to cell header structure
[in]is_cellhd1 cell header; 0 window
Returns

Definition at line 74 of file wr_cellhd.c.

References Cell_head::bottom, Cell_head::cols3, Cell_head::depths, Cell_head::ew_res3, G__write_Cell_head(), G_format_resolution(), Cell_head::ns_res3, Cell_head::proj, Cell_head::rows3, Cell_head::tb_res, and Cell_head::top.

◆ G_add_error_handler()

void G_add_error_handler ( void(*)(void *)  func,
void *  closure 
)

Add new error handler.

Example

static void error_handler(void *p) {
const char *map = (const char *) p;
}
G_add_error_handler(error_handler, new->answer);
void G_add_error_handler(void(*)(void *), void *)
Add new error handler.
Definition: gis/handler.c:71
int Vect_delete(const char *)
Delete vector map including attribute tables.
Definition: map.c:367
Parameters
funchandler to add
closurepointer to closure data

Definition at line 71 of file gis/handler.c.

Referenced by db_set_error_handler_driver().

◆ G_add_keyword()

void G_add_keyword ( const char *  keyword)

Add keyword to the list.

Parameters
keywordkeyword string

Definition at line 866 of file parser.c.

References G_realloc, G_store(), and st.

◆ G_add_mapset_to_search_path()

void G_add_mapset_to_search_path ( const char *  mapset)

Add mapset to the list of mapsets in search path.

Mapset is add in memory only, not to the SEARCH_PATH file! List is check first if already exists.

Parameters
mapsetmapset name to be added to the search path

Definition at line 203 of file mapset_nme.c.

References G_is_mapset_in_search_path().

◆ G_adjust_Cell_head()

void G_adjust_Cell_head ( struct Cell_head cellhd,
int  row_flag,
int  col_flag 
)

Adjust cell header.

This function fills in missing parts of the input cell header (or region). It also makes projection-specific adjustments. The cellhd structure must have its north, south, east, west, and proj fields set.

If row_flag is true, then the north-south resolution is computed from the number of rows in the cellhd structure. Otherwise the number of rows is computed from the north-south resolution in the structure, similarly for col_flag and the number of columns and the east-west resolution.

Note: 3D values are not adjusted.

Parameters
[in,out]cellhdpointer to Cell_head structure
row_flagcompute n-s resolution
col_flagcompute e-w resolution

Definition at line 51 of file adj_cellhd.c.

References _, Cell_head::cols, Cell_head::ew_res, G_fatal_error(), Cell_head::north, Cell_head::ns_res, Cell_head::proj, PROJECTION_LL, Cell_head::rows, and Cell_head::south.

◆ G_adjust_Cell_head3()

void G_adjust_Cell_head3 ( struct Cell_head cellhd,
int  row_flag,
int  col_flag,
int  depth_flag 
)

Adjust cell header for 3D values.

This function fills in missing parts of the input cell header (or region). It also makes projection-specific adjustments. The cellhd structure must have its north, south, east, west, and proj fields set.

If row_flag is true, then the north-south resolution is computed from the number of rows in the cellhd structure. Otherwise the number of rows is computed from the north-south resolution in the structure, similarly for col_flag and the number of columns and the east-west resolution.

If depth_flag is true, top-bottom resolution is calculated from depths. If depth_flag are false, number of depths is calculated from top-bottom resolution.

Warning
This function can cause segmentation fault without any warning when it is called with Cell_head top and bottom set to zero.
Parameters
[in,out]cellhdpointer to Cell_head structure
row_flagcompute n-s resolution
col_flagcompute e-w resolution
depth_flagcompute t-b resolution

Definition at line 163 of file adj_cellhd.c.

References _, Cell_head::cols, Cell_head::cols3, Cell_head::depths, Cell_head::ew_res, Cell_head::ew_res3, G_fatal_error(), Cell_head::north, Cell_head::ns_res, Cell_head::ns_res3, Cell_head::proj, PROJECTION_LL, Cell_head::rows, Cell_head::rows3, Cell_head::south, and Cell_head::tb_res.

◆ G_adjust_east_longitude()

double G_adjust_east_longitude ( double  east,
double  west 
)

Adjust east longitude.

This routine returns an equivalent east that is at least as large as the west coordinate.

Note: This routine should be used only with latitude-longitude coordinates.

Parameters
easteast coordinate
westwest coordinate
Returns
east coordinate

Definition at line 32 of file gis/window_map.c.

◆ G_adjust_easting()

double G_adjust_easting ( double  east,
const struct Cell_head window 
)

Returns east not smaller than west.

If the region projection is PROJECTION_LL, then this routine returns an equivalent east that is not smaller than the coordinate for the western edge of the region and, if possible, smaller than the coordinate for the eastern edge of the region. Otherwise no adjustment is made and the original east is returned.

Parameters
easteast coordinate
windowpointer to Cell_head
Returns
east coordinate

Definition at line 58 of file gis/window_map.c.

Referenced by G_plot_where_en().

◆ G_adjust_window_ll()

int G_adjust_window_ll ( struct Cell_head cellhd)

Adjust window for lat/lon.

This function tries to automatically fix fp precision issues and adjust rounding errors for lat/lon.

Note: 3D values are not adjusted.

Parameters
[in,out]cellhdpointer to Cell_head structure
Returns
1 if window was adjusted
0 if window was not adjusted

Definition at line 552 of file adj_cellhd.c.

References _, Cell_head::east, Cell_head::ew_res, G_fatal_error(), G_lat_format(), G_lat_scan(), G_llres_format(), G_llres_scan(), G_lon_format(), G_lon_scan(), Cell_head::north, Cell_head::ns_res, Cell_head::proj, PROJECTION_LL, Cell_head::south, and Cell_head::west.

◆ G_adjust_window_to_box()

void G_adjust_window_to_box ( const struct Cell_head src,
struct Cell_head dst,
int  rows,
int  cols 
)

Adjusts window to a rectangular box.

Creates a new window dst from a window src which fits into the rectangular box with dimensions rows by cols.

Parameters
[in]srcsource window
[in,out]dstdestination window
[in]rowsnumber of rows in box
[in]colsnumber of columns in box
Returns

Definition at line 31 of file wind_2_box.c.

References dst, and src.

◆ G_aprintf()

int int int G_aprintf ( const char *  format,
  ... 
)

Adjust the width of string specifiers to the display space instead of the number of bytes for wide characters and print them formatted using the adjusted display width.

compare

printf("%10s|\n%10s|\n", "ABCD", "가나");

ABCD|

가나|

and

G_aprintf("%10s|\n%10s|\n", "ABCD", "가나");

ABCD|

가나|

Parameters
[in]formatstring format
[in]...arguments for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 465 of file aprintf.c.

◆ G_area_for_zone_on_ellipsoid()

double G_area_for_zone_on_ellipsoid ( double  north,
double  south 
)

Calculates area between latitudes.

This routine shows how to calculate area between two lats, but isn't efficient for row by row since G_darea0_on_ellipsoid() will be called twice for the same lat, once as a south then again as a north.

Returns the area between latitudes north and south scaled by the factor s passed to G_begin_zone_area_on_ellipsoid().

Parameters
northnorth coordinate
southsouth coordinate
Returns
cell area

Definition at line 89 of file area_ellipse.c.

References G_darea0_on_ellipsoid().

◆ G_area_for_zone_on_sphere()

double G_area_for_zone_on_sphere ( double  north,
double  south 
)

Calculates area between latitudes.

This routine shows how to calculate area between two lats, but isn't efficient for row by row since G_darea0_on_sphere() will be called twice for the same lat, once as a south then again as a north.

Returns the area between latitudes north and south scaled by the factor s passed to G_begin_zone_area_on_sphere().

Parameters
north
[in]south
Returns
double

Definition at line 69 of file area_sphere.c.

References G_darea0_on_sphere().

◆ G_area_of_cell_at_row()

double G_area_of_cell_at_row ( int  row)

Cell area in specified row.

This routine returns the area in square meters of a cell in the specified row. This value is constant for planimetric grids and varies with the row if the projection is latitude-longitude.

Parameters
rowrow number
Returns
cell area

Definition at line 87 of file gis/area.c.

References PROJECTION_LL, and st.

◆ G_area_of_polygon()

double G_area_of_polygon ( const double *  x,
const double *  y,
int  n 
)

Area in square meters of polygon.

Returns the area in square meters of the polygon described by the n pairs of x,y coordinate vertices. It is used both for planimetric and latitude-longitude projections.

You should call G_begin_polygon_area_calculations() function before calling this function.

Note: If the database is planimetric with the non-meter grid, this routine performs the required unit conversion to produce square meters.

Parameters
xarray of x coordinates
yarray of y coordinates
nnumber of x,y coordinate pairs
Returns
area in square meters of the polygon

Definition at line 159 of file gis/area.c.

References G_ellipsoid_polygon_area(), G_planimetric_polygon_area(), PROJECTION_LL, st, and x.

◆ G_ascii_check()

void G_ascii_check ( char *  string)

Removes non-ascii characters from buffer.

Updates string with non_ascii characters removed, except for tabs, which are turned into spaces.

Parameters
[in,out]stringbuffer to have non-ascii characters removed
Returns

Definition at line 31 of file ascii_chk.c.

References SPACE, and TAB.

Referenced by Rast__read_history().

◆ G_asprintf()

◆ G_basename()

char* G_basename ( char *  filename,
const char *  desired_ext 
)

Truncates filename to the base part (before the last '.') if it matches the extension, otherwise leaves it unchanged.

Checks if a filename matches a certain file extension (case insensitive) and if so, truncates the string to the base file name (cf. basename Unix command)

Parameters
filenamestring containing filename
desired_extstring containing extension to look for (case insensitive)
Returns
pointer to filename

Definition at line 36 of file basename.c.

Referenced by G_parser().

◆ G_begin_cell_area_calculations()

int G_begin_cell_area_calculations ( void  )

Begin cell area calculations.

This routine must be called once before any call to G_area_of_cell_at_row(). It perform all inititalizations needed to do area calculations for grid cells, based on the current window "projection" field. It can be used in either planimetric projections or the latitude-longitude projection.

Returns
0 if the projection is not measurable (ie. imagery or xy)
1 if the projection is planimetric (ie. UTM or SP)
2 if the projection is non-planimetric (ie. latitude-longitude)

Definition at line 46 of file gis/area.c.

◆ G_begin_distance_calculations()

int int G_begin_distance_calculations ( void  )

Begin distance calculations.

Initializes the distance calculations. It is used both for the planimetric and latitude-longitude projections.

Returns
0 if projection has no metrix (ie. imagery)
1 if projection is planimetric
2 if projection is latitude-longitude

Definition at line 42 of file gis/distance.c.

Referenced by Vect_line_geodesic_distance().

◆ G_begin_ellipsoid_polygon_area()

void G_begin_ellipsoid_polygon_area ( double  a,
double  e2 
)

Begin area calculations.

This initializes the polygon area calculations for the ellipsoid with semi-major axis a (in meters) and ellipsoid eccentricity squared e2.

Parameters
asemi-major axis
e2ellipsoid eccentricity squared

Definition at line 66 of file area_poly1.c.

◆ G_begin_execute()

void G_begin_execute ( void(*)(void *)  func,
void *  ,
void **  ,
int   
)

◆ G_begin_geodesic_distance()

void G_begin_geodesic_distance ( double  a,
double  e2 
)

Begin geodesic distance.

Initializes the distance calculations for the ellipsoid with semi-major axis a (in meters) and ellipsoid eccentricity squared e2. It is used only for the latitude-longitude projection.

Note: Must be called once to establish the ellipsoid.

Parameters
asemi-major axis in meters
e2ellipsoid eccentricity

Definition at line 50 of file geodist.c.

◆ G_begin_geodesic_equation()

int G_begin_geodesic_equation ( double  lon1,
double  lat1,
double  lon2,
double  lat2 
)

Definition at line 38 of file geodesic.c.

◆ G_begin_polygon_area_calculations()

int G_begin_polygon_area_calculations ( void  )

Begin polygon area calculations.

This initializes the polygon area calculation routines. It is used both for planimetric and latitude-longitude projections.

Returns
0 if the projection is not measurable (ie. imagery or xy)
1 if the projection is planimetric (ie. UTM or SP)
2 if the projection is non-planimetric (ie. latitude-longitude)

Definition at line 120 of file gis/area.c.

◆ G_begin_rhumbline_equation()

int G_begin_rhumbline_equation ( double  lon1,
double  lat1,
double  lon2,
double  lat2 
)

Start rhumbline calculations.

Note: This function must be called before other rhumbline functions to initialize parameters.

Parameters
[in]lon1,lat1longitude, latitude of first point
[in]lon2,lat2longitude, latitude of second point
Returns
1 on success
0 on error

Definition at line 58 of file rhumbline.c.

◆ G_begin_zone_area_on_ellipsoid()

void G_begin_zone_area_on_ellipsoid ( double  a,
double  e2,
double  s 
)

Begin area calculations for ellipsoid.

Initializes raster area calculations for an ellipsoid, where a is the semi-major axis of the ellipse (in meters), e2 is the ellipsoid eccentricity squared, and s is a scale factor to allow for calculations of part of the zone (s=1.0 is full zone, s=0.5 is half the zone, and s=360/ew_res is for a single grid cell).

Note: e2 must be positive. A negative value makes no sense, and zero implies a sphere.

Parameters
asemi-major axis
e2ellipsoid eccentricity
sscale factor

Definition at line 47 of file area_ellipse.c.

◆ G_begin_zone_area_on_sphere()

void G_begin_zone_area_on_sphere ( double  r,
double  s 
)

Initialize calculations for sphere.

Initializes raster area calculations for a sphere. The radius of the sphere is r and s is a scale factor to allow for calculations of a part of the zone (see G_begin_zone_area_on_ellipsoid()).

Parameters
rradius of sphere
sscale factor

Definition at line 35 of file area_sphere.c.

◆ G_bresenham_line()

void G_bresenham_line ( int  x0,
int  y0,
int  x1,
int  y1,
int(*)(int, int)  point 
)

Bresenham line algorithm.

Draws a line from x1,y1 to x2,y2 using Bresenham's algorithm. A routine to plot points must be provided, as is defined as: point(x, y) plot a point at x,y.

This routine does not require a previous call to G_setup_plot() to function correctly, and is independent of all following routines.

Parameters
x0,y0first point
x1,y1end point
pointpointer to point plotting function

Definition at line 30 of file bres_line.c.

◆ G_bz2_compress()

int G_bz2_compress ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 85 of file cmprbzip.c.

References _, dst, err(), G_bz2_compress_bound(), G_calloc, G_fatal_error(), G_free(), G_warning(), NULL, and src.

◆ G_bz2_expand()

int G_bz2_expand ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 168 of file cmprbzip.c.

References _, dst, err(), G_fatal_error(), G_warning(), NULL, and src.

◆ G_check_compressor()

int G_check_compressor ( int  number)

Definition at line 140 of file compress.c.

Referenced by Rast__open_old().

◆ G_check_input_output_name()

int G_check_input_output_name ( const char *  input,
const char *  output,
int  error 
)

Check input and output file names.

Check: 1) output is legal map name, 2) if can find input map, and 3) if input was found in current mapset, check if input != output.

Parameters
inputinput map name
outputoutput map name
errorerror type: G_FATAL_EXIT, G_FATAL_PRINT, G_FATAL_RETURN
Returns
0 OK
1 error

Definition at line 71 of file legal_name.c.

◆ G_check_overwrite()

int G_check_overwrite ( int  argc,
char **  argv 
)

Check for overwrite mode.

Check variables OVERWRITE, GRASS_OVERWRITE and '–o' flag.

The parser G_parser() checks if the map already exists in current mapset, we can switch out the check and do it in the module after the parser.

Parameters
argcnumber of arguments
argvarray of arguments
Returns
1 if overwrite
0 if not overwrite

Definition at line 34 of file overwrite.c.

References G_getenv_nofatal(), and G_setenv_nogisrc().

◆ G_chop()

char* G_chop ( char *  line)

Chop leading and trailing white spaces.

space, \f, \n, \r, \t, \v 

Modified copy of G_squeeze() by RB in March 2000.

Parameters
linebuffer to be worked on
Returns
pointer to string

Definition at line 332 of file strings.c.

Referenced by check_create_export_opts(), check_create_import_opts(), check_mapset_in_layer_name(), dig_read_frmt_ascii(), G_str_to_color(), and read_coor().

◆ G_clicker()

void G_clicker ( void  )

Definition at line 17 of file clicker.c.

◆ G_close_mail()

void G_close_mail ( struct Popen mail)

Definition at line 65 of file pager.c.

References G_popen_close().

◆ G_close_option_file()

void G_close_option_file ( FILE *  fp)

Close an input/output file returned by G_open_option_file(). If the file pointer is stdin, stdout, or stderr, nothing happens.

Parameters
filepointer

Definition at line 1958 of file parser.c.

◆ G_close_pager()

void G_close_pager ( struct Popen pager)

Definition at line 35 of file pager.c.

References G_popen_close().

◆ G_color_name()

const char* G_color_name ( int  n)

Definition at line 35 of file named_colr.c.

◆ G_color_rules_description_type()

char* G_color_rules_description_type ( void  )

Get color rules description for Option->descriptions.

The type of color rule including range is appended to the description

Returns
allocated buffer with name, description, and type

Definition at line 124 of file gis/color_rules.c.

References name.

Referenced by G_define_standard_option().

◆ G_color_rules_descriptions()

char* G_color_rules_descriptions ( void  )

Get color rules description for Option->descriptions.

Returns
allocated buffer with descriptions

Definition at line 79 of file gis/color_rules.c.

References G_malloc, and name.

◆ G_color_rules_options()

char* G_color_rules_options ( void  )

Get list of color rules for Option->options.

Returns
allocated string buffer with options

Definition at line 40 of file gis/color_rules.c.

References list, name, and NULL.

Referenced by G_define_standard_option().

◆ G_color_values()

int G_color_values ( const char *  name,
float *  r,
float *  g,
float *  b 
)

Definition at line 20 of file named_colr.c.

References b, g, and r.

◆ G_compare_projections()

int G_compare_projections ( const struct Key_Value proj_info1,
const struct Key_Value proj_units1,
const struct Key_Value proj_info2,
const struct Key_Value proj_units2 
)

Compare projections including units.

Parameters
proj_info1projection info to compare
proj_units1projection units to compare
proj_info2projection info to compare
proj_units2projection units to compare
Returns
-1 if not the same projection
-2 if linear unit translation to meters fails
-3 if not the same datum,
-4 if not the same ellipsoid,
-5 if UTM zone differs
-6 if UTM hemisphere differs,
-7 if false easting differs
-8 if false northing differs,
-9 if center longitude differs,
-10 if center latitude differs,
-11 if standard parallels differ,
1 if projections match.

Definition at line 231 of file make_loc.c.

References G_find_key_value(), NULL, and TRUE.

◆ G_compress()

int G_compress ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz,
int  number 
)

Definition at line 218 of file compress.c.

Referenced by G_write_compressed().

◆ G_compress_bound()

int G_compress_bound ( int  src_sz,
int  number 
)

Definition at line 202 of file compress.c.

Referenced by G_write_compressed().

◆ G_compressor_name()

char* G_compressor_name ( int  number)

Definition at line 118 of file compress.c.

Referenced by Rast__open_old().

◆ G_compressor_number()

int G_compressor_number ( char *  name)

Definition at line 100 of file compress.c.

References compressor, G_strcasecmp(), compressor_list::name, and name.

◆ G_config_path()

const char* G_config_path ( void  )

Get user's config path directory.

Returns a pointer to a string which is the full path name of the user's GRASS config directory in their home directory.

The path is not guaranteed to exist.

Todo:
should it be? see possible TODO below
Returns
pointer to string
NULL on error

Definition at line 98 of file home.c.

References _, CONFIG_DIR, G_fatal_error(), G_home(), G_initialize_done(), G_is_initialized(), G_mkdir(), G_store(), GPATH_MAX, HOST_DIRSEP, and NULL.

◆ G_convert_dirseps_from_host()

char* G_convert_dirseps_from_host ( char *  path)

Converts directory separator characters in a string from the native host character to the GRASS separator character (/)

Parameters
pathString to be converted
Returns
Pointer to the string

Definition at line 105 of file paths.c.

References GRASS_DIRSEP, and HOST_DIRSEP.

◆ G_convert_dirseps_to_host()

char* G_convert_dirseps_to_host ( char *  path)

Converts directory separator characters in a string to the native host separator character (/ on Unix, \ on Windows)

Parameters
pathString to be converted
Returns
Pointer to the string

Definition at line 83 of file paths.c.

References GRASS_DIRSEP, and HOST_DIRSEP.

◆ G_copy_file()

int G_copy_file ( const char *  infile,
const char *  outfile 
)

Copies one file to another.

Creates a copy of a file. The destination file will be overwritten if it already exists, so the calling module should check this first if it is important.

Parameters
infileString containing path to source file
outfileString containing path to destination file
Returns
1 on success; 0 if an error occurred (warning will be printed)

Definition at line 33 of file copy_file.c.

References G_warning(), and NULL.

Referenced by G_rename_file().

◆ G_counter_next()

int G_counter_next ( struct Counter c)

Definition at line 46 of file counter.c.

Referenced by G_tempfile_pid(), and G_tempfile_pid_basedir().

◆ G_create_alt_env()

void G_create_alt_env ( void  )

Set up alternative environment variables.

Definition at line 569 of file env.c.

References b, NULL, and st.

Referenced by G_make_mapset().

◆ G_create_alt_search_path()

void G_create_alt_search_path ( void  )

Define alternative mapset search path.

Definition at line 106 of file mapset_nme.c.

References st.

◆ G_create_key_value()

struct Key_Value* G_create_key_value ( void  )

Allocate and initialize Key_Value structure.

Returns
pointer to allocated Key_Value structure

Definition at line 23 of file key_value1.c.

References G_malloc, and G_zero().

Referenced by GPJ_osr_to_grass().

◆ G_darea0_on_ellipsoid()

double G_darea0_on_ellipsoid ( double  lat)

Calculate integral for area between two latitudes.

This routine is part of the integral for the area between two latitudes.

Parameters
latlatitude
Returns
cell area

Definition at line 63 of file area_ellipse.c.

References Radians, st, and x.

Referenced by G_area_for_zone_on_ellipsoid().

◆ G_darea0_on_sphere()

double G_darea0_on_sphere ( double  lat)

Calculates integral for area between two latitudes.

Parameters
latlatitude
Returns
area value

Definition at line 47 of file area_sphere.c.

References Radians, and st.

Referenced by G_area_for_zone_on_sphere().

◆ G_database_datum_name()

const char* G_database_datum_name ( void  )

Get datum name for the current location.

Returns a pointer to the name of the map datum of the current database. If there is no map datum explicitly associated with the actual database, the standard map datum WGS84 is returned, on error a NULL pointer is returned.

Returns
datum name

Definition at line 186 of file proj3.c.

References name.

◆ G_database_ellipse_name()

const char* G_database_ellipse_name ( void  )

Get ellipsoid name for the current location.

Returns
pointer to valid name if ok
NULL on error

Definition at line 212 of file proj3.c.

References name.

◆ G_database_epsg_code()

const char* G_database_epsg_code ( void  )

Get EPGS code for the current location.

Returns
pointer to valid EPSG code on success
NULL on error

Definition at line 236 of file proj3.c.

◆ G_database_projection_name()

const char* G_database_projection_name ( void  )

Query cartographic projection for the current location.

Returns a pointer to a string which is a printable name for projection code proj (as returned by G_projection). Returns NULL if proj is not a valid projection.

Returns
projection name

Definition at line 118 of file proj3.c.

References G_projection(), G_projection_name(), name, PROJECTION_LL, PROJECTION_UTM, and PROJECTION_XY.

Referenced by Vect_get_proj_name().

◆ G_database_unit()

int G_database_unit ( void  )

Get units id for the current location.

Returns
units id

Definition at line 66 of file proj3.c.

References G_projection(), G_projection_units(), name, and U_UNDEFINED.

Referenced by G_database_unit_name().

◆ G_database_unit_name()

const char* G_database_unit_name ( int  plural)

Get units (localized) name for the current location.

Returns a string describing the database grid units. It returns a plural form (eg. 'feet') if plural is non-zero. Otherwise it returns a singular form (eg. 'foot').

Parameters
pluralplural form if non-zero
Returns
localized units name

Definition at line 53 of file proj3.c.

References FALSE, G_database_unit(), and G_get_units_name().

Referenced by G_get_units_name(), G_units(), and gsd_scalebar().

◆ G_database_units_to_meters_factor()

double G_database_units_to_meters_factor ( void  )

Conversion to meters.

Returns a factor which converts the grid unit to meters (by multiplication). If the database is not metric (eg. imagery) then 0.0 is returned.

Returns
value

Definition at line 146 of file proj3.c.

Referenced by N_init_geom_data_3d().

◆ G_date()

const char* G_date ( void  )

Current date and time.

Returns a pointer to a string which is the current date and time. The format is the same as that produced by the UNIX date command.

Returns
pointer to a string holding date/time

Definition at line 26 of file date.c.

Referenced by Vect__init_head(), and Vect_hist_command().

◆ G_datum_description()

const char* G_datum_description ( int  n)

Definition at line 66 of file gis/datum.c.

References G_read_datum_table().

◆ G_datum_ellipsoid()

const char* G_datum_ellipsoid ( int  n)

Definition at line 76 of file gis/datum.c.

References G_read_datum_table().

◆ G_datum_name()

const char* G_datum_name ( int  n)

Definition at line 56 of file gis/datum.c.

References G_read_datum_table().

◆ G_debug()

int G_debug ( int  ,
const char *  ,
  ... 
)

Referenced by add_coor(), alloc_statistics(), Cairo_Color(), Cairo_end_raster(), Cairo_Erase(), Cairo_Graph_close(), Cairo_Graph_set(), cairo_read_image(), Cairo_Set_window(), cairo_write_image(), check_create_import_opts(), close_band_files(), db__driver_begin_transaction(), db__driver_commit_transaction(), db_close_database_shutdown_driver(), db_d_init_error(), db_delete_table(), db_get_login_dump(), db_set_default_connection(), db_start_driver_open_database(), dig__read_head(), dig__write_head(), dig_add_node(), dig_area_add_isle(), dig_area_del_isle(), dig_cidx_free(), dig_cidx_init(), dig_cidx_sort(), dig_find_area_box(), dig_find_isle_box(), dig_find_node(), dig_free_plus(), dig_free_plus_areas(), dig_free_plus_isles(), dig_free_plus_lines(), dig_free_plus_nodes(), dig_init_plus(), dig_load_plus(), dig_node_add_updated(), dig_node_line_angle(), dig_Rd_P_area(), dig_Rd_P_isle(), dig_Rd_P_line(), dig_Rd_P_node(), dig_Rd_Plus_head(), dig_Rd_spidx(), dig_Rd_spidx_head(), dig_read_cidx(), dig_read_cidx_head(), dig_read_frmt_ascii(), dig_select_areas(), dig_select_isles(), dig_select_lines(), dig_select_nodes(), dig_spidx_add_area(), dig_spidx_add_isle(), dig_spidx_add_node(), dig_spidx_del_area(), dig_spidx_del_isle(), dig_spidx_del_node(), dig_spidx_init(), dig_Wr_P_line(), dig_Wr_P_node(), dig_Wr_Plus_head(), dig_Wr_spidx(), dig_Wr_spidx_head(), dig_write_cidx_head(), free_perimeters(), G__read_Cell_head(), G__temp_element_basedir(), G_find_raster(), G_find_raster2(), G_find_vector(), G_find_vector2(), G_get_available_mapsets(), G_get_projepsg(), G_has_vector_timestamp(), G_math_add_spvector(), G_math_alloc_spmatrix(), G_math_alloc_spvector(), G_option_to_separator(), G_str_to_color(), get_key_data(), GP_delete_site(), gp_delete_site(), GP_draw_site(), gp_free_site(), gp_get_last_site(), gp_get_prev_site(), gp_get_site(), GP_get_trans(), GP_get_zmode(), gp_init_site(), GP_select_surf(), gp_set_defaults(), GP_set_trans(), GP_set_zmode(), GP_site_exists(), GP_surf_is_selected(), GP_unselect_surf(), GP_unset_style_thematic(), GPJ__get_datum_params(), GPJ_init_transform(), GPJ_osr_to_grass(), gs_calc_normals(), GS_clear(), GS_default_draw_color(), gs_delete_surf(), GS_delete_surface(), GS_done_draw(), GS_draw_fringe(), GS_draw_surf(), GS_draw_wire(), gs_free_surf(), gs_get_att_src(), gs_get_att_typbuff(), gs_get_att_type(), GS_get_drawres(), GS_get_exag_guess(), GS_get_focus(), GS_get_modelposition1(), gs_get_prev_surface(), gs_get_surf(), GS_get_to(), GS_get_trans(), GS_get_zextents(), GS_global_exag(), gs_init_surf(), gs_malloc_lookup(), GS_moveto(), GS_new_surface(), gs_num_datah_reused(), GS_ready_draw(), gs_set_att_const(), GS_set_att_defaults(), gs_set_att_src(), gs_set_defaults(), GS_set_drawres(), GS_set_exag(), GS_set_focus(), GS_set_focus_center_map(), GS_set_global_exag(), GS_set_infocus(), GS_set_nofocus(), GS_set_trans(), GS_set_viewport(), GS_set_wire_color(), GS_surf_exists(), Gs_update_attrange(), gs_update_curmask(), gsd_surf(), gsd_wire_arrows(), gsd_wire_surf(), gsd_wire_surf_const(), gsd_wire_surf_map(), gsds_free_datah(), gv_delete_vect(), GV_delete_vector(), gv_get_prev_vect(), gv_get_vect(), gv_init_vect(), gv_set_defaults(), GV_set_trans(), GV_unset_style_thematic(), GV_vect_exists(), gvd_vect(), GVL_delete_vol(), gvl_delete_vol(), GVL_draw_wire(), gvl_file_free_datah(), gvl_free_vol(), GVL_get_dims(), gvl_get_last_vol(), gvl_get_new_vol(), gvl_get_prev_vol(), gvl_get_vol(), gvl_getall_vols(), gvl_init_vol(), GVL_isosurf_add(), GVL_isosurf_del(), gvl_isosurf_freemem(), GVL_isosurf_get_att(), gvl_isosurf_get_att_src(), GVL_isosurf_get_drawres(), GVL_isosurf_get_flags(), gvl_isosurf_get_isosurf(), gvl_isosurf_init(), GVL_isosurf_num_isosurfs(), gvl_isosurf_set_att_changed(), gvl_isosurf_set_att_const(), GVL_isosurf_set_att_const(), gvl_isosurf_set_att_src(), GVL_isosurf_set_drawres(), GVL_isosurf_set_flags(), GVL_isosurf_unset_att(), GVL_new_vol(), GVL_set_draw_wire(), GVL_set_focus_center_map(), GVL_set_trans(), GVL_slice_get_drawres(), GVL_slice_num_slices(), GVL_slice_set_drawres(), GVL_vol_exists(), gvld_vol(), gvld_wind3_box(), gvld_wire_vol(), I_cluster_exec_allocate(), I_cluster_sum2(), I_find_subgroup(), I_find_subgroup2(), I_find_subgroup_file(), I_find_subgroup_file2(), I_iclass_add_signature(), I_iclass_analysis(), I_iclass_free_statistics(), I_iclass_init_group(), I_iclass_init_signatures(), I_iclass_init_statistics(), IL_write_point_2d(), M_do_copy(), make_all_statistics(), N_alloc_gradient_field_2d(), N_alloc_gradient_field_3d(), N_calc_gradient_field_2d_stats(), N_calc_gradient_field_3d_stats(), N_compute_gradient_field_2d(), N_compute_gradient_field_3d(), N_copy_array_2d(), N_copy_array_3d(), N_copy_gradient_2d(), N_copy_gradient_3d(), N_copy_gradient_field_2d(), N_copy_gradient_field_3d(), N_copy_gradient_neighbours_2d(), N_copy_gradient_neighbours_3d(), N_copy_gradient_neighbours_x(), N_copy_gradient_neighbours_y(), N_copy_gradient_neighbours_z(), N_create_27star(), N_create_5star(), N_create_7star(), N_create_9star(), N_create_gradient_2d(), N_create_gradient_3d(), N_create_gradient_neighbours_2d(), N_create_gradient_neighbours_3d(), N_create_gradient_neighbours_x(), N_create_gradient_neighbours_y(), N_create_gradient_neighbours_z(), N_free_les(), N_get_geom_data_area_of_cell(), N_get_gradient_2d(), N_get_gradient_neighbours_2d(), N_init_geom_data_3d(), N_les_integrate_dirichlet_2d(), N_les_integrate_dirichlet_3d(), Nviz_get_exag(), Nviz_get_exag_height(), Nviz_get_viewpoint_position(), Nviz_look_here(), Nviz_set_rotation(), Nviz_set_viewpoint_persp(), Nviz_set_viewpoint_position(), Nviz_set_viewpoint_twist(), open_band_files(), P_Create_Aux2_Table(), P_Create_Aux4_Table(), perimeter_add_point(), pg_addedge(), PNG_Graph_set(), print_vol_fields(), Rast__create_window_mapping(), Rast_get_next_marked_d_cat(), Rast_read_fp_range(), Rast_sort_cats(), Rast_unset_window(), rbtree_traverse(), rbtree_traverse_backwd(), read_band_row(), read_coor(), seg_setup(), sort_intersection_list(), sub_Vectmem(), V1_close_nat(), V1_close_ogr(), V1_close_pg(), V1_delete_line_nat(), V1_delete_line_ogr(), V1_delete_line_pg(), V1_open_new_nat(), V1_open_new_ogr(), V1_open_new_pg(), V1_open_old_nat(), V1_open_old_ogr(), V1_open_old_pg(), V1_read_next_line_nat(), V1_read_next_line_pg(), V1_rewind_ogr(), V1_rewind_pg(), V2_close_ogr(), V2_close_pg(), V2_open_old_ogr(), V2_open_old_pg(), V2_rewind_ogr(), V2_rewind_pg(), Vect__execute_get_value_pg(), Vect__execute_pg(), Vect__insert_face_pg(), Vect__load_map_lines_pg(), Vect__load_map_nodes_pg(), Vect__load_plus_head(), Vect__open_cursor_next_line_pg(), Vect__read_head(), Vect_array_to_cat_list(), Vect_attach_isle(), Vect_attach_isles(), Vect_build_line_area(), Vect_build_ogr(), Vect_build_partial(), Vect_build_pg(), Vect_build_sidx_from_topo(), Vect_cat_list_to_array(), Vect_check_dblink(), Vect_cidx_dump(), Vect_cidx_get_field_index(), Vect_cidx_open(), Vect_cidx_save(), Vect_close(), Vect_coor_info(), Vect_copy(), Vect_find_area(), Vect_find_node(), Vect_get_area_centroid(), Vect_get_area_isle(), Vect_get_area_num_isles(), Vect_get_area_points(), Vect_get_area_points_geos(), Vect_get_dblink(), Vect_get_field(), Vect_get_field2(), Vect_get_field_by_name(), Vect_get_field_number(), Vect_get_finfo_dsn_name(), Vect_get_finfo_geometry_type(), Vect_get_finfo_layer_name(), Vect_get_isle_area(), Vect_get_isle_points(), Vect_get_isle_points_geos(), Vect_get_next_line_id(), Vect_get_proj_name(), Vect_graph_add_edge(), Vect_graph_build(), Vect_graph_init(), Vect_graph_set_node_costs(), Vect_hist_command(), Vect_hist_copy(), Vect_hist_rewind(), Vect_hist_write(), Vect_line_parallel2(), Vect_map_del_dblink(), Vect_net_get_node_cost(), Vect_open_fidx(), Vect_open_new(), Vect_open_tmp_new(), Vect_open_topo(), Vect_point_buffer2(), Vect_read_dblinks(), Vect_read_next_line(), Vect_rewind(), Vect_save_fidx(), Vect_save_sidx(), Vect_save_topo(), Vect_select_areas_by_polygon(), Vect_select_isles_by_box(), Vect_select_nodes_by_box(), Vect_set_thresh(), Vect_set_updated(), Vect_spatial_index_add_item(), Vect_spatial_index_del_item(), Vect_spatial_index_destroy(), Vect_spatial_index_init(), Vect_write_dblinks(), vector2perimeters(), Vedit_delete_area_centroid(), Vedit_delete_areas_cat(), and Vedit_get_min_distance().

◆ G_default_compressor()

int G_default_compressor ( void  )

Definition at line 126 of file compress.c.

◆ G_define_flag()

struct Flag* G_define_flag ( void  )

Initializes a Flag struct.

Allocates memory for the Flag structure and returns a pointer to this memory.

Flags are always represented by single letters. A user "turns them on" at the command line using a minus sign followed by the character representing the flag.

Returns
Pointer to a Flag struct

Definition at line 157 of file parser.c.

References G_malloc, G_zero(), NULL, and st.

Referenced by G_define_standard_flag().

◆ G_define_module()

struct GModule* G_define_module ( void  )

Initializes a new module.

Returns
pointer to a GModule struct

Definition at line 256 of file parser.c.

References G_zero(), and st.

◆ G_define_option()

struct Option* G_define_option ( void  )

Initializes an Option struct.

Allocates memory for the Option structure and returns a pointer to this memory.

Options are provided by user on command line using the standard format: key=value. Options identified as REQUIRED must be specified by user on command line. The option string can either specify a range of values (e.g. "10-100") or a list of acceptable values (e.g. "red,orange,yellow"). Unless the option string is NULL, user provided input will be evaluated against this string.

Returns
pointer to an Option struct

Definition at line 211 of file parser.c.

References G_malloc, G_zero(), Option::multiple, NO, Option::required, and st.

Referenced by G_define_standard_option(), M_define_option(), and N_define_standard_option().

◆ G_define_standard_flag()

struct Flag* G_define_standard_flag ( int  flag)

Create standardised Flag structure.

This function will create a standardised Flag structure defined by parameter flag. A list of valid parameters below. It allocates memory for the Flag structure and returns a pointer to this memory.

If an invalid parameter was specified a empty Flag structure will be returned (not NULL).

  • G_FLG_V_TABLE (do not create attribute table)
  • G_FLG_V_TOPO (do not build topology)
Parameters
flagtype of Flag struct to create specified by STD_FLG enum.
Returns
pointer to an Flag struct

Definition at line 997 of file parser_standard_options.c.

References _, Flag::description, G_define_flag(), G_FLG_V_TABLE, G_FLG_V_TOPO, Flag::key, and Flag::label.

◆ G_define_standard_option()

struct Option* G_define_standard_option ( int  opt)

Create standardised Option structure.

This function will create a standardised Option structure defined by parameter opt.

Valid parameters are defined by the STD_OPT enum in the file gis.h. A list of valid parameter values sorted to groups is below.

This function allocates memory for the Option structure and returns a pointer to this memory.

If an invalid parameter was specified a empty Option structure will be returned (not NULL).

Values also need to be added to general/g.parser/standard_option.c

List of STD_OPT values sorted by module group
  • database:
  • G_OPT_DB_SQL
  • G_OPT_DB_WHERE
  • G_OPT_DB_TABLE
  • G_OPT_DB_DRIVER
  • G_OPT_DB_DATABASE
  • G_OPT_DB_SCHEMA
  • G_OPT_DB_COLUMN
  • G_OPT_DB_COLUMNS
  • G_OPT_DB_KEYCOLUMN
  • imagery:
  • G_OPT_I_GROUP
  • G_OPT_I_SUBGROUP
  • raster:
  • G_OPT_MEMORYMB
  • G_OPT_R_INPUT
  • G_OPT_R_INPUTS
  • G_OPT_R_OUTPUT
  • G_OPT_R_MAP
  • G_OPT_R_MAPS
  • G_OPT_R_BASE
  • G_OPT_R_COVER
  • G_OPT_R_ELEV
  • G_OPT_R_ELEVS
  • G_OPT_R_TYPE
  • G_OPT_R_INTERP_TYPE
  • G_OPT_R_BASENAME_INPUT
  • G_OPT_R_BASENAME_OUTPUT
  • raster3d:
  • G_OPT_R3_INPUT
  • G_OPT_R3_INPUTS
  • G_OPT_R3_OUTPUT
  • G_OPT_R3_MAP
  • G_OPT_R3_MAPS
  • vector:
  • G_OPT_V_INPUT
  • G_OPT_V_INPUTS
  • G_OPT_V_OUTPUT
  • G_OPT_V_MAP
  • G_OPT_V_MAPS
  • G_OPT_V_TYPE
  • G_OPT_V_FIELD
  • G_OPT_V_FIELD_ALL
  • G_OPT_V_CAT
  • G_OPT_V_CATS
  • G_OPT_V_ID
  • G_OPT_V_IDS
  • files
  • G_OPT_F_INPUT
  • G_OPT_F_BIN_INPUT
  • G_OPT_F_OUTPUT
  • G_OPT_F_SEP
  • colors
  • G_OPT_C
  • G_OPT_CN
  • G_OPT_C_FORMAT
  • misc
  • G_OPT_M_DIR
  • G_OPT_M_UNITS
  • G_OPT_M_DATATYPE
  • G_OPT_M_MAPSET
  • G_OPT_M_LOCATION
  • G_OPT_M_DBASE
  • G_OPT_M_COORDS
  • G_OPT_M_COLR
  • G_OPT_M_REGION
  • G_OPT_M_NULL_VALUE
  • G_OPT_M_NPROCS
  • temporal GIS framework
  • G_OPT_STDS_INPUT
  • G_OPT_STDS_INPUTS
  • G_OPT_STDS_OUTPUT
  • G_OPT_STRDS_INPUT
  • G_OPT_STRDS_INPUTS
  • G_OPT_STRDS_OUTPUT
  • G_OPT_STRDS_OUTPUTS
  • G_OPT_STR3DS_INPUT
  • G_OPT_STR3DS_INPUTS
  • G_OPT_STR3DS_OUTPUT
  • G_OPT_STVDS_INPUT
  • G_OPT_STVDS_INPUTS
  • G_OPT_STVDS_OUTPUT
  • G_OPT_MAP_INPUT
  • G_OPT_MAP_INPUTS
  • G_OPT_STDS_TYPE
  • G_OPT_MAP_TYPE
  • G_OPT_T_TYPE
  • G_OPT_T_WHERE
Parameters
opttype of Option struct to create specified by STD_OPT enum
Returns
pointer to an Option struct

Definition at line 140 of file parser_standard_options.c.

References _, Option::answer, DEFAULT_FG_COLOR, Option::description, Option::descriptions, G_asprintf(), G_color_rules_description_type(), G_color_rules_options(), G_define_option(), G_getenv_nofatal(), G_OPT_C, G_OPT_C_FORMAT, G_OPT_CN, G_OPT_DB_COLUMN, G_OPT_DB_COLUMNS, G_OPT_DB_DATABASE, G_OPT_DB_DRIVER, G_OPT_DB_KEYCOLUMN, G_OPT_DB_SCHEMA, G_OPT_DB_SQL, G_OPT_DB_TABLE, G_OPT_DB_WHERE, G_OPT_F_BIN_INPUT, G_OPT_F_FORMAT, G_OPT_F_INPUT, G_OPT_F_OUTPUT, G_OPT_F_SEP, G_OPT_I_GROUP, G_OPT_I_SUBGROUP, G_OPT_M_COLR, G_OPT_M_COORDS, G_OPT_M_DATATYPE, G_OPT_M_DBASE, G_OPT_M_DIR, G_OPT_M_LOCATION, G_OPT_M_MAPSET, G_OPT_M_NPROCS, G_OPT_M_NULL_VALUE, G_OPT_M_REGION, G_OPT_M_UNITS, G_OPT_MAP_INPUT, G_OPT_MAP_INPUTS, G_OPT_MAP_TYPE, G_OPT_MEMORYMB, G_OPT_R3_COMPRESSION, G_OPT_R3_INPUT, G_OPT_R3_INPUTS, G_OPT_R3_MAP, G_OPT_R3_MAPS, G_OPT_R3_OUTPUT, G_OPT_R3_PRECISION, G_OPT_R3_TILE_DIMENSION, G_OPT_R3_TYPE, G_OPT_R_BASE, G_OPT_R_BASENAME_INPUT, G_OPT_R_BASENAME_OUTPUT, G_OPT_R_COVER, G_OPT_R_ELEV, G_OPT_R_ELEVS, G_OPT_R_INPUT, G_OPT_R_INPUTS, G_OPT_R_INTERP_TYPE, G_OPT_R_MAP, G_OPT_R_MAPS, G_OPT_R_OUTPUT, G_OPT_R_OUTPUTS, G_OPT_R_TYPE, G_OPT_STDS_INPUT, G_OPT_STDS_INPUTS, G_OPT_STDS_OUTPUT, G_OPT_STDS_TYPE, G_OPT_STR3DS_INPUT, G_OPT_STR3DS_INPUTS, G_OPT_STR3DS_OUTPUT, G_OPT_STRDS_INPUT, G_OPT_STRDS_INPUTS, G_OPT_STRDS_OUTPUT, G_OPT_STRDS_OUTPUTS, G_OPT_STVDS_INPUT, G_OPT_STVDS_INPUTS, G_OPT_STVDS_OUTPUT, G_OPT_T_SAMPLE, G_OPT_T_TYPE, G_OPT_T_WHERE, G_OPT_V3_TYPE, G_OPT_V_CAT, G_OPT_V_CATS, G_OPT_V_FIELD, G_OPT_V_FIELD_ALL, G_OPT_V_ID, G_OPT_V_IDS, G_OPT_V_INPUT, G_OPT_V_INPUTS, G_OPT_V_MAP, G_OPT_V_MAPS, G_OPT_V_OUTPUT, G_OPT_V_TYPE, G_store(), Option::gisprompt, GV_KEY_COLUMN, Option::key, Option::key_desc, Option::label, Option::multiple, NO, Option::options, Option::required, Option::type, TYPE_DOUBLE, TYPE_INTEGER, TYPE_STRING, and YES.

◆ G_disable_interactive()

void G_disable_interactive ( void  )

Disables the ability of the parser to operate interactively.

When a user calls a command with no arguments on the command line, the parser will enter its own standardized interactive session in which all flags and options are presented to the user for input. A call to G_disable_interactive() disables the parser's interactive prompting.

Definition at line 140 of file parser.c.

References st.

◆ G_distance()

double G_distance ( double  e1,
double  n1,
double  e2,
double  n2 
)

Returns distance in meters.

This routine computes the distance, in meters, from x1,y1 to x2,y2. If the projection is latitude-longitude, this distance is measured along the geodesic. Two routines perform geodesic distance calculations.

Parameters
e1,n1east-north coordinates of first point
e2,n2east-north coordinates of second point
Returns
distance

Definition at line 75 of file gis/distance.c.

References G_geodesic_distance(), PROJECTION_LL, and st.

Referenced by Vect_line_geodesic_distance().

◆ G_distance2_point_to_line()

double G_distance2_point_to_line ( double  x,
double  y,
double  x1,
double  y1,
double  x2,
double  y2 
)

Definition at line 15 of file gis/line_dist.c.

◆ G_distance_between_line_segments()

double G_distance_between_line_segments ( double  ax1,
double  ay1,
double  ax2,
double  ay2,
double  bx1,
double  by1,
double  bx2,
double  by2 
)

Returns distance between two line segments in meters.

Parameters
ax1,ay1,ax2,ay2first segment
bx1,by1,bx2,by2second segment
Returns
distance value

Definition at line 91 of file gis/distance.c.

References G_intersect_line_segments(), and x.

◆ G_distance_point_to_line_segment()

double G_distance_point_to_line_segment ( double  xp,
double  yp,
double  x1,
double  y1,
double  x2,
double  y2 
)

Returns distance between a point and line segment in meters.

Parameters
xp,yppoint coordinates
x1,y1segment point coordinates
x2,y2segment point coordinates
Returns
distance

Definition at line 117 of file gis/distance.c.

◆ G_done_msg()

void G_done_msg ( const char *  ,
  ... 
)

◆ G_double_to_basename_format()

char* G_double_to_basename_format ( double  number,
size_t  ndigits,
size_t  ndecimals 
)

Convert a double to a string substituting the dot with underscore 12.3456 => '12_3456'.

Parameters
numberthe double number that will be convert to string
ndigitsthe number of integer digits in the output string
ndecimalsthe number of decimals in the output string
Returns
a formatted string

Definition at line 76 of file basename.c.

References G_malloc, and GNAME_MAX.

Referenced by G_generate_basename().

◆ G_drand48()

double G_drand48 ( void  )

Generate a floating-point value in the range [0,1)

Returns
the generated value

Definition at line 166 of file lrand48.c.

References r.

Referenced by G_math_rand().

◆ G_ellipsoid_description()

const char* G_ellipsoid_description ( int  n)

Get description for nth ellipsoid.

This function returns a pointer to the description text for the nth ellipsoid. If n is less than 0 or greater than the number of known ellipsoids, it returns a NULL pointer.

Parameters
nellipsoid identificator
Returns
pointer to ellipsoid description
NULL if no ellipsoid found

Definition at line 182 of file get_ellipse.c.

References G_read_ellipsoid_table().

◆ G_ellipsoid_name()

const char* G_ellipsoid_name ( int  n)

Get ellipsoid name.

This function returns a pointer to the short name for the nth ellipsoid. If n is less than 0 or greater than the number of known ellipsoids, it returns a NULL pointer.

Parameters
nellipsoid identificator
Returns
ellipsoid name
NULL if no ellipsoid found

Definition at line 132 of file get_ellipse.c.

References G_read_ellipsoid_table().

◆ G_ellipsoid_polygon_area()

double G_ellipsoid_polygon_area ( const double *  lon,
const double *  lat,
int  n 
)

Area of lat-long polygon.

Returns the area in square meters of the polygon described by the n pairs of lat,long vertices for latitude-longitude grids.

Note: This routine computes the area of a polygon on the ellipsoid. The sides of the polygon are rhumb lines and, in general, not geodesics. Each side is actually defined by a linear relationship between latitude and longitude, i.e., on a rectangular/equidistant cylindrical/Plate Carr{'e}e grid, the side would appear as a straight line. For two consecutive vertices of the polygon, (lat_1, long1) and (lat_2,long_2), the line joining them (i.e., the polygon's side) is defined by:

lat_2  -  lat_1
lat = lat_1 + (long - long_1) * ---------------
long_2 - long_1

where long_1 < long < long_2. The values of QbarA, etc., are determined by the integration of the Q function. Into www.integral-calculator.com, paste this expression :

sin(x)+ (2/3)e^2(sin(x))^3 + (3/5)e^4(sin(x))^5 + (4/7)e^6(sin(x))^7

and you'll get their values. (Last checked 30 Oct 2013).

This function correctly computes (within the limits of the series approximation) the area of a quadrilateral on the ellipsoid when two of its sides run along meridians and the other two sides run along parallels of latitude.

Parameters
lonarray of longitudes
latarray of latitudes
nnumber of lat,lon pairs
Returns
area in square meters

Definition at line 134 of file area_poly1.c.

Referenced by G_area_of_polygon().

◆ G_end_execute()

void G_end_execute ( void **  )

◆ G_expand()

int G_expand ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz,
int  number 
)

Definition at line 233 of file compress.c.

Referenced by G_read_compressed().

◆ G_faprintf()

int G_faprintf ( FILE *  stream,
const char *  format,
  ... 
)

fprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]streamfile pointer
[in]formatstring format
[in]...arguments for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 485 of file aprintf.c.

◆ G_fatal_error()

void void void void G_fatal_error ( const char *  ,
  ... 
)

Referenced by AS_option_to_algorithm(), Cairo_Graph_set(), cairo_read_xid(), cairo_write_bmp(), cairo_write_ppm(), cairo_write_xid(), check_create_import_opts(), clean_dir(), db_d_append_error(), db_set_default_connection(), dig__read_head(), dig_area_del_isle(), dig_fwrite(), dig_load_plus(), dig_node_line_angle(), dig_Rd_Plus_head(), dig_Rd_spidx_head(), dig_read_cidx_head(), dig_spidx_del_area(), dig_spidx_del_isle(), dig_spidx_del_node(), dig_Wr_spidx_head(), G__read_gisrc_path(), G_adjust_Cell_head(), G_adjust_Cell_head3(), G_adjust_window_ll(), G_bz2_compress(), G_bz2_expand(), G_config_path(), G_fseek(), G_getenv(), G_getenv2(), G_home(), G_list(), G_location_path(), G_ls2(), G_make_mapset(), G_mapset(), G_mapset_path(), G_open_option_file(), G_option_to_separator(), G_owner(), G_read_key_value_file(), G_set_omp_num_threads(), G_srand48_auto(), G_vector_norm_euclid(), G_vector_norm_maxval(), G_write_key_value_file(), G_write_projsrid(), G_write_projwkt(), G_write_zeros(), G_zstd_compress(), G_zstd_compress_bound(), G_zstd_expand(), GK_print_keys(), GPJ_init_transform(), I_sort_signatures_by_semantic_label(), I_SortSigSetBySemanticLabel(), IL_create_bitmask(), IL_write_point_2d(), IL_write_temp_2d(), M_do_list(), M_do_remove(), main(), N_compute_gradient_field_2d(), N_compute_gradient_field_3d(), N_compute_gradient_field_components_2d(), N_compute_gradient_field_components_3d(), N_copy_array_2d(), N_copy_array_3d(), NetA_betweenness_closeness(), NetA_flow(), NetA_initialise_varray(), NetA_min_cut(), NetA_strongly_connected_components(), NetA_weakly_connected_components(), pg_addedge(), port_init(), Rast3d_fatal_error_noargs(), Rast__check_fp_type(), Rast__check_null_bit(), Rast__null_bitstream_size(), Rast__open_null_write(), Rast__open_old(), Rast_close(), Rast_get_cellhd(), Rast_get_vrt(), Rast_map_is_fp(), Rast_map_type(), Rast_option_to_interp_type(), Rast_put_cellhd(), Rast_put_reclass(), Rast_quantize_fp_map(), Rast_read_histogram(), Rast_set_fp_type(), Rast_set_quant_rules(), Rast_unopen(), Rast_window_cols(), Rast_window_rows(), Rast_write_fp_range(), Rast_write_history(), Rast_write_quant(), Rast_write_range(), Rast_write_rstats(), read_image(), RTreeWriteBranch(), RTreeWriteNode(), seg_seek_fast(), seg_seek_slow(), V1_close_nat(), V1_close_ogr(), V1_close_pg(), V1_delete_line_ogr(), V1_delete_line_pg(), V1_open_new_ogr(), V1_open_old_ogr(), V1_rewind_ogr(), V1_rewind_pg(), V2__write_area_sfa(), V2_close_ogr(), V2_close_pg(), V2_open_old_ogr(), V2_open_old_pg(), V2_rewind_ogr(), V2_rewind_pg(), Vect__get_area_points(), Vect_build_line_area(), Vect_build_ogr(), Vect_build_partial(), Vect_build_sidx(), Vect_cat_set(), Vect_cats_set_constraint(), Vect_copy(), Vect_get_area_centroid(), Vect_get_area_isle(), Vect_get_area_num_isles(), Vect_get_isle_area(), Vect_get_isle_points(), Vect_graph_add_edge(), Vect_graph_build(), Vect_new_line_struct(), Vect_new_map_struct(), Vect_open_fidx(), Vect_overlay(), Vect_save_fidx(), Vect_save_frmt(), Vect_set_db_updated(), Vect_sfa_get_num_features(), Vect_spatial_index_del_item(), write_bmp(), write_image(), write_pgm(), and write_ppm().

◆ G_fatal_longjmp()

jmp_buf* G_fatal_longjmp ( int  enable)

Definition at line 66 of file gis/error.c.

◆ G_file_name()

char* G_file_name ( char *  path,
const char *  element,
const char *  name,
const char *  mapset 
)

Builds full path names to GIS data files.

If name is of the form "nnn@ppp" then path is set as if name had been "nnn" and mapset had been "ppp" (mapset parameter itself is ignored in this case).

Paths to files are currently in form: /path/to/location/mapset/element/name

path input buffer memory must be allocated by caller.

C:

G_file_name(path, "fcell", "my_raster", "my_mapset");
// path now is "/full/path/to/my_mapset/fcell/my_raster"
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
Definition: file_name.c:61
#define GPATH_MAX
Definition: gis.h:194
Definition: path.h:15

Python:

import ctypes
from grass.pygrass.utils import decode
from grass.lib.gis import G_file_name, GPATH_MAX
path = ctypes.create_string_buffer(GPATH_MAX)
path_str = decode(G_file_name(path, "elem", "name", "mapset"))
print(path_str)
>>> /full/path/to/mapset/elem/name
Parameters
[out]pathallocated buffer to hold resultant full path to file
elementdatabase element (eg, "cell", "cellhd", "vector", etc)
namename of file to build path to (fully qualified names allowed)
mapsetmapset name
Returns
pointer to path buffer

Definition at line 61 of file file_name.c.

Referenced by G_get_projepsg(), G_get_projinfo(), G_get_projunits(), G_has_vector_timestamp(), G_make_mapset_element(), G_mapset_permissions(), G_myname(), G_rename(), G_write_projsrid(), G_write_projwkt(), list_subgroups(), M__empty(), M_do_copy(), main(), Rast_map_is_fp(), Rast_map_type(), V1_close_nat(), Vect__get_element_path(), and Vect_copy().

◆ G_file_name_basedir()

char* G_file_name_basedir ( char *  path,
const char *  element,
const char *  name,
const char *  mapset,
const char *  basedir 
)

Builds full path names to GIS data files in temporary directory (for internal use only)

By default the GRASS temporary directory is located at $LOCATION/$MAPSET/.tmp/$HOSTNAME/. If basedir is provided, the temporary directory is located at <basedir>/.tmp/$HOSTNAME/.

Parameters
[out]pathbuffer to hold resultant full path to file
elementdatabase element (eg, "cell", "cellhd", "vector", etc)
namename of file to build path to (fully qualified names allowed)
mapsetmapset name
Returns
pointer to path buffer

Definition at line 154 of file file_name.c.

◆ G_file_name_misc()

char* G_file_name_misc ( char *  path,
const char *  dir,
const char *  element,
const char *  name,
const char *  mapset 
)

Builds full path names to GIS misc data files.

Paths to misc files are currently in form: /path/to/location/mapset/dir/name/element

path input buffer memory must be allocated by caller.

C:

G_file_name_misc(path, "cell_misc", "history", "my_raster", "my_mapset");
// path now contains "/full/path/to/my_mapset/cell_misc/my_raster/history"
char * G_file_name_misc(char *, const char *, const char *, const char *, const char *)
Builds full path names to GIS misc data files.
Definition: file_name.c:101

Python:

import ctypes
from grass.pygrass.utils import decode
from grass.lib.gis import G_file_name_misc, GPATH_MAX
path = ctypes.create_string_buffer(GPATH_MAX)
path_str = decode(G_file_name_misc(path, "dir", "elem", "name", "mapset"))
print(path_str)
>>> /full/path/to/mapset/dir/name/elem
Parameters
[out]pathallocated buffer to hold resultant full path to file
dirmisc directory (e.g., "cell_misc", "group")
elementdatabase element (in this case – file to build path to e.g., "history", "REF")
namename of object (raster, group; fully qualified names allowed e.g., "my_raster@PERMANENT")
mapsetmapset name
Returns
pointer to path buffer

Definition at line 101 of file file_name.c.

Referenced by Rast3d_filename(), Rast__check_fp_type(), and Rast__close_null().

◆ G_file_name_tmp()

char* G_file_name_tmp ( char *  path,
const char *  element,
const char *  name,
const char *  mapset 
)

Builds full path names to GIS data files in temporary directory (for internal use only)

By default temporary directory is located $LOCATION/$MAPSET/.tmp/$HOSTNAME. If GRASS_VECTOR_TMPDIR_MAPSET is set to "0", the temporary directory is located in TMPDIR (environmental variable defined by the user or GRASS initialization script if not given). Note that GRASS_VECTOR_TMPDIR_MAPSET variable is currently used only by vector library.

Parameters
[out]pathbuffer to hold resultant full path to file
elementdatabase element (eg, "cell", "cellhd", "vector", etc)
namename of file to build path to (fully qualified names allowed)
mapsetmapset name
Returns
pointer to path buffer

Definition at line 125 of file file_name.c.

References NULL.

Referenced by G_make_mapset_element_tmp(), and Vect__get_element_path().

◆ G_find_color_rule()

int G_find_color_rule ( const char *  name)

Check if color rule is defined.

Parameters
namecolor rule name
Returns
1 found
0 not found

Definition at line 246 of file gis/color_rules.c.

◆ G_find_etc()

char* G_find_etc ( const char *  name)

searches for a file from the etc search list in GRASS_ADDON_ETC returns the full path to where the file was found.

note: rejects all names that begin with "."

Parameters
namefile name to look for
Returns
pointer to a string with full path to where file was found, or NULL if not found

Definition at line 62 of file find_etc.c.

◆ G_find_file()

const char* G_find_file ( const char *  element,
char *  name,
const char *  mapset 
)

Searches for a file from the mapset search list or in a specified mapset.

Returns the mapset name where the file was found.

If the user specifies a fully qualified element (name@mapset) which exists, then G_find_file() modifies "name" by removing the "@mapset" part.

Rejects all names that begin with "."

If name is of the form nnn in ppp then only mapset ppp is searched.

Parameters
elementdatabase element (eg, "cell", "cellhd", "colr", etc)
namefile name to look for
mapsetmapset to search. if mapset is "" will search in mapset search list
Returns
pointer to a string with name of mapset where file was found, or NULL if not found

Definition at line 186 of file find_file.c.

Referenced by G_find_raster(), and G_find_vector().

◆ G_find_file2()

const char* G_find_file2 ( const char *  element,
const char *  name,
const char *  mapset 
)

Searches for a file from the mapset search list or in a specified mapset. (look but don't touch)

Returns the mapset name where the file was found.

Exactly the same as G_find_file() except that if name is in the form "<i>name@mapset</i>", and is found, G_find_file2() will not alter name by removing the "@<i>mapset</i>" part.

Rejects all names that begin with "."

Parameters
elementdatabase element (eg, "cell", "cellhd", "colr", etc)
namefile name to look for
mapsetmapset to search. if mapset is "" will search in mapset search list
Returns
pointer to a string with name of mapset where file was found, or NULL if not found

Definition at line 234 of file find_file.c.

Referenced by G_find_raster2(), G_find_vector2(), Gs_load_3dview(), I_find_group(), I_find_group2(), M_find(), V1_close_ogr(), and Vect_close().

◆ G_find_file2_misc()

const char* G_find_file2_misc ( const char *  dir,
const char *  element,
const char *  name,
const char *  mapset 
)

Searches for a misc file from the mapset search list or in a specified mapset. (look but don't touch)

Returns the mapset name where the misc file was found. Paths to misc files currently follow structure: mapset/dir/name/element

Parameters
dirfile directory
elementdatabase element (eg, "cell", "cellhd", "colr", etc)
namefile name to look for
mapsetmapset to search. if mapset is "" will search in mapset search list
Returns
pointer to a string with name of mapset where file was found, or NULL if not found

Definition at line 257 of file find_file.c.

Referenced by G_find_raster3d(), G_has_raster3d_timestamp(), G_has_raster_timestamp(), I_find_group_file(), I_find_group_file2(), I_find_subgroup(), I_find_subgroup2(), I_find_subgroup_file(), I_find_subgroup_file2(), Rast_read_fp_range(), Rast_read_histogram(), and Rast_read_range().

◆ G_find_file_misc()

const char* G_find_file_misc ( const char *  dir,
const char *  element,
char *  name,
const char *  mapset 
)

Searches for a misc file from the mapset search list or in a specified mapset.

Returns the mapset name where the misc file was found. Paths to misc files currently follow structure: mapset/dir/name/element

Parameters
dirfile directory
elementdatabase element (eg, "cell", "cellhd", "colr", etc)
namefile name to look for
mapsetmapset to search. if mapset is "" will search in mapset search list
Returns
pointer to a string with name of mapset where file was found, or NULL if not found

Definition at line 208 of file find_file.c.

Referenced by Rast3d_mask_file_exists().

◆ G_find_key_value()

const char* G_find_key_value ( const char *  key,
const struct Key_Value kv 
)

Find given key (case sensitive)

Parameters
keykey to be found
kvpointer to Key_value structure
Returns
pointer to value of key
NULL if no key found

Definition at line 85 of file key_value1.c.

Referenced by G_compare_projections(), G_get_datumparams_from_projinfo(), G_get_projinfo(), GPJ__get_datum_params(), GPJ_osr_to_grass(), Rast__check_fp_type(), and Vect_close().

◆ G_find_raster()

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

Find a raster map.

Looks for the raster map name in the database. The mapset parameter can either be the empty string "", which means search all the mapsets in the user's current mapset search path (see Mapset_Search_Path for more details about the search path) or it can be a specific mapset name, which means look for the raster map only in this one mapset (for example, in the current mapset). If found, the mapset where the raster map lives is returned. If not found, the NULL pointer is returned.

Note: If the user specifies a fully qualified raster map which exists, then G_find_raster() modifies name by removing the "@<i>mapset</i>".

For example, to find a raster map anywhere in the database:

char *mapset;
if ((mapset = G_find_raster(name,"")) == NULL)
// not found
#define NULL
Definition: ccmath.h:32
const char * G_find_raster(char *, const char *)
Find a raster map.
Definition: find_rast.c:55
#define GNAME_MAX
Definition: gis.h:191
const char * name
Definition: named_colr.c:6

To check that the raster map exists in the current mapset:

// not found
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
Parameters
[in,out]namemap name
mapsetmapset name or ""
Returns
mapset where raster map was found
NULL if not found

Definition at line 55 of file find_rast.c.

References G_debug(), G_find_file(), and name.

Referenced by I_iclass_init_group(), Rast__check_for_auto_masking(), Rast__mask_info(), Rast_get_cellhd(), Rast_get_vrt(), and Rast_mask_is_present().

◆ G_find_raster2()

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

Find a raster map (look but don't touch)

The same as G_find_raster() but doesn't remove the "@<i>mapset</i>" qualification from name, if present.

Returns NULL if the map wasn't found, or the mapset the raster was found in if it was.

Parameters
namemap name
mapsetmapset name or ""
Returns
mapset where raster map was found
NULL if not found

Definition at line 76 of file find_rast.c.

References G_debug(), G_find_file2(), and name.

Referenced by IL_create_bitmask(), M_do_remove(), M_do_rename(), Rast__check_fp_type(), Rast__open_null_write(), Rast__open_old(), Rast_get_vrt(), Rast_map_is_fp(), and Rast_map_type().

◆ G_find_raster3d()

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

Search for a 3D raster map in current search path or in a specified mapset.

Note: rejects all names that begin with '.'

Parameters
namemap name
mapsetmapset to search. ("" for search path)
Returns
pointer to a string with name of mapset where the map was found
NULL if not found

Definition at line 28 of file find_rast3d.c.

References G_find_file2_misc(), and name.

Referenced by M_do_remove(), and M_do_rename().

◆ G_find_vector()

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

Finds a vector map.

Searches for a vector map from the mapset search list or in a specified mapset. Returns the mapset name where the vector map was found.

NOTES: If the user specifies a fully qualified vector map which exists, then G_find_vector() modifies name by removing the "@<i>mapset</i>" part.

Rejects all names that begin with "."

Parameters
namevector map name
mapsetmapset name or "" for search path
Returns
pointer to a string with name of mapset where vector map was found
NULL if not found

Definition at line 41 of file find_vect.c.

References G_debug(), G_find_file(), GV_DIRECTORY, and name.

◆ G_find_vector2()

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

Find a vector map (look but don't touch)

The same as G_find_vector() but doesn't remove the "@<i>mapset</i>" qualification from name, if present.

Returns NULL if the map wasn't found, or the mapset the vector was found in if it was.

Parameters
namevector map name
mapsetmapset name where to search
Returns
pointer to buffer containing mapset name
NULL when vector map not found

Definition at line 62 of file find_vect.c.

References G_debug(), G_find_file2(), GV_DIRECTORY, and name.

Referenced by M_do_remove(), M_do_rename(), and Vect_copy().

◆ G_finish_workers()

void G_finish_workers ( void  )

Definition at line 185 of file worker.c.

◆ G_fopen_append()

FILE* G_fopen_append ( const char *  element,
const char *  name 
)

Open a database file for update (append mode)

The database file name under the element in the current mapset is opened for for writing. The UNIX fopen() routine, with "a" append mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file descriptor from the fopen() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (FILE *)
NULL on error

Definition at line 278 of file gis/open.c.

◆ G_fopen_append_misc()

FILE* G_fopen_append_misc ( const char *  dir,
const char *  element,
const char *  name 
)

Definition at line 217 of file open_misc.c.

Referenced by I_fopen_group_file_append(), and I_fopen_subgroup_file_append().

◆ G_fopen_modify()

FILE* G_fopen_modify ( const char *  element,
const char *  name 
)

Open a database file for update (r+ mode)

The database file name under the element in the current mapset is opened for for writing. The UNIX fopen() routine, with "r+" append mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file descriptor from the fopen() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (FILE *)
NULL on error

Definition at line 306 of file gis/open.c.

Referenced by V1_open_new_nat(), and V1_open_old_nat().

◆ G_fopen_modify_misc()

FILE* G_fopen_modify_misc ( const char *  dir,
const char *  element,
const char *  name 
)

Definition at line 230 of file open_misc.c.

◆ G_fopen_new()

FILE* G_fopen_new ( const char *  element,
const char *  name 
)

Open a new database file.

The database file name under the element in the current mapset is created and opened for writing (but not reading). The UNIX fopen() routine, with "w" write mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the fopen() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (FILE *)
NULL on error

Definition at line 219 of file gis/open.c.

Referenced by G_put_3dview(), I_put_group(), Rast__quant_export(), Rast_put_cellhd(), Rast_write_history(), V1_open_new_nat(), Vect__write_head(), Vect_save_frmt(), Vect_save_topo(), and Vect_write_dblinks().

◆ G_fopen_new_misc()

FILE* G_fopen_new_misc ( const char *  dir,
const char *  element,
const char *  name 
)

open a new database misc file

The database file element under dir/name in the current mapset is created and opened for writing (but not reading). The UNIX fopen( ) routine, with "w" write mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the fopen( ) is returned.

Parameters
element
name
Returns
FILE *

Definition at line 178 of file open_misc.c.

Referenced by I_fopen_group_file_new(), I_fopen_signature_file_new(), I_fopen_sigset_file_new(), I_fopen_subgroup_file_new(), Rast3d_write_cats(), Rast3d_write_history(), Rast__quant_export(), and Rast_write_range().

◆ G_fopen_old()

FILE* G_fopen_old ( const char *  element,
const char *  name,
const char *  mapset 
)

Open a database file for reading.

The database file name under the element in the specified mapset is opened for reading (but not for writing). The UNIX fopen() routine, with "r" read mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file descriptor from the fopen() is returned.

Parameters
elementdatabase element name
namemap file name
mapsetmapset name containing map name
Returns
open file descriptor (FILE *)
NULL on error

Definition at line 251 of file gis/open.c.

Referenced by I_get_group(), Rast__quant_import(), Rast_get_cell_title(), Rast_get_cellhd(), Rast_read_history(), V1_open_old_nat(), Vect__read_head(), Vect_cidx_open(), Vect_close(), Vect_open_fidx(), and Vect_open_topo().

◆ G_fopen_old_misc()

FILE* G_fopen_old_misc ( const char *  dir,
const char *  element,
const char *  name,
const char *  mapset 
)

open a database misc file for reading

The database file element under dir/name in the specified mapset is opened for reading (but not for writing). The UNIX fopen( ) routine, with "r" read mode, is used to open the file. If the file does not exist, the NULL pointer is returned. Otherwise the file descriptor from the fopen( ) is returned.

Parameters
element
name
mapset
Returns
FILE *

Definition at line 205 of file open_misc.c.

Referenced by fopen_group_file_old(), fopen_subgroup_file_old(), I_fopen_signature_file_old(), I_fopen_sigset_file_old(), Rast3d_read_history(), Rast_get_vrt(), Rast_is_reclassed_to(), Rast_read_histogram(), and Rast_read_range().

◆ G_format_easting()

void G_format_easting ( double  east,
char *  buf,
int  projection 
)

Easting to ASCII.

Converts the double representation of the east coordinate to its ASCII representation (into buf).

Parameters
easteasting
[out]bufbuffer to hold formatted string
projectionprojection code, or -1 to force full precision FP

Definition at line 49 of file wind_format.c.

References G_lon_format(), and PROJECTION_LL.

Referenced by G__write_Cell_head().

◆ G_format_northing()

void G_format_northing ( double  north,
char *  buf,
int  projection 
)

Northing to ASCII.

Converts the double representation of the north coordinate to its ASCII representation (into buf).

Parameters
northnorthing
[out]bufbuffer to hold formatted string
projectionprojection code, or -1 to force full precision FP

Definition at line 29 of file wind_format.c.

References G_lat_format(), and PROJECTION_LL.

Referenced by G__write_Cell_head().

◆ G_format_resolution()

void G_format_resolution ( double  res,
char *  buf,
int  projection 
)

Resolution to ASCII.

Converts the double representation of the resolution to its ASCII representation (into buf).

Parameters
resolutionresolution value
[out]bufbuffer to hold formatted string
projectionprojection code, or -1 to force full precision FP

Definition at line 69 of file wind_format.c.

References G_llres_format(), and PROJECTION_LL.

Referenced by G__write_Cell_head(), and G__write_Cell_head3().

◆ G_format_timestamp()

int G_format_timestamp ( const struct TimeStamp ts,
char *  buf 
)

Create text string from TimeStamp structure.

Fills string *buf with info from TimeStamp structure *ts in a pretty way. The TimeStamp struct is defined in gis.h and populated with e.g. G_read_raster_timestamp().

Parameters
tsTimeStamp structure containing time info
bufstring to receive formatted timestamp
Returns
1 on success
-1 error

Definition at line 183 of file timestamp.c.

◆ G_fread_key_value()

struct Key_Value* G_fread_key_value ( FILE *  fd)

Read key/values pairs from file.

Allocated memory must be freed G_free_key_value().

Parameters
fdfile to read key/values from
Returns
pointer to allocated Key_Value structure
NULL on error

Definition at line 49 of file key_value2.c.

Referenced by G_read_key_value_file(), and Vect_close().

◆ G_free()

void G_free ( void *  buf)

Free allocated memory.

Parameters
[in,out]bufbuffer holding original data

Definition at line 150 of file gis/alloc.c.

References free().

Referenced by cairo_write_ppm(), close_band_files(), db_CatValArray_free(), db_d_append_error(), destroy_si_struct(), dig_cidx_free(), dig_file_free(), dig_free_area(), dig_free_isle(), dig_free_line(), dig_free_node(), dig_free_plus_areas(), dig_free_plus_isles(), dig_free_plus_lines(), dig_free_plus_nodes(), free_datum_list(), free_ellps_list(), free_fontcap(), free_perimeters(), free_slice_buff(), free_vol_buff(), free_volfile_buffs(), G__read_Cell_head(), G_bz2_compress(), G_free_fmatrix(), G_free_fvector(), G_free_ilist(), G_free_imatrix(), G_free_ivector(), G_free_key_value(), G_free_list(), G_free_ls_filter(), G_free_matrix(), G_free_tokens(), G_free_vector(), G_get_available_mapsets(), G_init_ilist(), G_list(), G_ls(), G_ls_regex_filter(), G_lz4_compress(), G_math_free_spmatrix(), G_math_free_spvector(), G_math_solver_sparse_gs(), G_math_solver_sparse_jacobi(), G_matrix_free(), G_matrix_LU_solve(), G_read_compressed(), G_vector_free(), G_write_compressed(), G_zlib_compress(), G_zstd_compress(), gk_free_key(), gk_make_linear_framesfromkeys(), GPJ_free_datum(), GPJ_free_datum_transform(), GPJ_free_ellps(), GPJ_init_transform(), GPJ_osr_to_grass(), GPJ_set_csv_loc(), gs_init_normbuff(), gs_malloc_lookup(), gs_set_att_src(), GS_write_ppm(), GS_write_tif(), gv_free_vectmem(), gvd_vect(), GVL_isosurf_del(), gvl_isosurf_freemem(), Gvl_unload_colors_data(), I_free(), I_free_double2(), I_free_double3(), I_free_int2(), I_free_signatures_list(), I_iclass_free_statistics(), I_sc_free_cats(), kdtree_destroy(), N_free_geom_data(), N_free_gradient_2d(), N_free_gradient_3d(), N_free_gradient_field_2d(), N_free_gradient_field_3d(), N_free_gradient_neighbours_2d(), N_free_gradient_neighbours_3d(), N_free_gradient_neighbours_x(), N_free_gradient_neighbours_y(), N_free_gradient_neighbours_z(), N_free_les(), N_les_integrate_dirichlet_2d(), NetA_timetable_result_release(), Nviz_destroy_render_window(), Nviz_draw_all_site(), Nviz_draw_all_vol(), Nviz_get_exag(), path_free(), pg_destroy_struct(), Rast__close_null(), Rast__color_free_fp_lookup(), Rast__color_free_lookup(), Rast__create_window_mapping(), Rast_clear_history(), Rast_close_gdal_link(), Rast_close_gdal_write_link(), Rast_close_vrt(), Rast_command_history(), Rast_format_history(), Rast_fpreclass_reset(), Rast_free_cats(), Rast_free_histogram(), Rast_free_history(), Rast_free_reclass(), Rast_get_vrt_row(), Rast_quant_free(), Rast_set_d_cat(), Rast_set_history(), Segment_close(), Segment_release(), set_proj_share(), tgis_free_map_list(), tgis_init_map_list(), V1_close_ogr(), V1_close_pg(), Vect__close_cursor_pg(), Vect__free_cache(), Vect__free_offset(), Vect__insert_face_pg(), Vect_build_ogr(), Vect_build_pg(), Vect_close(), Vect_destroy_boxlist(), Vect_destroy_cat_list(), Vect_destroy_cats_struct(), Vect_destroy_field_info(), Vect_destroy_line_struct(), Vect_destroy_list(), Vect_destroy_map_struct(), Vect_get_finfo_geometry_type(), Vect_new_varray(), Vect_set_comment(), Vect_set_date(), Vect_set_map_date(), Vect_set_map_name(), Vect_set_organization(), Vect_set_person(), and write_pgm().

◆ G_free_ilist()

void G_free_ilist ( struct ilist list)

Free allocated memory of an integer list.

Parameters
listThe pointer to an integer list

Definition at line 27 of file ilist.c.

References G_free().

Referenced by Rast_close_vrt().

◆ G_free_key_value()

void G_free_key_value ( struct Key_Value kv)

Free allocated Key_Value structure.

Parameters
[in]kvKey_Value structure to be freed

Definition at line 104 of file key_value1.c.

References G_free(), Key_Value::key, Key_Value::nalloc, Key_Value::nitems, and Key_Value::value.

Referenced by G_get_projinfo(), GPJ_get_datum_params(), and Rast__check_fp_type().

◆ G_free_list()

void G_free_list ( char **  list)

Free list.

Parameters
listchar* array to be freed
Returns

Definition at line 248 of file gis/list.c.

References G_free().

◆ G_free_ls_filter()

void G_free_ls_filter ( void *  regex)

Definition at line 190 of file ls_filter.c.

References G_free().

◆ G_free_tokens()

void G_free_tokens ( char **  tokens)

Free memory allocated to tokens.

Note: G_free_tokens() must be called when finished with tokens to release memory.

Parameters
[out]tokens

Definition at line 198 of file gis/token.c.

References G_free(), and NULL.

Referenced by check_create_export_opts(), check_create_import_opts(), V1_close_ogr(), and Vect__open_cursor_next_line_pg().

◆ G_fseek()

void G_fseek ( FILE *  fp,
off_t  offset,
int  whence 
)

Change the file position of the stream.

The value of whence must be one of the constants ‘SEEK_SET’, ‘SEEK_CUR’, or ‘SEEK_END’, to indicate whether the offset is relative to the beginning of the file, the current file position, or the end of the file, respectively.

Parameters
fpfile descriptor
offsetoffset
whence

Definition at line 50 of file gis/seek.c.

References _, and G_fatal_error().

Referenced by dfread_header(), dfwrite_header(), dig_fseek(), G__read_Cell_head(), IL_write_temp_2d(), new_dspf(), open_stream(), AMI_STREAM< T >::seek(), AMI_STREAM< T >::stream_len(), Vect_hist_copy(), and Vect_open_fidx().

◆ G_ftell()

off_t G_ftell ( FILE *  fp)

Get the current file position of the stream.

Parameters
fpfile descriptor
Returns
file position
-1 on failure

Definition at line 29 of file gis/seek.c.

Referenced by dfwrite_header(), dig_ftell(), AMI_STREAM< T >::read_item(), AMI_STREAM< T >::stream_len(), Vect_hist_copy(), and AMI_STREAM< T >::write_item().

◆ G_fully_qualified_name()

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

Get fully qualified element name.

Returns a fully qualified name for GIS element name in mapset. Currently this string is in the form name@mapset, but the programmer should pretend not to know this and always call this routine to get the fully qualified name.

String is allocated by G_store().

#include <grass/gis.h>
int main(char *argc, char **argv)
{
char name[GNAME_MAX], *mapset, *fqn;
char command[1024];
G_gisinit(argv[0]);
mapset = G_find_rast(name, "");
if (mapset == NULL)
exit(EXIT_SUCCESS);
fqn = G_fully_qualified_name (name, mapset);
printf (stdout, "map='%s'", fqn);
exit(EXIT_SUCCESS);
}
char * G_fully_qualified_name(const char *, const char *)
Get fully qualified element name.
Definition: nme_in_mps.c:101
#define G_gisinit(pgm)
Definition: gis.h:72
int main(int argc, char *argv[])
Definition: main.c:25
Parameters
nameelement name
mapsetmapset name
Returns
pointer to full element name (map@mapset)

Definition at line 101 of file nme_in_mps.c.

References G_store(), GMAPSET_MAX, GNAME_MAX, and name.

Referenced by M_do_copy(), Rast__check_fp_type(), Rast__open_old(), Rast__quant_import(), Rast_map_is_fp(), Rast_mask_name(), Rast_quantize_fp_map(), Rast_read_fp_range(), and Rast_read_range().

◆ G_fwrite_key_value()

int G_fwrite_key_value ( FILE *  fd,
const struct Key_Value kv 
)

Write key/value pairs to file.

Parameters
[in,out]fdfile to write to
kvpointer Key_Value structure
Returns
0 success
-1 error writing

Definition at line 25 of file key_value2.c.

References err(), Key_Value::key, Key_Value::nitems, and Key_Value::value.

Referenced by G_write_key_value_file().

◆ G_generate_basename()

char* G_generate_basename ( const char *  basename,
double  number,
size_t  ndigits,
size_t  ndecimals 
)

Generate the format string.

Parameters
basenameString with the basename
digitsNumber of digits number
decimalsNumber of decimal number
fillerString used to fill, default is 0
Returns
Format string

Definition at line 162 of file basename.c.

References G_double_to_basename_format(), G_get_basename_separator(), and G_malloc.

◆ G_geodesic_distance()

double G_geodesic_distance ( double  lon1,
double  lat1,
double  lon2,
double  lat2 
)

Calculates geodesic distance.

Calculates the geodesic distance from lon1,lat1 to lon2,lat2 in meters.

Note: The calculation of the geodesic distance is fairly costly.

Parameters
lon1,lat1longitude,latitude of first point
lon2,lat2longitude,latitude of second point
Returns
distance in meters

Definition at line 195 of file geodist.c.

References G_geodesic_distance_lon_to_lon(), G_set_geodesic_distance_lat1(), and G_set_geodesic_distance_lat2().

Referenced by G_distance().

◆ G_geodesic_distance_lon_to_lon()

double G_geodesic_distance_lon_to_lon ( double  lon1,
double  lon2 
)

Calculates geodesic distance.

Calculates the geodesic distance from lon1,lat1 to lon2,lat2 in meters where lat1 was the latitude passed to G_set_geodesic_distance_latl() and lat2 was the latitude passed to G_set_geodesic_distance_lat2().

Parameters
lon1first longitude
lon2second longitude
Returns
double distance in meters

Definition at line 121 of file geodist.c.

Referenced by G_geodesic_distance().

◆ G_geodesic_lat_from_lon()

double G_geodesic_lat_from_lon ( double  lon)

Definition at line 78 of file geodesic.c.

◆ G_get_3dview()

int G_get_3dview ( const char *  fname,
const char *  mapset,
struct G_3dview View 
)

Gets a 3D View.

If reading an old format, the window boundaries are not checked against the current window since boundaries weren't saved.

Parameters
[in]fname
[in]mapset
[in,out]View
Returns
-1 on error
1 on success
2 if fname was written with this version of routine
0 if is older format (through 4.0)

Definition at line 243 of file view.c.

Referenced by Gs_load_3dview().

◆ G_get_3dview_defaults()

◆ G_get_available_mapsets()

char** G_get_available_mapsets ( void  )

Get list of available mapsets for current location.

List is updated by each call to this function.

Returns
pointer to NULL terminated array of available mapsets

Definition at line 147 of file mapset_nme.c.

References G_calloc, G_debug(), G_free(), G_location_path(), G_realloc, G_stat(), G_store(), GPATH_MAX, NULL, and st.

◆ G_get_basename_separator()

char* G_get_basename_separator ( void  )

Return the environmental basename variable or the default value.

return pointer to basename separator

Definition at line 109 of file basename.c.

References GBASENAME_SEP, and NULL.

Referenced by G_generate_basename(), and G_join_basename_strings().

◆ G_get_datum_by_name()

int G_get_datum_by_name ( const char *  name)

Definition at line 43 of file gis/datum.c.

References G_read_datum_table().

◆ G_get_datumparams_from_projinfo()

int G_get_datumparams_from_projinfo ( const struct Key_Value projinfo,
char *  datumname,
char *  params 
)

Definition at line 107 of file gis/datum.c.

References G_find_key_value(), and NULL.

◆ G_get_default_window()

void G_get_default_window ( struct Cell_head window)

Get the default region.

Reads the default region for the location into region. 3D values are set to defaults if not available in WIND file.

An error message is printed and exit() is called if there is a problem reading the default region.

Parameters
[out]windowpointer to Cell_head

Definition at line 95 of file get_window.c.

Referenced by G_make_mapset().

◆ G_get_element_window()

void G_get_element_window ( struct Cell_head window,
const char *  element,
const char *  name,
const char *  mapset 
)

Get region for selected element (raster, vector, window, etc.)

G_fatal_error() is called on error

Parameters
[out]windowpointer to Cell_head
elementelement type
nameelement name
mapsetmapset name

Definition at line 110 of file get_window.c.

◆ G_get_ellipsoid_by_name()

int G_get_ellipsoid_by_name ( const char *  name,
double *  a,
double *  e2 
)

Get ellipsoid parameters by name.

This routine returns the semi-major axis a (in meters) and eccentricity squared e2 for the named ellipsoid.

Parameters
nameellipsoid name
[out]asemi-major axis
[out]e2eccentricity squared
Returns
1 on success
0 if ellipsoid not found

Definition at line 104 of file get_ellipse.c.

◆ G_get_ellipsoid_parameters()

int G_get_ellipsoid_parameters ( double *  a,
double *  e2 
)

get ellipsoid parameters

This routine returns the semi-major axis a (in meters) and the eccentricity squared e2 for the ellipsoid associated with the database. If there is no ellipsoid explicitly associated with the database, it returns the values for the WGS 84 ellipsoid.

Parameters
[out]asemi-major axis
[out]e2eccentricity squared
Returns
1 success
0 default values used

Definition at line 66 of file get_ellipse.c.

◆ G_get_env_name()

const char* G_get_env_name ( int  n)

Get variable name for index n.

For example:

for (n = 0; ; n++)
if ((name = G_get_env_name(n)) == NULL)
break;
const char * G_get_env_name(int)
Get variable name for index n.
Definition: env.c:546
Parameters
nindex of variable
Returns
pointer to variable name
NULL not found

Definition at line 546 of file env.c.

◆ G_get_gisrc_mode()

int G_get_gisrc_mode ( void  )

Get info where variables are stored.

Returns
mode

Definition at line 73 of file env.c.

References st.

◆ G_get_mapset_name()

const char* G_get_mapset_name ( int  n)

Get name of the n'th mapset from the current mapset search path.

The first call will initialize the list.

Parameters
nmapset index
Returns
mapset name
NULL if mapset not found

Definition at line 44 of file mapset_nme.c.

References G__get_list_of_mapsets(), NULL, and st.

◆ G_get_num_decimals()

size_t G_get_num_decimals ( const char *  str)

Get number of decimals from a string.

Parameters
strString to analyse
Returns
number of decimals

Definition at line 54 of file basename.c.

References NULL.

◆ G_get_overwrite()

int G_get_overwrite ( void  )

Get overwrite value.

Returns
1 overwrite enabled
0 overwrite disabled

Definition at line 957 of file parser.c.

References st.

Referenced by V1_open_new_ogr().

◆ G_get_projepsg()

struct Key_Value* G_get_projepsg ( void  )

Gets EPSG information for the current location.

DEPRECATED: Use G_get_projsrid() instead.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Returns
pointer to Key_Value structure with key/value pairs
NULL when EPSG code is not defined for location

Definition at line 102 of file get_projinfo.c.

References EPSG_FILE, G_debug(), G_file_name(), G_location(), G_projection(), G_read_key_value_file(), GPATH_MAX, NULL, PERMANENT, and PROJECTION_XY.

Referenced by G_get_projinfo().

◆ G_get_projinfo()

struct Key_Value* G_get_projinfo ( void  )

Gets projection information for location.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Prints a warning if no projection information available.

Returns
pointer to Key_Value structure with key/value pairs
NULL on failure

Definition at line 61 of file get_projinfo.c.

References _, G_file_name(), G_find_key_value(), G_free_key_value(), G_get_projepsg(), G_location(), G_projection(), G_read_key_value_file(), G_set_key_value(), G_warning(), GPATH_MAX, NULL, PERMANENT, PROJECTION_FILE, and PROJECTION_XY.

Referenced by GPJ_get_datum_params().

◆ G_get_projsrid()

char* G_get_projsrid ( void  )

Get srid (spatial reference id) for the current location.

Typically an srid will be of the form authority NAME:CODE, e.g. EPSG:4326

This srid is passed to proj_create() using PROJ or OSRSetFromUserInput() using GDAL. Therefore various other forms of srid are possible, e.g. in OSRSetFromUserInput():

  1. Well Known Text definition - passed on to importFromWkt().
  2. "EPSG:n" - number passed on to importFromEPSG().
  3. "EPSGA:n" - number passed on to importFromEPSGA().
  4. "AUTO:proj_id,unit_id,lon0,lat0" - WMS auto projections.
  5. "urn:ogc:def:crs:EPSG::n" - ogc urns
  6. PROJ.4 definitions - passed on to importFromProj4().
  7. filename - file read for WKT, XML or PROJ.4 definition.
  8. well known name accepted by SetWellKnownGeogCS(), such as NAD27, NAD83, WGS84 or WGS72.
  9. "IGNF:xxxx", "ESRI:xxxx", etc. from definitions from the PROJ database;
  10. PROJJSON (PROJ >= 6.2)
Returns
pointer to srid string
NULL when srid is not available for the current location

Definition at line 237 of file get_projinfo.c.

References GPATH_MAX, and NULL.

◆ G_get_projunits()

struct Key_Value* G_get_projunits ( void  )

Gets units information for location.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Prints a warning if no units information available.

Returns
pointer to Key_Value structure with key/value pairs
NULL on failure

Definition at line 32 of file get_projinfo.c.

References _, G_file_name(), G_location(), G_projection(), G_read_key_value_file(), G_warning(), GPATH_MAX, NULL, PERMANENT, PROJECTION_XY, and UNIT_FILE.

◆ G_get_projwkt()

char* G_get_projwkt ( void  )

Get WKT information for the current location.

Returns
pointer to WKT string
NULL when WKT is not available for the current location

Definition at line 127 of file get_projinfo.c.

References GPATH_MAX, and NULL.

◆ G_get_set_window()

void G_get_set_window ( struct Cell_head window)

Get the current working window (region)

The current working window values are returned in the structure window.

Previous calls to G_set_window() affects values returned by this function. Previous calls to G_put_window() affects values returned by this function only if the current working window is not initialized.

Parameters
[out]windowpointer to window structure to be set
See also
G_set_window(), G_get_window()

Definition at line 35 of file gis/set_window.c.

Referenced by G_setup_plot(), GS_get_to_real(), GS_set_focus_real(), I_iclass_analysis(), and N_init_geom_data_3d().

◆ G_get_spheroid_by_name()

int G_get_spheroid_by_name ( const char *  name,
double *  a,
double *  e2,
double *  f 
)

Get spheroid parameters by name.

This function returns the semi-major axis a (in meters), the eccentricity squared e2 and the inverse flattening f for the named ellipsoid.

Parameters
namespheroid name
[out]asemi-major axis
[out]e2eccentricity squared
[out]finverse flattening
Returns
1 on success
0 if no spheroid found

Definition at line 153 of file get_ellipse.c.

◆ G_get_timestamps()

void G_get_timestamps ( const struct TimeStamp ts,
DateTime dt1,
DateTime dt2,
int *  count 
)

Copy TimeStamp into [two] Datetimes structs.

Use to copy the TimeStamp information into Datetimes, as the members of struct TimeStamp shouldn't be accessed directly.

  • count=0 means no datetimes were copied
  • count=1 means 1 datetime was copied into dt1
  • count=2 means 2 datetimes were copied
Parameters
tssource TimeStamp structure
[out]dt1first DateTime struct to be filled
[out]dt2second DateTime struct to be filled
[out]countreturn code

Definition at line 260 of file timestamp.c.

◆ G_get_units_name()

const char* G_get_units_name ( int  units,
int  plural,
int  square 
)

Get localized units name.

Units codes (gis.h):

  • U_METERS
  • U_KILOMETERS
  • U_ACRES
  • U_HECTARES
  • U_MILES
  • U_FEET
  • U_USFEET
Parameters
unitsunits code
pluralplural form if true
squarearea units if true
Returns
units name
NULL if units not found

Definition at line 204 of file units.c.

References _, G_database_unit_name(), G_get_units_name(), G_units(), NULL, U_ACRES, U_DAYS, U_DEGREES, U_FEET, U_HECTARES, U_HOURS, U_KILOMETERS, U_METERS, U_MILES, U_MINUTES, U_MONTHS, U_SECONDS, U_UNKNOWN, U_USFEET, and U_YEARS.

Referenced by G_database_unit_name(), G_get_units_name(), Rast3d_get_vertical_unit(), and Rast3d_print_header().

◆ G_get_window()

void G_get_window ( struct Cell_head window)

Get the current region.

Reads the region as stored in the WIND file in the user's current mapset into region.

3D values are set to defaults if not available in WIND file. An error message is printed and exit() is called if there is a problem reading the region.

Note: GRASS applications that read or write raster maps should not use this routine since its use implies that the active module region will not be used. Programs that read or write raster map data (or vector data) can query the active module region using Rast_window_rows() and Rast_window_cols().

Parameters
[out]windowpointer to Cell_head

Definition at line 47 of file get_window.c.

Referenced by G__init_window(), and P_set_dim().

◆ G_getenv()

const char* G_getenv ( const char *  name)

Get environment variable.

G_fatal_error() is called when variable is not found.

Parameters
namevariable name
Returns
char pointer to value for name

Definition at line 360 of file env.c.

References _, G_fatal_error(), G_getenv_nofatal(), name, and NULL.

Referenced by G_gisbase(), G_gisdbase(), and G_location().

◆ G_getenv2()

const char* G_getenv2 ( const char *  name,
int  loc 
)

Get variable from specific place.

Locations:

  • G_VAR_GISRC
  • G_VAR_MAPSET

G_fatal_error() is called when variable is not found.

Parameters
namevariable name
loclocation (G_VAR_GISRC, G_VAR_MAPSET)
Returns
variable value
NULL if not found

Definition at line 386 of file env.c.

References _, G_fatal_error(), G_getenv_nofatal2(), name, and NULL.

◆ G_getenv_nofatal()

const char* G_getenv_nofatal ( const char *  name)

Get environment variable.

Parameters
namevariable name
Returns
char pointer to value for name
NULL if name not set

Definition at line 405 of file env.c.

References name.

Referenced by G__mapset(), G_check_overwrite(), G_define_standard_option(), and G_getenv().

◆ G_getenv_nofatal2()

const char* G_getenv_nofatal2 ( const char *  name,
int  loc 
)

Get environment variable from specific place.

Parameters
namevariable name
loclocation (G_VAR_GISRC, G_VAR_MAPSET)
Returns
char pointer to value for name
NULL if name not set

Definition at line 424 of file env.c.

References name.

Referenced by db_get_connection(), db_get_default_database_name(), db_get_default_driver_name(), db_get_default_group_name(), db_get_default_schema_name(), G_getenv2(), tgis_get_connection(), tgis_get_database_name(), and tgis_get_driver_name().

◆ G_getl()

int G_getl ( char *  buf,
int  n,
FILE *  fd 
)

Gets a line of text from a file.

This routine runs fgets() to fetch a line of text from a file (advancing file pointer) and removes trailing newline.

Parameters
bufstring buffer to receive read data
nmaximum number of bytes to read
fdfile descriptor structure
Returns
1 on success
0 EOF
See also
G_getl2()

Definition at line 33 of file getl.c.

References G_getl2().

Referenced by G__read_Cell_head(), G_matrix_read(), G_myname(), Rast__read_history(), and Rast_get_cell_title().

◆ G_getl2()

int G_getl2 ( char *  buf,
int  n,
FILE *  fd 
)

Gets a line of text from a file of any pedigree.

This routine supports text files created on various platforms (UNIX, MacOS9, DOS), i.e. \n (\012), \r (\015), and \r\n (\015\012) style newlines.

Reads in at most n-1 characters from stream (the last spot is reserved for the end-of-string NUL) and stores them into the buffer pointed to by buf. Reading stops after an EOF or a newline. New line is not stored in the buffer. At least n bytes must be allocated for the string buffer.

Parameters
bufstring buffer to receive read data, at least n bytes must be allocated
nmaximum number of bytes to read
fdfile descriptor structure
Returns
1 on success
0 EOF

Definition at line 60 of file getl.c.

References NULL.

Referenced by dig_read_frmt_ascii(), G_getl(), I_get_group_title(), Rast_get_vrt(), read_coor(), Vect__read_head(), and Vect_read_ascii_head().

◆ G_gisbase()

const char* G_gisbase ( void  )

Get full path name of the top level module directory.

Returns the full path name of the top level directory for GRASS programs. This directory will have subdirectories which will contain modules and files required for the running of the system. Some of these directories are:

bin    commands run by the user
etc    modules and data files used by GRASS commands

The use of G_gisbase() to find these subdirectories enables GRASS modules to be written independently of where the GRASS system is actually installed on the machine. For example, to run the module sroff in the GRASS etc directory:

char command[200];
sprintf(command, "%s/etc/sroff", G_gisbase());
G_spawn(command, "sroff", NULL);
const char * G_gisbase(void)
Get full path name of the top level module directory.
Definition: gisbase.c:39
int G_spawn(const char *command,...)
Spawn new process based on command.
Definition: spawn.c:919
Returns
pointer to a string

Definition at line 39 of file gisbase.c.

References G_getenv().

Referenced by GPJ_osr_to_grass(), GPJ_set_csv_loc(), and parse_fontcap().

◆ G_gisdbase()

const char* G_gisdbase ( void  )

Get name of top level database directory.

Returns the full UNIX path name of the directory which holds the database locations.

Returns
pointer to string containing the base directory

Definition at line 26 of file gisdbase.c.

References G_getenv().

Referenced by G__location_path(), G__mapset_path(), G_make_mapset(), G_write_projsrid(), G_write_projwkt(), and Vect_hist_command().

◆ G_has_raster3d_timestamp()

int G_has_raster3d_timestamp ( const char *  name,
const char *  mapset 
)

Check if timestamp for 3D raster map exists.

Parameters
namemap name
mapsetmapset name
Returns
1 on success
0 no timestamp present

Definition at line 576 of file timestamp.c.

References G_find_file2_misc(), GRID3, and name.

◆ G_has_raster_timestamp()

int G_has_raster_timestamp ( const char *  name,
const char *  mapset 
)

Check if timestamp for raster map exists.

Parameters
namemap name
mapsetmapset name
Returns
1 on success
0 no timestamp present

Definition at line 356 of file timestamp.c.

References G_find_file2_misc(), name, and RAST_MISC.

◆ G_has_vector_timestamp()

int G_has_vector_timestamp ( const char *  name,
const char *  layer,
const char *  mapset 
)

Check if timestamp for vector map exists.

Parameters
namemap name
layerThe layer names, in case of NULL, layer one is assumed
mapsetmapset name
Returns
1 on success
0 no timestamp present

Definition at line 422 of file timestamp.c.

References G_debug(), G_file_name(), GNAME_MAX, GPATH_MAX, GV_DIRECTORY, GV_TIMESTAMP_ELEMENT, name, NULL, and R_OK.

◆ G_home()

const char* G_home ( void  )

Get user's home directory.

Returns a pointer to a string which is the full path name of the user's home directory.

Calls G_fatal_error() on failure.

Returns
pointer to string
NULL on error

Definition at line 32 of file home.c.

References _, G__home(), G_fatal_error(), and NULL.

Referenced by G_config_path().

◆ G_ilist_add()

void G_ilist_add ( struct ilist list,
int  val 
)

Add item to ilist.

This function adds an integer to the list but does not check for duplicates. In case reallocation fails, G_fatal_error() will be invoked by the allocation function.

Parameters
listThe ilist pointer
valThe value to attach

Definition at line 78 of file ilist.c.

References G_realloc.

Referenced by Rast_get_vrt().

◆ G_important_message()

void void void G_important_message ( const char *  ,
  ... 
)

Referenced by GPJ_init_transform().

◆ G_info_format()

int G_info_format ( void  )

Get current message format.

Maybe set to either "standard" or "gui" (normally GRASS takes care)

Returns
grass_info_format value

Definition at line 537 of file gis/error.c.

References G_init_logging().

◆ G_init_all()

◆ G_init_counter()

void G_init_counter ( struct Counter c,
int  v 
)

Definition at line 38 of file counter.c.

◆ G_init_debug()

void G_init_debug ( void  )

Initiate debugging.

Definition at line 27 of file debug.c.

References G_is_initialized().

Referenced by G_debug(), and G_init_all().

◆ G_init_env()

void G_init_env ( void  )

Initialize variables.

Returns

Definition at line 83 of file env.c.

Referenced by G_init_all().

◆ G_init_ilist()

void G_init_ilist ( struct ilist list)

Init an integer list and free allocated memory.

Parameters
listThe pointer to an integer list

Definition at line 58 of file ilist.c.

References G_free(), and NULL.

Referenced by G_new_ilist(), and RTreeSearch2().

◆ G_init_logging()

void G_init_logging ( void  )

Definition at line 355 of file gis/error.c.

Referenced by G_info_format(), and G_init_all().

◆ G_init_tempfile()

void G_init_tempfile ( void  )

Initialize environment for creating tempfiles.

Definition at line 29 of file tempfile.c.

References G_is_initialized().

Referenced by G_init_all(), G_tempfile_pid(), and G_tempfile_pid_basedir().

◆ G_init_timestamp()

void G_init_timestamp ( struct TimeStamp ts)

Initialize timestamp structure.

Parameters
tspointer to TimeStamp structure

Definition at line 95 of file timestamp.c.

◆ G_init_workers()

void G_init_workers ( void  )

Definition at line 181 of file worker.c.

◆ G_initialize_done()

void G_initialize_done ( int *  p)

Definition at line 77 of file counter.c.

Referenced by G__init_window(), G_config_path(), G_set_verbose(), G_verbose(), and Rast__init_window().

◆ G_insert_commas()

int G_insert_commas ( char *  buf)

Inserts commas into a number string.

Examples:

  • 1234567 becomes 1,234,567
  • 1234567.89 becomes 1,234,567.89
  • 12345 becomes 12,345
  • 1234 stays 1234

Note: Does not work with negative numbers.

Parameters
[in,out]bufstring
Returns
1 if no commas inserted
0 if commas inserted

Definition at line 36 of file commas.c.

References strcpy.

◆ G_intersect_line_segments()

int G_intersect_line_segments ( double  ax1,
double  ay1,
double  ax2,
double  ay2,
double  bx1,
double  by1,
double  bx2,
double  by2,
double *  ra,
double *  rb,
double *  x,
double *  y 
)

Definition at line 84 of file gis/intersect.c.

Referenced by G_distance_between_line_segments().

◆ G_is_absolute_path()

int G_is_absolute_path ( const char *  path)

Checks if a specified path looks like an absolute path on the host system.

Parameters
pathString containing path to check
Returns
1 if path looks like an absolute path, 0 if not

Definition at line 62 of file paths.c.

References G_is_dirsep().

Referenced by COM_Set_font().

◆ G_is_dirsep()

int G_is_dirsep ( char  c)

Checks if a specified character is a valid directory separator character on the host system.

Parameters
cCharacter to check
Returns
1 if c is a directory separator character, 0 if not

Definition at line 45 of file paths.c.

Referenced by G_is_absolute_path(), and G_parser().

◆ G_is_gisbase()

int G_is_gisbase ( const char *  path)

Test if specified directory is GISBASE.

Parameters
[in]pathPath to directory
Returns
1 The directory is GISBASE
0 The directory is not GISBASE

Definition at line 49 of file is.c.

◆ G_is_initialized()

◆ G_is_little_endian()

void int G_is_little_endian ( void  )

Tests for little ENDIAN.

Test if machine is little or big endian.

Returns
1 little endian
0 big endian

Definition at line 24 of file endian.c.

◆ G_is_location()

int G_is_location ( const char *  path)

Test if specified directory is location.

Parameters
[in]pathPath to directory
Returns
1 The directory is location
0 The directory is not location

Definition at line 62 of file is.c.

◆ G_is_mapset()

int G_is_mapset ( const char *  path)

Test if specified directory is mapset.

Parameters
[in]pathPath to directory
Returns
1 The directory is mapset
0 The directory is not mapset

Definition at line 75 of file is.c.

◆ G_is_mapset_in_search_path()

int G_is_mapset_in_search_path ( const char *  mapset)

Check if given mapset is in search path.

Parameters
mapsetmapset name
Returns
1 mapset found in search path
0 mapset not found

Definition at line 217 of file mapset_nme.c.

References st.

Referenced by G_add_mapset_to_search_path().

◆ G_is_units_type_spatial()

int G_is_units_type_spatial ( int  units)

Check if the unit is of spatial type.

Parameters
unitsunits code from gis.h
Returns
1 if True, 0 otherwise

Definition at line 134 of file units.c.

References U_ACRES, U_DEGREES, U_FEET, U_HECTARES, U_KILOMETERS, U_METERS, U_MILES, U_RADIANS, and U_USFEET.

◆ G_is_units_type_temporal()

int G_is_units_type_temporal ( int  units)

Check if the unit is of temporal type.

Parameters
unitsunits code from gis.h
Returns
1 if True, 0 otherwise

Definition at line 166 of file units.c.

References U_DAYS, U_HOURS, U_MINUTES, U_MONTHS, U_SECONDS, and U_YEARS.

◆ G_join_basename_strings()

char* G_join_basename_strings ( const char **  strings,
size_t  len 
)

join an array of strings using the basename separator

Parameters
stringsis an array of strings
lenis the length of the array
Returns
a joined string

Definition at line 126 of file basename.c.

References G_get_basename_separator(), G_malloc, and strcpy.

◆ G_lat_format()

void G_lat_format ( double  lat,
char *  buf 
)

Definition at line 40 of file ll_format.c.

Referenced by G_adjust_window_ll(), and G_format_northing().

◆ G_lat_format_string()

const char* G_lat_format_string ( void  )

Definition at line 50 of file ll_format.c.

◆ G_lat_parts()

void G_lat_parts ( double  lat,
int *  d,
int *  m,
double *  s,
char *  h 
)

Definition at line 116 of file ll_format.c.

◆ G_lat_scan()

int G_lat_scan ( const char *  buf,
double *  lat 
)

Definition at line 45 of file ll_scan.c.

Referenced by G_adjust_window_ll().

◆ G_legal_filename()

int G_legal_filename ( const char *  s)

Check for legal database file name.

Legal file names will not begin with '.' or NULL and must not contain the characters, ' ' (space), '/', '"'. '\'' (single quote), '@', ',', '=', '*', and all other non-alphanumeric characters within.

The function prints a warning on error.

Parameters
sfile name to check
Returns
1 success
-1 failure

Definition at line 34 of file legal_name.c.

Referenced by G_make_mapset().

◆ G_limit_east()

int G_limit_east ( double *  ,
int   
)

◆ G_limit_north()

int G_limit_north ( double *  north,
int  proj 
)

Limit north (y) coordinate.

If the projection has absolute limits (like lat/lon), then this routine modifies the input coordinate to be within the limit.

Parameters
[in,out]northnorth coordinate
[in]projprojection id
Returns
1 no change
0 changed

Definition at line 71 of file wind_limits.c.

References PROJECTION_LL.

◆ G_limit_south()

int G_limit_south ( double *  south,
int  proj 
)

Limit south (y) coordinate.

If the projection has absolute limits (like lat/lon), then this routine modifies the input coordinate to be within the limit.

Parameters
[in]southsouth coordinate
[in]projprojection id
Returns
1 no change
0 changed

Definition at line 100 of file wind_limits.c.

References PROJECTION_LL.

◆ G_limit_west()

int G_limit_west ( double *  ,
int   
)

◆ G_list()

char** G_list ( int  element,
const char *  gisbase,
const char *  location,
const char *  mapset 
)

List specified type of elements. Application must release the allocated memory.

Parameters
elementelement type (G_ELEMENT_RASTER, G_ELEMENT_VECTOR, G_ELEMENT_REGION )
gisbasepath to GISBASE
locationlocation name
mapsetmapset name
Returns
zero terminated array of element names

Definition at line 173 of file gis/list.c.

References _, count, G_calloc, G_ELEMENT_GROUP, G_ELEMENT_RASTER, G_ELEMENT_REGION, G_ELEMENT_VECTOR, G_fatal_error(), G_free(), G_malloc, list, NULL, and strcpy.

◆ G_list_color_rules()

void G_list_color_rules ( FILE *  out)

Print color rules.

Parameters
outfile where to print

Definition at line 175 of file gis/color_rules.c.

◆ G_list_color_rules_description_type()

void G_list_color_rules_description_type ( FILE *  out,
char *  name 
)

Print color rules with description and type.

The type of color rule including range is appended to the description. If a color rule name is given, color info is printed only for this rule.

Parameters
nameoptional color rule name, or NULL
outfile where to print

Definition at line 198 of file gis/color_rules.c.

◆ G_list_element()

void G_list_element ( const char *  element,
const char *  desc,
const char *  mapset,
int(*)(const char *, const char *, char *)  lister 
)

General purpose list function.

Will list files from all mapsets in the mapset list for a specified database element.

Note: output is to stdout piped thru the more utility

lister (char *name char *mapset, char* buf)

Given file name, and mapset, lister() should copy a string into 'buf' when called with name == "", should set buf to general title for mapset list.

Parameters
elementdatabase element (eg, "cell", "cellhd", etc.)
descdescription for element (if NULL, element is used)
mapsetmapset to be listed "" to list all mapsets in mapset search list "." will list current mapset
listerif given will call this routine to get a list title. NULL if no titles desired.

Definition at line 51 of file gis/list.c.

Referenced by M_do_list().

◆ G_llres_format()

void G_llres_format ( double  res,
char *  buf 
)

Definition at line 70 of file ll_format.c.

Referenced by G_adjust_window_ll(), and G_format_resolution().

◆ G_llres_format_string()

const char* G_llres_format_string ( void  )

Definition at line 81 of file ll_format.c.

◆ G_llres_scan()

int G_llres_scan ( const char *  buf,
double *  res 
)

Definition at line 55 of file ll_scan.c.

Referenced by G_adjust_window_ll(), and G_scan_resolution().

◆ G_location()

const char* G_location ( void  )

Get current location name.

Returns the name of the current database location. This routine should be used by modules that need to display the current location to the user. See Locations for an explanation of locations.

Returns
location name

Definition at line 32 of file location.c.

References G_getenv().

Referenced by G__location_path(), G__mapset_path(), G_get_projepsg(), G_get_projinfo(), G_get_projunits(), G_make_mapset(), I_location_info(), and Vect_hist_command().

◆ G_location_path()

char* G_location_path ( void  )

Get current location UNIX-like path.

Allocated buffer should be freed by G_free(). See G__location_path().

Returns the full UNIX path name of the current database location. For example, if the user is working in location spearfish in the /home/user/grassdata database directory, this routine will return a string which looks like /home/user/grassdata/spearfish.

This function also checks if location path is readable by the current user. It calls G_fatal_error() on failure.

Returns
buffer with location path

Definition at line 54 of file location.c.

References _, G__location_path(), and G_fatal_error().

Referenced by db_set_default_connection(), and G_get_available_mapsets().

◆ G_lon_format()

void G_lon_format ( double  lon,
char *  buf 
)

Definition at line 55 of file ll_format.c.

Referenced by G_adjust_window_ll(), and G_format_easting().

◆ G_lon_format_string()

const char* G_lon_format_string ( void  )

Definition at line 65 of file ll_format.c.

◆ G_lon_parts()

void G_lon_parts ( double  lon,
int *  d,
int *  m,
double *  s,
char *  h 
)

Definition at line 132 of file ll_format.c.

◆ G_lon_scan()

int G_lon_scan ( const char *  buf,
double *  lon 
)

Definition at line 50 of file ll_scan.c.

Referenced by G_adjust_window_ll().

◆ G_lookup_key_value_from_file()

int G_lookup_key_value_from_file ( const char *  file,
const char *  key,
char  value[],
int  n 
)

Look up for key in file.

Parameters
[in]filefilename
[in]keykey to be found in file
[out]valuevalue for key
[in]nnumber of characters to be copied
Returns
0 not found
1 ok

Definition at line 48 of file key_value4.c.

Referenced by GPJ_osr_to_grass().

◆ G_lrand48()

long G_lrand48 ( void  )

Generate an integer in the range [0, 2^31)

Returns
the generated value

Definition at line 136 of file lrand48.c.

References r.

◆ G_ls()

void G_ls ( const char *  dir,
FILE *  stream 
)

Prints a directory listing to a stream, in prettified column format.

A replacement for system("ls -C"). Lists the contents of the directory specified to the given stream, e.g. stderr. Tries to determine an appropriate column width to keep the number of lines used to a minimum and look pretty on the screen.

Parameters
dirDirectory to list
streamStream to print listing to

Definition at line 137 of file ls.c.

References G_free(), G_ls2(), and G_ls_format().

◆ G_ls2()

char** G_ls2 ( const char *  dir,
int *  num_files 
)

Stores a sorted directory listing in an array.

The filenames in the specified directory are stored in an array of strings, then sorted alphabetically. Each filename has space allocated using G_store(), which can be freed using G_free() if necessary. The same goes for the array itself.

Parameters
dirDirectory to list
num_filesPointer to an integer in which the total number of files listed will be stored
Returns
Pointer to array of strings containing the listing

Definition at line 94 of file ls.c.

References _, G_fatal_error(), G_realloc, G_store(), NULL, and st.

Referenced by G_ls(), and list_subgroups().

◆ G_ls_format()

void G_ls_format ( char **  list,
int  num_items,
int  perline,
FILE *  stream 
)

Prints a listing of items to a stream, in prettified column format.

Lists the contents of the array passed to the given stream, e.g. stderr. Prints the number of items specified by "perline" to each line, unless perline is given as 0 in which case the function tries to determine an appropriate column width to keep the number of lines used to a minimum and look pretty on the screen.

Parameters
listArray of strings containing items to be printed
num_itemsNumber of items in the array
perlineNumber of items to print per line, 0 for autodetect
streamStream to print listing to

Definition at line 165 of file ls.c.

References max, and screen_width.

Referenced by G_ls().

◆ G_ls_glob_filter()

void* G_ls_glob_filter ( const char *  pat,
int  exclude,
int  ignorecase 
)

Definition at line 171 of file ls_filter.c.

◆ G_ls_regex_filter()

void* G_ls_regex_filter ( const char *  pat,
int  exclude,
int  extended,
int  ignorecase 
)

Definition at line 151 of file ls_filter.c.

References G_free(), G_malloc, G_set_ls_exclude_filter(), and NULL.

◆ G_lstat()

int G_lstat ( const char *  file_name,
struct stat *  buf 
)

Get file status.

Returns information about the specified file.

Parameters
file_namefile name, in the case of a symbolic link, the link itself is stat-ed, not the file that it refers to
statpointer to structure filled with file information
Returns
Return value from system lstat function

Definition at line 145 of file paths.c.

Referenced by G_recursive_copy(), G_recursive_remove(), and list_subgroups().

◆ G_lz4_compress()

int G_lz4_compress ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 78 of file cmprlz4.c.

References _, dst, err(), G_calloc, G_free(), G_lz4_compress_bound(), G_warning(), LZ4_compress_default(), NULL, and src.

◆ G_lz4_expand()

int G_lz4_expand ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 146 of file cmprlz4.c.

References _, dst, err(), G_warning(), LZ4_decompress_safe(), NULL, and src.

◆ G_make_location()

int G_make_location ( const char *  location_name,
struct Cell_head wind,
const struct Key_Value proj_info,
const struct Key_Value proj_units 
)

Create a new location.

This function creates a new location in the current database, initializes the projection, default window and current window.

Parameters
location_nameName of the new location. Should not include the full path, the location will be created within the current database.
winddefault window setting for the new location. All fields should be set in this structure, and care should be taken to ensure that the proj/zone fields match the definition in the proj_info parameter(see G_set_cellhd_from_projinfo()).
proj_infoprojection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
proj_unitsprojection units suitable to write to the PROJ_UNITS file, or NULL.
Returns
0 on success
-1 to indicate a system error (check errno).
-2 failed to create projection file (currently not used)
-3 illegal name

Definition at line 53 of file make_loc.c.

◆ G_make_location_crs()

int G_make_location_crs ( const char *  location_name,
struct Cell_head wind,
const struct Key_Value proj_info,
const struct Key_Value proj_units,
const char *  proj_srid,
const char *  proj_wkt 
)

Create a new location.

This function creates a new location in the current database, initializes the projection, default window and current window, and sets WKT, srid, and EPSG code if present

Parameters
location_nameName of the new location. Should not include the full path, the location will be created within the current database.
winddefault window setting for the new location. All fields should be set in this structure, and care should be taken to ensure that the proj/zone fields match the definition in the proj_info parameter(see G_set_cellhd_from_projinfo()).
proj_infoprojection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
proj_unitsprojection units suitable to write to the PROJ_UNITS file, or NULL.
proj_epsgEPSG code suitable to write to the PROJ_EPSG file, or NULL.
proj_wktWKT definition suitable to write to the PROJ_WKT file, or NULL.
proj_sridSpatial reference ID suitable to write to the PROJ_SRID file, or NULL.
Returns
0 on success
-1 to indicate a system error (check errno).
-2 failed to create projection file (currently not used)
-3 illegal name

Definition at line 185 of file make_loc.c.

◆ G_make_location_epsg()

int G_make_location_epsg ( const char *  location_name,
struct Cell_head wind,
const struct Key_Value proj_info,
const struct Key_Value proj_units,
const struct Key_Value proj_epsg 
)

Create a new location.

This function creates a new location in the current database, initializes the projection, default window and current window, and sets the EPSG code if present

Parameters
location_nameName of the new location. Should not include the full path, the location will be created within the current database.
winddefault window setting for the new location. All fields should be set in this structure, and care should be taken to ensure that the proj/zone fields match the definition in the proj_info parameter(see G_set_cellhd_from_projinfo()).
proj_infoprojection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
proj_unitsprojection units suitable to write to the PROJ_UNITS file, or NULL.
proj_epsgEPSG code suitable to write to the PROJ_EPSG file, or NULL.
Returns
0 on success
-1 to indicate a system error (check errno).
-2 failed to create projection file (currently not used)
-3 illegal name

Definition at line 126 of file make_loc.c.

◆ G_make_mapset()

int G_make_mapset ( const char *  gisdbase_name,
const char *  location_name,
const char *  mapset_name 
)

Create a new mapset.

This function creates a new mapset in the given location, initializes default window and the current window.

Calls G_fatal_error() if location doesn't exist.

Parameters
gisdbase_namefull path of GISDBASE to create mapset in (NULL for the current GISDBASE)
location_namename of location to create mapset in (NULL for the current location)
mapset_nameName of the new mapset. Should not include the full path, the mapset will be created within the specified database and location.
Returns
0 on success
-1 to indicate a system error (check errno).
-2 illegal name

Definition at line 43 of file make_mapset.c.

References _, G_create_alt_env(), G_fatal_error(), G_get_default_window(), G_gisdbase(), G_legal_filename(), G_location(), G_mkdir(), G_put_element_window(), G_setenv_nogisrc(), G_switch_env(), GPATH_MAX, and NULL.

◆ G_make_mapset_dir_object()

int G_make_mapset_dir_object ( const char *  type,
const char *  name 
)

Create directory for an object of a given type.

Creates the specified element directory in the current mapset. It will check for the existence of the element and do nothing if it is found so this routine can be called even if the element already exists to ensure that it exists.

Any failure to create it, including the case when it exists (i.e., was created by another process after the existence test) is considered a failure because two processes should not attempt to create two objects of the same name (and type).

This function is for objects which are directories (the function does not create files).

Calls G_fatal_error() on failure.

Parameters
typeobject type (e.g., vector)
nameobject name (e.g., bridges)
Returns
0 no element defined
1 on success
See also
G_make_mapset_object_group()

Definition at line 108 of file mapset_msc.c.

Referenced by G__make_mapset_element_misc(), Rast3d_make_mapset_map_directory(), and Vect_copy().

◆ G_make_mapset_element()

int G_make_mapset_element ( const char *  p_element)

Create element in the current mapset.

Make the specified element in the current mapset will check for the existence of the element and do nothing if it is found so this routine can be called even if the element already exists.

Calls G_fatal_error() on failure.

Deprecated:
This function is deprecated due to confusion in element terminology. Use G_make_mapset_object_group() or G_make_mapset_dir_object() instead.
Parameters
p_elementelement to be created in mapset
Returns
0 no element defined
1 on success

Definition at line 44 of file mapset_msc.c.

References G_file_name(), G_mapset(), GPATH_MAX, and NULL.

◆ G_make_mapset_element_tmp()

int G_make_mapset_element_tmp ( const char *  p_element)

Create element in the temporary directory.

See G_file_name_tmp() for details.

Parameters
p_elementelement to be created in mapset (e.g., elevation)
Note
Use G_make_mapset_object_group_tmp() for creating common, shared directories which are for multiple concrete elements (objects).
Returns
0 no element defined
1 on success

Definition at line 131 of file mapset_msc.c.

References G_file_name_tmp(), G_mapset(), GPATH_MAX, and NULL.

◆ G_make_mapset_object_group()

int G_make_mapset_object_group ( const char *  type)

Create directory for group of elements of a given type.

Creates the specified element directory in the current mapset. It will check for the existence of the element and do nothing if it is found so this routine can be called even if the element already exists to ensure that it exists.

If creation fails, but the directory exists after the failure, the function reports success. Therefore, two processes creating a directory in this way can work in parallel.

Calls G_fatal_error() on failure.

Parameters
typeobject type (e.g., cell)
Returns
0 no element defined
1 on success
See also
G_make_mapset_dir_object()
G_make_mapset_object_group_tmp()

Definition at line 74 of file mapset_msc.c.

Referenced by db_set_default_connection(), G__temp_element_basedir(), M_do_copy(), and Rast__quant_export().

◆ G_make_mapset_object_group_basedir()

int G_make_mapset_object_group_basedir ( const char *  type,
const char *  basedir 
)

Create directory for type of objects in the temporary directory.

See G_file_name_basedir() for details.

Parameters
typeobject type (e.g., cell)
Note
Use G_make_mapset_object_group_basedir() for creating common, shared directories for temporary data.
Returns
0 no element defined
1 on success

Definition at line 175 of file mapset_msc.c.

Referenced by G__temp_element_basedir().

◆ G_make_mapset_object_group_tmp()

int G_make_mapset_object_group_tmp ( const char *  type)

Create directory for type of objects in the temporary directory.

See G_file_name_tmp() for details.

Parameters
typeobject type (e.g., cell)
Note
Use G_make_mapset_object_group_tmp() for creating common, shared directories which are for multiple concrete elements (objects).
Returns
0 no element defined
1 on success

Definition at line 153 of file mapset_msc.c.

◆ G_mapset()

◆ G_mapset_path()

char* G_mapset_path ( void  )

Get current mapset UNIX-like path.

Allocated buffer should be freed by G_free(). See G__mapset_path().

Returns the full UNIX path name of the current mapset. For example, if the user is working in mapset user1, location spearfish in the /home/user/grassdata database directory, this routine will return a string which looks like /home/user/grassdata/spearfish/user1.

This function also checks if mapset path is readable by the current user. It calls G_fatal_error() on failure.

Returns
buffer with location path

Definition at line 73 of file gis/mapset.c.

References _, G__mapset_path(), and G_fatal_error().

◆ G_mapset_permissions()

int G_mapset_permissions ( const char *  mapset)

Check for user mapset permission.

Parameters
mapsetmapset name
Returns
1 mapset exists, and user has permission
0 mapset exists, BUT user denied permission
-1 mapset does not exist

Definition at line 291 of file mapset_msc.c.

References G_file_name(), G_stat(), and GPATH_MAX.

◆ G_mapset_permissions2()

int G_mapset_permissions2 ( const char *  gisdbase,
const char *  location,
const char *  mapset 
)

Check for user mapset permission.

Parameters
gisdbasefull path to GISDBASE
locationlocation name
mapsetmapset name
Returns
1 mapset exists, and user has permission
0 mapset exists, BUT user denied permission
-1 mapset does not exist

Definition at line 320 of file mapset_msc.c.

References G_stat(), and GPATH_MAX.

◆ G_meridional_radius_of_curvature()

double G_meridional_radius_of_curvature ( double  lon,
double  a,
double  e2 
)

Meridional radius of curvature.

Returns the meridional radius of curvature at a given longitude:

$ \rho = \frac{a (1-e^2)}{(1-e^2\sin^2 lon)^{3/2}} $

Parameters
lonlongitude
aellipsoid semi-major axis
e2ellipsoid eccentricity squared
Returns
radius value

Definition at line 80 of file radii.c.

◆ G_message()

◆ G_meters_to_units_factor()

double G_meters_to_units_factor ( int  units)

Units conversion from meters to units.

Units codes (gis.h):

  • U_METERS
  • U_KILOMETERS
  • U_MILES
  • U_FEET
  • U_USFEET

Returns a factor which converts meters to units (by multiplication).

Parameters
unitsunits code
Returns
factor

Definition at line 38 of file units.c.

References U_FEET, U_KILOMETERS, U_METERS, U_MILES, and U_USFEET.

◆ G_meters_to_units_factor_sq()

double G_meters_to_units_factor_sq ( int  units)

Units conversion from square meters to square units.

Units codes (gis.h):

  • U_METERS
  • U_KILOMETERS
  • U_ACRES
  • U_HECTARES
  • U_MILES
  • U_FEET
  • U_USFEET

Returns a factor which converts square meters to square units (by multiplication).

Parameters
unitsunits code
Returns
factor

Definition at line 88 of file units.c.

References U_ACRES, U_FEET, U_HECTARES, U_KILOMETERS, U_METERS, U_MILES, and U_USFEET.

◆ G_mkdir()

int G_mkdir ( const char *  path)

Creates a new directory.

Creates a new directory with permissions 0777 (on Unix) or default permissions(?) on Windows.

Parameters
pathString containing path of directory to be created
Returns
Return value from system mkdir() function

Definition at line 27 of file paths.c.

Referenced by G_config_path(), G_make_mapset(), G_recursive_copy(), and V1_close_nat().

◆ G_mkstemp()

int G_mkstemp ( char *  template,
int  flags,
int  mode 
)

Returns a file descriptor.

This routine opens the file and returns a descriptor.

The last two take the arguments "flags" and "mode". "flags" should be O_WRONLY or O_RDWR, plus any other desired flags (e.g. O_APPEND). "mode" is the file mode (0666 would be typical).

The functions does not use the PID, although the caller can do so.

In theory, up to 26^5 (= ~12 million) filenames will be attempted until it finds one which doesn't exist.

Returns
file descriptor

Definition at line 128 of file mkstemp.c.

Referenced by ami_single_temp_name().

◆ G_mkstemp_fp()

FILE* G_mkstemp_fp ( char *  template,
int  flags,
int  mode 
)

Returns a file descriptor.

This routine opens the file and returns a FILE*.

The last two take the arguments "flags" and "mode". "flags" should be O_WRONLY or O_RDWR, plus any other desired flags (e.g. O_APPEND). "mode" is the file mode (0666 would be typical).

The functions does not use the PID, although the caller can do so.

In theory, up to 26^5 (= ~12 million) filenames will be attempted until it finds one which doesn't exist.

Returns
FILE*

Definition at line 163 of file mkstemp.c.

◆ G_mktemp()

char* G_mktemp ( char *  template)

Opens a temporary file.

This routine opens the file.

The last two take the arguments "flags" and "mode". "flags" should be O_WRONLY or O_RDWR, plus any other desired flags (e.g. O_APPEND). "mode" is the file mode (0666 would be typical).

The functions does not use the PID, although the caller can do so.

In theory, up to 26^5 (= ~12 million) filenames will be attempted until it finds one which doesn't exist.

Note: G_mktemp() as such it is prone to race conditions (some other process may create that file after G_mktemp() returns).

Returns
file name

Definition at line 105 of file mkstemp.c.

◆ G_mrand48()

long G_mrand48 ( void  )

Generate an integer in the range [-2^31, 2^31)

Returns
the generated value

Definition at line 151 of file lrand48.c.

References r.

Referenced by f_rand().

◆ G_myname()

char* G_myname ( void  )

Returns location title.

Returns a one line title for the database location. This title is read from the file MYNAME in the PERMANENT mapset. See also Permanent_Mapset for a discussion of the PERMANENT mapset.

Note: This name is the first line in the file $GISDBASE/$LOCATION_NAME/PERMANENT/MYNAME

Returns
pointer to a string

Definition at line 31 of file myname.c.

References _, G_file_name(), G_getl(), G_store(), GNAME_MAX, GPATH_MAX, name, and strcpy.

◆ G_name_is_fully_qualified()

int G_name_is_fully_qualified ( const char *  fullname,
char *  name,
char *  mapset 
)

Check if map name is fully qualified (map @ mapset)

Returns a fully qualified name for the file name in mapset. Currently this string is in the form name@mapset, but the programmer should pretend not to know this and always call this routine to get the fully qualified name.

Note:

  • name is char array of size GNAME_MAX
  • mapset is char array of size GMAPSET_MAX
Parameters
fullnamefull map name
[out]namemap name
[out]mapsetmapset name
Returns
1 if input map name is fully qualified
0 if input map name is not fully qualified

Definition at line 36 of file nme_in_mps.c.

References name.

Referenced by G_rename(), G_unqualified_name(), M_do_remove(), Rast__quant_export(), Rast__quant_import(), Rast_remove_colors(), Vect_copy(), and Vect_remove_colors().

◆ G_new_ilist()

struct ilist* G_new_ilist ( void  )

Return a new integer list.

G_fatal_error() will be invoked by the allocation function.

Returns
list The pointer to a new allocated integer list

Definition at line 43 of file ilist.c.

References G_init_ilist(), G_malloc, l, and NULL.

Referenced by Rast_get_vrt().

◆ G_newlines_to_spaces()

void G_newlines_to_spaces ( char *  s)

Definition at line 3 of file nl_to_spaces.c.

Referenced by Rast_set_cats_title(), and Rast_set_d_cat().

◆ G_no_compress()

int G_no_compress ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 155 of file compress.c.

References dst, NULL, and src.

◆ G_no_expand()

int G_no_expand ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 176 of file compress.c.

References dst, NULL, and src.

◆ G_num_standard_colors()

int G_num_standard_colors ( void  )

Get number of named colors (RGB triplets)

Returns
number of colors

Definition at line 54 of file color_str.c.

◆ G_number_of_tokens()

int G_number_of_tokens ( char **  tokens)

Return number of tokens.

Parameters
tokens
Returns
number of tokens

Definition at line 179 of file gis/token.c.

References NULL.

Referenced by G_set_keywords(), and Vect__open_cursor_next_line_pg().

◆ G_open_mail()

FILE* G_open_mail ( struct Popen mail)

Definition at line 45 of file pager.c.

References G_popen_clear(), G_popen_write(), G_whoami(), and NULL.

◆ G_open_new()

int G_open_new ( const char *  element,
const char *  name 
)

Open a new database file.

Creates name in the current mapset and opens it for write only.

The database file name under the element in the current mapset is created and opened for writing (but not reading). The UNIX open() routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the open() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (int)
-1 could not open

Definition at line 149 of file gis/open.c.

◆ G_open_new_misc()

int G_open_new_misc ( const char *  dir,
const char *  element,
const char *  name 
)

open a new database misc file

The database file element under dir/name in the current mapset is created and opened for writing (but not reading). The UNIX open( ) routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the open( ) is returned.

Parameters
element
name
Returns
int

Definition at line 111 of file open_misc.c.

Referenced by Rast_write_fp_range(), and Rast_write_rstats().

◆ G_open_old()

int G_open_old ( const char *  element,
const char *  name,
const char *  mapset 
)

Open a database file for reading.

The database file name under the element in the specified mapset is opened for reading (but not for writing). The UNIX open() routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file descriptor from the open() is returned.

Parameters
elementdatabase element name
namemap file name
mapsetmapset containing map name
Returns
open file descriptor (int)
-1 could not open

Definition at line 170 of file gis/open.c.

Referenced by Rast__open_old().

◆ G_open_old_misc()

int G_open_old_misc ( const char *  dir,
const char *  element,
const char *  name,
const char *  mapset 
)

open a database misc file for reading

The database file element under dir/name in the specified mapset is opened for reading (but not for writing). The UNIX open( ) routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file descriptor from the open( ) is returned.

Parameters
element
name
mapset
Returns
int

Definition at line 132 of file open_misc.c.

Referenced by Rast3d_open_cell_old_no_header(), Rast3d_read_range(), and Rast_read_fp_range().

◆ G_open_option_file()

FILE* G_open_option_file ( const struct Option option)

Get an input/output file pointer from the option. If the file name is omitted or '-', it returns either stdin or stdout based on the gisprompt.

Calls G_fatal_error() on error. File pointer can be later closed by G_close_option_file().

FILE *fp_input;
FILE *fp_output;
struct Option *opt_input;
struct Option *opt_output;
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
fp_input = G_open_option_file(opt_input);
fp_output = G_open_option_file(opt_output);
...
G_close_option_file(fp_input);
void G_close_option_file(FILE *)
Close an input/output file returned by G_open_option_file(). If the file pointer is stdin,...
Definition: parser.c:1958
int G_parser(int, char **)
Parse command line.
Definition: parser.c:321
struct Option * G_define_standard_option(int)
Create standardised Option structure.
FILE * G_open_option_file(const struct Option *)
Get an input/output file pointer from the option. If the file name is omitted or '-',...
Definition: parser.c:1919
@ G_OPT_F_INPUT
Definition: gis.h:314
@ G_OPT_F_OUTPUT
Definition: gis.h:316
Structure that stores option information.
Definition: gis.h:557
Parameters
optionpointer to a file option
Returns
file pointer

Definition at line 1919 of file parser.c.

References _, Option::answer, G_fatal_error(), Option::gisprompt, Option::key, Option::multiple, and NULL.

◆ G_open_pager()

FILE* G_open_pager ( struct Popen pager)

Definition at line 13 of file pager.c.

References G_popen_clear(), G_popen_write(), and NULL.

◆ G_open_update()

int G_open_update ( const char *  element,
const char *  name 
)

Open a database file for update.

The database file name under the element in the current mapset is opened for reading and writing. The UNIX open() routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the open() is returned.

Parameters
elementdatabase element name
namemap file name
Returns
open file descriptor (int)
-1 could not open

Definition at line 191 of file gis/open.c.

◆ G_open_update_misc()

int G_open_update_misc ( const char *  dir,
const char *  element,
const char *  name 
)

open a database misc file for update

The database file element under dir/name in the current mapset is opened for reading and writing. The UNIX open( ) routine is used to open the file. If the file does not exist, -1 is returned. Otherwise the file is positioned at the end of the file and the file descriptor from the open( ) is returned.

Parameters
element
name
Returns
int

Definition at line 152 of file open_misc.c.

◆ G_option_collective()

void G_option_collective ( void *  first,
  ... 
)

Sets the options to be collective.

If any option is present, all the other options must also be present all or nothing from a set.

The last item of the list must be NULL.

Parameters
firstfirst given option

Definition at line 380 of file parser_dependencies.c.

◆ G_option_excludes()

void G_option_excludes ( void *  first,
  ... 
)

Exclude selected options.

If the first option is present, none of the other options may also (should?) be present.

The last item of the list must be NULL.

Parameters
firstfirst given option

Definition at line 349 of file parser_dependencies.c.

◆ G_option_exclusive()

void G_option_exclusive ( void *  first,
  ... 
)

Sets the options to be mutually exclusive.

When running the module, at most one option from a set can be provided.

The last item of the list must be NULL.

Parameters
firstfirst given option

Definition at line 214 of file parser_dependencies.c.

◆ G_option_required()

void G_option_required ( void *  first,
  ... 
)

Sets the options to be required.

At least one option from a set must be given.

The last item of the list must be NULL.

Parameters
firstfirst given option

Definition at line 242 of file parser_dependencies.c.

◆ G_option_requires()

void G_option_requires ( void *  first,
  ... 
)

Define a list of options from which at least one option is required if first option is present.

If the first option is present, at least one of the other options must also be present.

The last item of the list must be NULL.

If you want all options to be provided use G_option_requires_all() function. If you want more than one option to be present but not all, call this function multiple times.

Parameters
firstfirst given option

Definition at line 278 of file parser_dependencies.c.

◆ G_option_requires_all()

void G_option_requires_all ( void *  first,
  ... 
)

Define additionally required options for an option.

If the first option is present, all the other options must also be present.

The last item of the list must be NULL.

If it is enough if only one option from a set is present, use G_option_requires() function.

See also
G_option_collective()
Parameters
firstfirst given option

Definition at line 318 of file parser_dependencies.c.

◆ G_option_rule()

void G_option_rule ( int  type,
int  nopts,
void **  opts 
)

Set generic option rule.

Supported rule types:

  • RULE_EXCLUSIVE
  • RULE_REQUIRED
  • RULE_REQUIRES
  • RULE_REQUIRES_ALL
  • RULE_EXCLUDES
  • RULE_COLLECTIVE
Parameters
typerule type
noptsnumber of options in the array
optsarray of options

Definition at line 77 of file parser_dependencies.c.

◆ G_option_to_separator()

char* G_option_to_separator ( const struct Option option)

Get separator string from the option.

Calls G_fatal_error() on error. Allocated string can be later freed by G_free().

char *fs;
struct Option *opt_fs;
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
fs = G_option_to_separator(opt_fs);
char * G_option_to_separator(const struct Option *)
Get separator string from the option.
Definition: parser.c:1857
@ G_OPT_F_SEP
Definition: gis.h:317
Parameters
optionpointer to separator option
Returns
allocated string with separator

Definition at line 1857 of file parser.c.

References _, Option::answer, G_debug(), G_fatal_error(), G_store(), Option::gisprompt, Option::key, and NULL.

◆ G_original_program_name()

const char* G_original_program_name ( void  )

Return original path of the executed program.

This function returns the name of the program as set by the call to G_gisinit().

Unlike G_program_name() which returns name of the module this function return original path which was used to execute the program. For standard GRASS modules, it will be the same as the result from G_program_name() function.

Returns
pointer to string with program name or full path

Definition at line 46 of file progrm_nme.c.

◆ G_owner()

int G_owner ( const char *  path)

Get owner id of path.

Returns information about the specified file.

Parameters
pathpath to check
Returns
Return owner id

Definition at line 164 of file paths.c.

References _, G_fatal_error(), G_stat(), NULL, and TRUE.

◆ G_parser()

int G_parser ( int  argc,
char **  argv 
)

Parse command line.

The command line parameters argv and the number of parameters argc from the main() routine are passed directly to G_parser(). G_parser() accepts the command line input entered by the user, and parses this input according to the input options and/or flags that were defined by the programmer.

Note: The only functions which can legitimately be called before G_parser() are:

The usual order a module calls functions is:

  1. G_gisinit()
  2. G_define_module()
  3. G_define_standard_flag()
  4. G_define_standard_option()
  5. G_define_flag()
  6. G_define_option()
  7. G_option_exclusive()
  8. G_option_required()
  9. G_option_requires()
  10. G_option_requires_all()
  11. G_option_excludes()
  12. G_option_collective()
  13. G_parser()
Parameters
argcnumber of arguments
argvargument list
Returns
0 on success
-1 on error and calls G_usage()

Definition at line 321 of file parser.c.

References _, err(), FALSE, G_basename(), G_is_dirsep(), G_store(), G_verbose_std(), G_warning(), Option::key, NULL, Option::required, and st.

◆ G_percent()

void G_percent ( long  n,
long  d,
int  s 
)

Print percent complete messages.

This routine prints a percentage complete message to stderr. The percentage complete is (n/d)*100, and these are printed only for each s percentage. This is perhaps best explained by example:

#include <stdio.h>
#include <grass/gis.h>
int row;
int nrows;
nrows = 1352; // 1352 is not a special value - example only
G_message(_("Percent complete..."));
for (row = 0; row < nrows; row++)
{
G_percent(row, nrows, 10);
do_calculation(row);
}
G_percent(1, 1, 1);
void G_percent(long, long, int)
Print percent complete messages.
Definition: percent.c:61
void G_message(const char *,...) __attribute__((format(printf
#define _(str)
Definition: glocale.h:10

This example code will print completion messages at 10% increments; i.e., 0%, 10%, 20%, 30%, etc., up to 100%. Each message does not appear on a new line, but rather erases the previous message.

Note that to prevent the illusion of the module stalling, the G_percent() call is placed before the time consuming part of the for loop, and an additional call is generally needed after the loop to "finish it off" at 100%.

Parameters
ncurrent element
dtotal number of elements
sincrement size

Definition at line 61 of file percent.c.

Referenced by NetA_betweenness_closeness().

◆ G_percent_reset()

void G_percent_reset ( void  )

Reset G_percent() to 0%; do not add newline.

Definition at line 117 of file percent.c.

References st.

Referenced by NetA_betweenness_closeness().

◆ G_planimetric_polygon_area()

double G_planimetric_polygon_area ( const double *  x,
const double *  y,
int  n 
)

Calculates planimetric polygon area.

Parameters
xarray of x values
yarray of y values
nnumber of x,y pairs
Returns
polygon area in map units

Definition at line 25 of file area_poly2.c.

Referenced by G_area_of_polygon().

◆ G_plot_area()

int G_plot_area ( double *const *  xs,
double *const *  ys,
int *  rpnts,
int  rings 
)

Plot multiple polygons.

Like G_plot_polygon(), except it takes a set of polygons, each with npts[i] vertices, where the number of polygons is specified with the rings argument. It is especially useful for plotting vector areas with interior islands.

Parameters
xspointer to pointer for X's
yspointer to pointer for Y's
rpntsarray of ints w/ num points per ring
ringsnumber of rings
Returns
0 on success
2 n < 3
-1 weird internal error
1 no memory

Definition at line 504 of file plot.c.

◆ G_plot_fx()

void G_plot_fx ( double(*)(double)  f,
double  east1,
double  east2 
)

Plot f(east1) to f(east2)

The function f(east) is plotted from east1 to east2. The function f(east) must return the map northing coordinate associated with east.

Parameters
fplotting function
east1easting (first point)
east2easting (second point)

Definition at line 782 of file plot.c.

References G_plot_line(), and st.

◆ G_plot_line()

void G_plot_line ( double  east1,
double  north1,
double  east2,
double  north2 
)

Plot line between latlon coordinates (fastline)

A line from east1,north1 to east2,north2 is plotted in output x,y coordinates (e.g. pixels for graphics.) This routine handles global wrap-around for latitude-longitude databases.

Parameters
east1,north1first point (start line node)
east2,north2second point (end line node)

Definition at line 209 of file plot.c.

Referenced by G_plot_fx().

◆ G_plot_line2()

void G_plot_line2 ( double  east1,
double  north1,
double  east2,
double  north2 
)

Plot line between latlon coordinates (slowline)

A line from east1,north1 to east2,north2 is plotted in output x,y coordinates (e.g. pixels for graphics.) This routine handles global wrap-around for latitude-longitude databases.

Parameters
east1,north1first point (start line node)
east2,north2second point (end line node)

Definition at line 224 of file plot.c.

◆ G_plot_point()

void G_plot_point ( double  east,
double  north 
)

Plot point.

Parameters
easteasting
northnorthing

Definition at line 190 of file plot.c.

References G_plot_where_xy(), st, and x.

◆ G_plot_polygon()

int G_plot_polygon ( const double *  x,
const double *  y,
int  n 
)

Plot filled polygon with n vertices.

The polygon, described by the n vertices east,north, is plotted in the output x,y space as a filled polygon.

Parameters
xcoordinates of vertices
ycoordinates of vertices
nnumber of vertices
Returns
0 on success
2 n < 3
-1 weird internal error
1 no memory

Definition at line 374 of file plot.c.

◆ G_plot_where_en()

void G_plot_where_en ( int  x,
int  y,
double *  east,
double *  north 
)

Converts x,y to east,north.

The pixel coordinates x,y are converted to map coordinates east,north.

Parameters
xx coordinate
yy coordinate
easteasting
northnorthing

Definition at line 178 of file plot.c.

References EAST, G_adjust_easting(), NORTH, st, and x.

◆ G_plot_where_xy()

void G_plot_where_xy ( double  east,
double  north,
int *  x,
int *  y 
)

Converts east,north to x,y.

The map coordinates east,north are converted to pixel coordinates x,y.

Parameters
easteasting
northnothing
xx coordinate
yy coordinate

Definition at line 160 of file plot.c.

References x.

Referenced by G_plot_point().

◆ G_point_in_region()

int G_point_in_region ( double  easting,
double  northing 
)

Returns TRUE if coordinate is within the current region settings.

Parameters
easting
northing
Returns
int

Definition at line 25 of file wind_in.c.

◆ G_point_in_window()

int G_point_in_window ( double  easting,
double  northing,
const struct Cell_head window 
)

Returns TRUE if coordinate is within the given map region.

Use instead of G_point_in_region() when used in a loop (it's more efficient to only fetch the window once) or for checking if a point is in another region (e.g. contained with a raster map's bounds).

Parameters
easting
northing
window
Returns
int

Definition at line 48 of file wind_in.c.

◆ G_pole_in_polygon()

int G_pole_in_polygon ( const double *  x,
const double *  y,
int  n 
)

Check if pole is in polygon.

For latitude-longitude coordinates, this routine determines if the polygon defined by the n coordinate vertices x,y contains one of the poles.

Note: Use this routine only if the projection is PROJECTION_LL.

Parameters
xarray of x coordinates
yarray of y coordinates
nnumber of coordinates
Returns
-1 if it contains the south pole
1 if it contains the north pole
0 if it contains neither pole.

Definition at line 35 of file pole_in_poly.c.

◆ G_popen_clear()

void G_popen_clear ( struct Popen state)

Definition at line 56 of file popen.c.

References NULL, and state.

Referenced by G_open_mail(), and G_open_pager().

◆ G_popen_close()

void G_popen_close ( struct Popen state)

Definition at line 72 of file popen.c.

References G_wait(), and state.

Referenced by G_close_mail(), and G_close_pager().

◆ G_popen_read()

FILE* G_popen_read ( struct Popen state,
const char *  program,
const char **  args 
)

Definition at line 67 of file popen.c.

◆ G_popen_write()

FILE* G_popen_write ( struct Popen state,
const char *  program,
const char **  args 
)

Definition at line 62 of file popen.c.

Referenced by G_open_mail(), and G_open_pager().

◆ G_program_name()

const char* G_program_name ( void  )

Return module name.

Routine returns the name of the module as set by the call to G_gisinit().

Returns
pointer to string with program name

Definition at line 28 of file progrm_nme.c.

References name.

◆ G_progress()

void G_progress ( long  n,
int  s 
)

Print progress info messages.

Use G_percent() when number of elements is defined.

This routine prints a progress info message to stderr. The value n is printed only for each s. This is perhaps best explained by example:

#include <grass/vector.h>
int line;
G_message(_("Reading features..."));
line = 0;
while(TRUE)
{
if (Vect_read_next_line(Map, Points, Cats) < 0)
break;
line++;
G_progress(line, 1e3);
}
G_progress(1, 1);
void G_progress(long, int)
Print progress info messages.
Definition: percent.c:158
int Vect_read_next_line(struct Map_info *, struct line_pnts *, struct line_cats *)
Read next vector feature.
#define TRUE
Definition: gis.h:79

This example code will print progress in messages at 1000 increments; i.e., 1000, 2000, 3000, 4000, etc., up to number of features for given vector map. Each message does not appear on a new line, but rather erases the previous message.

Parameters
ncurrent element
sincrement size
Returns
always returns 0

Definition at line 158 of file percent.c.

◆ G_projection()

int G_projection ( void  )

Query cartographic projection.

This routine returns a code indicating the projection for the active region. The current values are (see gis.h)

  • PROJECTION_XY 0 - x,y (Raw imagery)
  • PROJECTION_UTM 1 - UTM Universal Transverse Mercator
  • PROJECTION_SP 2 - State Plane (in feet) - not used, removed
  • PROJECTION_LL 3 - Latitude-Longitude
  • PROJECTION_OTHER 99 - others

Others may be added in the future.

Returns
projection code (see above)

Definition at line 32 of file proj1.c.

Referenced by G_database_projection_name(), G_database_unit(), G_get_projepsg(), G_get_projinfo(), G_get_projunits(), G_shortest_way(), and Rast__check_for_auto_masking().

◆ G_projection_name()

const char* G_projection_name ( int  n)

Get projection name.

Parameters
nprojection code
Returns
projection name
NULL on error

Definition at line 55 of file proj2.c.

References _, NULL, PROJECTION_LL, PROJECTION_OTHER, PROJECTION_UTM, and PROJECTION_XY.

Referenced by G_database_projection_name(), Rast__open_old(), and Vect_get_proj_name().

◆ G_projection_units()

int G_projection_units ( int  n)

Get projection units code (for internal use only)

Parameters
nprojection code

Supported units (see gis.h):

  • U_UNKNOWN (XY)
  • U_METERS (UTM)
  • U_FEET (SP)
  • U_USFEET (a few SP)
  • U_DEGREES (LL)
Returns
units code (see gis.h)
U_UNDEFINED if not defined

Definition at line 32 of file proj2.c.

References PROJECTION_LL, PROJECTION_UTM, PROJECTION_XY, U_DEGREES, U_METERS, U_UNDEFINED, and U_UNKNOWN.

Referenced by G_database_unit().

◆ G_put_3dview()

int G_put_3dview ( const char *  fname,
const struct G_3dview View,
const struct Cell_head Win 
)

Saves info to a 3d.view file in the current mapset.

The address of a window (struct Cell_head *) may be passed, or if NULL is passed, the Cell_head structure inside the G_3dview struct will be used. e.g., if you called G_get_3dview_defaults with the Cell_head you want saved, the G_3dview returned already contains the new Cell_head. But if you're using all the keywords, so didn't need defaults, pass this routine the address of a Cell_head.

User should call G_get_3dview_defaults before filling a G_3dview struct to be written if not using all of the optional keywords.

These keywords are constant in all 3d.view files:
PGM_ID
cell keywords:
north
south
east
west
rows
cols
required keywords:
TO_EASTING
TO_NORTHING
TO_HEIGHT
FROM_EASTING
FROM_NORTHING
FROM_HEIGHT
Z_EXAG
FIELD_VIEW
optional keywords: (defaults provided when reading)
TWIST
MESH_FREQ
POLY_RES
DOAVG
DISPLAY_TYPE
DOZERO
COLORGRID
SHADING
FRINGE
BG_COL
GRID_COL
OTHER_COL
LIGHTS_ON
LIGHTPOS
LIGHTCOL
LIGHTAMBIENT
SHINE
SURFACEONLY

Parameters
[in]fnamefile name
[in]View
[in]Win
Returns
1 on success
-1 on error

Definition at line 163 of file view.c.

References _, G_fopen_new(), G_warning(), and NULL.

Referenced by Gs_save_3dview().

◆ G_put_element_window()

int G_put_element_window ( const struct Cell_head window,
const char *  dir,
const char *  name 
)

Write the region.

Writes the region file (WIND) in the user's current mapset from region.

Warning: Since this routine actually changes the region, it should only be called by modules which the user knows will change the region. It is probably fair to say that only the g.region should call this routine.

Parameters
[in,out]windowpointer to Cell_head
dirdirectory name
namefile name
Returns
1 on success
-1 on error (no diagnostic message is printed)
See also
G_put_window()

Definition at line 74 of file put_window.c.

Referenced by G_make_mapset().

◆ G_put_window()

int G_put_window ( const struct Cell_head window)

Writes the region (window)

Writes the region file (WIND) in the user's current mapset or when environmental variable WIND_OVERRIDE is set, it writes the region to file specified by WIND_OVERRIDE variable.

When WIND_OVERRIDE is set the current process and child processes are affected. Otherwise the whole GRASS session is affected.

Warning
When environmental variable WIND_OVERRIDE is not set, this routine actually changes the region. So in this case it should only be called by modules which the user knows will change the region. It is probably fair to say that only the g.region should call this routine unless WIND_OVERRIDE is set.

This function does not adjust the window before setting the region so you should call G_adjust_Cell_head() before calling this function.

Parameters
[in,out]windowpointer to Cell_head
Returns
1 on success
-1 on error (no diagnostic message is printed)
See also
G_get_window(), G_set_window(), python.core.use_temp_region()

Definition at line 46 of file put_window.c.

◆ G_putenv()

void G_putenv ( const char *  name,
const char *  value 
)

Sets the UNIX environment variable name to value.

Parameters
nameenv name
valueenv value

Definition at line 31 of file putenv.c.

References G_store(), and name.

◆ G_radius_of_conformal_tangent_sphere()

double G_radius_of_conformal_tangent_sphere ( double  lon,
double  a,
double  e2 
)

Radius of conformal tangent sphere.

Returns the radius of the conformal sphere tangent to ellipsoid at a given longitude:

$ r = \frac{a (1-e^2)^{1/2}}{(1-e^2\sin^2 lon)} $

Parameters
lonlongitude
aellipsoid semi-major axis
e2ellipsoid eccentricity squared
Returns
radius value

Definition at line 133 of file radii.c.

◆ G_rasprintf()

int int G_rasprintf ( char **  ,
size_t *  ,
const char *  ,
  ... 
)

◆ G_rc_path()

char* G_rc_path ( const char *  element,
const char *  item 
)

Returns path to element and item.

Either element or item can be NULL, but not both. If element is NULL, then the file is assumed to live at the top level. If file is NULL, then it is assumed the caller is not interested in the file. If the element or rc dir do not exist, they are created. However, the file is never checked for.

Parameters
[in]element
[in]item
Returns
Pointer to string path

Definition at line 288 of file user_config.c.

◆ G_read_compressed()

int G_read_compressed ( int  fd,
int  rbytes,
unsigned char *  dst,
int  nbytes,
int  number 
)

Definition at line 244 of file compress.c.

References _, b, dst, err(), G_calloc, G_COMPRESSED_NO, G_COMPRESSED_YES, G_expand(), G_free(), G_warning(), and NULL.

◆ G_read_datum_table()

void G_read_datum_table ( void  )

Definition at line 141 of file gis/datum.c.

References file, and GPATH_MAX.

Referenced by G_datum_description(), G_datum_ellipsoid(), G_datum_name(), G_get_datum_by_name(), and G_init_all().

◆ G_read_ellipsoid_table()

int G_read_ellipsoid_table ( int  fatal)

Read ellipsoid table.

Parameters
fatalnon-zero value for G_fatal_error(), otherwise G_warning() is used
Returns
1 on success
0 on error

Definition at line 246 of file get_ellipse.c.

References file, and GPATH_MAX.

Referenced by G_ellipsoid_description(), G_ellipsoid_name(), and G_init_all().

◆ G_read_key_value_file()

struct Key_Value* G_read_key_value_file ( const char *  file)

Read key/values pairs from file.

Allocated memory must be freed G_free_key_value(). Call G_fatal_error() when unable to read key/value items from the file.

Parameters
[in]filefilename for reading
Returns
pointer to allocated Key_Value structure
NULL on error

Definition at line 55 of file key_value3.c.

References _, file, G_fatal_error(), and G_fread_key_value().

Referenced by G_get_projepsg(), G_get_projinfo(), G_get_projunits(), and Rast__check_fp_type().

◆ G_read_raster3d_timestamp()

int G_read_raster3d_timestamp ( const char *  name,
const char *  mapset,
struct TimeStamp ts 
)

Read timestamp from 3D raster map.

Parameters
namemap name
mapsetmapset name
[out]tsTimeStamp struct to populate
Returns
1 on success
0 or negative on error

Definition at line 594 of file timestamp.c.

◆ G_read_raster_timestamp()

int G_read_raster_timestamp ( const char *  name,
const char *  mapset,
struct TimeStamp ts 
)

Read timestamp from raster map.

Parameters
namemap name
mapsetmapset the map lives in
[out]tsTimeStamp struct to populate
Returns
1 on success
0 or negative on error

Definition at line 374 of file timestamp.c.

◆ G_read_vector_timestamp()

int G_read_vector_timestamp ( const char *  name,
const char *  layer,
const char *  mapset,
struct TimeStamp ts 
)

Read timestamp from vector map.

Parameters
namemap name
layerThe layer names, in case of NULL, layer one is assumed
mapsetmapset name
[out]tsTimeStamp struct to populate
Returns
1 on success
0 no timestamp present
-1 Unable to open file
-2 invalid time stamp

Definition at line 458 of file timestamp.c.

◆ G_recreate_command()

char* G_recreate_command ( void  )

Creates command to run non-interactive.

Creates a command-line that runs the current command completely non-interactive.

Returns
pointer to a char string

Definition at line 838 of file parser.c.

References FALSE, and recreate_command().

Referenced by Rast_command_history(), and Vect_hist_command().

◆ G_recursive_copy()

int G_recursive_copy ( const char *  src,
const char *  dst 
)

Copy recursively source directory to destination directory.

RULE:

  1. If destination does not exist, copy source to destination as expected.
  2. If destination already exists and it's a file, destination will be deleted first and apply RULE 1.
  3. If destination already exists which is a directory and source is a file, try to copy source to destination directory.
  4. If destination already exists which is a directory and source is also a directory, try to copy all contents in source to destination directory.

This rule is designed according to general/manage/lib/copy.sh.

POSSIBLE CASES:

* if src is a file:
*      if dst does not exist:
*              copy src to dst                         RULE 1
*      if dst is a file:
*              delete dst and copy src to dst          RULE 2
*      if dst is a directory:
*              try recursive_copy(src, dst/src)        RULE 3
* if src is a directory:
*      if dst does not exist:
*              copy src to dst                         RULE 1
*      if dst is a file:
*              delete dst and copy src to dst          RULE 2
*      if dst is a directory:
*              try                                     RULE 4
*              for i in `ls src`
*              do
*                      recursive_copy(src/$i, dst/$i)
*              done
* 
Parameters
srcsource directory
dstdestination directory
Returns
0 if successful, otherwise 1

Definition at line 70 of file copy_dir.c.

References dst, G_lstat(), G_mkdir(), G_recursive_copy(), GPATH_MAX, and src.

Referenced by G_recursive_copy(), M_do_copy(), and V1_close_nat().

◆ G_recursive_remove()

int G_recursive_remove ( const char *  path)

Recursively remove all files in given directory.

Equivalent to rm -rf path.

Parameters
pathpath to the directory which should be removed
Returns
0 on success
-1 on error

Definition at line 113 of file remove.c.

References G_lstat(), G_recursive_remove(), GPATH_MAX, and NULL.

Referenced by G_recursive_remove().

◆ G_remove()

int G_remove ( const char *  element,
const char *  name 
)

Remove a database file.

The file or directory name under the database element directory in the current mapset is removed.

If name is a directory, everything within the directory is removed as well.

Parameters
elementelement name
namefile name
Returns
0 if name does not exist
1 if successful
-1 on error

Definition at line 44 of file remove.c.

Referenced by G_remove_vector_timestamp(), M_do_copy(), M_do_remove(), M_do_rename(), Rast__quant_export(), Rast_remove_colors(), and Vect_remove_colors().

◆ G_remove_commas()

void G_remove_commas ( char *  buf)

Removes commas from number string.

Examples:

  • 1,234,567 becomes 1234567
  • 1,234,567.89 becomes 1234567.89
  • 12,345 becomes 12345
  • 1234 stays 1234
Parameters
[in,out]bufstring
Returns

Definition at line 85 of file commas.c.

References b.

◆ G_remove_error_handler()

void G_remove_error_handler ( void(*)(void *)  func,
void *  closure 
)

Remove existing error handler.

Parameters
funchandler to be remove
closurepointer to closure data

Definition at line 85 of file gis/handler.c.

Referenced by db_unset_error_handler_driver().

◆ G_remove_misc()

int G_remove_misc ( const char *  dir,
const char *  element,
const char *  name 
)

Remove a database misc file.

The file or directory name under the database element directory in the current mapset is removed.

If name is a directory, everything within the directory is removed as well.

Parameters
elementelement name
namefile name
Returns
0 if name does not exist
1 if successful
-1 on error

Definition at line 65 of file remove.c.

Referenced by G_remove_raster3d_timestamp(), G_remove_raster_timestamp(), Rast3d_remove_color(), Rast__quant_export(), Rast__remove_fp_range(), Rast_remove_histogram(), Rast_write_fp_range(), Rast_write_range(), and Rast_write_rstats().

◆ G_remove_raster3d_timestamp()

int G_remove_raster3d_timestamp ( const char *  name)

Remove timestamp from 3D raster map.

Only timestamp files in current mapset can be removed.

Parameters
namemap name
Returns
0 if no file
1 on success
-1 on failure

Definition at line 627 of file timestamp.c.

References G_remove_misc(), GRID3, and name.

◆ G_remove_raster_timestamp()

int G_remove_raster_timestamp ( const char *  name)

Remove timestamp from raster map.

Only timestamp files in current mapset can be removed.

Parameters
namemap name
Returns
0 if no file
1 on success
-1 on error

Definition at line 407 of file timestamp.c.

References G_remove_misc(), name, and RAST_MISC.

◆ G_remove_vector_timestamp()

int G_remove_vector_timestamp ( const char *  name,
const char *  layer 
)

Remove timestamp from vector map.

Only timestamp files in current mapset can be removed.

Parameters
namemap name
layerThe layer names, in case of NULL, layer one is assumed
Returns
0 if no file
1 on success
-1 on failure

Definition at line 553 of file timestamp.c.

References G_remove(), GNAME_MAX, GPATH_MAX, GV_DIRECTORY, GV_TIMESTAMP_ELEMENT, and name.

◆ G_rename()

int G_rename ( const char *  element,
const char *  oldname,
const char *  newname 
)

Rename a database file.

The file or directory oldname under the database element directory in the current mapset is renamed to newname.

Bug:
This routine does not check to see if the newname name is a valid database file name.
Parameters
elementelement name
oldnamecurrent name
newnamenew name
Returns
0 if oldname does not exist
1 if successful
-1 on error

Definition at line 69 of file rename.c.

References G_file_name(), G_mapset(), G_name_is_fully_qualified(), G_rename_file(), GMAPSET_MAX, GNAME_MAX, and GPATH_MAX.

Referenced by M_do_rename().

◆ G_rename_file()

int G_rename_file ( const char *  oldname,
const char *  newname 
)

Rename a file or a directory in the filesystem.

The file or directory oldname is renamed to newname.

Parameters
oldnamecurrent name
newnamenew name
Returns
0 if successful
-1 on error

Definition at line 31 of file rename.c.

References G_copy_file().

Referenced by G_rename(), and PS_Graph_close().

◆ G_reset_mapsets()

void G_reset_mapsets ( void  )

Reset number of mapsets.

Definition at line 135 of file mapset_nme.c.

References st.

◆ G_rhumbline_lat_from_lon()

double G_rhumbline_lat_from_lon ( double  lon)

Calculates rhumbline latitude.

Note: Function only works if lon1 < lon < lon2.

Parameters
[in]lonlongitude
Returns
double latitude in degrees

Definition at line 97 of file rhumbline.c.

References Degrees, M_PI_2, Radians, and st.

◆ G_rle_compress()

int G_rle_compress ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 73 of file cmprrle.c.

References dst, NULL, and src.

◆ G_rle_expand()

int G_rle_expand ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 139 of file cmprrle.c.

References dst, NULL, and src.

◆ G_rotate_around_point()

void G_rotate_around_point ( double  X0,
double  Y0,
double *  X1,
double *  Y1,
double  angle 
)

Rotate point (double version)

Given a point, angle, and origin, rotate the point around the origin by the given angle. Coordinates and results are double prec floating point.

Parameters
X0X component of origin (center of circle)
Y0Y component of origin (center of circle)
[out]X1X component of point to be rotated (variable is modified!)
[out]Y1Y component of point to be rotated (variable is modified!)
anglein degrees, measured CCW from east

Definition at line 33 of file rotate.c.

Referenced by G_rotate_around_point_int().

◆ G_rotate_around_point_int()

void G_rotate_around_point_int ( int  X0,
int  Y0,
int *  X1,
int *  Y1,
double  angle 
)

Rotate point (int version)

Given a point, angle, and origin, rotate the point around the origin by the given angle. Coordinates are given in integer and results are rounded back to integer.

Parameters
X0X component of origin (center of circle)
Y0Y component of origin (center of circle)
[out]X1X component of point to be rotated (variable is modified!)
[out]Y1Y component of point to be rotated (variable is modified!)
anglein degrees, measured CCW from east

Definition at line 60 of file rotate.c.

References G_rotate_around_point(), and x.

◆ G_saprintf()

int G_saprintf ( char *  str,
const char *  format,
  ... 
)

sprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]strstring buffer
[in]formatstring format
[in]...arguments for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 505 of file aprintf.c.

◆ G_scan_easting()

int G_scan_easting ( const char *  buf,
double *  easting,
int  projection 
)

ASCII easting to double.

Converts the ASCII "easting" coordinate string in buf to its double representation (into easting).

Supported projection codes (see gis.h):

  • PROJECTION_XY
  • PROJECTION_UTM
  • PROJECTION_LL
  • PROJECTION_OTHER
Parameters
bufbuffer containing string easting
[out]eastingeasting
projectionprojection code
Returns
0 on error
1 on success

Definition at line 69 of file wind_scan.c.

References PROJECTION_LL.

◆ G_scan_northing()

int G_scan_northing ( const char *  buf,
double *  northing,
int  projection 
)

ASCII northing to double.

Converts the ASCII "northing" coordinate string in buf to its double representation (into northing).

Supported projection codes (see gis.h):

  • PROJECTION_XY
  • PROJECTION_UTM
  • PROJECTION_LL
  • PROJECTION_OTHER
Parameters
bufbuffer hold string northing
[out]northingnorthing
projectionprojection code
Returns
0 on error
1 on success

Definition at line 38 of file wind_scan.c.

References PROJECTION_LL.

◆ G_scan_resolution()

int G_scan_resolution ( const char *  buf,
double *  res,
int  projection 
)

ASCII resolution to double.

Converts the ASCII "resolution" string in buf to its double representation (into resolution).

Supported projection codes (see gis.h):

  • PROJECTION_XY
  • PROJECTION_UTM
  • PROJECTION_LL
  • PROJECTION_OTHER
Parameters
bufbuffer containing string resolution
[out]resolutionresolution value
projectionprojection code
Returns
0 on error
1 on success

Definition at line 100 of file wind_scan.c.

References G_llres_scan(), and PROJECTION_LL.

◆ G_scan_timestamp()

int G_scan_timestamp ( struct TimeStamp ts,
const char *  buf 
)

Fill a TimeStamp structure from a datetime string.

Populate a TimeStamp structure (defined in gis.h) from a text string. Checks to make sure text string is in valid GRASS datetime format.

Parameters
tsTimeStamp structure to be populated
bufstring containing formatted time info
Returns
1 on success
-1 error

Definition at line 217 of file timestamp.c.

◆ G_set_distance_to_line_tolerance()

void G_set_distance_to_line_tolerance ( double  t)

Definition at line 8 of file gis/line_dist.c.

References t, and TOLERANCE.

◆ G_set_error_routine()

void G_set_error_routine ( int(*)(const char *, int)  error_routine)

Establishes error_routine as the routine that will handle the printing of subsequent error messages.

Parameters
error_routineroutine will be called like this: error_routine(msg, fatal)
Returns

Definition at line 260 of file gis/error.c.

◆ G_set_geodesic_distance_lat1()

void G_set_geodesic_distance_lat1 ( double  lat1)

Sets geodesic distance lat1.

Set the first latitude.

Note: Must be called first.

Parameters
lat1first latitude
Returns

Definition at line 69 of file geodist.c.

References Radians, and st.

Referenced by G_geodesic_distance().

◆ G_set_geodesic_distance_lat2()

void G_set_geodesic_distance_lat2 ( double  lat2)

Sets geodesic distance lat2.

Set the second latitude.

Note: Must be called second.

Parameters
lat2second latitidue

Definition at line 83 of file geodist.c.

References Radians, and st.

Referenced by G_geodesic_distance().

◆ G_set_gisrc_mode()

void G_set_gisrc_mode ( int  mode)

Set where to find/store variables.

Modes:

  • G_GISRC_MODE_FILE
  • G_GISRC_MODE_MEMORY
Parameters
modemode to find/store variables (G_GISRC_MODE_FILE by default)

Definition at line 63 of file env.c.

◆ G_set_key_value()

void G_set_key_value ( const char *  key,
const char *  value,
struct Key_Value kv 
)

Set value for given key.

Parameters
keykey to be set up
valuevalue for given key
[in,out]kvKey_value structure to be modified

Definition at line 39 of file key_value1.c.

Referenced by G_get_projinfo(), and GPJ_osr_to_grass().

◆ G_set_keywords()

void G_set_keywords ( const char *  keywords)

Set keywords from the string.

Parameters
keywordskeywords separated by commas

Definition at line 882 of file parser.c.

References G_number_of_tokens(), G_tokenize(), and st.

◆ G_set_ls_exclude_filter()

void G_set_ls_exclude_filter ( int(*)(const char *, void *)  ,
void *   
)

Referenced by G_ls_regex_filter().

◆ G_set_ls_filter()

void G_set_ls_filter ( int(*)(const char *, void *)  ,
void *   
)

◆ G_set_omp_num_threads()

int G_set_omp_num_threads ( struct Option opt)

Set the number of threads for OpenMP The intended usage is at the beginning of a C tool when parameters are processed, namely the G_OPT_M_NPROCS standard option.

Parameters
optA nprocs Option struct to specify the number of threads
Returns
the number of threads set up for OpenMP parallel computing

Definition at line 19 of file omp_threads.c.

References _, Option::answer, G_fatal_error(), G_verbose_message(), G_warning(), Option::key, and NULL.

◆ G_set_percent_routine()

void G_set_percent_routine ( int(*)(int)  percent_routine)

Establishes percent_routine as the routine that will handle the printing of percentage progress messages.

Parameters
percent_routineroutine will be called like this: percent_routine(x)

Definition at line 192 of file percent.c.

◆ G_set_program_name()

void G_set_program_name ( const char *  s)

Set program name.

Program name set to name (name will be returned by G_program_name*())

Extension like .exe or .py is stripped from program name.

Parameters
sprogram name

Definition at line 61 of file progrm_nme.c.

◆ G_set_timestamp()

void G_set_timestamp ( struct TimeStamp ,
const struct DateTime  
)

◆ G_set_timestamp_range()

void G_set_timestamp_range ( struct TimeStamp ,
const struct DateTime ,
const struct DateTime  
)

◆ G_set_verbose()

int G_set_verbose ( int  level)

Set verbosity level.

Parameters
levelnew verbosity level (-1,0,1,2,3)
Returns
0 on invalid verbosity level (verbosity level untouched)
1 on success

Definition at line 125 of file verbose.c.

References G_initialize_done(), G_is_initialized(), MAXLEVEL, MINLEVEL, and st.

◆ G_set_window()

void G_set_window ( struct Cell_head window)

Establishes window as the current working window (region).

This function adjusts the window before setting the region so you don't have to call G_adjust_Cell_head().

Note
Only the current process is affected.
Parameters
windowwindow to become operative window
See also
G_get_set_window(), G_put_window()

Definition at line 53 of file gis/set_window.c.

◆ G_setenv()

void G_setenv ( const char *  name,
const char *  value 
)

Set environment variable (updates .gisrc)

If value is NULL, becomes an G_unsetenv().

Parameters
namevariable name
valuevariable value

Definition at line 442 of file env.c.

◆ G_setenv2()

void G_setenv2 ( const char *  name,
const char *  value,
int  loc 
)

Set environment variable from specific place (updates .gisrc)

If value is NULL, becomes an G_unsetenv().

Parameters
namevariable name
valuevariable value
loclocation (G_VAR_GISRC, G_VAR_MAPSET)

Definition at line 459 of file env.c.

Referenced by db_set_connection(), and tgis_set_connection().

◆ G_setenv_nogisrc()

void G_setenv_nogisrc ( const char *  name,
const char *  value 
)

Set environment name to value (doesn't update .gisrc)

Parameters
namevariable name
valuevariable value

Definition at line 472 of file env.c.

Referenced by G_check_overwrite(), and G_make_mapset().

◆ G_setenv_nogisrc2()

void G_setenv_nogisrc2 ( const char *  name,
const char *  value,
int  loc 
)

Set environment name to value from specific place (doesn't update .gisrc)

Parameters
namevariable name
valuevariable value
loclocation (G_VAR_GISRC, G_VAR_MAPSET)

Definition at line 486 of file env.c.

◆ G_setup_fill()

void G_setup_fill ( int  gap)

Set row_fill routine to row_solid_fill or row_dotted_fill.

After calling this function, G_plot_polygon() and G_plot_area() fill shapes with solid or dotted lines. If gap is greater than zero, this value will be used for row_dotted_fill. Otherwise, row_solid_fill is used.

Parameters
gap

Definition at line 133 of file plot.c.

References st.

◆ G_setup_plot()

void G_setup_plot ( double  t,
double  b,
double  l,
double  r,
int(*)(int, int)  Move,
int(*)(int, int)  Cont 
)

Initialize plotting routines.

Initializes the plotting capability. This routine must be called once before calling the G_plot_*() routines described below. The parameters t, b, l, r are the top, bottom, left, and right of the output x,y coordinate space. They are not integers, but doubles to allow for subpixel registration of the input and output coordinate spaces. The input coordinate space is assumed to be the current GRASS region, and the routines supports both planimetric and latitude-longitude coordinate systems.

Move and Cont are subroutines that will draw lines in x,y space. They will be called as follows:

  • Move(x, y) move to x,y (no draw)
  • Cont(x, y) draw from previous position to x,y. Cont(~) is responsible for clipping
Parameters
t,b,l,rtop, bottom, left, right
moveMove function
ContCont function

Definition at line 97 of file plot.c.

References b, G_get_set_window(), l, r, st, and t.

◆ G_shortest_way()

void G_shortest_way ( double *  east1,
double *  east2 
)

Shortest way between two eastings.

For lat-lon projection (PROJECTION_LL), east1, east2 are changed so that they are no more than 180 degrees apart. Their true locations are not changed. For all other projections, this function does nothing.

Parameters
[in,out]east1east (x) coordinate of first point
[in,out]east2east (x) coordinate of second point

Definition at line 28 of file short_way.c.

References G_projection(), and PROJECTION_LL.

◆ G_sleep()

void G_sleep ( unsigned int  seconds)

Definition at line 11 of file sleep.c.

Referenced by dig_falloc(), dig_frealloc(), and main().

◆ G_sleep_on_error()

int G_sleep_on_error ( int  flag)

Turn on/off no_sleep flag.

If flag is 0, then no pause will occur after printing an error or warning message. Otherwise the pause will occur.

Parameters
flagif non-zero/zero value is given G_sleep() will be activated/deactivated
Returns
previous no_sleep value

Definition at line 242 of file gis/error.c.

◆ G_snaprintf()

int G_snaprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

snprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]strstring buffer
[in]sizestring buffer size
[in]formatstring format
[in]...arguments for the format string
Returns
number of bytes that would be printed if size was big enough or fatal error on error

Definition at line 527 of file aprintf.c.

◆ G_snprintf()

int G_snprintf ( char *  ,
size_t  ,
const char *  ,
  ... 
)

◆ G_squeeze()

void G_squeeze ( char *  line)

Remove superfluous white space.

Leading and trailing white space is removed from the string line and internal white space which is more than one character is reduced to a single space character. White space here means spaces, tabs, linefeeds, newlines, and formfeeds.

Parameters
[in,out]line
Returns
Pointer to line

Definition at line 446 of file strings.c.

◆ G_srand48()

void G_srand48 ( long  seedval)

Seed the pseudo-random number generator.

Parameters
seedval32-bit integer used to seed the PRNG

Definition at line 53 of file lrand48.c.

References x.

Referenced by G_math_srand(), and G_srand48_auto().

◆ G_srand48_auto()

long G_srand48_auto ( void  )

Seed the pseudo-random number generator from the time and PID.

A weak hash of the current time and PID is generated and used to seed the PRNG

Returns
generated seed value passed to G_srand48()

Definition at line 72 of file lrand48.c.

References _, G_fatal_error(), G_srand48(), NULL, and t.

Referenced by G_math_srand_auto().

◆ G_stat()

int G_stat ( const char *  file_name,
struct stat *  buf 
)

Get file status.

Returns information about the specified file.

Parameters
file_namefile name
statpointer to structure filled with file information
Returns
Return value from system lstat function

Definition at line 128 of file paths.c.

Referenced by G_get_available_mapsets(), G_mapset_permissions(), G_mapset_permissions2(), and G_owner().

◆ G_store()

char* G_store ( const char *  s)

Copy string to allocated memory.

This routine allocates enough memory to hold the string s, copies s to the allocated memory, and returns a pointer to the allocated memory.

If s is NULL then empty string is returned.

Parameters
sstring
Returns
pointer to newly allocated string

Definition at line 87 of file strings.c.

Referenced by cairo_read_ppm(), cairo_write_ppm(), db_get_default_database_name(), db_get_default_driver_name(), db_get_default_group_name(), db_get_default_schema_name(), db_whoami(), dig_read_frmt_ascii(), G__read_Cell_head(), G_add_keyword(), G_config_path(), G_define_standard_option(), G_fully_qualified_name(), G_get_available_mapsets(), G_ls2(), G_myname(), G_option_to_separator(), G_parser(), G_putenv(), GPJ__get_datum_params(), GPJ_get_datum_by_name(), GPJ_get_default_datum_params_by_name(), GPJ_get_ellipsoid_by_name(), GPJ_init_transform(), GPJ_osr_to_grass(), I_iclass_init_statistics(), I_SetClassTitle(), I_SetSigTitle(), M__add_element(), Rast3d_open_cell_old_no_header(), Rast3d_set_unit(), Rast__open_null_write(), Rast__read_history(), Rast_append_history(), Rast_get_cell_title(), Rast_get_semantic_label_or_name(), Rast_get_vrt(), Rast_mask_info(), Rast_set_cats_title(), Rast_set_d_cat(), Rast_set_history(), read_pgm(), tgis_get_database_name(), tgis_get_default_database_name(), tgis_get_driver_name(), Vect_close(), Vect_get_dblink(), Vect_get_finfo_geometry_type(), Vect_get_finfo_layer_name(), Vect_get_finfo_topology_info(), Vect_get_proj_name(), Vect_maptype_info(), Vect_read_area_to_wkt2(), Vect_set_comment(), Vect_set_date(), Vect_set_map_date(), Vect_set_map_name(), Vect_set_organization(), Vect_set_person(), and write_pgm().

◆ G_store_lower()

char* G_store_lower ( const char *  s)

Copy string to allocated memory and convert copied string to lower case.

This routine allocates enough memory to hold the string s, copies s to the allocated memory, and returns a pointer to the allocated memory.

If s is NULL then empty string is returned.

Parameters
sstring
Returns
pointer to newly allocated lower case string

Definition at line 141 of file strings.c.

◆ G_store_upper()

char* G_store_upper ( const char *  s)

Copy string to allocated memory and convert copied string to upper case.

This routine allocates enough memory to hold the string s, copies s to the allocated memory, and returns a pointer to the allocated memory.

If s is NULL then empty string is returned.

Parameters
sstring
Returns
pointer to newly allocated upper case string

Definition at line 117 of file strings.c.

Referenced by GPJ_init_transform().

◆ G_str_concat()

char* G_str_concat ( const char **  src_strings,
int  num_strings,
const char *  sep,
int  maxsize 
)

String concatenation.

Concatenates the strings in src_strings, which consists of num_strings number of strings, with the separator sep. The size of the concatenated string is limited by maxsize.

Parameters
src_stringsarray of strings to concatenate
num_stringscount of strings in src_strings
sepseparator string
maxsizemaximum number of characters of returned string
Returns
the concatenated string (allocated)

Definition at line 267 of file strings.c.

References NULL.

◆ G_str_replace()

char* G_str_replace ( const char *  buffer,
const char *  old_str,
const char *  new_str 
)

Replace all occurrences of old_str in buffer with new_str.

Code example:

char *name;
name = G_str_replace ( inbuf, ".exe", "" );
...
G_free (name);
char * G_str_replace(const char *, const char *, const char *)
Replace all occurrences of old_str in buffer with new_str.
Definition: strings.c:189
Parameters
bufferinput string buffer
old_strstring to be replaced
new_strnew string
Returns
the newly allocated string, input buffer is unchanged

Definition at line 189 of file strings.c.

Referenced by Vect_get_finfo_geometry_type().

◆ G_str_to_lower()

void G_str_to_lower ( char *  str)

Convert string to lower case.

Parameters
[in,out]strpointer to string

Definition at line 383 of file strings.c.

Referenced by Vect_get_finfo_geometry_type().

◆ G_str_to_sql()

int G_str_to_sql ( char *  str)

Make string SQL compliant.

Parameters
[in,out]strpointer to string
Returns
number of changed characters

Definition at line 403 of file strings.c.

References count.

◆ G_str_to_upper()

void G_str_to_upper ( char *  str)

Convert string to upper case.

Parameters
[in,out]strpointer to string

Definition at line 365 of file strings.c.

◆ G_strcasecmp()

int int G_strcasecmp ( const char *  x,
const char *  y 
)

String compare ignoring case (upper or lower)

Returning a value that has the same sign as the difference between the first differing pair of characters.

Note: strcasecmp() is affected by the locale (LC_CTYPE), while G_strcasecmp() isn't.

Parameters
xfirst string to compare
ysecond string to compare
Returns
0 the two strings are equal
-1, 1

Definition at line 47 of file strings.c.

Referenced by AS_option_to_algorithm(), Cairo_Graph_set(), check_mapset_in_layer_name(), clean_dir(), dig_read_frmt_ascii(), G_compressor_number(), G_str_to_color(), GPJ_get_datum_by_name(), GPJ_get_ellipsoid_by_name(), GPJ_osr_to_grass(), M_do_copy(), M_do_remove(), M_do_rename(), M_get_element(), PNG_Graph_set(), PS_Graph_set(), Rast_close_gdal_write_link(), read_image(), V1_close_nat(), Vect_close(), Vect_set_db_updated(), and write_image().

◆ G_strcasestr()

char* G_strcasestr ( const char *  str,
const char *  substr 
)

Finds the first occurrence of the sub-string in the null-terminated string ignoring case (upper or lower)

Parameters
strstring where to find sub-string
substrsub-string
Returns
a pointer to the first occurrence of sub-string
NULL if no occurrences are found

Definition at line 477 of file strings.c.

References G_strncasecmp(), and NULL.

◆ G_strchg()

char* G_strchg ( char *  bug,
char  character,
char  new 
)

Replace all occurrences of character in string bug with new.

Parameters
[in,out]bugbase string
charactercharacter to replace
newnew character
Returns
bug string

Definition at line 160 of file strings.c.

◆ G_strip()

void G_strip ( char *  buf)

Removes all leading and trailing white space from string.

Parameters
[in,out]bufbuffer to be worked on

Definition at line 300 of file strings.c.

Referenced by Rast_get_cell_title(), Rast_set_cats_title(), and Rast_set_d_cat().

◆ G_strlcat()

size_t G_strlcat ( char *  dst,
const char *  src,
size_t  dsize 
)

Size-bounded string concatenation.

Appends string src to the end of dst. It will append at most dstsize - strlen(dst) - 1 characters. It will then NUL-terminate, unless dstsize is 0 or the original dst string was longer than dstsize (in practice this should not happen as it means that either dstsize is incorrect or that dst is not a proper string).

If the src and dst strings overlap, the behavior is undefined. This function is a safer alternative to strncat.

Parameters
[out]dstPointer to the destination buffer. Must be a NUL-terminated C string.
[in]srcPointer to the source string, which will be appended. Must be a NUL-terminated C string.
[in]dsizeThe size of the destination buffer.
Returns
The total length of the string src, which was attempted to be created (the initial length of dst plus the length of src, not including the terminating NUL character). If the return value is >= dsize, truncation occurred.

Definition at line 57 of file strlcat.c.

References dst, and src.

◆ G_strlcpy()

size_t G_strlcpy ( char *  dst,
const char *  src,
size_t  dsize 
)

Safe string copy function.

Copy string src to buffer dst of size dsize. At most dsize-1 characters will be copied. Always NUL terminates (unless dsize == 0). This function is a safer alternative to strncpy.

Parameters
[out]dstPointer to the destination buffer.
[in]srcPointer to the source string. Must be a NUL-terminated C string.
[in]dsizeThe size of the destination buffer.
Returns
The total length of the string src (not including the terminating NUL character). If the return value is >= dsize, truncation occurred.
Note
If truncation occurred, the return value is the length of the string that would have been created if enough space had been available.
Warning
This function does not pad the destination buffer with NUL bytes if the source string is shorter than dsize-1 bytes, unlike strncpy.
The src string must be a valid NUL-terminated C string. Passing an unterminated string may result in buffer overrun.

Definition at line 52 of file strlcpy.c.

References dst, and src.

Referenced by dig_read_frmt_ascii(), G_matrix_print(), and Rast__mask_info().

◆ G_strncasecmp()

int G_strncasecmp ( const char *  x,
const char *  y,
int  n 
)

String compare ignoring case (upper or lower) - limited number of characters.

Returning a value that has the same sign as the difference between the first differing pair of characters.

Note: strcasecmp() is affected by the locale (LC_CTYPE), while G_strcasecmp() isn't.

Parameters
xfirst string to compare
ysecond string to compare
nnumber or characters to compare
Returns
0 the two strings are equal
-1, 1

Definition at line 69 of file strings.c.

Referenced by check_create_export_opts(), check_create_import_opts(), and G_strcasestr().

◆ G_suppress_warnings()

void int G_suppress_warnings ( int  flag)

Suppress printing a warning message to stderr.

Parameters
flaga warning message will be suppressed if non-zero value is given
Returns
previous flag

Definition at line 222 of file gis/error.c.

Referenced by I_get_group(), I_get_group_title(), I_get_subgroup(), and I_get_target().

◆ G_switch_env()

void G_switch_env ( void  )

Switch environments.

Definition at line 591 of file env.c.

Referenced by G_make_mapset().

◆ G_switch_search_path()

void G_switch_search_path ( void  )

Switch mapset search path.

Definition at line 117 of file mapset_nme.c.

References count, and st.

◆ G_temp_element()

void G_temp_element ( char *  element)

Populates element with a path string.

Parameters
[out]elementelement name

Definition at line 147 of file tempfile.c.

References FALSE, and G__temp_element().

Referenced by G_tempfile_pid(), and main().

◆ G_tempfile()

char* G_tempfile ( void  )

Returns a temporary file name.

This routine returns a pointer to a string containing a unique temporary file name that can be used as a temporary file within the module. Successive calls to G_tempfile() will generate new names. Only the file name is generated. The file itself is not created. To create the file, the module must use standard UNIX functions which create and open files, e.g., creat() or fopen().

Successive calls will generate different names the names are of the form pid.n where pid is the programs process id number and n is a unique identifier.

Note: It is recommended to unlink() (remove) the temp file on exit/error. Only if GRASS is left with 'exit', the GIS mapset management will clean up the temp directory (ETC/clean_temp).

Returns
pointer to a character string containing the name. The name is copied to allocated memory and may be released by the unix free() routine.

Definition at line 62 of file tempfile.c.

References G_tempfile_pid().

◆ G_tempfile_basedir()

char* G_tempfile_basedir ( const char *  basedir)

Returns a temporary file name.

Similar to G_tempfile(), but the temporary file name will include a provided base directory instead of the path to the current mapset.

Returns
pointer to a character string containing the name. The name is copied to allocated memory and may be released by the unix free() routine.

Definition at line 77 of file tempfile.c.

References G_tempfile_pid_basedir().

◆ G_tempfile_pid()

char* G_tempfile_pid ( int  pid)

Create tempfile from process id.

See G_tempfile().

Parameters
pid
Returns
pointer to string path

Definition at line 90 of file tempfile.c.

References G_counter_next(), G_init_tempfile(), G_temp_element(), GNAME_MAX, GPATH_MAX, and name.

Referenced by G_tempfile().

◆ G_tempfile_pid_basedir()

char* G_tempfile_pid_basedir ( int  pid,
const char *  basedir 
)

Create tempfile from process id in given base directory.

See G_tempfile_basedir().

Parameters
pid
Returns
pointer to string path

Definition at line 120 of file tempfile.c.

References G__temp_element_basedir(), G_counter_next(), G_init_tempfile(), GNAME_MAX, GPATH_MAX, and name.

Referenced by G_tempfile_basedir().

◆ G_tokenize()

char** G_tokenize ( const char *  buf,
const char *  delim 
)

Tokenize string.

Given a string, buf, turn delimiter, delim, into '\0' (NULL) and place pointers to tokens in tokens. buf must not contain a new line (
). delim may consist of more than one character. G_free_tokens() must be called when finished with tokens to release memory.

Example:

char **tokens;
int ntok, i;
tokens = G_tokenize(buf, " |:,");
ntok = G_number_of_tokens(tokens);
for (i=0; i < ntok; i++) {
G_debug(1, "%d=[%s]", i, tokens[i]);
}
G_free_tokens(tokens);
void G_free_tokens(char **)
Free memory allocated to tokens.
Definition: gis/token.c:198
int G_number_of_tokens(char **)
Return number of tokens.
Definition: gis/token.c:179
int G_debug(int, const char *,...) __attribute__((format(printf
char ** G_tokenize(const char *, const char *)
Tokenize string.
Definition: gis/token.c:47
Parameters
bufinput string
delimstring delimiter
Returns
pointer to string token

Definition at line 47 of file gis/token.c.

Referenced by check_create_export_opts(), check_create_import_opts(), check_mapset_in_layer_name(), G_set_keywords(), and Vect__open_cursor_next_line_pg().

◆ G_tokenize2()

char** G_tokenize2 ( const char *  buf,
const char *  delim,
const char *  valchar 
)

Tokenize string.

This function behaves similarly to G_tokenize().

It introduces valchar which defines borders of token. Within token delim is ignored.

Example:

char *str = "a,'b,c',d";
char **tokens1, **tokens2;
int ntok1, ntok2;
tokens1 = G_tokenize(str, ",");
ntok1 = G_number_of_tokens(tokens1);
tokens1 = G_tokenize2(str, ",", "'");
ntok2 = G_number_of_tokens(tokens2);
char ** G_tokenize2(const char *, const char *, const char *)
Tokenize string.
Definition: gis/token.c:83

In this example ntok1 will be 4, ntok2 only 3, i.e. { "a", "'b, c'", "d"}

Parameters
bufinput string
delimstring delimiter
valcharcharacter defining border of token
Returns
pointer to string token

Definition at line 83 of file gis/token.c.

◆ G_tolcase()

char* G_tolcase ( char *  string)

convert string to lower case

Upper case letters in the string s are converted to their lower case equivalent. Returns s.

Parameters
string
Returns
char

Definition at line 18 of file mapcase.c.

◆ G_toucase()

char* G_toucase ( char *  string)

convert string to upper case

Lower case letters in the string s are converted to their upper case equivalent. Returns s.

Parameters
string
Returns
char

Definition at line 46 of file mapcase.c.

◆ G_transverse_radius_of_curvature()

double G_transverse_radius_of_curvature ( double  lon,
double  a,
double  e2 
)

Transverse radius of curvature.

Returns the transverse radius of curvature at a given longitude:

$ \nu = \frac{a}{(1-e^2\sin^2 lon)^{1/2}} $

Parameters
lonlongitude
aellipsoid semi-major axis
e2ellipsoid eccentricity squared
Returns
radius value

Definition at line 106 of file radii.c.

◆ G_trim_decimal()

void G_trim_decimal ( char *  buf)

Removes trailing zeros from decimal number.

Example: 23.45000 would come back as 23.45

Parameters
[in,out]buf

Definition at line 24 of file trim_dec.c.

Referenced by db_convert_value_to_string(), and Rast3d_write_cats().

◆ G_units()

int G_units ( const char *  units_name)

Get units code by name.

Units codes (gis.h):

  • U_METERS
  • U_KILOMETERS
  • U_ACRES
  • U_HECTARES
  • U_MILES
  • U_FEET
  • U_USFEET
  • ...
  • U_YEARS
  • ...
Parameters
units_nameunits name (singular or plural form)
Returns
units code
U_UNKNOWN if not found

Definition at line 320 of file units.c.

References G_database_unit_name(), G_units(), NULL, U_ACRES, U_DAYS, U_DEGREES, U_FEET, U_HECTARES, U_HOURS, U_KILOMETERS, U_METERS, U_MILES, U_MINUTES, U_MONTHS, U_SECONDS, U_UNKNOWN, U_USFEET, and U_YEARS.

Referenced by G_get_units_name(), G_units(), and Rast3d_set_vertical_unit().

◆ G_unqualified_name()

int G_unqualified_name ( const char *  name,
const char *  mapset,
char *  xname,
char *  xmapset 
)

Returns unqualified map name (without @ mapset)

Returns an unqualified name for the file name in mapset.

Note:

  • name, xname are char array of size GNAME_MAX
  • mapset, xmapset are char array of size GMAPSET_MAX
Parameters
namemap name
mapsetmapset to check or NULL
[out]xnamemap name
[out]xmapsetmapset name
Returns
1 if input map name is fully qualified
0 if name is not fully qualified
-1 if input mapset invalid (mapset != xmapset)

Definition at line 134 of file nme_in_mps.c.

References G_name_is_fully_qualified(), name, and strcpy.

Referenced by I_fopen_signature_file_old(), I_fopen_sigset_file_old(), Rast3d_open_cell_old_no_header(), Rast__open_null_write(), and Rast__open_old().

◆ G_unset_error_routine()

void G_unset_error_routine ( void  )

After this call subsequent error messages will be handled in the default method.

Error messages are printed directly to the screen: ERROR: message or WARNING: message

Returns
0

Definition at line 274 of file gis/error.c.

◆ G_unset_percent_routine()

void G_unset_percent_routine ( void  )

After this call subsequent percentage progress messages will be handled in the default method.

Percentage progress messages are printed directly to stderr.

Definition at line 203 of file percent.c.

◆ G_unset_window()

void G_unset_window ( void  )

Unset current region.

Definition at line 135 of file get_window.c.

References st, and G__::window_set.

◆ G_unsetenv()

void G_unsetenv ( const char *  name)

Remove name from environment.

Updates .gisrc

Parameters
namevariable name

Definition at line 499 of file env.c.

◆ G_unsetenv2()

void G_unsetenv2 ( const char *  name,
int  loc 
)

Remove name from environment from specific place.

Updates .gisrc

Parameters
namevariable name
loclocation (G_VAR_GISRC, G_VAR_MAPSET)

Definition at line 514 of file env.c.

Referenced by db_set_connection().

◆ G_update_key_value_file()

void G_update_key_value_file ( const char *  file,
const char *  key,
const char *  value 
)

Update file, set up value for given key.

Parameters
[in]filefilename to be updated
[in]keykey value
[in]valuevalue to be updated

Definition at line 26 of file key_value4.c.

◆ G_usage()

void G_usage ( void  )

Command line help/usage message.

Calls to G_usage() allow the programmer to print the usage message at any time. This will explain the allowed and required command line input to the user. This description is given according to the programmer's definitions for options and flags. This function becomes useful when the user enters options and/or flags on the command line that are syntactically valid to the parser, but functionally invalid for the command (e.g. an invalid file name.)

For example, the parser logic doesn't directly support grouping options. If two options be specified together or not at all, the parser must be told that these options are not required and the programmer must check that if one is specified the other must be as well. If this additional check fails, then G_parser() will succeed, but the programmer can then call G_usage() to print the standard usage message and print additional information about how the two options work together.

Definition at line 48 of file parser_help.c.

◆ G_vaprintf()

int G_vaprintf ( const char *  format,
va_list  ap 
)

vprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]formatstring format
[in]apvariable argument list for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 379 of file aprintf.c.

◆ G_vasprintf()

int G_vasprintf ( char **  out,
const char *  fmt,
va_list  ap 
)

Safe replacement for asprintf().

Allocate a string large enough to hold the new output, including the terminating NULL, and return the number of characters printed. The pointer out is set to the output string and should be passed to G_free() to release the allocated storage when it is no longer needed.

Parameters
[out]out
[in]fmt
ap
Returns
number of bytes written

Definition at line 41 of file asprintf.c.

References count, G_malloc, and G_realloc.

Referenced by G_asprintf(), Rast_append_format_history(), and Rast_format_history().

◆ G_verbose()

int G_verbose ( void  )

Get current verbosity level.

Currently, there are 5 levels of verbosity (see return codes)

Returns
-1 - nothing will be printed (also errors and warnings will be also discarded)
0 - nothing will be printed except of errors and warnings (G_fatal_error(), G_warning()). Triggered by –q or –quiet flag..
1 - only progress information (G_percent()) and important messages (G_important_message()) will be printed
2 - all messages (G_message() and G_important_message()) will be printed
3 - also verbose messages (G_verbose_message()) will be printed. Triggered by –v or –verbose flag.

Definition at line 60 of file verbose.c.

References G_initialize_done(), G_is_initialized(), st, and STDLEVEL.

Referenced by G_fatal_error(), G_important_message(), G_init_all(), G_message(), G_verbose_message(), and notice_processor().

◆ G_verbose_max()

int G_verbose_max ( void  )

Get max verbosity level.

Returns
max verbosity level

Definition at line 81 of file verbose.c.

References MAXLEVEL.

◆ G_verbose_message()

void void G_verbose_message ( const char *  ,
  ... 
)

◆ G_verbose_min()

int G_verbose_min ( void  )

Get min verbosity level.

Returns
min verbosity level

Definition at line 101 of file verbose.c.

References MINLEVEL.

Referenced by G_important_message().

◆ G_verbose_std()

int G_verbose_std ( void  )

Get standard verbosity level.

Returns
standard verbosity level

Definition at line 91 of file verbose.c.

References STDLEVEL.

Referenced by G_message(), G_parser(), G_verbose_message(), and notice_processor().

◆ G_vfaprintf()

int G_vfaprintf ( FILE *  stream,
const char *  format,
va_list  ap 
)

vfprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]streamfile pointer
[in]formatstring format
[in]apvariable argument list for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 392 of file aprintf.c.

◆ G_vsaprintf()

int G_vsaprintf ( char *  str,
const char *  format,
va_list  ap 
)

vsprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]strstring buffer
[in]formatstring format
[in]apvariable argument list for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 411 of file aprintf.c.

◆ G_vsnaprintf()

int G_vsnaprintf ( char *  str,
size_t  size,
const char *  format,
va_list  ap 
)

vsnprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]strstring buffer
[in]sizestring buffer size
[in]formatstring format
[in]apvariable argument list for the format string
Returns
number of bytes that would be printed if size was big enough or fatal error on error

Definition at line 432 of file aprintf.c.

◆ G_warning()

void G_warning ( const char *  ,
  ... 
)

Referenced by clean_dir(), close_g3d_file(), D_close_driver(), db_delete_table(), db_get_table_number_of_rows(), db_start_driver_open_database(), dig__read_head(), dig_out_of_memory(), dig_Rd_Plus_head(), dig_Rd_spidx_head(), dig_read_cidx_head(), dig_read_frmt_ascii(), dig_write_plus_file(), fopen_group_file_old(), fopen_subgroup_file_old(), G__matrix_add(), G_bz2_compress(), G_bz2_expand(), G_copy_file(), G_get_projinfo(), G_get_projunits(), G_lz4_compress(), G_lz4_expand(), G_matrix_init(), G_matrix_inverse(), G_matrix_LU_solve(), G_matrix_product(), G_matrix_read(), G_matrix_scalar_mul(), G_matrix_set_element(), G_matvect_extract_vector(), G_matvect_get_column(), G_matvect_get_row(), G_parser(), G_put_3dview(), G_read_compressed(), G_set_omp_num_threads(), G_vector_copy(), G_vector_init(), G_vector_norm1(), G_vector_product(), G_vector_sub(), G_write_compressed(), G_write_uncompressed(), G_zlib_compress(), G_zlib_expand(), G_zstd_compress(), G_zstd_expand(), gk_make_linear_framesfromkeys(), GP_str_to_marker(), GPJ_init_transform(), GPJ_osr_to_grass(), gs_err(), Gs_load_3dview(), gs_malloc_lookup(), GS_write_ppm(), GS_write_tif(), GS_write_zoom(), gsd_rot(), I_cluster_exec(), I_create_cat_rast(), I_fopen_group_file_append(), I_fopen_group_file_new(), I_fopen_subgroup_file_append(), I_fopen_subgroup_file_new(), I_get_control_points(), I_get_target(), I_iclass_analysis(), I_iclass_init_group(), I_iclass_statistics_get_histo(), I_iclass_statistics_get_max(), I_iclass_statistics_get_mean(), I_iclass_statistics_get_min(), I_iclass_statistics_get_product(), I_iclass_statistics_get_range_max(), I_iclass_statistics_get_range_min(), I_iclass_statistics_get_stddev(), I_iclass_statistics_get_sum(), I_put_control_points(), I_ReadSigSet(), M_do_copy(), M_do_remove(), M_do_rename(), main(), NetA_distance_to_points(), NetA_initialise_varray(), NetA_strongly_connected_components(), NetA_timetable_shortest_path(), NetA_weakly_connected_components(), Nviz_color_from_str(), Nviz_make_current_render_window(), Nviz_set_focus_state(), P_Create_Aux2_Table(), P_Create_Aux4_Table(), parse_fontcap(), Rast3d_read_range(), Rast3d_rewrite_header(), Rast__check_for_auto_masking(), Rast__check_fp_type(), Rast__close_null(), Rast__quant_import(), Rast_close_gdal_write_link(), Rast_is_null_value(), Rast_read_fp_range(), Rast_read_histogram(), Rast_read_history(), Rast_read_range(), Rast_set_null_value(), Rast_write_quant(), rbtree_create(), Rowio_setup(), seg_pageout(), seg_setup(), Segment_init(), Segment_put(), SimpleErrorMessage(), V1_close_pg(), V1_delete_line_ogr(), V1_delete_line_pg(), V1_open_new_ogr(), V1_open_new_pg(), V1_open_old_nat(), V1_open_old_ogr(), V1_open_old_pg(), V2__update_area_pg(), V2__write_area_sfa(), V2_close_ogr(), V2_close_pg(), V2_open_old_ogr(), V2_open_old_pg(), Vect__close_cursor_pg(), Vect__execute_get_value_pg(), Vect__execute_pg(), Vect__load_map_lines_pg(), Vect__load_map_nodes_pg(), Vect__load_plus_head(), Vect__open_cursor_next_line_pg(), Vect__read_head(), Vect__write_head(), Vect_area_alive(), Vect_build_line_area(), Vect_build_ogr(), Vect_build_pg(), Vect_build_sidx_from_topo(), Vect_cats_in_constraint(), Vect_cats_set_constraint(), Vect_cidx_open(), Vect_close(), Vect_coor_info(), Vect_copy(), Vect_copy_map_dblinks(), Vect_fidx_dump(), Vect_get_area_box(), Vect_get_area_points(), Vect_get_area_points_geos(), Vect_get_dblink(), Vect_get_finfo_dsn_name(), Vect_get_finfo_format_info(), Vect_get_finfo_geometry_type(), Vect_get_finfo_layer_name(), Vect_get_finfo_topology_info(), Vect_get_isle_box(), Vect_get_isle_points(), Vect_get_next_line_id(), Vect_get_node_coor(), Vect_isle_alive(), Vect_level(), Vect_map_del_dblink(), Vect_node_alive(), Vect_open_fidx(), Vect_open_topo(), Vect_read_ascii_head(), Vect_read_next_line(), Vect_save_fidx(), Vect_save_frmt(), Vect_save_sidx(), Vect_save_topo(), Vect_set_constraint_field(), Vect_sfa_get_num_features(), Vect_write_dblinks(), vector2perimeters(), and Vedit_delete_area_centroid().

◆ G_whoami()

const char* G_whoami ( void  )

Gets user's name.

Returns a pointer to a string containing the user's login name.

Tries getlogin() first, then goes to the password file. However, some masscomp getlogin() fails in ucb universe because the ttyname(0) rotuine fails in ucb universe. So we check for this, too.

Returns
pointer to string ("anonymous" by default)

Definition at line 35 of file gis/whoami.c.

Referenced by G_init_all(), G_open_mail(), Vect__init_head(), and Vect_hist_command().

◆ G_window_overlap()

int G_window_overlap ( const struct Cell_head window,
double  N,
double  S,
double  E,
double  W 
)

Determines if a box overlays a map window.

Given a map window, and a box of N,S,E,W does the box overlap the map window?

Note: knows about global wrap-around for lat-long.

Parameters
[in]windowpointer to window structure
[in]Nnorth
[in]Ssouth
[in]Eeast
[in]Wwest
Returns
1 if box overlaps window
0 if box does not overlap window

Definition at line 35 of file wind_overlap.c.

◆ G_window_percentage_overlap()

double G_window_percentage_overlap ( const struct Cell_head window,
double  N,
double  S,
double  E,
double  W 
)

Determines percentage of box is contained in the window.

This version returns the percentage (from 0 to 1) of the box contained in the window. This feature can be used during vector plotting to decide if it is more efficient to do a level-one read of the whole vector map, or to pay the price of a level-two startup so only those arcs that enter the window are actually read.

Parameters
[in]windowpointer to widnow structure
[in]Nnorth
[in]Ssouth
[in]Eeast
[in]Wwest
Returns
percentage of overlap

Definition at line 80 of file wind_overlap.c.

◆ G_write_compressed()

int G_write_compressed ( int  fd,
unsigned char *  src,
int  nbytes,
int  number 
)

◆ G_write_key_value_file()

void G_write_key_value_file ( const char *  file,
const struct Key_Value kv 
)

Write key/value pairs to file.

Parameters
filefilename for writing
kvpointer Key_Value structure
Returns
0 success
1 error writing

Definition at line 28 of file key_value3.c.

References _, file, G_fatal_error(), and G_fwrite_key_value().

◆ G_write_projsrid()

int G_write_projsrid ( const char *  location_name,
const char *  sridstring 
)

Write srid (spatial reference id) to file.

A srid consists of an authority name and code and must be known to PROJ.

Parameters
location_namename of the location to write the srid
sridstringpointer to srid string
Returns
0 success
-1 error writing

Definition at line 563 of file make_loc.c.

References _, err(), G_fatal_error(), G_file_name(), G_gisdbase(), GPATH_MAX, and SRID_FILE.

◆ G_write_projwkt()

int G_write_projwkt ( const char *  location_name,
const char *  wktstring 
)

Write WKT definition to file.

Any WKT string and version recognized by PROJ is supported.

Parameters
location_namename of the location to write the WKT definition
wktstringpointer to WKT string
Returns
0 success
-1 error writing

Definition at line 511 of file make_loc.c.

References _, err(), G_fatal_error(), G_file_name(), G_gisdbase(), GPATH_MAX, and WKT_FILE.

◆ G_write_raster3d_timestamp()

int G_write_raster3d_timestamp ( const char *  name,
const struct TimeStamp ts 
)

Write timestamp of 3D raster map.

Parameters
namemap name
[out]tsTimeStamp struct to populate
Returns
1 on success
-1 error - can't create timestamp file
-2 error - invalid datetime in ts

Definition at line 611 of file timestamp.c.

◆ G_write_raster_timestamp()

int G_write_raster_timestamp ( const char *  name,
const struct TimeStamp ts 
)

Write timestamp of raster map.

Parameters
namemap name
[out]tsTimeStamp struct to populate
Returns
1 on success
-1 error - can't create timestamp file
-2 error - invalid datetime in ts

Definition at line 391 of file timestamp.c.

◆ G_write_timestamp()

int G_write_timestamp ( FILE *  fd,
const struct TimeStamp ts 
)

Output TimeStamp structure to a file as a formatted string.

A handy fd might be "stdout".

Parameters
[in,out]fdfile descriptor
tspointer to TimeStamp structure
Returns
0 on success
-1 on error

Definition at line 160 of file timestamp.c.

◆ G_write_unompressed()

int G_write_unompressed ( int  ,
unsigned char *  ,
int   
)

◆ G_write_vector_timestamp()

int G_write_vector_timestamp ( const char *  name,
const char *  layer,
const struct TimeStamp ts 
)

Write timestamp of vector map.

Parameters
namemap name
layerThe layer names, in case of NULL, layer one is assumed
[out]tsTimeStamp struct to populate
Returns
1 on success
-1 error - can't create timestamp file
-2 error - invalid datetime in ts

Definition at line 507 of file timestamp.c.

◆ G_write_zeros()

void G_write_zeros ( int  fd,
size_t  n 
)

Writes n bytes of zero to file descriptor fd

Parameters
[in]fdfile descriptor
[in]nnumber of bytes to write
Returns

Definition at line 30 of file writ_zeros.c.

References _, and G_fatal_error().

◆ G_xdr_get_double()

void G_xdr_get_double ( double *  dst,
const void *  src 
)

Definition at line 89 of file gis/xdr.c.

Referenced by Rast3d_read_range(), and Rast_read_fp_range().

◆ G_xdr_get_float()

void G_xdr_get_float ( float *  dst,
const void *  src 
)

Definition at line 79 of file gis/xdr.c.

◆ G_xdr_get_int()

void G_xdr_get_int ( int *  dst,
const void *  src 
)

Definition at line 69 of file gis/xdr.c.

◆ G_xdr_put_double()

void G_xdr_put_double ( void *  dst,
const double *  src 
)

Definition at line 94 of file gis/xdr.c.

Referenced by Rast_write_fp_range(), and Rast_write_rstats().

◆ G_xdr_put_float()

void G_xdr_put_float ( void *  dst,
const float *  src 
)

Definition at line 84 of file gis/xdr.c.

◆ G_xdr_put_int()

void G_xdr_put_int ( void *  dst,
const int *  src 
)

Definition at line 74 of file gis/xdr.c.

◆ G_zero()

◆ G_zlib_compress()

int G_zlib_compress ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

◆ G_zlib_expand()

int G_zlib_expand ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 165 of file cmprzlib.c.

References _, dst, err(), G_warning(), NULL, and src.

◆ G_zone()

int G_zone ( void  )

Query cartographic zone.

This routine returns the zone for the active region. The meaning for the zone depends on the projection. For example, zone 18 for projection type 1 would be UTM zone 18.

Returns
int cartographic zone

Definition at line 24 of file zone.c.

Referenced by Rast__check_for_auto_masking(), and Vect_get_zone().

◆ G_zstd_compress()

int G_zstd_compress ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 86 of file cmprzstd.c.

References _, dst, err(), G_calloc, G_fatal_error(), G_free(), G_warning(), G_zstd_compress_bound(), NULL, and src.

◆ G_zstd_expand()

int G_zstd_expand ( unsigned char *  src,
int  src_sz,
unsigned char *  dst,
int  dst_sz 
)

Definition at line 162 of file cmprzstd.c.

References _, dst, err(), G_fatal_error(), G_warning(), NULL, and src.