Similar to #2174515: SQLSTATE[42S22]: Column not found: 1054 Unknown column error when using location data via Relationship, bounding seems broken when processing the argument against data coming in over a relationship. I was testing this against latest dev with patches at comments 14 and 15 on #1839554: BBox argument handler fixes, but found some of the changes were breaking bounding over a relationship. I noticed that at 17425ec the original commit of the patch at comment 14 was reverted. I've come up with an alternative that implements some of the original changes from the reverted patch, and allows bounding to come in over a relationship.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpgeek’s picture

Status: Active » Needs review
FileSize
3.93 KB

Here is the patch. I've tested this with the geocluster stack and loaded bounding over a simple relationship (user->profile2) and over a complex/two-level relationship (user->profile2->field_collection_item). The main points of interest here are (1) figuring out the alias to the relationship then using the alias in the where clauses, and (2) the use of ${lat|lon}_field_obj->real_field when computing the field names. I'm not sure i understand why field vs. real_field works, but generating GeoJSON feeds with related data now works.

mpgeek’s picture

Title: Bounding broken when argument is loaded over a relationship » Bounding broken when loading location data over a relationship
mpgeek’s picture

The patch at #1 breaks the "bounding when location data does NOT come in over a relationship" use case. This patch checks for a relationship on the lat/lon source and adds the tables either over the relationship or directly from the base table (as you would expect).

mariacha1’s picture

Status: Needs review » Needs work

This patch loads an empty set of coordinates if you have relationships that are unrelated to the geolocation fields. In my case, I was needed to pull in a group user, but the fact that I had declared relationships meant that this evaluated to true:

if (count($this->view->relationship) > 0) {

So no geolocation relationship table is being added at all.

Also, the if statement to add lat and lon tables used to be:

  // Add JOIN(s) to query.
   $this->query->add_table($lat_field_table);
    if ($lon_field_table != $lat_field_table) {
      $this->query->add_table($lon_field_table);
    }

But now it's

  // Add JOIN(s) to query.
   $this->query->add_table($lat_field_table);
    if ($lon_field_table != $lat_field_table) {
      $this->query->add_table($lat_field_table);
    }

(That adds the lat field twice.)

Pol’s picture

Status: Needs work » Postponed (maintainer needs more info)

Did this is still working with dev version ?

Thanks

mpgeek’s picture

I believe so. I used it against 7.x-1.x (cc2bc0b) for a production build here: https://github.com/mpgeek/Vista-Map/blob/master/vista_map.make. That SHA isn't that old.

Pol’s picture

Assigned: Unassigned » Pol