Kia ora!
I’ve finally figured out how to get a local install going (M1 Mac - 13.2.1, Java). I have this custom class, with which I intend to test the upper limits of running ORS locally (I’ve changed the maximum number of routes to 100,000,000):
private static APIEnums.Profile car;
private static MatrixRequest matrixLocationsRequest;
private static Double[][] bareCoordinates;
public static void main(String[] args) throws StatusCodeException {
car = APIEnums.Profile.DRIVING_CAR;
int n = 1000;
float lon_min = 7.70847f; // I don't currently know how to change the default location ORS thinks we're handling.
float lon_max = 9.10395f;
float lat_min = 49.3326f;
float lat_max = 49.5168f;
bareCoordinates = new Double[n][];
String st[] = new String[]{"all"};
int i = 0;
while (i < n){
double lon = (float)Math.random() * (lon_max - lon_min) + lon_min;
double lat = (float)Math.random() * (lat_max - lat_min) + lat_min;
MatrixRequest tempReq = new MatrixRequest(new Double[][]{new Double[]{lon, lat}, new Double[]{lon, lat}});
tempReq.setSources(st);
tempReq.setDestinations(st);
tempReq.setProfile(car);
tempReq.setMetrics(new MatrixRequestEnums.Metrics[]{MatrixRequestEnums.Metrics.DURATION});
tempReq.setResponseType(APIEnums.MatrixResponseType.JSON);
MatrixResult res;
try {
res = tempReq.generateMatrixFromRequest();
if(res != null && res.getTable(1)[0] == -1) // res.getTable(1)[x] should == 0, as from a valid node i to i == dist 0, but if == -1, we have failed to identify a valid points
continue;
} catch (Exception e){
continue;
}
bareCoordinates[i] = new Double[] {lon, lat};
i++;
}
System.out.println("fin random generation");
long start = System.currentTimeMillis();
matrixLocationsRequest = new MatrixRequest(bareCoordinates);
matrixLocationsRequest.setResolveLocations(true);
matrixLocationsRequest.setSources(st);
matrixLocationsRequest.setDestinations(st);
matrixLocationsRequest.setProfile(car);
matrixLocationsRequest.setMetrics(new MatrixRequestEnums.Metrics[]{MatrixRequestEnums.Metrics.DURATION});
matrixLocationsRequest.setResponseType(APIEnums.MatrixResponseType.JSON);
MatrixResult res = matrixLocationsRequest.generateMatrixFromRequest();
long end = System.currentTimeMillis();
System.out.println("Comp time (s): " + ((end - start)/1000));
float[] distances = res.getTable(1);
System.out.println("distances len: " + distances.length);
int count = 0;
for (i = 0; i < distances.length; i++) {
if (distances[i] != -1) {
count++;
}
}
System.out.println(count); // the number of feasible distance calculations
}
I have the following outstanding problems:
- I presume
res.getTables()[1](metric1) refers to the requestedDURATIONmetric? - How do I parse the single-dimension
valuesarray (length1,000,000)? Is theindexof the cost (duration/distance) from nodeito nodejequal toindex = j * n + i, wherenis the number of destination nodes? - Approximately 25% of the values in my
res.getTables()[1]array equal-1. My only explanation for routes that can’t be found is if the graphs upon which pointiandjoccur are disconnected. Is someone able to confirm this? Note: these all occur whensptItem.getParent() == nullin thecalcValuesmethod of theMultiTreeMetricsExtractorclass. [linked question] - I believe there are two cases for generating a value of
0: a) two randomly generated points are so (geographically) close that they snap to the same graph node (the rarest), and b) two geographic points are equal (the most common). Is this correct? - I’ve tried changing the
ors-config.jsonfile inopenrouteservice/target/classesto point to a custom .osm.pbf (osm.gz and .osm) file, but none have changed the bounding box that ORS defaults to using.
Appreciate your help.
Cheers