Using the result conversion hooks I stumbled upon an error in the convert function and the table generate function.
When the factor is an array it will generate a 500 error.

So for the function _unitsapi_key_table() replace if ($curr_kind == 'temperature') with if (is_array($unit['factor']))

and for the function unitsapi_convert() replace the switch statement with

  $result=0;

  // Execute the conversion factors differently based on the kind.  For example, temperature needs to be executed differently.
  switch ($units[$from]['kind']) {
    case 'temperature':
        $result = _unitsapi_convert_temperature($value, $units[$to]['factor'][$from]);
      break;
  }  
  
  if(!is_array($units[$from]['factor']) && !is_array($units[$to]['factor']))
  {
      $from_si = $units[$from]['factor'];
      $to_si = $units[$to]['factor'];
      $from_convert = $value * $from_si;
      $result = $from_convert / $to_si;
  }

and perhaps you can also provide all the arguments in the alter_hook if someone wishes to overload the function

$args = func_get_args();
  // Allow other modules to modify conversion results.
  drupal_alter('unitsapi_result', $result_array, $args);

I also attached a screenshot that maybe will explain why this is necessary :-) for the function overloading I need to provide the from key as a parameter.

CommentFileSizeAuthor
Selection_004.png51.3 KBbugster

Comments

raspberryman’s picture

Status: Active » Fixed

Thanks for this feedback! I modified the units.xml to now support multiple factors as a given, and updated the module to respect that change. See: http://drupalcode.org/project/unitsapi.git/commit/69044a7

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.