@@ -46,6 +46,8 @@ public function testCorrectCodeFromCoordinates(float $latitude, float $longitude
4646 $ resultCode = $ floatCal ->encode ($ latitude , $ longitude , OpenLocationCode::CODE_PRECISION_NORMAL );
4747 $ this ->assertEquals ($ resultCode , $ expectedCode );
4848 $ resultCodeArea = $ floatCal ->decode ($ expectedCode );
49+ $ this ->confirmCoordinatesValidity ($ resultCodeArea ->northLatitude , $ resultCodeArea ->eastLongitude );
50+ $ this ->confirmCoordinatesValidity ($ resultCodeArea ->southLatitude , $ resultCodeArea ->westLongitude );
4951 $ this ->assertTrue ($ resultCodeArea ->contains ($ latitude , $ longitude ));
5052 if (PHP_INT_SIZE >= 8 ) {
5153 // at least 64-bit, which means we can use "long" ints here
@@ -57,6 +59,16 @@ public function testCorrectCodeFromCoordinates(float $latitude, float $longitude
5759 }
5860 }
5961
62+ private function confirmCoordinatesValidity (float $ latitude , float $ longitude ): void
63+ {
64+ // check latitude
65+ $ this ->assertGreaterThanOrEqual (-90 , $ latitude );
66+ $ this ->assertLessThanOrEqual (90 , $ latitude );
67+ // check longitude
68+ $ this ->assertGreaterThanOrEqual (-180 , $ longitude );
69+ $ this ->assertLessThanOrEqual (180 , $ longitude );
70+ }
71+
6072 public static function codeValidityProvider (): array
6173 {
6274 return [
@@ -76,7 +88,7 @@ public static function encodingProvider(): array
7688 "Changi Airport, Singapore " => [1.357063 , 103.988563 , "6PH59X4Q+RC " ],
7789 "International Antarctic Centre, Christchurch " => [-43.489063 , 172.547188 , "4V8JGG6W+9V " ],
7890 "Christo Redentor, Rio de Janeiro " => [-22.951937 , -43.210437 , "589R2QXQ+6R " ],
79- "New Chitose Airport, Chitose " => [42.786062 ,141.680937 , "8RJ3QMPJ+C9 " ],
91+ "New Chitose Airport, Chitose " => [42.786062 , 141.680937 , "8RJ3QMPJ+C9 " ],
8092 "Berling Strait " => [65.759937 , -169.149437 , "92QGQV52+X6 " ],
8193 "Null point " => [0 , 0 , "6FG22222+22 " ],
8294 ];
0 commit comments