Getting error when requesting asymetric distance matrix


#1

Hi there,

I’ve been having a similar problem to the one posted here.

Whenever I have an asymmetric distance matrix request, the response is either a matrix of ‘null’ values (in the case where the number of sources is less than the number of destinations) or an HTTP 500 (when the number of sources is greater than the number of destinations), with the message:

Could not write JSON: (was java.lang.ArrayIndexOutOfBoundsException); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.ArrayIndexOutOfBoundsException) (through reference chain: heigit.ors.api.responses.matrix.JSONMatrixResponseObjects.JSONMatrixResponse[“matrix”])

Below is a JSON with 1 source and 50 destinations, using either the profile driving-hgv or driving-car:

{“locations”:[[-9.22364,38.7245],[38.699964,-9.228724],[38.72511,-9.226697999999999],[38.724542,-9.229082],[38.724668,-9.227764],[38.717421,-9.231227],[38.721934999999995,-9.227033],[38.724823,-9.226500999999999],[38.717937,-9.230781],[38.724956,-9.227272],[38.702624,-9.233547],[38.724105,-9.22414],[38.723977000000005,-9.227385],[38.711736,-9.245047],[38.722625,-9.228284],[38.719384999999996,-9.264483],[38.723024,-9.221397],[38.713305,-9.238038000000001],[38.710316999999996,-9.243889],[38.719181,-9.231102],[38.719071,-9.230567],[38.725343,-9.226583999999999],[38.725469,-9.228047],[38.725469,-9.228047],[38.728054,-9.241292999999999],[38.723684999999996,-9.227046000000001],[38.724908,-9.227260000000001],[38.705535,-9.232178999999999],[38.708619,-9.227438000000001],[38.706813000000004,-9.23971],[38.715246,-9.2438],[38.706462,-9.225954],[38.724489,-9.22251],[38.723556,-9.227911],[38.723556,-9.227911],[38.729875,-9.246381],[38.720075,-9.230806],[38.725503,-9.228325],[38.725359999999995,-9.227427],[38.717426,-9.230801],[38.707158,-9.229979],[38.725342,-9.226623],[38.724562,-9.228139],[38.724563,-9.228138000000001],[38.708312,-9.242773],[38.725402,-9.222009],[38.713621,-9.23672],[38.704075,-9.227255],[38.720284,-9.219457],[38.711535,-9.248978],[38.7244,-9.22363]],“sources”:[0],“destinations”:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50],“metrics”:[“distance”],“units”:“m”}

which returns:

{“distances”:[[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]],“destinations”:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],“sources”:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],“metadata”:{“attribution”:“openrouteservice.org | OpenStreetMap contributors”,“service”:“matrix”,“timestamp”:1554647956613,“query”:{“locations”:[[-9.22364,38.7245],[38.699964,-9.228724],[38.72511,-9.226697999999999],[38.724542,-9.229082],[38.724668,-9.227764],[38.717421,-9.231227],[38.721934999999995,-9.227033],[38.724823,-9.226500999999999],[38.717937,-9.230781],[38.724956,-9.227272],[38.702624,-9.233547],[38.724105,-9.22414],[38.723977000000005,-9.227385],[38.711736,-9.245047],[38.722625,-9.228284],[38.719384999999996,-9.264483],[38.723024,-9.221397],[38.713305,-9.238038000000001],[38.710316999999996,-9.243889],[38.719181,-9.231102],[38.719071,-9.230567],[38.725343,-9.226583999999999],[38.725469,-9.228047],[38.725469,-9.228047],[38.728054,-9.241292999999999],[38.723684999999996,-9.227046000000001],[38.724908,-9.227260000000001],[38.705535,-9.232178999999999],[38.708619,-9.227438000000001],[38.706813000000004,-9.23971],[38.715246,-9.2438],[38.706462,-9.225954],[38.724489,-9.22251],[38.723556,-9.227911],[38.723556,-9.227911],[38.729875,-9.246381],[38.720075,-9.230806],[38.725503,-9.228325],[38.725359999999995,-9.227427],[38.717426,-9.230801],[38.707158,-9.229979],[38.725342,-9.226623],[38.724562,-9.228139],[38.724563,-9.228138000000001],[38.708312,-9.242773],[38.725402,-9.222009],[38.713621,-9.23672],[38.704075,-9.227255],[38.720284,-9.219457],[38.711535,-9.248978],[38.7244,-9.22363]],“profile”:“driving-hgv”,“responseType”:“json”,“sources”:[“0”],“destinations”:[“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“11”,“12”,“13”,“14”,“15”,“16”,“17”,“18”,“19”,“20”,“21”,“22”,“23”,“24”,“25”,“26”,“27”,“28”,“29”,“30”,“31”,“32”,“33”,“34”,“35”,“36”,“37”,“38”,“39”,“40”,“41”,“42”,“43”,“44”,“45”,“46”,“47”,“48”,“49”,“50”],“metrics”:[“distance”],“units”:“m”},“engine”:{“version”:“5.0”,“build_date”:“2019-03-21T12:24:30Z”}}}

And here is a JSON with 50 sources and 1 destination, using the profile driving-car:

{“locations”:[[-9.228724,38.699964],[-9.226697999999999,38.72511],[-9.229082,38.724542],[-9.227764,38.724668],[-9.231227,38.717421],[-9.227033,38.721934999999995],[-9.226500999999999,38.724823],[-9.230781,38.717937],[-9.227272,38.724956],[-9.233547,38.702624],[-9.22414,38.724105],[-9.227385,38.723977000000005],[-9.245047,38.711736],[-9.228284,38.722625],[-9.264483,38.719384999999996],[-9.221397,38.723024],[-9.238038000000001,38.713305],[-9.243889,38.710316999999996],[-9.231102,38.719181],[-9.230567,38.719071],[-9.226583999999999,38.725343],[-9.228047,38.725469],[-9.228047,38.725469],[-9.241292999999999,38.728054],[-9.227046000000001,38.723684999999996],[-9.227260000000001,38.724908],[-9.232178999999999,38.705535],[-9.227438000000001,38.708619],[-9.23971,38.706813000000004],[-9.2438,38.715246],[-9.225954,38.706462],[-9.22251,38.724489],[-9.227911,38.723556],[-9.227911,38.723556],[-9.246381,38.729875],[-9.230806,38.720075],[-9.228325,38.725503],[-9.227427,38.725359999999995],[-9.230801,38.717426],[-9.229979,38.707158],[-9.226623,38.725342],[-9.228139,38.724562],[-9.228138000000001,38.724563],[-9.242773,38.708312],[-9.222009,38.725402],[-9.23672,38.713621],[-9.227255,38.704075],[-9.219457,38.720284],[-9.248978,38.711535],[-9.22363,38.7244],[-9.22364,38.7245]],“sources”:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49],“destinations”:[50],“metrics”:[“distance”],“units”:“m”}

which returns an HTTP 500 error with the message:

Could not write JSON: (was java.lang.ArrayIndexOutOfBoundsException); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.ArrayIndexOutOfBoundsException) (through reference chain: heigit.ors.api.responses.matrix.JSONMatrixResponseObjects.JSONMatrixResponse[“matrix”])

I have also tested this by reducing the total number of locations and maintaining an asymetric request (always specifying the sources and the destinations), and I obtained the same results.

I recognize that the issue is very similar to the one I linked above, I just wanted to give extra information and inform you that the driving-hgv only fixed half the problem for me (when there are more sources than destinations this works, but not when there are more destinations than sources).

Thank you for your time!