thephpleague / geotools

Geo-related tools PHP 7.3+ library built atop Geocoder and React libraries
MIT License
1.37k stars 122 forks source link

php 8.1.9 #180

Open ahmedesa opened 1 year ago

ahmedesa commented 1 year ago

problem with Coordinate

error : Deprecated: Implicit conversion from float -104.84929305556 to int loses precision

FabrizioReitano commented 1 year ago

I can also add:

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at /var/www/project/vendor/league/geotools/src/Geohash/Geohash.php:140

Surfoo commented 1 year ago

Hello,

Thanks for your feedback! Can you show a test case ?

ASlatius commented 7 months ago

Tested with php 8.2.13 raises the same issue. Any example will work new \League\Geotools\Coordinate\Coordinate([2.307266, 48.823405]), The first issue menthioned bij @ahmedesa most likely lies in this code;

public function normalizeLongitude($longitude)
{
    if (180 === $longitude % 360) {
        return 180.0;
    }

Looking at the code and modifying it to (int)$longitude should be safe and removes the depricated warning.