Subissue of #1469956: [Meta] - Improve Views-powered Geofield proximity searches

query function in geofield_proximity_argument.inc

function query() {

    if (!empty($this->argument)) {
      $geocoded = geocoder('yahoo', $this->argument);
      if ($geocoded) {
        $lat  = $geocoded->coords[1];
        $long = $geocoded->coords[0];

        $lat_alias = $this->query->add_field($this->table_alias, $this->definition['field_name'] . '_lat');
        $lon_alias = $this->query->add_field($this->table_alias, $this->definition['field_name'] . '_lon');

        $this->ensure_my_table();

        $field  = "$this->table_alias.$this->real_field";
        $radius = $this->options['radius']['radius_of_earth'];
        $dist   = $this->options['radius']['dist'];

        $haversine = geofield_haversine($lat, $long, $this->table_alias . '.' . $lat_alias, $this->table_alias . '.' . $lon_alias, $radius);

        $this->query->add_where_expression(0, $haversine . ' <= ' . $dist);
      }
    }
  }

Note that $geocoded is hard-coded to accept 'yahoo' as it's geocoder handler.

Comments

phayes’s picture

Yahoo hacked our git repo. Smoking gun.

phayes’s picture

This

        $lat  = $geocoded->coords[1];
        $long = $geocoded->coords[0];

Should be this:

         $centroid = $geocoded->centroid();
        $lat  = $centroid->y();
        $long = $centroid->x();
Brandonian’s picture

Status: Active » Fixed

Non-issue, since geofield_proximity is no longer a submodule.

Status: Fixed » Closed (fixed)

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