cleanup and bugfixes

This commit is contained in:
Arndt Brenschede 2016-09-02 19:05:50 +02:00
parent e217f12e71
commit ead7f2ac6d
7 changed files with 58 additions and 67 deletions

View file

@ -729,7 +729,7 @@ public final class OsmTrack
return e.message; return e.message;
} }
e = e.origin; e = e.origin;
if ( cnt++ == 10000 ) if ( cnt++ == 1000000 )
{ {
throw new IllegalArgumentException( "ups?" ); throw new IllegalArgumentException( "ups?" );
} }

View file

@ -68,30 +68,33 @@ public class RoutingEngine extends Thread
this.infoLogEnabled = outfileBase != null; this.infoLogEnabled = outfileBase != null;
this.routingContext = rc; this.routingContext = rc;
File baseFolder = new File( routingContext.localFunction ).getParentFile().getParentFile(); File baseFolder = new File( routingContext.localFunction ).getParentFile();
try baseFolder = baseFolder == null ? null : baseFolder.getParentFile();
if ( baseFolder != null )
{ {
File debugLog = new File( baseFolder, "debug.txt" ); try
if ( debugLog.exists() )
{ {
infoLogWriter = new FileWriter( debugLog, true ); File debugLog = new File( baseFolder, "debug.txt" );
logInfo( "********** start request at " ); if ( debugLog.exists() )
logInfo( "********** " + new Date() ); {
infoLogWriter = new FileWriter( debugLog, true );
logInfo( "********** start request at " );
logInfo( "********** " + new Date() );
}
}
catch( IOException ioe )
{
throw new RuntimeException( "cannot open debug-log:" + ioe );
}
File stackLog = new File( baseFolder, "stacks.txt" );
if ( stackLog.exists() )
{
stackSampler = new StackSampler( stackLog, 1000 );
stackSampler.start();
logInfo( "********** started stacksampling" );
} }
} }
catch( IOException ioe )
{
throw new RuntimeException( "cannot open debug-log:" + ioe );
}
File stackLog = new File( baseFolder, "stacks.txt" );
if ( stackLog.exists() )
{
stackSampler = new StackSampler( stackLog, 1000 );
stackSampler.start();
logInfo( "********** started stacksampling" );
}
boolean cachedProfile = ProfileCache.parseProfile( rc ); boolean cachedProfile = ProfileCache.parseProfile( rc );
if ( hasInfo() ) if ( hasInfo() )
{ {
@ -406,6 +409,18 @@ public class RoutingEngine extends Thread
{ {
preloadPosition( mwp.waypoint ); preloadPosition( mwp.waypoint );
} }
if ( nodesCache.first_file_access_failed )
{
throw new IllegalArgumentException( "datafile " + nodesCache.first_file_access_name + " not found" );
}
for( MatchedWaypoint mwp : unmatchedWaypoints )
{
if ( mwp.crosspoint == null )
{
throw new IllegalArgumentException( mwp.waypoint.name + "-position not mapped in existing datafile" );
}
}
} }
private void preloadPosition( OsmNode n ) private void preloadPosition( OsmNode n )
@ -558,7 +573,7 @@ public class RoutingEngine extends Thread
logInfo( "NodesCache status before reset=" + nodesCache.formatStatus() ); logInfo( "NodesCache status before reset=" + nodesCache.formatStatus() );
} }
nodesMap = new OsmNodesMap(); nodesMap = new OsmNodesMap();
nodesCache = new NodesCache(segmentDir, nodesMap, routingContext.expctxWay, routingContext.carMode, routingContext.forceSecondaryData, nodesCache ); nodesCache = new NodesCache(segmentDir, nodesMap, routingContext.expctxWay, routingContext.forceSecondaryData, nodesCache );
} }
private OsmNode getStartNode( long startId ) private OsmNode getStartNode( long startId )
@ -991,16 +1006,6 @@ public class RoutingEngine extends Thread
} }
} }
private void preloadPosition( OsmNode n, int minRingWidth, int minCount )
{
int c = 0;
int ring = 0;
while( ring <= minRingWidth || ( c < minCount && ring <= 5 ) )
{
c += preloadRing( n, ring++ );
}
}
private int preloadRing( OsmNode n, int ring ) private int preloadRing( OsmNode n, int ring )
{ {
int d = 12500; int d = 12500;

View file

@ -44,15 +44,6 @@ public final class RoutingHelper
{ {
if ( fileName.endsWith( ".rd5" ) ) return true; if ( fileName.endsWith( ".rd5" ) ) return true;
} }
File carSubset = new File( dir, "carsubset" );
if ( carSubset.isDirectory() )
{
fileNames = carSubset.list();
for( String fileName : fileNames )
{
if ( fileName.endsWith( ".cd5" ) ) return true;
}
}
return false; return false;
} }
} }

View file

@ -67,11 +67,5 @@ public class MapcreatorTest
File segments = new File( tmpdir, "segments" ); File segments = new File( tmpdir, "segments" );
segments.mkdir(); segments.mkdir();
new WayLinker().process( unodes55, waytiles55, bordernodes, lookupFile, profileAllFile, segments, "rd5" ); new WayLinker().process( unodes55, waytiles55, bordernodes, lookupFile, profileAllFile, segments, "rd5" );
// run WayLinker, car subset
File carsubset = new File( segments, "carsubset" );
carsubset.mkdir();
File profileCarFile = new File( profileDir, "car-test.brf" );
new WayLinker().process( unodes55, waytiles55, bordernodes, lookupFile, profileCarFile, carsubset, "cd5" );
} }
} }

View file

@ -25,7 +25,6 @@ public final class NodesCache
private BExpressionContextWay expCtxWay; private BExpressionContextWay expCtxWay;
private int lookupVersion; private int lookupVersion;
private int lookupMinorVersion; private int lookupMinorVersion;
private boolean carMode;
private boolean forceSecondaryData; private boolean forceSecondaryData;
private String currentFileName; private String currentFileName;
@ -48,15 +47,13 @@ public final class NodesCache
return "collecting=" + garbageCollectionEnabled + " cacheSum=" + cacheSum; return "collecting=" + garbageCollectionEnabled + " cacheSum=" + cacheSum;
} }
public NodesCache( String segmentDir, OsmNodesMap nodesMap, BExpressionContextWay ctxWay, boolean carMode, boolean forceSecondaryData, public NodesCache( String segmentDir, OsmNodesMap nodesMap, BExpressionContextWay ctxWay, boolean forceSecondaryData, NodesCache oldCache )
NodesCache oldCache )
{ {
this.segmentDir = new File( segmentDir ); this.segmentDir = new File( segmentDir );
this.nodesMap = nodesMap; this.nodesMap = nodesMap;
this.expCtxWay = ctxWay; this.expCtxWay = ctxWay;
this.lookupVersion = ctxWay.meta.lookupVersion; this.lookupVersion = ctxWay.meta.lookupVersion;
this.lookupMinorVersion = ctxWay.meta.lookupMinorVersion; this.lookupMinorVersion = ctxWay.meta.lookupMinorVersion;
this.carMode = carMode;
this.forceSecondaryData = forceSecondaryData; this.forceSecondaryData = forceSecondaryData;
first_file_access_failed = false; first_file_access_failed = false;
@ -238,7 +235,7 @@ public final class NodesCache
String slat = lat < 0 ? "S" + ( -lat ) : "N" + lat; String slat = lat < 0 ? "S" + ( -lat ) : "N" + lat;
String filenameBase = slon + "_" + slat; String filenameBase = slon + "_" + slat;
currentFileName = filenameBase + ".rd5/cd5"; currentFileName = filenameBase + ".rd5";
PhysicalFile ra = null; PhysicalFile ra = null;
if ( !fileCache.containsKey( filenameBase ) ) if ( !fileCache.containsKey( filenameBase ) )
@ -254,21 +251,10 @@ public final class NodesCache
} }
if ( f == null ) if ( f == null )
{ {
if ( carMode ) // look for carsubset-files only in secondary (primaries are now good for car-mode) File secondary = new File( secondarySegmentsDir, filenameBase + ".rd5" );
if ( secondary.exists() )
{ {
File carFile = new File( secondarySegmentsDir, "carsubset/" + filenameBase + ".cd5" ); f = secondary;
if ( carFile.exists() )
{
f = carFile;
}
}
if ( f == null )
{
File secondary = new File( secondarySegmentsDir, filenameBase + ".rd5" );
if ( secondary.exists() )
{
f = secondary;
}
} }
} }
if ( f != null ) if ( f != null )

View file

@ -332,7 +332,7 @@ public class BRouterActivity extends Activity implements OnInitListener
{ {
showWaypointDatabaseHelp(); showWaypointDatabaseHelp();
} }
else if ( wpCount == -1 ) else if ( wpCount == -1 || wpCount == -3 )
{ {
finish(); finish();
} }

View file

@ -34,6 +34,8 @@ public class BRouterService extends Service
@Override @Override
public String getTrackFromParams( Bundle params ) throws RemoteException public String getTrackFromParams( Bundle params ) throws RemoteException
{ {
logBundle( params );
BRouterWorker worker = new BRouterWorker(); BRouterWorker worker = new BRouterWorker();
// get base dir from private file // get base dir from private file
@ -227,6 +229,19 @@ public class BRouterService extends Service
} }
} }
private void logBundle( Bundle params )
{
if ( AppLogger.isLogging() )
{
for( String k : params.keySet() )
{
Object val = "remoteProfile".equals( k ) ? "<..cut..>" : params.get(k);
String desc = "key=" + k + (val == null ? "" : " class=" + val.getClass() + " val=" + val.toString() );
AppLogger.log( desc );
}
}
}
}; };
@Override @Override