- $client = HTTPClient::start();
-
- // XXX: break down a name by commas, narrow by each
-
- $str = http_build_query(array('maxRows' => 1,
- 'q' => $name,
- 'lang' => $language,
- 'type' => 'json'));
-
- $result = $client->get('http://ws.geonames.org/search?'.$str);
-
- if ($result->code == "200") {
- $rj = json_decode($result->body);
- if (count($rj['geonames']) > 0) {
- $n = $rj['geonames'][0];
- $location = new Location();
- $location->lat = $n->lat;
- $location->lon = $n->lon;
- $location->name = $n->name;
- $location->location_id = $n->geonameId;
- $location->location_ns = Location:geonames;
- }
+
+ // Let a third-party handle it
+
+ if (Event::handle('LocationFromLatLon',
+ array($lat, $lon, $language, &$location))) {
+ // Default is just the lat/lon pair
+
+ $location = new Location();
+
+ $location->lat = $lat;
+ $location->lon = $lon;