reverse() public method

public reverse ( $latitude, $longitude )
Ejemplo n.º 1
0
 public function testReverseWithVillage()
 {
     if (!isset($_SERVER['OPENCAGE_API_KEY'])) {
         $this->markTestSkipped('You need to configure the OPENCAGE_API_KEY value in phpunit.xml');
     }
     $provider = new OpenCage($this->getAdapter($_SERVER['OPENCAGE_API_KEY']), $_SERVER['OPENCAGE_API_KEY']);
     $results = $provider->reverse(49.1390924, 1.6572462);
     $this->assertInstanceOf('Geocoder\\Model\\AddressCollection', $results);
     $this->assertCount(1, $results);
     /** @var \Geocoder\Model\Address $result */
     $result = $results->first();
     $this->assertInstanceOf('\\Geocoder\\Model\\Address', $result);
     $this->assertEquals('Bray-et-Lû', $result->getLocality());
 }
Ejemplo n.º 2
0
 public function testReverseWithRealCoordinates()
 {
     if (!isset($_SERVER['OPENCAGE_API_KEY'])) {
         $this->markTestSkipped('You need to configure the OPENCAGE_API_KEY value in phpunit.xml');
     }
     $provider = new OpenCage($this->getAdapter($_SERVER['OPENCAGE_API_KEY']), $_SERVER['OPENCAGE_API_KEY']);
     $results = $provider->reverse(54.0484068, -2.7990345);
     $this->assertInstanceOf('Geocoder\\Model\\AddressCollection', $results);
     $this->assertCount(1, $results);
     /** @var \Geocoder\Model\Address $result */
     $result = $results->first();
     $this->assertInstanceOf('\\Geocoder\\Model\\Address', $result);
     $this->assertEquals(54.0484068, $result->getLatitude(), '', 0.001);
     $this->assertEquals(-2.7990345, $result->getLongitude(), '', 0.001);
     $this->assertTrue($result->getBounds()->isDefined());
     $this->assertEquals(54.0482731, $result->getBounds()->getSouth());
     $this->assertEquals(-2.7998815, $result->getBounds()->getWest());
     $this->assertEquals(54.0494992, $result->getBounds()->getNorth());
     $this->assertEquals(-2.79813, $result->getBounds()->getEast());
     $this->assertNull($result->getStreetNumber());
     $this->assertNull($result->getStreetName());
     $this->assertNull($result->getPostalCode());
     $this->assertEquals('Lancaster', $result->getLocality());
     $this->assertCount(2, $result->getAdminLevels());
     $this->assertEquals('Lancashire', $result->getAdminLevels()->get(2)->getName());
     $this->assertEquals('England', $result->getAdminLevels()->get(1)->getName());
     $this->assertEquals('United Kingdom', $result->getCountry()->getName());
     $this->assertEquals('GB', $result->getCountry()->getCode());
     $this->assertEquals('Europe/London', $result->getTimezone());
 }