extended configuration (to hande Kitkat issues)
This commit is contained in:
parent
a6878ba04e
commit
631057cd5f
10 changed files with 251 additions and 40 deletions
BIN
brouter-routing-app/assets/segments3.zip
Normal file
BIN
brouter-routing-app/assets/segments3.zip
Normal file
Binary file not shown.
|
|
@ -0,0 +1,68 @@
|
|||
package btools.routingapp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
|
||||
/**
|
||||
* static logger interface to be used in the android app
|
||||
*/
|
||||
public class AppLogger
|
||||
{
|
||||
private static FileWriter debugLogWriter = null;
|
||||
private static boolean initDone = false;
|
||||
|
||||
private static void init()
|
||||
{
|
||||
try
|
||||
{
|
||||
// open logfile if existing
|
||||
File sd = Environment.getExternalStorageDirectory();
|
||||
if ( sd == null ) return;
|
||||
File debugLog = new File( sd, "brouterapp.txt" );
|
||||
if ( debugLog.exists() )
|
||||
{
|
||||
debugLogWriter = new FileWriter( debugLog, true );
|
||||
}
|
||||
}
|
||||
catch( IOException ioe ) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* log an info trace to the app log file, if any
|
||||
*/
|
||||
public static boolean isLogging()
|
||||
{
|
||||
if ( !initDone )
|
||||
{
|
||||
initDone = true;
|
||||
init();
|
||||
log( "logging started at " + new Date() );
|
||||
}
|
||||
return debugLogWriter != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* log an info trace to the app log file, if any
|
||||
*/
|
||||
public static void log( String msg )
|
||||
{
|
||||
if ( isLogging() )
|
||||
{
|
||||
try
|
||||
{
|
||||
debugLogWriter.write( msg );
|
||||
debugLogWriter.write( '\n' );
|
||||
debugLogWriter.flush();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "cannot write appdebug.txt: " + e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
import btools.mapaccess.PhysicalFile;
|
||||
import btools.router.RoutingHelper;
|
||||
|
||||
public class BInstallerView extends View
|
||||
{
|
||||
|
|
@ -209,8 +210,15 @@ public class BInstallerView extends View
|
|||
{
|
||||
clearTileSelection( MASK_INSTALLED_CD5 | MASK_INSTALLED_RD5 );
|
||||
|
||||
scanExistingFiles( new File( baseDir + "/brouter/segments2" ), ".rd5", MASK_INSTALLED_RD5 );
|
||||
scanExistingFiles( new File( baseDir + "/brouter/segments2/carsubset" ), ".cd5", MASK_INSTALLED_CD5 );
|
||||
scanExistingFiles( new File( baseDir + "/brouter/segments3" ), ".rd5", MASK_INSTALLED_RD5 );
|
||||
scanExistingFiles( new File( baseDir + "/brouter/segments3/carsubset" ), ".cd5", MASK_INSTALLED_CD5 );
|
||||
|
||||
File secondary = RoutingHelper.getSecondarySegmentDir( baseDir + "/brouter/segments3" );
|
||||
if ( secondary != null )
|
||||
{
|
||||
scanExistingFiles( secondary, ".rd5", MASK_INSTALLED_RD5 );
|
||||
scanExistingFiles( new File( secondary, "carsubset" ), ".cd5", MASK_INSTALLED_CD5 );
|
||||
}
|
||||
|
||||
StatFs stat = new StatFs(baseDir);
|
||||
availableSize = (long)stat.getAvailableBlocks()*stat.getBlockSize();
|
||||
|
|
@ -599,7 +607,7 @@ float tx, ty;
|
|||
input = connection.getInputStream();
|
||||
|
||||
int slidx = surl.lastIndexOf( "segments3/" );
|
||||
fname = baseDir + "/brouter/segments2/" + surl.substring( slidx+10 );
|
||||
fname = baseDir + "/brouter/segments3/" + surl.substring( slidx+10 );
|
||||
tmp_file = new File( fname + "_tmp" );
|
||||
if ( new File( fname ).exists() ) return "internal error: file exists: " + fname;
|
||||
output = new FileOutputStream( tmp_file );
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class BRouterService extends Service
|
|||
{
|
||||
String modesFile = baseDir + "/brouter/modes/serviceconfig.dat";
|
||||
br = new BufferedReader( new FileReader (modesFile ) );
|
||||
worker.segmentDir = baseDir + "/brouter/segments2";
|
||||
worker.segmentDir = baseDir + "/brouter/segments3";
|
||||
for(;;)
|
||||
{
|
||||
String line = br.readLine();
|
||||
|
|
@ -67,7 +67,7 @@ public class BRouterService extends Service
|
|||
worker.profilePath = baseDir + "/brouter/profiles2/" + smc.profile + ".brf";
|
||||
worker.rawTrackPath = baseDir + "/brouter/modes/" + mode_key + "_rawtrack.dat";
|
||||
|
||||
CoordinateReader cor = CoordinateReader.obtainValidReader( baseDir );
|
||||
CoordinateReader cor = CoordinateReader.obtainValidReader( baseDir, worker.segmentDir );
|
||||
worker.nogoList = new ArrayList<OsmNodeNamed>();
|
||||
// veto nogos by profiles veto list
|
||||
for(OsmNodeNamed nogo : cor.nogopoints )
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
@ -36,6 +37,7 @@ import btools.router.OsmNodeNamed;
|
|||
import btools.router.OsmTrack;
|
||||
import btools.router.RoutingContext;
|
||||
import btools.router.RoutingEngine;
|
||||
import btools.router.RoutingHelper;
|
||||
|
||||
public class BRouterView extends View
|
||||
{
|
||||
|
|
@ -71,6 +73,7 @@ public class BRouterView extends View
|
|||
|
||||
private int[] imgPixels;
|
||||
|
||||
|
||||
public void startSimulation() {
|
||||
}
|
||||
|
||||
|
|
@ -138,18 +141,19 @@ public class BRouterView extends View
|
|||
ConfigHelper.writeBaseDir( getContext(), baseDir );
|
||||
}
|
||||
String basedir = fbd.getAbsolutePath();
|
||||
AppLogger.log( "using basedir: " + basedir );
|
||||
|
||||
// create missing directories
|
||||
assertDirectoryExists( "project directory", basedir + "/brouter", null );
|
||||
segmentDir = basedir + "/brouter/segments2";
|
||||
assertDirectoryExists( "data directory", segmentDir, null );
|
||||
segmentDir = basedir + "/brouter/segments3";
|
||||
assertDirectoryExists( "data directory", segmentDir, "segments3.zip" );
|
||||
assertDirectoryExists( "carsubset directory", segmentDir + "/carsubset", null );
|
||||
profileDir = basedir + "/brouter/profiles2";
|
||||
assertDirectoryExists( "profile directory", profileDir, "profiles2.zip" );
|
||||
modesDir = basedir + "/brouter/modes";
|
||||
assertDirectoryExists( "modes directory", modesDir, "modes.zip" );
|
||||
|
||||
cor = CoordinateReader.obtainValidReader( basedir );
|
||||
cor = CoordinateReader.obtainValidReader( basedir, segmentDir );
|
||||
wpList = cor.waypoints;
|
||||
nogoList = cor.nogopoints;
|
||||
nogoVetoList = new ArrayList<OsmNodeNamed>();
|
||||
|
|
@ -176,23 +180,7 @@ public class BRouterView extends View
|
|||
}
|
||||
}
|
||||
|
||||
boolean segmentFound = false;
|
||||
String[] fileNames = new File( segmentDir ).list();
|
||||
for( String fileName : fileNames )
|
||||
{
|
||||
if ( fileName.endsWith( ".rd5" ) ) segmentFound = true;
|
||||
}
|
||||
File carSubset = new File( segmentDir, "carsubset" );
|
||||
if ( carSubset.isDirectory() )
|
||||
{
|
||||
fileNames = carSubset.list();
|
||||
for( String fileName : fileNames )
|
||||
{
|
||||
if ( fileName.endsWith( ".cd5" ) ) segmentFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
fileNames = new File( profileDir ).list();
|
||||
String[] fileNames = new File( profileDir ).list();
|
||||
ArrayList<String> profiles = new ArrayList<String>();
|
||||
|
||||
boolean lookupsFound = false;
|
||||
|
|
@ -216,7 +204,7 @@ public class BRouterView extends View
|
|||
+ " contains no routing profiles (*.brf)."
|
||||
+ " see www.dr-brenschede.de/brouter for setup instructions." );
|
||||
}
|
||||
if ( !segmentFound )
|
||||
if ( !RoutingHelper.hasDirectoryAnyDatafiles( segmentDir ) )
|
||||
{
|
||||
((BRouterActivity)getContext()).startDownloadManager();
|
||||
waitingForSelection = true;
|
||||
|
|
@ -295,7 +283,6 @@ public class BRouterView extends View
|
|||
String[] wpts = new String[allpoints.size()];
|
||||
int i = 0;
|
||||
for( OsmNodeNamed wp : allpoints.values() ) wpts[i++] = wp.name;
|
||||
System.out.println( "calling selectWaypoint..." );
|
||||
((BRouterActivity)getContext()).selectWaypoint( wpts );
|
||||
}
|
||||
}
|
||||
|
|
@ -304,7 +291,6 @@ System.out.println( "calling selectWaypoint..." );
|
|||
{
|
||||
wpList.add( cor.allpoints.get( waypoint ) );
|
||||
cor.allpoints.remove( waypoint );
|
||||
System.out.println( "updateWaypointList: " + waypoint + " wpList.size()=" + wpList.size() );
|
||||
}
|
||||
|
||||
public void finishWaypointSelection()
|
||||
|
|
@ -410,6 +396,7 @@ System.out.println( "updateWaypointList: " + waypoint + " wpList.size()=" + wpLi
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void assertDirectoryExists( String message, String path, String assetZip )
|
||||
{
|
||||
File f = new File( path );
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@ package btools.routingapp;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.os.Environment;
|
||||
import btools.router.OsmNodeNamed;
|
||||
import btools.router.RoutingHelper;
|
||||
|
||||
/**
|
||||
* Read coordinates from a gpx-file
|
||||
|
|
@ -96,7 +98,7 @@ public abstract class CoordinateReader
|
|||
protected abstract void readPointmap() throws Exception;
|
||||
|
||||
|
||||
public static CoordinateReader obtainValidReader( String basedir ) throws Exception
|
||||
public static CoordinateReader obtainValidReader( String basedir, String segmentDir ) throws Exception
|
||||
{
|
||||
CoordinateReader cor = null;
|
||||
ArrayList<CoordinateReader> rl = new ArrayList<CoordinateReader>();
|
||||
|
|
@ -117,10 +119,32 @@ public abstract class CoordinateReader
|
|||
}
|
||||
}
|
||||
|
||||
// eventually add explicit directory
|
||||
File additional = RoutingHelper.getAdditionalMaptoolDir(segmentDir);
|
||||
if ( additional != null )
|
||||
{
|
||||
String base3 = additional.getAbsolutePath();
|
||||
|
||||
AppLogger.log( "additional maptool-base from storage-config: " + base3 );
|
||||
|
||||
rl.add( new CoordinateReaderOsmAnd(base3) );
|
||||
rl.add( new CoordinateReaderLocus(base3) );
|
||||
rl.add( new CoordinateReaderOrux(base3) );
|
||||
}
|
||||
|
||||
long tmax = 0;
|
||||
for( CoordinateReader r : rl )
|
||||
{
|
||||
long t = r.getTimeStamp();
|
||||
|
||||
if ( t != 0 )
|
||||
{
|
||||
if ( AppLogger.isLogging() )
|
||||
{
|
||||
AppLogger.log( "found coordinate source at " + r.basedir + r.rootdir + " with timestamp " + new Date( t ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( t > tmax )
|
||||
{
|
||||
tmax = t;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue