function getlocations_latlon_check in Get Locations 7
Same name and namespace in other branches
- 6.2 getlocations.module \getlocations_latlon_check()
- 6 getlocations.module \getlocations_latlon_check()
- 7.2 getlocations.module \getlocations_latlon_check()
Function to check a lat,lon string
Parameters
string $latlon:
Return value
Returns normalized string or false
34 calls to getlocations_latlon_check()
- getlocations_cb_w3w in ./
getlocations.module - getlocations_commentmap in ./
getlocations.module - Page callback: Displays a map.
- getlocations_element_validate_latlon in ./
getlocations.module - Function
- getlocations_fields_getmap in modules/
getlocations_fields/ getlocations_fields.module - input map
- getlocations_fields_save_locations in modules/
getlocations_fields/ getlocations_fields.module
File
- ./
getlocations.module, line 1667 - getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_latlon_check($latlon) {
if (!empty($latlon)) {
$ll = explode(',', $latlon);
$lat = isset($ll[0]) ? $ll[0] : FALSE;
$lon = isset($ll[1]) ? $ll[1] : FALSE;
$lat = trim($lat);
$lon = trim($lon);
if ((abs($lat) || abs($lon)) && is_numeric($lat) && is_numeric($lon)) {
$latregex = "/[-+]{0,1}[0-9]{1,}\\.{1}[0-9]{1,}/";
if (!strpos($lat, '.')) {
$latregex = "/[-+]{0,1}[0-9]{1,}/";
}
$lonregex = "/[-+]{0,1}[0-9]{1,}\\.{1}[0-9]{1,}/";
if (!strpos($lon, '.')) {
$lonregex = "/[-+]{0,1}[0-9]{1,}/";
}
if (preg_match($latregex, $lat) && preg_match($lonregex, $lon)) {
// Normalize coordinates.
$lat = getlocations_normalizelat($lat);
$lon = getlocations_normalizelng($lon);
return $lat . "," . $lon;
}
}
}
return FALSE;
}