GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
units.c File Reference

GIS Library - Units management and conversion. More...

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

Go to the source code of this file.

Functions

double G_meters_to_units_factor (int units)
 Units conversion from meters to units. More...
 
double G_meters_to_units_factor_sq (int units)
 Units conversion from square meters to square units. More...
 
int G_is_units_type_spatial (int units)
 Check if the unit is of spatial type. More...
 
int G_is_units_type_temporal (int units)
 Check if the unit is of temporal type. More...
 
const char * G_get_units_name (int units, int plural, int square)
 Get localized units name. More...
 
int G_units (const char *units_name)
 Get units code by name. More...
 

Detailed Description

GIS Library - Units management and conversion.

(C) 2001-2010 by the GRASS Development Team

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

Author
Original author CERL
Adopted for libgis by Martin Landa <landa.martin gmail.com> (2010)
Temporal units and unit type check from Soeren gebbert <soerengebbert googlemail.com> (2012)

Definition in file units.c.

Function Documentation

◆ 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 203 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_database_unit_name(), Rast3d_get_vertical_unit(), and Rast3d_print_header().

◆ 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 133 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 165 of file units.c.

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

◆ 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 37 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 87 of file units.c.

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

◆ 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 319 of file units.c.

References G_database_unit_name(), 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(), and Rast3d_set_vertical_unit().