You are here

function farm_area_default_units in farmOS 7

Return the default units for an area measure, with optional relative size.

Parameters

string $measure: The measure to use. Possible values are 'area' and 'length'. Defaults to 'area'.

string $size: The relative size of the units to return. Possible values are 'big' and 'small'. Defaults to 'big'. For example, a $size of 'big' with a 'metric' system of measurement will return 'hectares'. A $size of 'small' will return 'square meters'.

Return value

string Returns the a string representing the default units.

4 calls to farm_area_default_units()
farm_area_format_calculated_area in modules/farm/farm_area/farm_area.module
Format a calculated area in the default system of measurement.
farm_area_relative_size in modules/farm/farm_area/farm_area.module
Subjectively define the relative size of an area measurement.
farm_soil_amendment_form in modules/farm/farm_soil/farm_soil.farm_quick.amendment.inc
Soil amendment quick form.
farm_soil_disturbance_form in modules/farm/farm_soil/farm_soil.farm_quick.disturbance.inc
Soil disturbance quick form.

File

modules/farm/farm_area/farm_area.module, line 584

Code

function farm_area_default_units($measure = 'area', $size = 'big') {

  // Get the system of measurement.
  $system = farm_quantity_system_of_measurement();

  // Define the default units for each system of measurement and size.
  // The values returned by this function should exist in
  // farm_quantity_units(), for consistency.
  $default_units = array(
    'metric' => array(
      'area' => array(
        'big' => 'hectares',
        'small' => 'square meters',
      ),
      'length' => array(
        'big' => 'kilometers',
        'small' => 'meters',
      ),
    ),
    'us' => array(
      'area' => array(
        'big' => 'acres',
        'small' => 'square feet',
      ),
      'length' => array(
        'big' => 'miles',
        'small' => 'feet',
      ),
    ),
  );

  // Return the units for the given system of measure and size.
  $units = '';
  if (!empty($default_units[$system][$measure][$size])) {
    $units = $default_units[$system][$measure][$size];
  }
  return $units;
}