function getlocations_earth_longitude_range in Get Locations 7
Same name and namespace in other branches
- 7.2 getlocations.module \getlocations_earth_longitude_range()
This function uses earth_asin_safe so is not accurate for all possible parameter combinations. This means this function doesn't work properly for high distance values. This function needs to be re-written to work properly for larger distance values. See http://drupal.org/node/821628
http://drupal.org/node/471040 provides a fix, this has been applied here.
5 calls to getlocations_earth_longitude_range()
- getlocations_fields_handler_argument_distance::query in modules/
getlocations_fields/ handlers/ getlocations_fields_handler_argument_distance.inc - Set up the query for this argument.
- getlocations_fields_handler_filter_distance::query in modules/
getlocations_fields/ handlers/ getlocations_fields_handler_filter_distance.inc - Add this filter to the query.
- getlocations_js_settings_do in ./
getlocations.module - Function sets up javascript settings
- getlocations_leaflet_map_settings_do in modules/
getlocations_leaflet/ getlocations_leaflet.module - Function
- getlocations_search_info_sql in modules/
getlocations_search/ getlocations_search.module
File
- ./
getlocations.module, line 6191 - getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_earth_longitude_range($latitude, $longitude, $distance) {
// Estimate the min and max longitudes within $distance of a given location.
if (!$distance > 0) {
$distance = 1;
}
$long = deg2rad($longitude);
$lat = deg2rad($latitude);
$radius = getlocations_earth_radius($latitude) * cos($lat);
if ($radius > 0) {
$angle = abs($distance / $radius);
$angle = min($angle, pi());
}
else {
$angle = pi();
}
$minlong = $long - $angle;
$maxlong = $long + $angle;
if ($minlong < -pi()) {
$minlong = $minlong + pi() * 2;
}
if ($maxlong > pi()) {
$maxlong = $maxlong - pi() * 2;
}
return array(
rad2deg($minlong),
rad2deg($maxlong),
);
}