jacketizer / libnmea

Lightweight C library for parsing NMEA 0183 sentences
MIT License
260 stars 92 forks source link

Detect if device has taken a turn using GPS location ? #15

Closed SandyWare closed 7 years ago

SandyWare commented 7 years ago

How can I detect if device has taken a turn using GPS location. Is comparing previous & current azimuth value will give me a result ? Ex: int precision = 10; if ( (nmeaMathRadianToDegree(azimuth[it][0]) - nmeaMathRadianToDegree(azimuth[it][1]) ) < precision * -1) cout<<"Taken -> RIGHT"<<endl; else if ( (nmeaMathRadianToDegree(azimuth[it][0]) - nmeaMathRadianToDegree(azimuth[it][1]) ) > precision) cout<<"Taken -> LEFT"<<endl;

jacketizer commented 7 years ago

I have actually no idea but if I would take a guess, you seem to be on the right track. However, you may want to think about how a turn looks like in the terms of time and movement. Is it wide or narrow? How much time will it take to perform the turn? I think it depends a lot on the application. A more straight forward approach would be to just compare two azimuth values at different points in time, lets say 10 seconds apart, and then make a decision. But what if the user drives in a roundabout or makes a turn that takes more than 10 seconds to finish? Is it the end result that matters or do you have to track all kinds of turns, even in roundabouts etc?