Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
arcsin is only real for values between -1 & 1.
The earth_longitude_range() function in earth.inc sometimes uses values outside that range.
Comment | File | Size | Author |
---|---|---|---|
#5 | location-821628-5.patch | 2.12 KB | rooby |
#1 | location-821628-1.patch | 654 bytes | rooby |
Comments
Comment #1
rooby CreditAttribution: rooby commentedPossible solution
Comment #2
rooby CreditAttribution: rooby commentedComment #3
YesCT CreditAttribution: YesCT commentedcode style looks ok. adds comment. approach makes sense to keep values within -1 to 1 (just cuts off values outside that range).
how big is the world? if a search is for locations within say 10,000 miles, would this find "all" locations?
to finish the review, I think what is needed is to
1) get the latest dev
2) apply this patch
3) try searches that are large? and across datelines?
4) reply here with a summary of what functional tests (searches) you tried and the results, and say what the results were before the patch and after the patch
Powered by Dreditor.
Comment #4
rooby CreditAttribution: rooby commentedYeah, that was a quick fix without having to think about it. Will have to think it through properly.
The main thing though is that values outside that range cannot be passed into asin because it returns NAN which is not acceptable.
Comment #5
rooby CreditAttribution: rooby commentedI have looked at this problem a bit and have come to the following conclusion.
This method is the only real fix for this function. This patch is the same solution as in #1 but a bit neater and with better commenting.
This will mean we don't get NAN results from the asin function.
It also means that for large values of distance the calculation won't be accurate.
This is not regression because getting NAN means the calculation won't work at all, it just means the function has never worked properly for large distance values.
I think this patch should be committed for now but the function needs to be rewritten using a different formula so it works for larger 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):
Any thoughts/opposition?
Will look at rewriting those range functions sometime soon.
Comment #6
rooby CreditAttribution: rooby commentedCommitted #5.
http://drupal.org/cvs?commit=387922
http://drupal.org/cvs?commit=387920
http://drupal.org/cvs?commit=387918
There is still an outstanding issue regarding this function. See #844756: Range functions in earth.inc are not accurate for large distances