How to track route of user between two locations? - android

I have two Addresses let say Location A and Location B. And I have series of location between those Location A and Location B. I get those series of locations via Fused location API. and saved them on the server. Now following are my requirements :
What I want:
I want to calculate the distance between the Location A and Location B. Right Now I am using a code (link of post here) but it is giving me displacement.
Problems and Confusions:
I know about Google Distance matrix API and Google Directions api, but I really do not want to work on these apis as these are costly to me. But if I use them, I really did not understand that how API will know the route user selected. I mean it is possible that User has adopted the long way towards his destination. And I think google Direction and Distance API are returning the distance between Location A and Loation B using shortest route.
I really do not want to use the API, but if there is non other
possible way to do that then How could I get that ? and what is best
for me. Please suggest me the solution.

I think you have just idea of your logic but you do not know what it is called. Though it is too late but I am posting for your information or in case of if someone later on visit here.
To draw lines between two points on Map,Use Polylines and polygons. To read further I will refer you to this google page, It has a breif introduction and also a source code. And it is even really easy to implement. Here you go.

Related

Geofencing procedure

How does geofencing works? I mean I just need two GPS coordinates (user's and target's GPS coordinates) and radius, then find distance between of them and if distance is less than or equal to radius then person is in geofence . Or there is more?
That's pretty much it. There's probably some smoothing algorithms (to protect against bad readings causing a jump in a person's location),but its pretty much a distance check between two coordinates.
The above solution work fine if we have a circular geofence, But if we have a geofence in a polygon shape, then we have to check if the user's location is within the boundry of the polygon.
There are many ways to do so
1. Google apis (if we are looking for android development).
2. Here map ( if we are going to expose rest apis, it is paid service).
3. Openmap provide library which can be used to create rest back end points . (free)

Android Algorithm Google Direction Check start point and destination point in the polyline

I have a project, it 's a carpooling app that means you can find people who can give you a lift if, in there plan road, they can pick you up and take you to where you want to go.
The problem is about algỏrithm to find a suitable trip match with my start place and destination place, that mean my start place location and destination place location have to be in their road and same direction.
I think about user google map direction to download overview_polyline then I can have a list of latlng to test, but then I have to save the list to firebase data and get them whatever I want to test, that requires a lot of data because latlng points of the road is too many and also too many posts about the trip have to be saved.
if you guys have a better idea for this situation or know some tool, algorithm, API which can solve this problem please show me your answer.
I think you should store the user's navigation route as a polyline(i.e. save it's geometry), maybe in PostGIS because you will have 100's and 1000's of routes to be saved, and then whenever any user queries to find any available car you apply intersection between the user's current location and the saved route in the PostGIS DB.
Hope it helped. :)

How to sort list of locations according to driving list on one trip route?

My Android app scenario is the following:
The user is a bus driver and he has some people to deliver to their locations(places). Is there is a way to do the following:
Get the best route passes from their locations.
Sort this list according to driving distance on that route.
Get each location's driving distance according to that route.
Can any of the Google APIs help me accomplish the above? Or perhaps a combination of two APIs?
Update:
I see that google-matrix-API give me the driving distance from an origin location to some destinations but I am not sure that it will calculate them as on the one driving trip.

How do I find the point on a google map that's closest to me?

I am writing an Android-application that is supposed to download a bunch of addresses from my SQL-server, reverse geocode them, compare them all to my current location and return the one that is closest to me, not geometrically, but the one that I am the shortest driving distance from.
I have managed to get the reversed geocoding to work, but when I run my program a few times, I hit the OVER_QUERY_LIMIT on google. Needless to say, there are quite a few addresses in my database.
I understand that I could do this the quick and dirty way and just see which address is nearest to me by comparing the latitude and longitude of my current position and that of my addresses as opposed to comparing it to the actual driving distance. The problem with this is that this application will be used in a region where there are quite a lot of lakes to drive around and using that method will likely return quite a few stupid results.
How can I keep this from happening over and over? Can I present google with a view of all my addresses and just do a comparison once? I really need help with this one.
Actually, you will have to query a routing service (not necessarily Google Maps, to my knowledge also Cloudmade provides you with routing; there definitely are more) to get driving directions to each of the Points Of Interest around you and then select the closest one. This is a very bad practice, as you are very limited with the request amount.
According to the Google Maps API TOS (paragraph 10.1.3) you are not always allowed to do that.
What I did in a similar case was to store the coordinates for all POI, and look up the closest ones just by range of lat/lng.

android: show direction in google maps

i am developing an android application that use map view.
i can add point to the map, zoom, get current location and animate to point.
but how to get direction between 2 points?
when user click on point to show direction between current location and clicked location.
Thanks
but how to get direction between 2 points?
Math. This has nothing to do with Android. It has little to do with maps, even. It has everything to do with math.
Depending on the distances involved, you might be able to get away with treating things as plain Carteisan coordinates and do the necessary trigonometry. Over a significant distance, though, the curvature of the Earth starts to play a role, and the math will get harder.
You might consider using a search engine to find whatever versions of the formulas you would like to use.
in order to show a direction on maps (android)
you can try to make an Overlaying custom route on your application.
We shall further assume that the route returned may contain additional information such as the local slope of the route (which could be important if one is negotiating the route in a wheelchair, for example). Since this requires a network access that could block the main UI thread if there are network difficulties, we shall also use this example to introduce the important skill of putting time-consuming or potential UI-blocking tasks on a background thread. and use AsyncTask to run the process in the background. To use AsyncTask we must subclass it.
maybe this is helped you out.

Categories

Resources