0

I have direction steps from city A to city B (obtained from Google Directions API). I need to differentiate the interstate road distances from non-interstate distances in the route.

Google Directions API is not giving that information, it gives the points of each turn, and also gives text instructions for the route. Unfortunately, it doesn't give information about which street/highway the current path is currently on (Bing Maps API gives that information, but I can't use it). So the first solution that came to my mind was checking the roads with the instruction text. I tried to separate the roads from the given instruction texts, but the precision was not so good, as the texts have lots of different instructions, checking all of the text templates is impossible, as at one point there will be a text which will be classified wrong for some direction.

Another possible solution is to get each segment's coordinates, place into Google Roads API (which gives the places which were visited), then use Places API for each visited place to detect if it was interstate road or not. This will work fine, but there are lots of steps with coordinates (I need to go step by step because I want to get the distance), and the Roads API takes at most 100 coordinates per request. It equals to about 7000 requests, which is also very costly for one direction.

Yet another solution is to download the interstate roads coordinates, then check if the current step is in one of the interstate road. Though it is still lots of calculations, but it is an acceptable solution. However, I think that it may not work, as even a small interstate road point offset would make the results incorrect. So I am thinking about making a polygon out of the each of the roads' polylines/coordinates, making the area larger (having the same line form, but thickened), to be sure that the direction coordinates/polylines which intersects the interstate roads in real life, will surely be contained within the interstate polygons. For this I need either polygons of interstate roads or a way to make them out of coordinates/polylines (I can get the coordinates/polylines).

Is there easier solution, but if no, what can you suggest? I need the end task to be done in PHP, however I can use Python or any other free tools to make the intermediate files and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.