How to calculate speed of our car using iphone
Asked Answered
N

2

12

For my application I want to calculate my car/bike speed using iphone. How can i do that? Ideally, it should run continuously in the background.

Nisen answered 29/9, 2010 at 5:16 Comment(1)
I may be missing something, but: take GPS reading. Some period of time later, take another GPS reading. Find distance between these two points, divide by the time difference between the two readings. That's your speed. Repeat.Dustydusza
O
15

CLLocation includes a speed property that will give you the current speed of the device. (Note the comment about the accuracy at that link.)

To get the user's current location, follow the steps in the Location Awareness Programming Guide, under "Getting the User's Current Location".

Finally, to enable location updates in the background, see Receiving Location Events in the Background in the iOS Application Programming Guide.

Oodles answered 29/9, 2010 at 5:27 Comment(2)
The Location Awareness Programming Guide has sample code. Also, look at the "Related Sample Code" for the CLLocationManager class reference. developer.apple.com/library/ios/#documentation/CoreLocation/…Oodles
Just be aware that speed will be reliable once in motion and you are getting regular location updates. Once you have stopped, then updates will only occur if you travel the required distance configured when location service updates were started.Bryophyte
K
0

the only way i can think of is thru GPS. the accelerometer is out. but im not sure if enough information is provided thru "GPS API".

Kinglet answered 29/9, 2010 at 5:19 Comment(1)
If it provides position, "just" calculate its change within an interval, and there's your speed (accuracy issues aside).Intergrade

© 2022 - 2024 — McMap. All rights reserved.