voice hints, here: cf=9999 survive decoder

This commit is contained in:
Arndt 2016-05-01 11:51:42 +02:00
parent 23d1812371
commit e8d8bc084a
6 changed files with 40 additions and 17 deletions

View file

@ -95,7 +95,8 @@ public final class MicroCache2 extends MicroCache
selev += nodeEleDiff.decodeSignedValue(); selev += nodeEleDiff.decodeSignedValue();
writeShort( (short) selev ); writeShort( (short) selev );
writeVarBytes( nodeTagCoder.decodeTagValueSet() ); TagValueWrapper nodeTags = nodeTagCoder.decodeTagValueSet();
writeVarBytes( nodeTags == null ? null : nodeTags.data );
int links = bc.decodeNoisyNumber( 1 ); int links = bc.decodeNoisyNumber( 1 );
if ( debug ) System.out.println( "*** decoding node with links=" + links ); if ( debug ) System.out.println( "*** decoding node with links=" + links );
@ -120,7 +121,7 @@ public final class MicroCache2 extends MicroCache
writeVarLengthSigned( dlon_remaining = extLonDiff.decodeSignedValue() ); writeVarLengthSigned( dlon_remaining = extLonDiff.decodeSignedValue() );
writeVarLengthSigned( dlat_remaining = extLatDiff.decodeSignedValue() ); writeVarLengthSigned( dlat_remaining = extLatDiff.decodeSignedValue() );
} }
byte[] wayTags = wayTagCoder.decodeTagValueSet(); TagValueWrapper wayTags = wayTagCoder.decodeTagValueSet();
if ( wayTags != null ) if ( wayTags != null )
{ {
@ -133,10 +134,10 @@ public final class MicroCache2 extends MicroCache
} }
} }
writeModeAndDesc( isReverse, wayTags ); writeModeAndDesc( isReverse, wayTags == null ? null : wayTags.data );
if ( !isReverse ) // write geometry for forward links only if ( !isReverse ) // write geometry for forward links only
{ {
WaypointMatcher matcher = wayTags == null ? null : waypointMatcher; WaypointMatcher matcher = wayTags == null || wayTags.accessType < 2 ? null : waypointMatcher;
if ( matcher != null ) matcher.startNode( ilon, ilat ); if ( matcher != null ) matcher.startNode( ilon, ilat );
int ilontarget = ilon + dlon_remaining; int ilontarget = ilon + dlon_remaining;
int ilattarget = ilat + dlat_remaining; int ilattarget = ilat + dlat_remaining;

View file

@ -46,7 +46,7 @@ public final class TagValueCoder
} }
} }
public byte[] decodeTagValueSet() public TagValueWrapper decodeTagValueSet()
{ {
Object node = tree; Object node = tree;
while (node instanceof TreeNode) while (node instanceof TreeNode)
@ -55,7 +55,7 @@ public final class TagValueCoder
boolean nextBit = bc.decodeBit(); boolean nextBit = bc.decodeBit();
node = nextBit ? tn.child2 : tn.child1; node = nextBit ? tn.child2 : tn.child1;
} }
return (byte[]) node; return (TagValueWrapper) node;
} }
public void encodeDictionary( BitCoderContext bc ) public void encodeDictionary( BitCoderContext bc )
@ -120,9 +120,13 @@ public final class TagValueCoder
byte[] res = new byte[len]; byte[] res = new byte[len];
System.arraycopy( buffer, 0, res, 0, len ); System.arraycopy( buffer, 0, res, 0, len );
if ( validator == null || validator.accessAllowed( res ) ) int accessType = validator == null ? 2 : validator.accessType( res );
if ( accessType > 0 )
{ {
return res; TagValueWrapper w = new TagValueWrapper();
w.data = res;
w.accessType = accessType;
return w;
} }
return null; return null;
} }

View file

@ -5,7 +5,7 @@ public interface TagValueValidator
{ {
/** /**
* @param tagValueSet the way description to check * @param tagValueSet the way description to check
* @return true if access is allowed in the current profile * @return 0 = nothing, 1=no matching, 2=normal
*/ */
public boolean accessAllowed( byte[] tagValueSet ); public int accessType( byte[] tagValueSet );
} }

View file

@ -0,0 +1,12 @@
package btools.codec;
/**
* TagValueWrapper wrapps a description bitmap
* to add the access-type
*/
public final class TagValueWrapper
{
public byte[] data;
public int accessType;
}

View file

@ -304,7 +304,7 @@ final class OsmPath implements OsmLinkHolder
} }
float fcost = dist * costfactor + 0.5f; float fcost = dist * costfactor + 0.5f;
if ( ( costfactor > 9999. && !detailMode ) || fcost + cost >= 2000000000. ) if ( ( costfactor > 9998. && !detailMode ) || fcost + cost >= 2000000000. )
{ {
cost = -1; cost = -1;
return; return;

View file

@ -49,13 +49,19 @@ public final class BExpressionContextWay extends BExpressionContext implements T
} }
@Override @Override
public boolean accessAllowed( byte[] description ) public int accessType( byte[] description )
{ {
evaluate( false, description, null ); evaluate( false, description, null );
boolean ok = getCostfactor() < 10000.; float minCostFactor = getCostfactor();
if ( minCostFactor >= 9999.f )
{
evaluate( true, description, null ); evaluate( true, description, null );
ok |= getCostfactor() < 10000.; float reverseCostFactor = getCostfactor();
return ok; if ( reverseCostFactor < minCostFactor )
{
minCostFactor = reverseCostFactor;
}
}
return minCostFactor < 9999.f ? 2 : minCostFactor < 10000.f ? 1 : 0;
} }
} }