/**
  * Test20205
  *
  * @return void
  */
 public function test20205()
 {
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse(fopen(__DIR__ . '/responses/capabilities.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/PEARBug20205_moskau_ru.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/PEARBug20205_moskau_en.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/PEARBug20205_russia_en.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/PEARBug20205_russia_fr.xml', 'rb'));
     $config = array('adapter' => $mock, 'server' => 'http://api06.dev.openstreetmap.org/');
     $osm = new Services_OpenStreetMap($config);
     $osm->getConfig()->setAcceptLanguage('ru,en-AU');
     $test = $osm->getPlace('Moskau');
     $attribs = $test[0]->attributes();
     $display = (string) $attribs['display_name'];
     $expected = "Москва, " . "Центральный федеральный округ, " . "Российская Федерация";
     $this->assertEquals($display, $expected);
     $osm->getConfig()->setAcceptLanguage('en');
     $test = $osm->getPlace('Moskau');
     $attribs = $test[0]->attributes();
     $display = (string) $attribs['display_name'];
     $expected = 'Moscow, Central Federal District, Russian Federation';
     $this->assertEquals($display, $expected);
     $test = $osm->getPlace('Russia');
     $attribs = $test[0]->attributes();
     $display = (string) $attribs['display_name'];
     $expected = 'Russian Federation';
     $this->assertEquals($display, $expected);
     $osm->getConfig()->setAcceptLanguage('fr');
     $test = $osm->getPlace('Russia');
     $attribs = $test[0]->attributes();
     $display = (string) $attribs['display_name'];
     $expected = 'Fédération de Russie';
     $this->assertEquals($display, $expected);
 }
/**
 * example1_savetolocalfile.php
 * 22-Nov-2009
 *
 * PHP Version 5
 *
 * @category Services
 * @package  Services_OpenStreetMap
 * @author   Ken Guest <*****@*****.**>
 * @license  BSD http://www.opensource.org/licenses/bsd-license.php
 * @version  Release: @package_version@
 * @link     osmx.php
*/
$version = '@package_version@';
if (strstr($version, 'package_version')) {
    set_include_path(dirname(dirname(__FILE__)) . ':' . get_include_path());
}
require_once 'Services/OpenStreetMap.php';
$osm = new Services_OpenStreetMap(array('verbose' => true));
var_dump($osm->getConfig());
try {
    $osm->getConfig()->setServer('http://api.openstreetmap.org/');
} catch (Exception $ex) {
    var_dump($ex->getMessage());
    // Fall back to default server...so carry on.
}
$osm->get(52.84824191354071, -8.247245026639696, 52.89957825532213, -8.174161478654796);
// $osm->get(52.9208049, -8.1156559, 52.9695733, -8.0005314);
file_put_contents("osm.osm", $osm->getXml());
// vim:set et ts=4 sw=4:
 /**
  * Test PEAR Bug 20205
  *
  * @return void
  */
 public function test20205()
 {
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse(fopen(__DIR__ . '/responses/nominatim_search_20205_1.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/nominatim_search_20205_2.xml', 'rb'));
     $osm = new Services_OpenStreetMap(array('adapter' => $mock));
     $osm->getConfig()->setAcceptLanguage('en');
     $test = $osm->getPlace('Moskau');
     $attribs = $test[0]->attributes();
     $display = (string) $attribs['display_name'];
     $this->assertEquals("Moscow, Central Federal District, Russian Federation", $display);
     $osm->getConfig()->setAcceptLanguage('ru,en-AU');
     $test = $osm->getPlace('Moscow');
     $attribs = $test[0]->attributes();
     $display = (string) $attribs['display_name'];
     $this->assertEquals("Москва, " . "Центральный федеральный округ, " . "Российская Федерация", $display);
 }
Ejemplo n.º 4
0
 /**
  * Test generator
  *
  * @return void
  */
 public function testGenerator()
 {
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse(fopen(__DIR__ . '/responses/capabilities.xml', 'rb'));
     $config = array('api_version' => '0.6', 'adapter' => $mock, 'password' => null, 'passwordfile' => null, 'user' => null, 'verbose' => false, 'User-Agent' => 'Services_OpenStreetMap', 'server' => 'http://api06.dev.openstreetmap.org/');
     $osm = new Services_OpenStreetMap($config);
     $generator = $osm->getConfig()->getGenerator();
     $this->assertEquals($generator, 'OpenStreetMap server');
     $mock2 = new HTTP_Request2_Adapter_Mock();
     $mock2->addResponse(fopen(__DIR__ . '/responses/capabilities_jxapi.xml', 'rb'));
     $config['adapter'] = $mock2;
     $osm = new Services_OpenStreetMap($config);
     $generator = $osm->getConfig()->getGenerator();
     $this->assertEquals($generator, 'Java XAPI Server');
 }