Thursday, 2 April 2015

osm2po - Graph.traverse() maximum targetIds?


I am using the function:


traverse(Graph graph, int sourceId, int[] targetIds, float maxCost,                     java.util.Properties params) 

and I found out that if I feed more than 144 targetIds it will throw an ArrayOutOfBounds exception, anything below 144 works fine.


Is this an intrinsic limitation of the function or am I doing something wrong?



Answer




No! There is no magic number 144. Can you give me more infos in shape of a hopefully generated stacktrace? Maybe one of the IDs you have passed is not part of the Graph. The maximum number of VertexIDs depends on the max. number of edges which is limited to 2 Gig by design.


Nevertheless, I'm assuming, you are using the PoiRouter to create a distance matrix. Since v4.8.8 this can be done with the new TspMatrix-Interface.


General info for all readers / followers:


the Java example on the home page calculates a route but no Matrix.


It demonstrates how to



  1. find IDs for nearest vertices given a lat/lon coord.

  2. what kind of optional params (Properties) are possible.

  3. reconstruct data from routing results



you can adopt 85% of this example for the TspMatrix call. The TspMatrix() is a functor, which passes an array of vertexIds(stations/crossings) to osm2po's MultiTargetRouter (PoiRouter). The result is a cost matrix and an additional one for all corresponding paths. By the way, I decided to make osm2po an easy to use library. I'm a fan of the KISS paradigm, so 5 minutes of debugging, analizing some variables should give you a quick AHA-effect.


Here is the call:


TspMatrix tspMatrix = new TspDefaultMatrix(Graph graph, int[] vertexIds,
float maxCost, Log log, Properties params);

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...