mjaschen / phpgeo

Simple Yet Powerful Geo Library for PHP
https://phpgeo.marcusjaschen.de
MIT License
1.56k stars 195 forks source link

Warning emitted for valid coordinates in CoordinateFactory #68

Closed bonesnap closed 4 years ago

bonesnap commented 4 years ago

PHP version: 7.4.6 Library version: 3.0.0

Passing a set of non-decimal coordinates without seconds to CoordinateFactory::fromString() will emit the following PHP warning:

PHP Warning: A non-numeric value encountered in /home/../vendor/mjaschen/phpgeo/src/Factory/CoordinateFactory.php on line 177

Reproducible by the following code:

$coordinates = CoordinateFactory::fromString('11°17′N 15°50′W');

The coordinates are for an airport in Guinea-Bissau. It should be noted that the library still calculates the correct latitude and longitude, so it works, but the warning poses a problem for anyone who converts warnings, notices, etc. into exceptions automatically (typically done when using a framework).

The warning is not emitted if you add zero-filled seconds to the coordinates:

$coordinates = CoordinateFactory::fromString('11°17′00″N 15°50′00″W');

However the coordinates in question are of a valid format, so the library shouldn't be emitting the warning.

mjaschen commented 4 years ago

Thanks for reporting this. We're working on a fix.

mjaschen commented 4 years ago

Fixed in version 3.0.1.