Snap to road

2 posts / 0 new
Last post
bikerfab
Snap to road

hello,

my application requires the user to click start-end points on a map to get directions. The points are passed to the direction query url using "locations:[  ]". If the points are not exactly on a road, the directions are generated snapping to the closest road, but if they are "too far" from any road, direction request fails. Is there any way to get the point on a road (any road) closest to a specified one which is not on a road, regardless the distance from the road ? For my application would be acceptable to change the start-end points snapping to roads, just giving a warning to the user.

For example:

http://www.mapquestapi.com/directions/v2/route?key=my_key&ambiguities=ignore&outFormat=json&inFormat=json&callback=renderMQDirections&json={locations:["45.72384346651454,9.690756797790527","45.71810584183191,9.697322845458984"],options:{disallows:[Toll Road, Unpaved],avoidTimedConditions:false,doReverseGeocode:false,shapeFormat:raw,generalize:0,routeType:bicycle,timeType:0,unit:k,cyclingRoadFactor:1,roadGradeStrategy:AVOID_UP_HILL,narrativeType:none}}

This query fails (602 unable to generate route).

It would be acceptable to modify the query using a slighlty different start point (i selected it manually clicking closer to a road):

http://www.mapquestapi.com/directions/v2/route?key=my_key&ambiguities=ignore&outFormat=json&inFormat=json&callback=renderMQDirections&json={locations:["45.72218066464547,9.687860012054443","45.71810584183191,9.697322845458984"],options:{disallows:[Toll Road, Unpaved],avoidTimedConditions:false,doReverseGeocode:false,shapeFormat:raw,generalize:0,routeType:bicycle,timeType:0,unit:k,cyclingRoadFactor:1,roadGradeStrategy:AVOID_UP_HILL,narrativeType:none}}

By the way, the end point is not on a road as well but is automatically snapped to the closest one.

Thanks

Fabio

 

PS: is there any search feature on this forum ? I don't see a button to search previously answered questions by search terms. It would be very useful.


MQBrianCoakley
Sorry, no search. Yet.
Sorry, no search. Yet.   If I removed the unpaved restriction from that route it works great.   The router will search within a mile or so of the given locations for a routable road segment. If it's beyond that then the route will fail. There is no function to grab the nearest routable road segment beyond that distance.