GRASS GIS 8 Programmer's Manual 8.4.1(2025)-45ca3179ab
Loading...
Searching...
No Matches
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.
 
double G_meters_to_units_factor_sq (int units)
 Units conversion from square meters to square units.
 
int G_is_units_type_spatial (int units)
 Check if the unit is of spatial type.
 
int G_is_units_type_temporal (int units)
 Check if the unit is of temporal type.
 
const char * G_get_units_name (int units, int plural, int square)
 Get localized units name.
 
int G_units (const char *units_name)
 Get units code by name.
 

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

References G_database_unit_name(), G_get_units_name(), G_units(), and NULL.

Referenced by G_database_unit_name(), and G_get_units_name().

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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(), and NULL.

Referenced by G_get_units_name(), and G_units().