1. When the user entered source text fails to geocode: EXPECTED show an error message and no results ACTUAL show all results.

2. When one of the entities has a null value for the location field: EXPECTED the proximity filter should exclude it ACTUAL it is included as if distance = zero so before the real results. [Easy workaround to add a second filter on location<>NULL.]

Patch coming up

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Status: Active » Needs review
StatusFileSize
new1.14 KB
itamair’s picture

StatusFileSize
new1.82 KB

Right @AdamPS ... but your patch is right only when the proximity filter is not exposed.
In case of exposed Geofield Proximity Filter, an empty Origin shouldn't affect the final result, for what discussed here: https://www.drupal.org/project/geofield/issues/3012750#comment-12857795.

A consequently tuned (and new) patch attached.

  • itamair committed e5aee75 on 8.x-1.x
    GeofieldProximityFilter: Better Validation on Empty and not Valid Origin...
itamair’s picture

Last commit includes the #3, and additionally includes better validation on empty and not valid origin, and corrects validation on required origin on exposed proximity filter.

itamair’s picture

Status: Needs review » Fixed
adamps’s picture

Great, thanks

Anonymous’s picture

Status: Fixed » Active

Since this commit in version 1.2, notices are thrown on a view:

Notice: Undefined index: origin in Drupal\geofield\Plugin\views\filter\GeofieldProximityFilter->validateExposed() (line 305 of modules/contrib/geofield/src/Plugin/views/filter/GeofieldProximityFilter.php).

The filtering works ok though.

itamair’s picture

Version: 8.x-1.x-dev » 8.x-1.2
Status: Active » Fixed
StatusFileSize
new2.21 KB

Yes you are right. My fault. I missed to handle the case of address (geolocated) origin.
New patch attached upon the 8.x-1.2 version .... going to commit.

  • itamair committed 7f207ac on 8.x-1.x
    Issue #3041549 by itamair, AdamPS: Proximity filter must handle geocode...
Anonymous’s picture

Great, thank you.
Works nicely.

Status: Fixed » Closed (fixed)

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

adamps’s picture

OK so it's still not working. I have a view with an exposed filter. It's the completely standard and obvious map search: users type in a town or zip/postal code and they get results nearby.

If I type in "lodnon" then I get a random list of results from anywhere in the country. Surely this is not what any user wants or how any other site works?? If the geocode of the origin fails then I expect to see an error "no results found".

Right @AdamPS ... but your patch is right only when the proximity filter is not exposed.
In case of exposed Geofield Proximity Filter, an empty Origin shouldn't affect the final result, for what discussed here: https://www.drupal.org/project/geofield/issues/3012750#comment-12857795.

So you are referring to my comment:-) I'm not sure which of the numbered points you mean - perhaps the closest is 3.

On the view itself, if you leave the proximity filter distance field blank, there is an error "The Distance value is not valid.". I would expect blank to be allowed unless the filter is required, in which case the error should say that the field is required.

However #3 is referring to the distance. It's completely different: leaving distance empty naturally has the meaning "unlimited distance". Leaving the origin empty does not naturally have the meaning "random results from anywhere".

I think if you check any other sites on the internet or get users to do usability testing it will confirm this. I don't have permission to re-open this issue so have created #3053372: Proximity filter must handle geocode failures.