DIstance Matrix API not including last location in export

Hi,
I have a problem when getting a distance matrix of 100 jobs via the API. I send them ok, and I see in the response that “count”:100. However, the results matrix is only 9,507 elements long, and when I manually scroll through the response at the To and From numbers, I’m noticing that the highest index is 98, not 99. For instance, this is the last element of the distances array:

{“9506”: {  “from”: 97,
  “to”: 98,
  “distance”: 43498,
  “duration”: 2988,
  “router”: true
}}

Is there a bug that could be causing me to get an incomplete matrix?

Not sure. When we test the distances the full matrix is returned. It may be input related. We’d need the exact data you send to check it out in more detail. Please either share it here or email to info@routexl.com

It seems the location with name “43585464” has an error. The longitude key name has a space in it and is spelled as "lng ". The API can’t find the lng value for this location and it gets skipped.

We’ll note down for development to add a better input check to the API.

You are right, that was a mistake. We took the input from the email notification we had received. It probably has some formatting added. Our bad, sorry!

Still, the error is input related. Another location with address “43589184” has empty lat and lng values. It is therefore skipped.

{"address":"43589184","lat":"","lng":"","servicetime":0,"restrictions":{"ready":0,"due":0}}

Thank you for the suggestions. We’ll take note of them for future development.

Thanks, please see below:

locations=[{“address”:“43380081”,“lat”:“41.697666”,“lng”:"-74.5400439",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43178164”,“lat”:“41.80518621”,“lng”:"-74.75218478",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43537006”,“lat”:“41.8728408813477”,“lng”:"-73.9791717529297",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43148380”,“lat”:“41.85577796”,“lng”:"-74.07355195",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43206047”,“lat”:“41.5617”,“lng”:"-74.4516769",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43550230”,“lat”:“41.717533”,“lng”:"-73.9553569",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43525552”,“lat”:“41.78878011”,“lng”:"-74.74995252",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43495039”,“lat”:“41.7847326”,“lng”:"-74.75856194",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43525566”,“lat”:“41.79931718”,“lng”:"-74.76006601",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43427930”,“lat”:“41.682736”,“lng”:"-73.971366",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43522710”,“lat”:“41.92421855”,“lng”:"-73.98387077",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43522712”,“lat”:“41.90261394”,“lng”:"-73.98059935",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43525864”,“lat”:“41.69832516”,“lng”:"-74.58364987",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43527451”,“lat”:“41.63011843”,“lng”:"-74.47292707",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43546450”,“lat”:“41.64955155”,“lng”:"-74.46829398",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43546451”,“lat”:“41.65132217”,“lng”:"-74.54060183",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43547224”,“lat”:“41.917544”,“lng”:"-73.985431",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43547464”,“lat”:“41.92337737”,“lng”:"-73.9965598",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43547500”,“lat”:“41.650194”,“lng”:"-74.5246439",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43547709”,“lat”:“41.60913755”,“lng”:"-73.98064686",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43548801”,“lat”:“41.74750447”,“lng”:"-74.08948539",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43548385”,“lat”:“41.79411236”,“lng”:"-74.68778282",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43483262”,“lat”:“41.77807406”,“lng”:"-74.57343141",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43528900”,“lat”:“41.891576”,“lng”:"-74.0028249",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43528901”,“lat”:“41.9190659”,“lng”:"-73.9940646",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43247253”,“lat”:“41.79726162”,“lng”:"-74.76212303",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43571182”,“lat”:“41.92666848”,“lng”:"-73.98559305",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43571188”,“lat”:“42.127775”,“lng”:"-73.9589189",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43571332”,“lat”:“41.63215078”,“lng”:"-74.67324191",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43572413”,“lat”:“41.7163375”,“lng”:"-74.65036171",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43572486”,“lat”:“41.453577”,“lng”:"-74.074605",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43463851”,“lat”:“41.90603873”,“lng”:"-74.06033099",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43464368”,“lat”:“41.697951”,“lng”:"-74.5789139",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43465894”,“lat”:“41.93386779”,“lng”:"-73.99497742",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43488804”,“lat”:“42.06338533”,“lng”:"-73.959724",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43561474”,“lat”:“41.63277774”,“lng”:"-74.71452711",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43566204”,“lat”:“41.59012106”,“lng”:"-74.49952997",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43566370”,“lat”:“41.7797539”,“lng”:"-74.578286",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43568038”,“lat”:“41.784309”,“lng”:"-74.070111",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43568044”,“lat”:“41.59659774”,“lng”:"-74.39677667",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43572766”,“lat”:“41.615136”,“lng”:"-73.9708879",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43572801”,“lat”:“41.464258”,“lng”:"-74.088707",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43572818”,“lat”:“41.51794639”,“lng”:"-74.5720732",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43573199”,“lat”:“42.013649”,“lng”:"-73.984672",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43575283”,“lat”:“41.490888”,“lng”:"-74.022671",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43561459”,“lat”:“41.80511129”,“lng”:"-74.74257524",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43561442”,“lat”:“41.77791828”,“lng”:"-74.93400507",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43566785”,“lat”:“41.79961243”,“lng”:"-74.75275034",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43572780”,“lat”:“41.77944825”,“lng”:"-74.68200766",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43581195”,“lat”:“41.92459417”,“lng”:"-74.05295361",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43581236”,“lat”:“42.15590812”,“lng”:"-74.01667442",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43581361”,“lat”:“41.48527035”,“lng”:"-74.01751595",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43581368”,“lat”:“41.69705”,“lng”:"-73.984134",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43581378”,“lat”:“41.61727474”,“lng”:"-74.0733509",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43581383”,“lat”:“41.768188”,“lng”:"-74.736915",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43581393”,“lat”:“41.717688”,“lng”:"-74.857455",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43588860”,“lat”:“41.515446”,“lng”:"-74.089259",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43589128”,“lat”:“41.771398”,“lng”:"-74.492071",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43589132”,“lat”:“41.6670424”,“lng”:"-73.9608631",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43589135”,“lat”:“41.65159685”,“lng”:"-74.54168441",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43589184”,“lat”:"",“lng”:"",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43590137”,“lat”:“41.712078”,“lng”:"-74.3862709",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43590270”,“lat”:“41.98449193”,“lng”:"-74.00454835",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43590324”,“lat”:“41.52803735”,“lng”:"-74.07943979",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43590334”,“lat”:“41.555559”,“lng”:"-74.082446",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43590369”,“lat”:“41.785131”,“lng”:"-74.2277079",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43586055”,“lat”:“41.81075236”,“lng”:"-74.74276602",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43590368”,“lat”:“41.8006914”,“lng”:"-74.69000696",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43486564”,“lat”:“41.94655911”,“lng”:"-74.00563643",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43530539”,“lat”:“41.92576196”,“lng”:"-73.98755451",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43530549”,“lat”:“41.49492257”,“lng”:"-74.017158",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43566816”,“lat”:“41.95863891”,“lng”:"-74.01225669",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43566817”,“lat”:“41.902186”,“lng”:"-74.151066",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43566822”,“lat”:“42.004757”,“lng”:"-74.110593",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43570164”,“lat”:“41.466364”,“lng”:"-74.033957",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43570160”,“lat”:“41.80521966”,“lng”:"-74.99312768",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43589243”,“lat”:“41.83873503”,“lng”:"-74.59421287",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43596818”,“lat”:“41.791855”,“lng”:"-74.029316",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43596847”,“lat”:“41.855812”,“lng”:"-74.55715118",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43596922”,“lat”:“41.813934”,“lng”:"-74.31192",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43596927”,“lat”:“41.473972”,“lng”:"-74.144516",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43597046”,“lat”:“41.724522”,“lng”:"-74.392234",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43600872”,“lat”:“41.4492972”,“lng”:"-74.12219938",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43428523”,“lat”:“42.05722676”,“lng”:"-73.96235508",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43515093”,“lat”:“41.92904051”,“lng”:"-73.99281424",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43520050”,“lat”:“41.81823013”,“lng”:"-74.88542935",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43553602”,“lat”:“41.51121155”,“lng”:"-74.02515938",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43553674”,“lat”:“41.57335226”,“lng”:"-74.48816069",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43553719”,“lat”:“41.5972”,“lng”:"-73.9906",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43553724”,“lat”:“41.86702569”,“lng”:"-74.20581045",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43575801”,“lat”:“41.6124539”,“lng”:"-74.67768696",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43584791”,“lat”:“41.73880711”,“lng”:"-74.38390728",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43584794”,“lat”:“41.621872”,“lng”:"-74.740061",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43584862”,“lat”:“41.70949118”,“lng”:"-74.58008047",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43584928”,“lat”:“41.50574536”,“lng”:"-74.0394097",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43585464”,“lat”:“41.996051”,“lng”:"-73.969873",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43586101”,“lat”:“41.51181884”,“lng”:"-74.0162718",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43586228”,“lat”:“41.65753761”,“lng”:"-74.68544578",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“43586306”,“lat”:“41.432742”,“lng”:"-74.113473",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}},{“address”:“home”,“lat”:“41.5712866187096”,“lng”:"-74.1843666136265",“servicetime”:0,“restrictions”:{“ready”:0,“due”:0}}]

I’m sorry, I can’t find a typo there (perhaps you can reply with the text as it appears to you). No spaces, and all addresses have key spelled “lng” as in the documentation. Also, since each address entry in this request is generated by the same code, I’d be confused if there was a typo in just one.

I definitely don’t see the issue you are describing, maybe it is a formatting issue on this page or my error. Perhaps you can send the request without the typo, and let me know if you can reproduce my issue? If so, you will see the last element in the response be “97 to 98”, and no mention of index 99.

Thanks so much, I should’ve caught that. Great support guys. 

Just a suggestion: to identify the points returned in the matrix response, i have to keep track of the addresses I sent and their order. Thats do-able, but little things like this are pretty hard to recover from, cause it throws the whole table off. maybe you guys can either:

  1. give a count of the returned elements, then i can see if they match the request
  2. include a reference table so the name values included in the request can be matched to an index in the matrix
  3. Still include elements that were skipped, and provide an error similar to router:false
    As it stands now i’ve implemented a workaround which has helped me fix a biiiiiig issue in my software that i was stuck on, thanks again!