From c6cd043ebc45c1a91e8bbffef852a05049bb216c Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 23 Aug 2026 22:02:05 +0200 Subject: [PATCH 1/2] Fix coordinate order for setBounds in LocationIQ.php --- src/Provider/LocationIQ/LocationIQ.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Provider/LocationIQ/LocationIQ.php b/src/Provider/LocationIQ/LocationIQ.php index 9320426de..c1d4b0969 100644 --- a/src/Provider/LocationIQ/LocationIQ.php +++ b/src/Provider/LocationIQ/LocationIQ.php @@ -154,7 +154,7 @@ private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressN if ($boundsAttr) { $bounds = []; list($bounds['south'], $bounds['north'], $bounds['west'], $bounds['east']) = explode(',', $boundsAttr); - $builder->setBounds((float) $bounds['south'], (float) $bounds['north'], (float) $bounds['west'], (float) $bounds['east']); + $builder->setBounds((float) $bounds['south'], (float) $bounds['west'], (float) $bounds['north'], (float) $bounds['east']); } return $builder->build(); From cdc22a1d2f610745f7640ebbf954315377357561 Mon Sep 17 00:00:00 2001 From: Patrick Fischer Date: Thu, 17 Sep 2026 20:57:44 +0200 Subject: [PATCH 2/2] test: add LocationIQ bounds test --- .../LocationIQ/Tests/LocationIQTest.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/Provider/LocationIQ/Tests/LocationIQTest.php b/src/Provider/LocationIQ/Tests/LocationIQTest.php index dc60da86b..0d1d3b2d0 100644 --- a/src/Provider/LocationIQ/Tests/LocationIQTest.php +++ b/src/Provider/LocationIQ/Tests/LocationIQTest.php @@ -15,6 +15,8 @@ use Geocoder\Collection; use Geocoder\IntegrationTest\BaseTestCase; use Geocoder\Location; +use Geocoder\Model\Address; +use Geocoder\Model\Bounds; use Geocoder\Provider\LocationIQ\LocationIQ; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; @@ -87,4 +89,37 @@ public function testGetNodeStreetName(): void $this->assertInstanceOf(\Geocoder\Model\Address::class, $result); $this->assertEquals('Rue Quincampoix', $result->getStreetName()); } + + public function testCorrectBounds(): void + { + $provider = new LocationIQ($this->getHttpClient($_SERVER['LOCATIONIQ_API_KEY']), $_SERVER['LOCATIONIQ_API_KEY']); + + $results = $provider->geocodeQuery(GeocodeQuery::create('10 Downing Street, London, United Kingdom')); + + $this->assertInstanceOf(\Geocoder\Model\AddressCollection::class, $results); + $this->assertCount(1, $results); + + /** @var Address $result */ + $result = $results->first(); + + $this->assertInstanceOf(\Geocoder\Model\Address::class, $result); + $this->assertEquals('Downing Street', $result->getStreetName()); + $this->assertEquals('United Kingdom', $result->getCountry()->getName()); + + /** @var Bounds $bounds */ + $bounds = $result->getBounds(); + + $north = $bounds->getNorth(); + $south = $bounds->getSouth(); + $west = $bounds->getWest(); + $east = $bounds->getEast(); + + $this->assertTrue($north > $south); + $this->assertTrue($east > $west); + + $this->assertEqualsWithDelta(51.5033074, $south, 1E-6); + $this->assertEqualsWithDelta(51.5036913, $north, 1E-6); + $this->assertEqualsWithDelta(-0.1277991, $west, 1E-6); + $this->assertEqualsWithDelta(-0.1273088, $east, 1E-6); + } }