stanleyhuangyc / Freematics

Official source code repository for Freematics
https://freematics.com
419 stars 345 forks source link

Update the invalid coordinates filter to be on the same scale #103

Closed DaJackkal closed 4 years ago

DaJackkal commented 4 years ago

The lat and lng variables have the dd.dddddd format, and that's what the gpsData->lat and gpsData->lng is assigned if the good flag is true. So we must make the comparison on the same scale. At the moment, if lat (or lng) is 51.123456 and the gpsData->lat is 51.100000, the formula will be 51.123456 - 51.100000 1000000, while it should be on the same scale, like 51.123456 1000000 - 51.100000 * 100000 and then the formula makes sense. The same formula is user on the else branch of the outer if statement, but there it makes sens because the gpsData->lat = lat/1000000.