From 0fe5d5144ade93f621ae6431eaa9c98601306b65 Mon Sep 17 00:00:00 2001 From: Arndt Date: Sun, 8 Feb 2015 10:05:50 +0100 Subject: [PATCH] changed error message for missing datafile to include filename --- .../src/main/java/btools/router/RoutingEngine.java | 6 +++++- .../src/main/java/btools/mapaccess/NodesCache.java | 12 ++++++++++++ .../src/test/java/btools/server/RouterTest.java | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index 277ffe3..d1fb894 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -298,9 +298,13 @@ public class RoutingEngine extends Thread return mwp; } } + if ( minRingWith == 1 && nodesCache.first_file_access_failed ) + { + throw new IllegalArgumentException( "datafile " + nodesCache.first_file_access_name + " not found" ); + } if ( minRingWith++ == 5 ) { - throw new IllegalArgumentException( wp.name + "-position not mapped" ); + throw new IllegalArgumentException( wp.name + "-position not mapped in existing datafile" ); } } } diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/NodesCache.java b/brouter-mapaccess/src/main/java/btools/mapaccess/NodesCache.java index 4393a67..a531fa4 100644 --- a/brouter-mapaccess/src/main/java/btools/mapaccess/NodesCache.java +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/NodesCache.java @@ -33,6 +33,8 @@ public final class NodesCache public DistanceChecker distanceChecker; public boolean oom_carsubset_hint = false; + public boolean first_file_access_failed = false; + public String first_file_access_name; private long cacheSum = 0; private boolean garbageCollectionEnabled = false; @@ -48,6 +50,9 @@ public final class NodesCache this.carMode = carMode; this.forceSecondaryData = forceSecondaryData; + first_file_access_failed = false; + first_file_access_name = null; + if ( !this.segmentDir.isDirectory() ) throw new RuntimeException( "segment directory " + segmentDir + " does not exist" ); if ( oldCache != null ) @@ -249,6 +254,13 @@ public final class NodesCache OsmFile osmf = new OsmFile( ra, tileIndex, iobuffer ); osmf.lonDegree = lonDegree; osmf.latDegree = latDegree; + + if ( first_file_access_name == null ) + { + first_file_access_name = currentFileName; + first_file_access_failed = osmf.filename == null; + } + return osmf; } diff --git a/brouter-server/src/test/java/btools/server/RouterTest.java b/brouter-server/src/test/java/btools/server/RouterTest.java index 6933536..3b4612e 100644 --- a/brouter-server/src/test/java/btools/server/RouterTest.java +++ b/brouter-server/src/test/java/btools/server/RouterTest.java @@ -39,7 +39,7 @@ public class RouterTest msg = calcRoute( 8.720897, 50.002515, 16.723658, 49.997510, "notrack" ); - Assert.assertTrue( msg, msg != null && msg.indexOf( "not mapped" ) >= 0 ); + Assert.assertTrue( msg, msg != null && msg.indexOf( "not found" ) >= 0 ); } private String calcRoute( double flon, double flat, double tlon, double tlat, String trackname ) throws Exception