airos: fix latitude having an extra - in the middle after the decimal point (#13454)

* fix latitude having an extra - in the middle after the decimal point

fix latitude having an extra - in the middle after the decimal point

* consolidate

* style

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Jamie Baker
2021-11-02 04:18:21 +00:00
committed by GitHub
parent 3c37020f36
commit aa5205b95e

View File

@@ -73,8 +73,10 @@ class Airos extends OS implements
{
$location = parent::fetchLocation();
// fix longitude having an extra - in the middle after the decimal point
$location->lng = (float) preg_replace('/(-?\d+)\.-?(\d+)/', '$1.$2', $location->getAttributes()['lng']);
// fix having an extra - in the middle after the decimal point
$regex = '/(-?\d+)\.-?(\d+)/';
$location->lng = (float) preg_replace($regex, '$1.$2', $location->getAttributes()['lng']);
$location->lat = (float) preg_replace($regex, '$1.$2', $location->getAttributes()['lat']);
return $location;
}