v1.4.3
This commit is contained in:
parent
19fd3112bf
commit
42e9ddbdd1
21 changed files with 327 additions and 135 deletions
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-codec</artifactId>
|
<artifactId>brouter-codec</artifactId>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-core</artifactId>
|
<artifactId>brouter-core</artifactId>
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import btools.mapaccess.OsmPos;
|
import btools.mapaccess.OsmPos;
|
||||||
|
@ -31,6 +32,7 @@ public final class OsmTrack
|
||||||
|
|
||||||
public MatchedWaypoint endPoint;
|
public MatchedWaypoint endPoint;
|
||||||
public long[] nogoChecksums;
|
public long[] nogoChecksums;
|
||||||
|
public long profileTimestamp;
|
||||||
public boolean isDirty;
|
public boolean isDirty;
|
||||||
|
|
||||||
private static class OsmPathElementHolder
|
private static class OsmPathElementHolder
|
||||||
|
@ -160,10 +162,11 @@ public final class OsmTrack
|
||||||
dos.writeLong( nogoChecksums[1] );
|
dos.writeLong( nogoChecksums[1] );
|
||||||
dos.writeLong( nogoChecksums[2] );
|
dos.writeLong( nogoChecksums[2] );
|
||||||
dos.writeBoolean( isDirty );
|
dos.writeBoolean( isDirty );
|
||||||
|
dos.writeLong( profileTimestamp );
|
||||||
dos.close();
|
dos.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OsmTrack readBinary( String filename, OsmNodeNamed newEp, long[] nogoChecksums, StringBuilder debugInfo )
|
public static OsmTrack readBinary( String filename, OsmNodeNamed newEp, long[] nogoChecksums, long profileChecksum, StringBuilder debugInfo )
|
||||||
{
|
{
|
||||||
OsmTrack t = null;
|
OsmTrack t = null;
|
||||||
if ( filename != null )
|
if ( filename != null )
|
||||||
|
@ -177,7 +180,12 @@ public final class OsmTrack
|
||||||
MatchedWaypoint ep = MatchedWaypoint.readFromStream( dis );
|
MatchedWaypoint ep = MatchedWaypoint.readFromStream( dis );
|
||||||
int dlon = ep.waypoint.ilon - newEp.ilon;
|
int dlon = ep.waypoint.ilon - newEp.ilon;
|
||||||
int dlat = ep.waypoint.ilat - newEp.ilat;
|
int dlat = ep.waypoint.ilat - newEp.ilat;
|
||||||
if ( dlon < 20 && dlon > -20 && dlat < 20 && dlat > -20 )
|
boolean targetMatch = dlon < 20 && dlon > -20 && dlat < 20 && dlat > -20;
|
||||||
|
if ( debugInfo != null )
|
||||||
|
{
|
||||||
|
debugInfo.append( "target-delta = " + dlon + "/" + dlat + " targetMatch=" + targetMatch );
|
||||||
|
}
|
||||||
|
if ( targetMatch )
|
||||||
{
|
{
|
||||||
t = new OsmTrack();
|
t = new OsmTrack();
|
||||||
t.endPoint = ep;
|
t.endPoint = ep;
|
||||||
|
@ -192,31 +200,40 @@ public final class OsmTrack
|
||||||
}
|
}
|
||||||
t.cost = last_pe.cost;
|
t.cost = last_pe.cost;
|
||||||
t.buildMap();
|
t.buildMap();
|
||||||
}
|
|
||||||
long[] al = new long[3];
|
|
||||||
try
|
|
||||||
{
|
|
||||||
al[0] = dis.readLong();
|
|
||||||
al[1] = dis.readLong();
|
|
||||||
al[2] = dis.readLong();
|
|
||||||
}
|
|
||||||
catch (EOFException eof) { /* kind of expected */ }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
boolean isDirty = dis.readBoolean();
|
|
||||||
if ( t != null ) t.isDirty = isDirty;
|
|
||||||
}
|
|
||||||
catch (EOFException eof) { /* kind of expected */ }
|
|
||||||
dis.close();
|
|
||||||
boolean nogoCheckOk = Math.abs( al[0] - nogoChecksums[0] ) <= 20
|
|
||||||
&& Math.abs( al[1] - nogoChecksums[1] ) <= 20
|
|
||||||
&& Math.abs( al[2] - nogoChecksums[2] ) <= 20;
|
|
||||||
|
|
||||||
if ( debugInfo != null )
|
// check cheecksums, too
|
||||||
{
|
long[] al = new long[3];
|
||||||
debugInfo.append( "target-delta = " + dlon + "/" + dlat + " nogoCheckOk=" + nogoCheckOk );
|
long pchecksum = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
al[0] = dis.readLong();
|
||||||
|
al[1] = dis.readLong();
|
||||||
|
al[2] = dis.readLong();
|
||||||
|
}
|
||||||
|
catch (EOFException eof) { /* kind of expected */ }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
t.isDirty = dis.readBoolean();
|
||||||
|
}
|
||||||
|
catch (EOFException eof) { /* kind of expected */ }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pchecksum = dis.readLong();
|
||||||
|
}
|
||||||
|
catch (EOFException eof) { /* kind of expected */ }
|
||||||
|
boolean nogoCheckOk = Math.abs( al[0] - nogoChecksums[0] ) <= 20
|
||||||
|
&& Math.abs( al[1] - nogoChecksums[1] ) <= 20
|
||||||
|
&& Math.abs( al[2] - nogoChecksums[2] ) <= 20;
|
||||||
|
boolean profileCheckOk = pchecksum == profileChecksum;
|
||||||
|
|
||||||
|
if ( debugInfo != null )
|
||||||
|
{
|
||||||
|
debugInfo.append( " nogoCheckOk=" + nogoCheckOk + " profileCheckOk=" + profileCheckOk );
|
||||||
|
debugInfo.append( " al=" + formatLongs(al) + " nogoChecksums=" + formatLongs(nogoChecksums) );
|
||||||
|
}
|
||||||
|
if ( !(nogoCheckOk && profileCheckOk) ) return null;
|
||||||
}
|
}
|
||||||
if ( !nogoCheckOk ) return null;
|
dis.close();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -227,6 +244,20 @@ public final class OsmTrack
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String formatLongs( long[] al )
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append( '{' );
|
||||||
|
for( long l : al )
|
||||||
|
{
|
||||||
|
sb.append( l );
|
||||||
|
sb.append( ' ' );
|
||||||
|
}
|
||||||
|
sb.append( '}' );
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addNodes( OsmTrack t )
|
public void addNodes( OsmTrack t )
|
||||||
{
|
{
|
||||||
for ( OsmPathElement n : t.nodes )
|
for ( OsmPathElement n : t.nodes )
|
||||||
|
@ -343,7 +374,7 @@ public final class OsmTrack
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.append( " creator=\"BRouter-1.4.2\" version=\"1.1\">\n" );
|
sb.append( " creator=\"BRouter-1.4.3\" version=\"1.1\">\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( turnInstructionMode == 3) // osmand style
|
if ( turnInstructionMode == 3) // osmand style
|
||||||
|
|
|
@ -40,6 +40,7 @@ public final class ProfileCache
|
||||||
profileDir = new File( profileBaseDir );
|
profileDir = new File( profileBaseDir );
|
||||||
profileFile = new File( profileDir, rc.localFunction + ".brf" ) ;
|
profileFile = new File( profileDir, rc.localFunction + ".brf" ) ;
|
||||||
}
|
}
|
||||||
|
rc.profileTimestamp = profileFile.lastModified();
|
||||||
File lookupFile = new File( profileDir, "lookups.dat" );
|
File lookupFile = new File( profileDir, "lookups.dat" );
|
||||||
|
|
||||||
// check for re-use
|
// check for re-use
|
||||||
|
@ -47,7 +48,7 @@ public final class ProfileCache
|
||||||
{
|
{
|
||||||
if ( profileFile.equals( lastProfileFile ) && lookupFile.equals( lastLookupFile ) )
|
if ( profileFile.equals( lastProfileFile ) && lookupFile.equals( lastLookupFile ) )
|
||||||
{
|
{
|
||||||
if ( profileFile.lastModified() == lastProfileTimestamp
|
if ( rc.profileTimestamp == lastProfileTimestamp
|
||||||
&& lookupFile.lastModified() == lastLookupTimestamp )
|
&& lookupFile.lastModified() == lastLookupTimestamp )
|
||||||
{
|
{
|
||||||
rc.expctxWay = expctxWay;
|
rc.expctxWay = expctxWay;
|
||||||
|
|
|
@ -27,6 +27,7 @@ public final class RoutingContext implements DistanceChecker
|
||||||
}
|
}
|
||||||
public int alternativeIdx = 0;
|
public int alternativeIdx = 0;
|
||||||
public String localFunction;
|
public String localFunction;
|
||||||
|
public long profileTimestamp;
|
||||||
|
|
||||||
public String rawTrackPath;
|
public String rawTrackPath;
|
||||||
|
|
||||||
|
|
|
@ -305,10 +305,10 @@ public class RoutingEngine extends Thread
|
||||||
|
|
||||||
// check for a track for that target
|
// check for a track for that target
|
||||||
OsmTrack nearbyTrack = null;
|
OsmTrack nearbyTrack = null;
|
||||||
if ( refTracks[waypoints.size()-2] == null )
|
if ( lastTracks[waypoints.size()-2] == null )
|
||||||
{
|
{
|
||||||
StringBuilder debugInfo = hasInfo() ? new StringBuilder() : null;
|
StringBuilder debugInfo = hasInfo() ? new StringBuilder() : null;
|
||||||
nearbyTrack = OsmTrack.readBinary( routingContext.rawTrackPath, waypoints.get( waypoints.size()-1), routingContext.getNogoChecksums(), debugInfo );
|
nearbyTrack = OsmTrack.readBinary( routingContext.rawTrackPath, waypoints.get( waypoints.size()-1), routingContext.getNogoChecksums(), routingContext.profileTimestamp, debugInfo );
|
||||||
if ( nearbyTrack != null )
|
if ( nearbyTrack != null )
|
||||||
{
|
{
|
||||||
nUnmatched--;
|
nUnmatched--;
|
||||||
|
@ -532,7 +532,10 @@ public class RoutingEngine extends Thread
|
||||||
dirtyMessage = iae;
|
dirtyMessage = iae;
|
||||||
logInfo( "using fast partial recalc" );
|
logInfo( "using fast partial recalc" );
|
||||||
}
|
}
|
||||||
maxRunningTime += System.currentTimeMillis() - startTime; // reset timeout...
|
if ( maxRunningTime > 0 )
|
||||||
|
{
|
||||||
|
maxRunningTime += System.currentTimeMillis() - startTime; // reset timeout...
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,6 +563,7 @@ public class RoutingEngine extends Thread
|
||||||
foundRawTrack = mergeTrack( matchPath, track );
|
foundRawTrack = mergeTrack( matchPath, track );
|
||||||
foundRawTrack.endPoint = endWp;
|
foundRawTrack.endPoint = endWp;
|
||||||
foundRawTrack.nogoChecksums = routingContext.getNogoChecksums();
|
foundRawTrack.nogoChecksums = routingContext.getNogoChecksums();
|
||||||
|
foundRawTrack.profileTimestamp = routingContext.profileTimestamp;
|
||||||
foundRawTrack.isDirty = true;
|
foundRawTrack.isDirty = true;
|
||||||
}
|
}
|
||||||
throw iae;
|
throw iae;
|
||||||
|
@ -589,6 +593,7 @@ public class RoutingEngine extends Thread
|
||||||
logInfo( "supplying new reference track, dirty=" + isDirty );
|
logInfo( "supplying new reference track, dirty=" + isDirty );
|
||||||
track.endPoint = endWp;
|
track.endPoint = endWp;
|
||||||
track.nogoChecksums = routingContext.getNogoChecksums();
|
track.nogoChecksums = routingContext.getNogoChecksums();
|
||||||
|
track.profileTimestamp = routingContext.profileTimestamp;
|
||||||
track.isDirty = isDirty;
|
track.isDirty = isDirty;
|
||||||
foundRawTrack = track;
|
foundRawTrack = track;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-expressions</artifactId>
|
<artifactId>brouter-expressions</artifactId>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-map-creator</artifactId>
|
<artifactId>brouter-map-creator</artifactId>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-mapaccess</artifactId>
|
<artifactId>brouter-mapaccess</artifactId>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-mem-router</artifactId>
|
<artifactId>brouter-mem-router</artifactId>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:versionCode="13"
|
android:versionCode="14"
|
||||||
android:versionName="1.4.2" package="btools.routingapp">
|
android:versionName="1.4.3" package="btools.routingapp">
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||||
<activity android:name=".BRouterActivity"
|
<activity android:name=".BRouterActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-routing-app</artifactId>
|
<artifactId>brouter-routing-app</artifactId>
|
||||||
|
@ -60,9 +60,9 @@
|
||||||
<include>${project.build.directory}/${project.artifactId}.apk</include>
|
<include>${project.build.directory}/${project.artifactId}.apk</include>
|
||||||
</includes>
|
</includes>
|
||||||
<keystore>\sign\mystore</keystore>
|
<keystore>\sign\mystore</keystore>
|
||||||
<alias>abrensch</alias>
|
<alias>myalias</alias>
|
||||||
<storepass>peru1511</storepass>
|
<storepass>mypass</storepass>
|
||||||
<keypass>peru1511</keypass>
|
<keypass>mypass</keypass>
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -2,9 +2,14 @@ package btools.routingapp;
|
||||||
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
|
@ -24,85 +29,201 @@ public class BRouterService extends Service
|
||||||
return myBRouterServiceStub;
|
return myBRouterServiceStub;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBRouterService.Stub myBRouterServiceStub = new IBRouterService.Stub()
|
private IBRouterService.Stub myBRouterServiceStub = new IBRouterService.Stub()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String getTrackFromParams(Bundle params) throws RemoteException
|
public String getTrackFromParams( Bundle params ) throws RemoteException
|
||||||
{
|
{
|
||||||
BRouterWorker worker = new BRouterWorker();
|
BRouterWorker worker = new BRouterWorker();
|
||||||
|
|
||||||
// get base dir from private file
|
// get base dir from private file
|
||||||
String baseDir = null;
|
String baseDir = null;
|
||||||
InputStream configInput = null;
|
InputStream configInput = null;
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
configInput = openFileInput( "config.dat" );
|
||||||
|
BufferedReader br = new BufferedReader( new InputStreamReader( configInput ) );
|
||||||
|
baseDir = br.readLine();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( configInput != null ) try { configInput.close(); } catch (Exception ee) {}
|
||||||
|
}
|
||||||
|
worker.segmentDir = baseDir + "/brouter/segments4";
|
||||||
|
|
||||||
|
String remoteProfile = params.getString( "remoteProfile" );
|
||||||
|
|
||||||
|
if ( remoteProfile == null )
|
||||||
|
{
|
||||||
|
remoteProfile = checkForTestDummy( baseDir );
|
||||||
|
}
|
||||||
|
|
||||||
|
String errMsg = remoteProfile == null
|
||||||
|
? getConfigFromMode( worker, baseDir, params.getString( "v" ), params.getString( "fast" ) )
|
||||||
|
: getConfigForRemoteProfile( worker, baseDir, remoteProfile );
|
||||||
|
|
||||||
|
if ( errMsg != null )
|
||||||
|
{
|
||||||
|
return errMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return worker.getTrackFromParams( params );
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException iae)
|
||||||
|
{
|
||||||
|
return iae.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getConfigFromMode( BRouterWorker worker, String baseDir, String mode, String fast )
|
||||||
|
{
|
||||||
|
boolean isFast = "1".equals( fast ) || "true".equals( fast ) || "yes".equals( fast );
|
||||||
|
String mode_key = mode + "_" + ( isFast ? "fast" : "short" );
|
||||||
|
|
||||||
|
BufferedReader br = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String modesFile = baseDir + "/brouter/modes/serviceconfig.dat";
|
||||||
|
br = new BufferedReader( new FileReader( modesFile ) );
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
String line = br.readLine();
|
||||||
|
if ( line == null )
|
||||||
|
break;
|
||||||
|
ServiceModeConfig smc = new ServiceModeConfig( line );
|
||||||
|
if ( !smc.mode.equals( mode_key ) )
|
||||||
|
continue;
|
||||||
|
worker.profilePath = baseDir + "/brouter/profiles2/" + smc.profile + ".brf";
|
||||||
|
worker.rawTrackPath = baseDir + "/brouter/modes/" + mode_key + "_rawtrack.dat";
|
||||||
|
|
||||||
|
CoordinateReader cor = CoordinateReader.obtainValidReader( baseDir, worker.segmentDir );
|
||||||
|
worker.nogoList = new ArrayList<OsmNodeNamed>();
|
||||||
|
// veto nogos by profiles veto list
|
||||||
|
for ( OsmNodeNamed nogo : cor.nogopoints )
|
||||||
|
{
|
||||||
|
if ( !smc.nogoVetos.contains( nogo.ilon + "," + nogo.ilat ) )
|
||||||
{
|
{
|
||||||
configInput = openFileInput( "config.dat" );
|
worker.nogoList.add( nogo );
|
||||||
BufferedReader br = new BufferedReader( new InputStreamReader (configInput ) );
|
|
||||||
baseDir = br.readLine();
|
|
||||||
}
|
}
|
||||||
catch( Exception e ) {}
|
}
|
||||||
finally
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return "no brouter service config found, mode " + mode_key;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( br != null ) try { br.close(); } catch( Exception ee ) {}
|
||||||
|
}
|
||||||
|
return "no brouter service config found for mode " + mode_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getConfigForRemoteProfile( BRouterWorker worker, String baseDir, String remoteProfile )
|
||||||
|
{
|
||||||
|
worker.profilePath = baseDir + "/brouter/profiles2/remote.brf";
|
||||||
|
worker.rawTrackPath = baseDir + "/brouter/modes/remote_rawtrack.dat";
|
||||||
|
|
||||||
|
// store profile only if not identical (to preserve timestamp)
|
||||||
|
byte[] profileBytes = remoteProfile.getBytes();
|
||||||
|
File profileFile = new File( worker.profilePath );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// add nogos from waypoint database
|
||||||
|
CoordinateReader cor = CoordinateReader.obtainValidReader( baseDir, worker.segmentDir );
|
||||||
|
worker.nogoList = new ArrayList<OsmNodeNamed>( cor.nogopoints );
|
||||||
|
|
||||||
|
if ( !fileEqual( profileBytes, profileFile ) )
|
||||||
|
{
|
||||||
|
OutputStream os = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
os = new FileOutputStream( profileFile );
|
||||||
|
os.write( profileBytes );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( os != null ) try { os.close(); } catch( IOException io ) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
return "error caching remote profile: " + e;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean fileEqual( byte[] fileBytes, File file ) throws Exception
|
||||||
|
{
|
||||||
|
if ( !file.exists() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int nbytes = fileBytes.length;
|
||||||
|
int pos = 0;
|
||||||
|
int blen = 8192;
|
||||||
|
byte[] buf = new byte[blen];
|
||||||
|
InputStream is = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
is = new FileInputStream( file );
|
||||||
|
while( pos < nbytes )
|
||||||
|
{
|
||||||
|
int len = is.read( buf, 0, blen );
|
||||||
|
if ( len <= 0 ) return false;
|
||||||
|
if ( pos + len > nbytes ) return false;
|
||||||
|
for( int j=0; j<len; j++ )
|
||||||
|
{
|
||||||
|
if ( fileBytes[pos++] != buf[j] )
|
||||||
{
|
{
|
||||||
if ( configInput != null ) try { configInput.close(); } catch( Exception ee ) {}
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( is != null ) try { is.close(); } catch( IOException io ) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String fast = params.getString( "fast" );
|
private String checkForTestDummy( String baseDir )
|
||||||
boolean isFast = "1".equals( fast ) || "true".equals( fast ) || "yes".equals( fast );
|
{
|
||||||
String mode_key = params.getString( "v" ) + "_" + (isFast ? "fast" : "short");
|
File testdummy = new File( baseDir + "/brouter/profiles2/remotetestdummy.brf" );
|
||||||
|
if ( !testdummy.exists() ) return null;
|
||||||
|
BufferedReader br = null;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
br = new BufferedReader( new FileReader( testdummy ) );
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
String line = br.readLine();
|
||||||
|
if ( line == null )
|
||||||
|
break;
|
||||||
|
sb.append( line ).append( '\n' );
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException( "error reading " + testdummy );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( br != null ) try { br.close(); } catch( Exception ee ) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean configFound = false;
|
|
||||||
|
|
||||||
BufferedReader br = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String modesFile = baseDir + "/brouter/modes/serviceconfig.dat";
|
|
||||||
br = new BufferedReader( new FileReader (modesFile ) );
|
|
||||||
worker.segmentDir = baseDir + "/brouter/segments4";
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
String line = br.readLine();
|
|
||||||
if ( line == null ) break;
|
|
||||||
ServiceModeConfig smc = new ServiceModeConfig( line );
|
|
||||||
if ( !smc.mode.equals( mode_key ) ) continue;
|
|
||||||
worker.profilePath = baseDir + "/brouter/profiles2/" + smc.profile + ".brf";
|
|
||||||
worker.rawTrackPath = baseDir + "/brouter/modes/" + mode_key + "_rawtrack.dat";
|
|
||||||
|
|
||||||
CoordinateReader cor = CoordinateReader.obtainValidReader( baseDir, worker.segmentDir );
|
|
||||||
worker.nogoList = new ArrayList<OsmNodeNamed>();
|
|
||||||
// veto nogos by profiles veto list
|
|
||||||
for(OsmNodeNamed nogo : cor.nogopoints )
|
|
||||||
{
|
|
||||||
if ( !smc.nogoVetos.contains( nogo.ilon + "," + nogo.ilat ) )
|
|
||||||
{
|
|
||||||
worker.nogoList.add( nogo );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
configFound = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
return "no brouter service config found, mode " + mode_key;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if ( br != null ) try { br.close(); } catch( Exception ee ) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !configFound )
|
|
||||||
{
|
|
||||||
return "no brouter service config found for mode " + mode_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return worker.getTrackFromParams(params);
|
|
||||||
}
|
|
||||||
catch( IllegalArgumentException iae )
|
|
||||||
{
|
|
||||||
return iae.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -167,20 +167,22 @@ public class BRouterView extends View
|
||||||
String basedir = fbd.getAbsolutePath();
|
String basedir = fbd.getAbsolutePath();
|
||||||
AppLogger.log( "using basedir: " + basedir );
|
AppLogger.log( "using basedir: " + basedir );
|
||||||
|
|
||||||
|
String version = "v1.4.3";
|
||||||
|
|
||||||
// create missing directories
|
// create missing directories
|
||||||
assertDirectoryExists( "project directory", basedir + "/brouter", null );
|
assertDirectoryExists( "project directory", basedir + "/brouter", null, null );
|
||||||
segmentDir = basedir + "/brouter/segments4";
|
segmentDir = basedir + "/brouter/segments4";
|
||||||
if ( assertDirectoryExists( "data directory", segmentDir, "segments4.zip" ) )
|
if ( assertDirectoryExists( "data directory", segmentDir, "segments4.zip", null ) )
|
||||||
{
|
{
|
||||||
ConfigMigration.tryMigrateStorageConfig(
|
ConfigMigration.tryMigrateStorageConfig(
|
||||||
new File( basedir + "/brouter/segments3/storageconfig.txt" ),
|
new File( basedir + "/brouter/segments3/storageconfig.txt" ),
|
||||||
new File( basedir + "/brouter/segments4/storageconfig.txt" ) );
|
new File( basedir + "/brouter/segments4/storageconfig.txt" ) );
|
||||||
}
|
}
|
||||||
profileDir = basedir + "/brouter/profiles2";
|
profileDir = basedir + "/brouter/profiles2";
|
||||||
assertDirectoryExists( "profile directory", profileDir, "profiles2.zip" );
|
assertDirectoryExists( "profile directory", profileDir, "profiles2.zip", version );
|
||||||
modesDir = basedir + "/brouter/modes";
|
modesDir = basedir + "/brouter/modes";
|
||||||
assertDirectoryExists( "modes directory", modesDir, "modes.zip" );
|
assertDirectoryExists( "modes directory", modesDir, "modes.zip", null );
|
||||||
assertDirectoryExists( "readmes directory", basedir + "/brouter/readmes", "readmes.zip" );
|
assertDirectoryExists( "readmes directory", basedir + "/brouter/readmes", "readmes.zip", version );
|
||||||
|
|
||||||
cor = CoordinateReader.obtainValidReader( basedir, segmentDir );
|
cor = CoordinateReader.obtainValidReader( basedir, segmentDir );
|
||||||
wpList = cor.waypoints;
|
wpList = cor.waypoints;
|
||||||
|
@ -196,7 +198,7 @@ public class BRouterView extends View
|
||||||
if ( cor.tracksdir != null )
|
if ( cor.tracksdir != null )
|
||||||
{
|
{
|
||||||
tracksDir = cor.basedir + cor.tracksdir;
|
tracksDir = cor.basedir + cor.tracksdir;
|
||||||
assertDirectoryExists( "track directory", tracksDir, null );
|
assertDirectoryExists( "track directory", tracksDir, null, null );
|
||||||
|
|
||||||
// output redirect: look for a pointerfile in tracksdir
|
// output redirect: look for a pointerfile in tracksdir
|
||||||
File tracksDirPointer = new File( tracksDir + "/brouter.redirect" );
|
File tracksDirPointer = new File( tracksDir + "/brouter.redirect" );
|
||||||
|
@ -465,6 +467,12 @@ public class BRouterView extends View
|
||||||
rc.prepareNogoPoints( nogoList );
|
rc.prepareNogoPoints( nogoList );
|
||||||
rc.nogopoints = nogoList;
|
rc.nogopoints = nogoList;
|
||||||
|
|
||||||
|
// for profile remote, use ref-track logic same as service interface
|
||||||
|
if ( "remote".equals( profileName ) )
|
||||||
|
{
|
||||||
|
rc.rawTrackPath = modesDir + "/remote_rawtrack.dat";
|
||||||
|
}
|
||||||
|
|
||||||
cr = new RoutingEngine( tracksDir + "/brouter", null, segmentDir, wpList, rc );
|
cr = new RoutingEngine( tracksDir + "/brouter", null, segmentDir, wpList, rc );
|
||||||
cr.start();
|
cr.start();
|
||||||
invalidate();
|
invalidate();
|
||||||
|
@ -477,12 +485,27 @@ public class BRouterView extends View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean assertDirectoryExists( String message, String path, String assetZip )
|
private boolean assertDirectoryExists( String message, String path, String assetZip, String versionTag )
|
||||||
{
|
{
|
||||||
File f = new File( path );
|
File f = new File( path );
|
||||||
if ( !f.exists() )
|
|
||||||
|
boolean exists = f.exists();
|
||||||
|
if ( !exists )
|
||||||
{
|
{
|
||||||
f.mkdirs();
|
f.mkdirs();
|
||||||
|
}
|
||||||
|
if ( versionTag != null )
|
||||||
|
{
|
||||||
|
File vtag = new File( f, versionTag );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
exists = !vtag.createNewFile();
|
||||||
|
}
|
||||||
|
catch( IOException io ) { throw new RuntimeException( "error checking version tag " + vtag ); }
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !exists )
|
||||||
|
{
|
||||||
// default contents from assets archive
|
// default contents from assets archive
|
||||||
if ( assetZip != null )
|
if ( assetZip != null )
|
||||||
{
|
{
|
||||||
|
@ -680,11 +703,20 @@ public class BRouterView extends View
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String result = "version = BRouter-1.4.2\n" + "distance = " + cr.getDistance() / 1000. + " km\n" + "filtered ascend = " + cr.getAscend()
|
String result = "version = BRouter-1.4.3\n" + "distance = " + cr.getDistance() / 1000. + " km\n" + "filtered ascend = " + cr.getAscend()
|
||||||
+ " m\n" + "plain ascend = " + cr.getPlainAscend();
|
+ " m\n" + "plain ascend = " + cr.getPlainAscend();
|
||||||
|
|
||||||
rawTrack = cr.getFoundRawTrack();
|
rawTrack = cr.getFoundRawTrack();
|
||||||
|
|
||||||
|
// for profile "remote", always persist referencetrack
|
||||||
|
if ( cr.getAlternativeIndex() == 0 )
|
||||||
|
{
|
||||||
|
if ( "remote".equals( profileName ) )
|
||||||
|
{
|
||||||
|
writeRawTrackToMode( "remote" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String title = "Success";
|
String title = "Success";
|
||||||
if ( cr.getAlternativeIndex() > 0 )
|
if ( cr.getAlternativeIndex() > 0 )
|
||||||
title += " / " + cr.getAlternativeIndex() + ". Alternative";
|
title += " / " + cr.getAlternativeIndex() + ". Alternative";
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class BRouterWorker
|
||||||
cr.doRun( maxRunningTime );
|
cr.doRun( maxRunningTime );
|
||||||
|
|
||||||
// store new reference track if any
|
// store new reference track if any
|
||||||
// (can exist fot timeed-out search)
|
// (can exist for timed-out search)
|
||||||
if ( cr.getFoundRawTrack() != null )
|
if ( cr.getFoundRawTrack() != null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -17,6 +17,7 @@ interface IBRouterService {
|
||||||
// "nogoRadi"-->double[] array of nogo radius in meters; may be null.
|
// "nogoRadi"-->double[] array of nogo radius in meters; may be null.
|
||||||
// "fast"-->[0|1]
|
// "fast"-->[0|1]
|
||||||
// "v"-->[motorcar|bicycle|foot]
|
// "v"-->[motorcar|bicycle|foot]
|
||||||
|
// "remoteProfile"--> (String), net-content of a profile. If remoteProfile != null, v+fast are ignored
|
||||||
//return null if all ok and no path given, the track if ok and path given, an error message if it was wrong
|
//return null if all ok and no path given, the track if ok and path given, an error message if it was wrong
|
||||||
//call in a background thread, heavy task!
|
//call in a background thread, heavy task!
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-server</artifactId>
|
<artifactId>brouter-server</artifactId>
|
||||||
|
@ -51,11 +51,11 @@
|
||||||
<artifactId>brouter-map-creator</artifactId>
|
<artifactId>brouter-map-creator</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>
|
<dependency>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter-mem-router</artifactId>
|
<artifactId>brouter-mem-router</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency> -->
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class BRouter
|
||||||
}
|
}
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
System.out.println("BRouter 1.4.2 / 16052016 / abrensch");
|
System.out.println("BRouter 1.4.3 / 06082016 / abrensch");
|
||||||
if ( args.length < 6 )
|
if ( args.length < 6 )
|
||||||
{
|
{
|
||||||
System.out.println("Find routes in an OSM map");
|
System.out.println("Find routes in an OSM map");
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class RouteServer extends Thread
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
System.out.println("BRouter 1.4.2 / 16052016");
|
System.out.println("BRouter 1.4.3 / 06082016");
|
||||||
if ( args.length != 5 )
|
if ( args.length != 5 )
|
||||||
{
|
{
|
||||||
System.out.println("serve BRouter protocol");
|
System.out.println("serve BRouter protocol");
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>brouter-util</artifactId>
|
<artifactId>brouter-util</artifactId>
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.btools</groupId>
|
<groupId>org.btools</groupId>
|
||||||
<artifactId>brouter</artifactId>
|
<artifactId>brouter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.3</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<url>http://brouter.de/brouter/</url>
|
<url>http://brouter.de/brouter/</url>
|
||||||
<name>brouter</name>
|
<name>brouter</name>
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
<module>brouter-mapaccess</module>
|
<module>brouter-mapaccess</module>
|
||||||
<module>brouter-core</module>
|
<module>brouter-core</module>
|
||||||
<module>brouter-map-creator</module>
|
<module>brouter-map-creator</module>
|
||||||
<!-- <module>brouter-mem-router</module> -->
|
<module>brouter-mem-router</module>
|
||||||
<module>brouter-server</module>
|
<module>brouter-server</module>
|
||||||
<module>brouter-routing-app</module>
|
<module>brouter-routing-app</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
Loading…
Reference in a new issue