I have multiple geotags assigned to nodes in a designated geospatial field.
I want to create a view which - for example - only shows the geotags within Spain and Portugal.

So I have created a view with display-fields: node-id, node-title, geotag-longitude and geotag-latitude.
Now I want to set a filter using the geotag field, using the "within" option, the widget "Well known text" and the term "POLYGON((-10.810546875 44.024421519659,3.779296875 43.389081939117,3.1640625 35.389049966912,-10.634765625 35.389049966912,-10.810546875 44.024421519659))" in the box.

I expect to receive in the hitlist only the geotags of Spain and Portugal, but the results list is empty.

The view works correctly when I remove the filter.

Comments

geoffff’s picture

I also tried something similar using "within" and a POLYGON, and got similar (empty) results.

ahtih’s picture

Version: » 6.x-1.x-dev

This might be related to http://drupal.org/node/883032 so you can try the patch there.

martin.l’s picture

Have you found a solution for your requirement in the meantime? I have exactly the same requirement ...

KhaledBlah’s picture

In the file includes/views/geo.views.inc (version: alpha5) on line 479 (function "geo_views_set_target") it says:

$target = geo_value($value, 'wkt', 'array'); // TODO assumption of array

This appearantly leads to problems when using WKT other than POINT. When I use a POLYGON for instance (in a filter) and any of the target functions this will fail. If, however, I change it to

$target = geo_value($value, 'wkt', 'wkt'); // TODO assumption of array

the filter will work as expected. Of course, I know that using 'wkt' twice as parameter causes geo_value to simply return the input value. So I am wondering with which intention the 'array' parameter was used here and what side effects this change might have.

Is there anyone who can enlighten me?

KhaledBlah’s picture

After doing some more testing it looks like the code change in #4 has side effects. The code above only works when the handler that calls the function the code is in is a filter handler. It doesn't work with field or sort handlers appearantly. It also doesn't work when the target is a lat/lon field.

So here is a new version that takes that into account. To apply it modify includes/views/geo.views.inc and replace line 479 with this:

        if (is_string($value) && get_class($handler) === 'views_handler_filter_geo') {
          $target = $value;
        }
        else {
          $target = geo_value($value, 'wkt', 'array');
        }