It seems that the Distance/Proximity Filter, when a distance is too great, will return no results.
I have a tested and working view with Location/Proximity Filter with a location that is 400 miles from the inputted zip code. When I put in 2000 miles, it returns the same results. But when I request locations 4000 miles away, the view returns no results. These are both from fresh searches, that is, I've reloaded the view in between attempting the search
I've attached the exported view, and screenshots follow:
2000 miles
4000 miles
Comment | File | Size | Author |
---|---|---|---|
#23 | location-fix-471040-23-earth_longitude_range-not-correct-D6.patch | 924 bytes | hutch |
#17 | 0001-fix-471040-earth_longitude_range-not-correct-for-lar.patch | 1.24 KB | geek-merlin |
Zip_code_filter_view.txt | 13.18 KB | glass.dimly | |
4000-miles.png | 15.12 KB | glass.dimly | |
2000-miles.png | 31.82 KB | glass.dimly |
Comments
Comment #1
mrtoner CreditAttribution: mrtoner commentedThe cut-off appears to be 3285 -- anything above that and the view is empty.
That's for miles, though; it's 5288 in kilometers, the same distance.
http://www.convertunits.com/distance/from/YMA/to/BOO
Comment #2
YesCT CreditAttribution: YesCT commentedrelated to #446404: Incorrect longitude range in SQL queries?
Comment #3
glass.dimly CreditAttribution: glass.dimly commentedI have a theme-based workaround for this issue, though it in no way addresses the bug itself, which is rather serious, if I do say so myself.
This code is to be embedded in a the themed location view, and simply checks the value that was passed to the view by the Distance/Proximity Filter and rewrites that value if it surpasses 3280 miles.
1) Create a template file that overrides the view's theme. For instance, the name of my view is zip-code-proximity-test-2 and so I make a template file called views-view--zip-code-proximity-test-2.tpl.php.
2) Then I figure out what views wants me to put there using the handy views "Theme: Information" and clicking the link that corresponds to the view I wish to create. I cut and paste it into the tpl.php file.
3) Next, I add this code:
4) Make sure to empty your cache, and it should work.
Comment #4
Ofer Morag CreditAttribution: Ofer Morag commentedHi,
Thanks for the code.
In which file may I insert this code to achieve the sought after results?
Thanks,
O.M.
Comment #5
glass.dimly CreditAttribution: glass.dimly commentedO.M.,
Please re-read what I wrote above. What I am speaking of is the a tpl.php file created to theme a view. If you are unsure what I'm talking about, you may refer to the documentation on theming views.
-glass.dimly
Comment #6
osopolarWorkaround by the use of a custom helper module with the following code:
Comment #7
gooddesignusa CreditAttribution: gooddesignusa commentedThanks for the custom module code. Took me awhile to find this issue since it was posted a while back.
Comment #8
YesCT CreditAttribution: YesCT commentedthanks for the fix!
Still needs a proper fix/patch... :)
Comment #9
hutch CreditAttribution: hutch commentedCan anyone confirm where the cutoff point is? Or why? This might lie in the maths in earth.inc, over my head I'm afraid.
mrtoner in #1 suggests 3285 miles, 5288 kilometers or 5288000 meters (or a bit less to be safe)
These limits should be in the form validation functions in the argument and filter handlers, not in theme hook_form_alter.
A new function in location.inc might be the way, eg location_distance_check($dist, $unit). This could be called by validators.
Alternately they could be imposed in _location_convert_distance_to_meters() but this might lead to confounding results.
Comment #10
YesCT CreditAttribution: YesCT commentedBrandon is super busy, so if anyone can figure this out, please post. But I'll add the tag "location bdragon check" which I use for architecture type questions... or questions someone who know most of the code might be needed to answer, but that person could be anyone, I just picked a kind of bad name for the tag way back when. :)
Comment #11
hutch CreditAttribution: hutch commentedOK, I'm happy to do the coding but these are policy decisions, once these are made ping me ;-)
Comment #12
Cliff CreditAttribution: Cliff commentedI have no idea why the values are what they are, but find it interesting that they are within 1% of 48 degrees, or two-fifteenths of Earth's circumference at the Equator. (They're right at 47.5 degrees.)
Earth rotates through that distance in 3 hours and 12 minutes (3:10, if we're using 47.5 degrees).
What's significant about any of that? I have no idea. Perhaps nothing at all. But if there is any significance to it, perhaps expressing the distance in these terms will jog the connection in someone else's mind.
Comment #13
rooby CreditAttribution: rooby commentedI created an issue (#844756: Range functions in earth.inc are not accurate for large distances)about this before as I didn't see this one so that one is marked as a duplicate of this.
This is not a views specific issue, it goes deeper than that.
Here is my post from the above mentioned issue:
For original discussion of this issue see #821628: earth_longitude_range() in earth.inc uses invalid values with asin()
Basically, the range functions use simplified logic that is inaccurate for large distances.
More complex functions are required that work properly for all distance values.
For reference, these are the around about the maximum values of distance that can be used with this function before you start getting inaccurate results, the max value changes relative to the latitude of the point you are measuring from (if my calculations are correct):
I have seen better formulae for calculating this stuff that shouldn't suffer from this, they are just more complex.
I'll just have to get into math mode sometime and work it all out.
Comment #14
rooby CreditAttribution: rooby commentedAnd to answer other conversation from this thread, we can't add help text to say that certain distances are not supported because the distance is not constant but varies depending on the latitude.
We just have to fix the math that does the range calculations.
Comment #15
rooby CreditAttribution: rooby commentedAlso, from memory the views should not return no results after that distance but any results outside of that distance will not be displayed.
I think that was how it was happening.
Comment #16
geek-merlincool, some math to chew on ;-) !
here is the patch (against 7.x-3.x) that fixes this.
and here some manual tests:
Comment #17
geek-merlinComment #18
podarok#1931088: [META] Fixing tests tests were broken, so triggering to active
Comment #19
podarokbot
Comment #20
podarok#17 commited pushed to 7.x-3.x
thanks!
Comment #21
rooby CreditAttribution: rooby commentedThat's great thanks.
I'm thinking I will backport this to drupal 6 as it is a pretty major issue.
Someone else is also welcome to do it if they want.
Comment #22
podarok#17: 0001-fix-471040-earth_longitude_range-not-correct-for-lar.patch queued for re-testing.
Comment #23
hutch CreditAttribution: hutch commentedPatch on fresh pull of location-6.x-3.x-dev attached, not tested.
Comment #24
podaroktag
Comment #25
podarok#23 commited pushed to 6.x-3.x-dev
Thanks!