2 /* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3 and is published under the AGPL license. */
5 class NominatimController extends Zend_Controller_Action
8 public function indexAction() {
9 $search = $this->getRequest()->getQuery('nominatim-search');
10 if (!isset($search)) {
11 throw new Syj_Exception_Request();
14 $serverUrl = rtrim($this->view->serverUrl(), '/');
15 $baseUrl = trim($this->view->baseUrl(), '/');
16 $href = $serverUrl . '/' . ($baseUrl ? ($baseUrl . '/'): '');
18 $client = new Zend_Http_Client('http://nominatim.openstreetmap.org/search', array(
19 'useragent' => ('Zend_Http_Client for ' . $href)));
20 $client->setParameterGet(array('q' => $search,
22 'email' => Zend_Controller_Front::getInstance()->getParam('webmasterEmail')));
24 $response = $client->request();
25 $data = json_decode($response->getBody());
29 $this->_helper->SyjApi->setBodyJson($data)->setCode($response->getStatus());