protected function SearchApiViewsHandlerArgumentLocation::_parse_point in Search API Location 7.2
Internal function to parse a string argument to point to lat lon.
2 calls to SearchApiViewsHandlerArgumentLocation::_parse_point()
- SearchApiViewsHandlerArgumentLocationGeofilt::query in search_api_location_views/
handler_argument_location.inc - Set up the query for this argument.
- SearchApiViewsHandlerArgumentLocationPoint::query in search_api_location_views/
handler_argument_location.inc - Accepts a $this->argument of any value that geoPHP can load.
File
- search_api_location_views/
handler_argument_location.inc, line 33 - Provides the views argument handler for location fields.
Class
- SearchApiViewsHandlerArgumentLocation
- Base class for Views location seperate point radius arguments.
Code
protected function _parse_point($argument) {
$point = array();
if (module_exists('geophp')) {
// Try to use geoPHP to read type.
try {
geophp_load();
$format = geoPHP::detectFormat($argument);
if ($format) {
$args = explode(':', $format);
array_unshift($args, $argument);
$location = call_user_func_array(array(
'geoPHP',
'load',
), $args);
$point['lat'] = $location
->y();
$point['lon'] = $location
->x();
}
} catch (Exception $e) {
// GeoPHP couldn't handle type. Treat as invalid/no argument, silently.
}
}
if (empty($point)) {
// Try Solr LatLonType.
if (preg_match("/^([+-]?[0-9]+(?:\\.[0-9]+)?),([+-]?[0-9]+(?:\\.[0-9]+)?)\$/", $argument, $match)) {
$point['lat'] = $match[1];
$point['lon'] = $match[2];
}
}
return empty($point) ? FALSE : $point;
}