Answer the question
In order to leave comments, you need to log in
How to implement a taximeter?
I am making a taximeter for online taxi. Every few seconds, the coordinates of the carrier (latitude and longitude) are sent to the server. And then we calculate the distance using the Haversine. But there is one thing - turns are not taken into account, etc. the distance in a straight line is considered. Is it right to do so? Or is there a more accurate calculation method?
Answer the question
In order to leave comments, you need to log in
If this is to determine the cost of a trip before ordering, then through the maps API.
If this is to determine the actual distance traveled, then just take readings often, turns will also be taken into account.
And what's the problem with taking api maps, building a route from points and they will give you the distance.
And so you have a broken line and many points, and count each segment, and add it up.
Well, in general, it’s easier to get km from a car, and travel time.
The problem of crooked tracks is solved by matching the track with the road graph. So if you want more accurate readings of distances, then dig in this direction. Here the guys are sawing a convenient graph for this case, but I read diagonally, I don’t know how complete it is there.
I would suggest not sending the coordinates to the server, but calculating the distance traveled on the device, and sending the distance traveled to the server. Or send a packaged track to the server with more frequent readings (for example, as here https://habrahabr.ru/post/318796 or here https://developers.google.com/maps/documentation/u...
In general, this is done like this: a special engineer puts a special device on the car (actually, a taximeter), which has a sensor associated with the transmission, and which transmits an electrical signal to the taximeter every 100-200 meters. The engineer then sits down and drives a predetermined distance to "teach" the sensor. When the driver presses the button (the passenger has taken a taxi), the countdown starts. The device is programmed in such a way that if it does not receive signals for some time (for example, 30 seconds), then it considers that idle time has begun, and starts counting the time as idle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question