I want to compare two routes to check if they are same or not in my iPhone app.
There is a person X who wants to go to point A to point B and another person wants to go to point A1 to point B1.
I can get a route between A to B using this direction APIs of google.
http://maps.googleapis.com/maps/api/directions/xml?origin=Point a A address&destination=Point B address&sensor=false
same way I can get route of A1 to B1.
but the latitude and longitude I am getting in xmls are not matching (even a single point is not matching). So here is my question how can I match two routes I want to know is this same route or not.
If the optimal route A1B1 is actually a subset of the route AB I'd expect the start_location and end_locations for the matching steps to share similar longitudes and latitudes, but this isn't a requirement of the directions API. The best path from A to B might pass through A1 and B1, but that doesn't mean the best path from A1 to B1 will share the exact same steps.
What I think you want to do is look at the polyline points returned for the route segments and see if they would pass through A1 and B1 in the correct order. You can expand the encoded polyline strings into a list of latitude and longitudes using this algorithm.