Issue with manyToOne route matrix request

6 posts / 0 new
Last post
zjsteeve
Issue with manyToOne route matrix request

 

Hi everyone,

I'm new to the forum...just started using the mapquest developer api for my graduate school research. I'm having a weird issue. When I pass a set of locations and make a oneToMany route matrix request, the travel times which are returned all make sense. However, if I pass the same set of locations and make a manyToOne route matrix request, some subset of the travel times which are returned equal 1. As in, if I pass 10 locations it may say that the travel time from 5 of those locations to the first location in my list is 1 second, which definitely doesn't make sense (but all the other times seem to make sense, all of the oneToMany travel times make sense). Any idea why this might be happening? Also, I know there is an allToAll option, but without getting into it that's not what I need to be doing, I really need the manyToOne functionality.

Thanks for any help you could offer!


MQBrianCoakley
Can you post a sample request
Can you post a sample request that produces this result?

zjsteeve
Hi,

Hi,

Yes, here is the first URL request for the with oneToMany set to true:

http://open.mapquestapi.com/directions/v2/routematrix?key=KEY&routeType=...{locations:[{latLng:{lat:42.906734,lng:-78.883541}},{latLng:{lat:42.904947,lng:-78.879507}},{latLng:{lat:42.905871,lng:-78.885044}},{latLng:{lat:42.906281,lng:-78.88359}},{latLng:{lat:42.907313,lng:-78.882587}},{latLng:{lat:42.908871,lng:-78.883587}},{latLng:{lat:42.9039424286,lng:-78.8845081819}},{latLng:{lat:42.9047434565,lng:-78.8865567172}}],options:{allToAll:false,oneToMany:true,manyToOne:false,doReverseGeocode:false}}

 

and the response (with the time matrix, the part I care about, in bold):

{"allToAll":false,"distance":[0,0.337,0.466,0.018,0.44,0.704,0.527,0.497],"time":[0,70,87,3,92,131,103,97],"locations":[{"latLng":{"lng":-78.883541,"lat":42.906734},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.883541,"lat":42.906734},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.879507,"lat":42.904947},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.879507,"lat":42.904947},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.885044,"lat":42.905871},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.885044,"lat":42.905871},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.88359,"lat":42.906281},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.88359,"lat":42.906281},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.882587,"lat":42.907313},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.882587,"lat":42.907313},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.883587,"lat":42.908871},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.883587,"lat":42.908871},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.884508,"lat":42.903942},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.884508,"lat":42.903942},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.886557,"lat":42.904743},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.886557,"lat":42.904743},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"}],"manyToOne":false,"info":{"copyright":{"text":"© 2017 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"© 2017 MapQuest, Inc."},"statuscode":0,"messages":[]}}

 

 

Here is the second URL request, with manyToOne set to true:

http://open.mapquestapi.com/directions/v2/routematrix?key=KEY&routeType=...{locations:[{latLng:{lat:42.906734,lng:-78.883541}},{latLng:{lat:42.904947,lng:-78.879507}},{latLng:{lat:42.905871,lng:-78.885044}},{latLng:{lat:42.906281,lng:-78.88359}},{latLng:{lat:42.907313,lng:-78.882587}},{latLng:{lat:42.908871,lng:-78.883587}},{latLng:{lat:42.9039424286,lng:-78.8845081819}},{latLng:{lat:42.9047434565,lng:-78.8865567172}}],options:{allToAll:false,oneToMany:false,manyToOne:true,doReverseGeocode:false}}

and the response (again with the time matrix in bold):

{"allToAll":false,"distance":[0,0.628,0.473,0.52,0.454,0.188,0.413,0.443],"time":[0,118,1,104,1,1,1,1],"locations":[{"latLng":{"lng":-78.883541,"lat":42.906734},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.883541,"lat":42.906734},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.879507,"lat":42.904947},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.879507,"lat":42.904947},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.885044,"lat":42.905871},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.885044,"lat":42.905871},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.88359,"lat":42.906281},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.88359,"lat":42.906281},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.882587,"lat":42.907313},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.882587,"lat":42.907313},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.883587,"lat":42.908871},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.883587,"lat":42.908871},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.884508,"lat":42.903942},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.884508,"lat":42.903942},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"},{"latLng":{"lng":-78.886557,"lat":42.904743},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"","adminArea3":"","type":"s","displayLatLng":{"lng":-78.886557,"lat":42.904743},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"LATLNG","geocodeQualityCode":"XXXXX","adminArea3Type":"State"}],"manyToOne":true,"info":{"copyright":{"text":"© 2017 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"© 2017 MapQuest, Inc."},"statuscode":0,"messages":[]}}

 

...It makes sense that that not all of the times would match, because there are a lot of one-way streets in this location. But I can't figure out why so many of the time values are being returned as 1 for the manyToOne case. Thanks again for any help!

 


MQBrianCoakley
I'm not sure what's up with
I'm not sure what's up with that, but switching from open to www.mapquestapi.com resolves the issue. Is that an option? It's better quality data so hopefully it's a quick and easy option.

zjsteeve
That fixed it for me too,

That fixed it for me too, thank you so much! I had only written open.mapquest.com based on the form of a code sample I found online. This works perfectly. Really appreciate it!


MQBrianCoakley
Cool. The open.mapquestapi
Cool. The open.mapquestapi.com version uses only Open Street Map data. The www.mapquestapi.com version uses the best data set possible, including OSM. It's usually a much safer bet.