voice-hints: locus-extensions
This commit is contained in:
parent
681adedde4
commit
62fd810e15
5 changed files with 44 additions and 10 deletions
|
@ -82,7 +82,7 @@ public final class OsmTrack
|
||||||
|
|
||||||
public void copyDetours( OsmTrack source )
|
public void copyDetours( OsmTrack source )
|
||||||
{
|
{
|
||||||
detourMap = new FrozenLongMap<OsmPathElementHolder>( source.detourMap );
|
detourMap = source.detourMap == null ? null : new FrozenLongMap<OsmPathElementHolder>( source.detourMap );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildMap()
|
public void buildMap()
|
||||||
|
@ -317,15 +317,29 @@ public final class OsmTrack
|
||||||
{
|
{
|
||||||
sb.append( " <wpt lon=\"" ).append( formatILon( hint.ilon ) ).append( "\" lat=\"" )
|
sb.append( " <wpt lon=\"" ).append( formatILon( hint.ilon ) ).append( "\" lat=\"" )
|
||||||
.append( formatILat( hint.ilat ) ).append( "\">" )
|
.append( formatILat( hint.ilat ) ).append( "\">" )
|
||||||
.append( "<name>" ).append( hint.message ).append( "</name>" )
|
.append( "<name>" ).append( hint.message ).append( "</name>" );
|
||||||
.append( "<sym>" ).append( hint.symbol ).append( "</sym>" )
|
if ( hint.turnInstructionMode == 2 )
|
||||||
.append( "<type>" ).append( hint.symbol ).append( "</type>" )
|
{
|
||||||
.append( "</wpt>\n" );
|
sb.append( "<extensions><locus:rteDistance>" ).append( hint.distanceToNext ).append( "</locus:rteDistance>" )
|
||||||
|
.append( "<locus:rtePointAction>" ).append( hint.locusAction ).append( "</locus:rtePointAction></extensions>" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.append( "<sym>" ).append( hint.symbol.toLowerCase() ).append( "</sym>" )
|
||||||
|
.append( "<type>" ).append( hint.symbol ).append( "</type>" );
|
||||||
|
}
|
||||||
|
sb.append( "</wpt>\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append( " <trk>\n" );
|
sb.append( " <trk>\n" );
|
||||||
sb.append( " <name>" ).append( name ).append( "</name>\n" );
|
sb.append( " <name>" ).append( name ).append( "</name>\n" );
|
||||||
|
|
||||||
|
if ( voiceHints != null && voiceHints.size() > 0 && voiceHints.get(0).turnInstructionMode == 2 )
|
||||||
|
{
|
||||||
|
sb.append( " <extensions><locus:rteComputeType>" ).append( voiceHints.get(0).locusRouteType ).append( "</locus:rteComputeType></extensions>\n" );
|
||||||
|
}
|
||||||
|
|
||||||
sb.append( " <trkseg>\n" );
|
sb.append( " <trkseg>\n" );
|
||||||
|
|
||||||
for ( OsmPathElement n : nodes )
|
for ( OsmPathElement n : nodes )
|
||||||
|
@ -563,8 +577,12 @@ public final class OsmTrack
|
||||||
voiceHints.add( hint );
|
voiceHints.add( hint );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processVoiceHints()
|
public void processVoiceHints( RoutingContext rc )
|
||||||
{
|
{
|
||||||
|
if ( detourMap == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
OsmPathElement node = nodes.get( nodes.size() - 1 );
|
OsmPathElement node = nodes.get( nodes.size() - 1 );
|
||||||
List<VoiceHint> inputs = new ArrayList<VoiceHint>();
|
List<VoiceHint> inputs = new ArrayList<VoiceHint>();
|
||||||
while (node != null)
|
while (node != null)
|
||||||
|
@ -575,6 +593,8 @@ public final class OsmTrack
|
||||||
inputs.add( input );
|
inputs.add( input );
|
||||||
input.ilat = node.origin.getILat();
|
input.ilat = node.origin.getILat();
|
||||||
input.ilon = node.origin.getILon();
|
input.ilon = node.origin.getILon();
|
||||||
|
input.locusRouteType = rc.carMode ? 4 : 5;
|
||||||
|
input.turnInstructionMode = rc.turnInstructionMode;
|
||||||
input.goodWay = node.message;
|
input.goodWay = node.message;
|
||||||
|
|
||||||
OsmPathElementHolder detours = detourMap.get( node.origin.getIdFromPos() );
|
OsmPathElementHolder detours = detourMap.get( node.origin.getIdFromPos() );
|
||||||
|
|
|
@ -95,6 +95,8 @@ public final class RoutingContext implements DistanceChecker
|
||||||
trafficDirectionFactor = expctxGlobal.getVariableValue( "trafficDirectionFactor", 0.9f );
|
trafficDirectionFactor = expctxGlobal.getVariableValue( "trafficDirectionFactor", 0.9f );
|
||||||
trafficSourceExponent = expctxGlobal.getVariableValue( "trafficSourceExponent", -0.7f );
|
trafficSourceExponent = expctxGlobal.getVariableValue( "trafficSourceExponent", -0.7f );
|
||||||
trafficSourceMinDist = expctxGlobal.getVariableValue( "trafficSourceMinDist", 3000.f );
|
trafficSourceMinDist = expctxGlobal.getVariableValue( "trafficSourceMinDist", 3000.f );
|
||||||
|
|
||||||
|
turnInstructionMode = (int)expctxGlobal.getVariableValue( "turnInstructionMode", 0.f );
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoutingMessageHandler messageHandler = new RoutingMessageHandler();
|
public RoutingMessageHandler messageHandler = new RoutingMessageHandler();
|
||||||
|
@ -123,6 +125,8 @@ public final class RoutingContext implements DistanceChecker
|
||||||
public double trafficSourceExponent;
|
public double trafficSourceExponent;
|
||||||
public double trafficSourceMinDist;
|
public double trafficSourceMinDist;
|
||||||
|
|
||||||
|
public int turnInstructionMode; // 0=none, 1=osmand, 2=locus
|
||||||
|
|
||||||
public static void prepareNogoPoints( List<OsmNodeNamed> nogos )
|
public static void prepareNogoPoints( List<OsmNodeNamed> nogos )
|
||||||
{
|
{
|
||||||
for( OsmNodeNamed nogo : nogos )
|
for( OsmNodeNamed nogo : nogos )
|
||||||
|
|
|
@ -934,10 +934,13 @@ public class RoutingEngine extends Thread
|
||||||
if ( nextId != guideNode.getIdFromPos() )
|
if ( nextId != guideNode.getIdFromPos() )
|
||||||
{
|
{
|
||||||
// not along the guide-track, discard, but register for voice-hint processing
|
// not along the guide-track, discard, but register for voice-hint processing
|
||||||
OsmPath detour = new OsmPath( currentNode, path, link, refTrack, true, routingContext );
|
if ( routingContext.turnInstructionMode > 0 )
|
||||||
if ( detour.cost >= 0. && nextId != startNodeId1 && nextId != startNodeId2 )
|
|
||||||
{
|
{
|
||||||
guideTrack.registerDetourForId( currentNode.getIdFromPos(), OsmPathElement.create( detour, false ) );
|
OsmPath detour = new OsmPath( currentNode, path, link, refTrack, true, routingContext );
|
||||||
|
if ( detour.cost >= 0. && nextId != startNodeId1 && nextId != startNodeId2 )
|
||||||
|
{
|
||||||
|
guideTrack.registerDetourForId( currentNode.getIdFromPos(), OsmPathElement.create( detour, false ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1124,7 @@ public class RoutingEngine extends Thread
|
||||||
if ( guideTrack != null )
|
if ( guideTrack != null )
|
||||||
{
|
{
|
||||||
track.copyDetours( guideTrack );
|
track.copyDetours( guideTrack );
|
||||||
track.processVoiceHints();
|
track.processVoiceHints( routingContext );
|
||||||
}
|
}
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ public class VoiceHint
|
||||||
int locusAction;
|
int locusAction;
|
||||||
MessageData goodWay;
|
MessageData goodWay;
|
||||||
List<MessageData> badWays;
|
List<MessageData> badWays;
|
||||||
|
double distanceToNext;
|
||||||
|
int locusRouteType;
|
||||||
|
int turnInstructionMode;
|
||||||
|
|
||||||
public void addBadWay( MessageData badWay )
|
public void addBadWay( MessageData badWay )
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,9 +14,11 @@ public final class VoiceHintProcessor
|
||||||
public static List<VoiceHint> process( List<VoiceHint> inputs )
|
public static List<VoiceHint> process( List<VoiceHint> inputs )
|
||||||
{
|
{
|
||||||
List<VoiceHint> results = new ArrayList<VoiceHint>();
|
List<VoiceHint> results = new ArrayList<VoiceHint>();
|
||||||
|
double distance = 0.;
|
||||||
for ( VoiceHint input : inputs )
|
for ( VoiceHint input : inputs )
|
||||||
{
|
{
|
||||||
// System.out.println( "***** processing: " + input.ilat + " " + input.ilon + " goodWay=" + input.goodWay );
|
// System.out.println( "***** processing: " + input.ilat + " " + input.ilon + " goodWay=" + input.goodWay );
|
||||||
|
distance += input.goodWay.linkdist;
|
||||||
if ( input.badWays != null )
|
if ( input.badWays != null )
|
||||||
{
|
{
|
||||||
float maxprio = 0.f;
|
float maxprio = 0.f;
|
||||||
|
@ -33,6 +35,8 @@ public final class VoiceHintProcessor
|
||||||
boolean isTurn = input.setTurnAngle( input.goodWay.turnangle );
|
boolean isTurn = input.setTurnAngle( input.goodWay.turnangle );
|
||||||
if ( isTurn || input.goodWay.priorityclassifier < maxprio )
|
if ( isTurn || input.goodWay.priorityclassifier < maxprio )
|
||||||
{
|
{
|
||||||
|
input.distanceToNext = distance;
|
||||||
|
distance = 0.;
|
||||||
results.add( input );
|
results.add( input );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue