Created
October 26, 2018 15:49
-
-
Save gaelg/4466550a8d66d77a66271dc854b534ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/geofield.module b/geofield.module | |
index 45cb326..41f9ddd 100644 | |
--- a/geofield.module | |
+++ b/geofield.module | |
@@ -135,7 +135,7 @@ function geofield_radius_options() { | |
* The generated SQL query snippet for haversine formula. | |
*/ | |
function geofield_haversine($options = []) { | |
- $formula = '( :earth_radius * ACOS( COS( RADIANS(:origin_latitude) ) * COS( RADIANS(:destination_latitude) ) * COS( RADIANS(:destination_longitude) - RADIANS(:origin_longitude) ) + SIN( RADIANS(:origin_latitude) ) * SIN( RADIANS(:destination_latitude) ) ) )'; | |
+ $formula = '( :earth_radius * ACOS( LEAST(1, COS( RADIANS(:origin_latitude) ) * COS( RADIANS(:destination_latitude) ) * COS( RADIANS(:destination_longitude) - RADIANS(:origin_longitude) ) + SIN( RADIANS(:origin_latitude) ) * SIN( RADIANS(:destination_latitude) ) ) ) )'; | |
foreach ($options as $key => $option) { | |
if (is_numeric($option)) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://www.drupal.org/project/geofield/issues/2654360#comment-12831745