Wouldn't it be possible to render long distances as km and short distances as m?
The following example explains what i have in mind:
in geofield_handler_field.inc

  function render($values) {
    $metric = $values->{$this->field};
    if ($metric >= 10) {
      $distance = round($metric,0);
      $distance_m = $distance." km";
    }
    elseif ($metric >= 0.5) {
      $distance = round($metric,1);
      $distance_m = $distance." km";
    }
    else {
      $distance = round($metric,3);
      $distance = $distance*1000;
      $distance_m = $distance." m";
    }
    return $distance_m;
  }

(Unit of Measure: Kilometers)

Comments

Brandonian’s picture

Good idea @e_log! I'll happily accept patches that accomplish this in a configurable manner.

e_log’s picture

Status: Active » Closed (works as designed)

We took a different approach to realize this. Since pages with individual distances are not cacheable (correct me if i'm wrong) we calculated the distance with JavaScript from a WKT field (with a readable output). The downside is of course, its not possible to order the nodes according to distance.

Brandonian’s picture

@e_log, AFAIK, our views integration isn't doing anything that would hinder caching. Was there something in particular that made you think otherwise? If it's true, then we definitely need to fix it.

e_log’s picture

You are right. Of course caching works if you use the distance field in views.
But we wanted to calculate the distance from the logged in user.
Sorry, i forgot to mention this important detail ;).
Our first idea was to overwrite the default values with geolocation values of the logged in user provided by the smart_ip module (see this thread: http://drupal.org/node/1445968). With this approach we would have had a caching problem because the distance field needed to be recalculated for every view of the node.
Now we calculate the distance from a node to the logged in user with JavaScript.

e_log’s picture

Issue summary: View changes

changed wording for clarification.