mjaschen / phpgeo

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

"Longitude value must be numeric" bad exception #70

Closed jonyrock closed 4 years ago

jonyrock commented 4 years ago

I get Longitude value must be numeric -180.0 .. +180.0 (given: 180) and looks like I should be able to put 180, right?

This is because in < instead of <= https://github.com/mjaschen/phpgeo/blob/3a03fe3df865cac5aa8a6383052b29eda2137098/src/Coordinate.php#L177

mjaschen commented 4 years ago

Hi,

I've added test cases for your example and they all pass.

Can you provide more details on how to reproduce your observations?


The bounds check accepts values with an equal value as the boundary limit: If you use an longitude value of 180 the test condition in isNumericInBounds() would be

!(180 < -180.0 || 180 > 180.0)!(false || false)!falsetrue

which is the expected result.

jonyrock commented 4 years ago

Well, maybe we can close this issue, but in me world: image

jonyrock commented 4 years ago

180 \in [-180, 180]

mjaschen commented 4 years ago

Well, maybe we can close this issue, but in me world:

Yes, 180 is in [-180, 180] and that's exactly what is checked for. I've explained the check in detail (https://github.com/mjaschen/phpgeo/issues/70#issuecomment-657103198).