|
15 | 15 | use Geocoder\Collection; |
16 | 16 | use Geocoder\IntegrationTest\BaseTestCase; |
17 | 17 | use Geocoder\Location; |
| 18 | +use Geocoder\Model\Address; |
| 19 | +use Geocoder\Model\Bounds; |
18 | 20 | use Geocoder\Provider\LocationIQ\LocationIQ; |
19 | 21 | use Geocoder\Query\GeocodeQuery; |
20 | 22 | use Geocoder\Query\ReverseQuery; |
@@ -87,4 +89,37 @@ public function testGetNodeStreetName(): void |
87 | 89 | $this->assertInstanceOf(\Geocoder\Model\Address::class, $result); |
88 | 90 | $this->assertEquals('Rue Quincampoix', $result->getStreetName()); |
89 | 91 | } |
| 92 | + |
| 93 | + public function testCorrectBounds(): void |
| 94 | + { |
| 95 | + $provider = new LocationIQ($this->getHttpClient($_SERVER['LOCATIONIQ_API_KEY']), $_SERVER['LOCATIONIQ_API_KEY']); |
| 96 | + |
| 97 | + $results = $provider->geocodeQuery(GeocodeQuery::create('10 Downing Street, London, United Kingdom')); |
| 98 | + |
| 99 | + $this->assertInstanceOf(\Geocoder\Model\AddressCollection::class, $results); |
| 100 | + $this->assertCount(1, $results); |
| 101 | + |
| 102 | + /** @var Address $result */ |
| 103 | + $result = $results->first(); |
| 104 | + |
| 105 | + $this->assertInstanceOf(\Geocoder\Model\Address::class, $result); |
| 106 | + $this->assertEquals('Downing Street', $result->getStreetName()); |
| 107 | + $this->assertEquals('United Kingdom', $result->getCountry()->getName()); |
| 108 | + |
| 109 | + /** @var Bounds $bounds */ |
| 110 | + $bounds = $result->getBounds(); |
| 111 | + |
| 112 | + $north = $bounds->getNorth(); |
| 113 | + $south = $bounds->getSouth(); |
| 114 | + $west = $bounds->getWest(); |
| 115 | + $east = $bounds->getEast(); |
| 116 | + |
| 117 | + $this->assertTrue($north > $south); |
| 118 | + $this->assertTrue($east > $west); |
| 119 | + |
| 120 | + $this->assertEqualsWithDelta(51.5033074, $south, 1E-6); |
| 121 | + $this->assertEqualsWithDelta(51.5036913, $north, 1E-6); |
| 122 | + $this->assertEqualsWithDelta(-0.1277991, $west, 1E-6); |
| 123 | + $this->assertEqualsWithDelta(-0.1273088, $east, 1E-6); |
| 124 | + } |
90 | 125 | } |
0 commit comments