explicit classifier for initial cost
This commit is contained in:
parent
3ed62bb2b3
commit
0316c41924
4 changed files with 25 additions and 12 deletions
|
@ -40,7 +40,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
public int originLat;
|
||||
|
||||
// the costfactor of the segment just before this paths position
|
||||
public float lastCostfactor;
|
||||
public float lastClassifier;
|
||||
|
||||
public String message;
|
||||
|
||||
|
@ -64,7 +64,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
this.cost = origin.cost;
|
||||
this.ehbd = origin.ehbd;
|
||||
this.ehbu = origin.ehbu;
|
||||
this.lastCostfactor = origin.lastCostfactor;
|
||||
this.lastClassifier = origin.lastClassifier;
|
||||
addAddionalPenalty(refTrack, recordTransferNodes, origin, link, rc );
|
||||
}
|
||||
|
||||
|
@ -260,12 +260,16 @@ final class OsmPath implements OsmLinkHolder
|
|||
int waycost = (int)(fcost);
|
||||
cost += waycost;
|
||||
|
||||
// *** add initial cost if factor changed
|
||||
float newcostfactor = (cfup + cfdown + cf)/3;
|
||||
float costdiff = newcostfactor - lastCostfactor;
|
||||
if ( costdiff > 0.0005 || costdiff < -0.0005 )
|
||||
// *** add initial cost if the classifier changed
|
||||
float newClassifier = rc.expctxWay.getInitialClassifier();
|
||||
if ( newClassifier == 0. )
|
||||
{
|
||||
lastCostfactor = newcostfactor;
|
||||
newClassifier = (cfup + cfdown + cf)/3;
|
||||
}
|
||||
float classifierDiff = newClassifier - lastClassifier;
|
||||
if ( classifierDiff > 0.0005 || classifierDiff < -0.0005 )
|
||||
{
|
||||
lastClassifier = classifierDiff;
|
||||
float initialcost = rc.expctxWay.getInitialcost();
|
||||
int iicost = (int)initialcost;
|
||||
msgData.linkinitcost += iicost;
|
||||
|
|
|
@ -11,6 +11,7 @@ final class BExpression
|
|||
private static final int ADD_EXP = 20;
|
||||
private static final int MULTIPLY_EXP = 21;
|
||||
private static final int MAX_EXP = 22;
|
||||
private static final int EQUAL_EXP = 23;
|
||||
|
||||
private static final int SWITCH_EXP = 30;
|
||||
private static final int ASSIGN_EXP = 31;
|
||||
|
@ -100,6 +101,10 @@ final class BExpression
|
|||
{
|
||||
exp.typ = MAX_EXP;
|
||||
}
|
||||
else if ( "equal".equals( operator ) )
|
||||
{
|
||||
exp.typ = EQUAL_EXP;
|
||||
}
|
||||
else
|
||||
{
|
||||
nops = 1; // check unary expressions
|
||||
|
@ -220,6 +225,7 @@ final class BExpression
|
|||
case ADD_EXP: return op1.evaluate(ctx) + op2.evaluate(ctx);
|
||||
case MULTIPLY_EXP: return op1.evaluate(ctx) * op2.evaluate(ctx);
|
||||
case MAX_EXP: return max( op1.evaluate(ctx), op2.evaluate(ctx) );
|
||||
case EQUAL_EXP: return op1.evaluate(ctx) == op2.evaluate(ctx) ? 1.f : 0.f;
|
||||
case SWITCH_EXP: return op1.evaluate(ctx) != 0.f ? op2.evaluate(ctx) : op3.evaluate(ctx);
|
||||
case ASSIGN_EXP: return ctx.assign( variableIdx, op1.evaluate(ctx) );
|
||||
case LOOKUP_EXP: return ctx.getLookupMatch( lookupNameIdx, lookupValueIdxArray );
|
||||
|
|
|
@ -399,7 +399,8 @@ public abstract class BExpressionContext
|
|||
|
||||
for( int vi=0; vi<buildInVariableIdx.length; vi++ )
|
||||
{
|
||||
arrayBuildInVariablesCache[vi][currentHashBucket] = variableData[buildInVariableIdx[vi]];
|
||||
int idx = buildInVariableIdx[vi];
|
||||
arrayBuildInVariablesCache[vi][currentHashBucket] = idx == -1 ? 0.f : variableData[idx];
|
||||
}
|
||||
|
||||
_receiver = null;
|
||||
|
@ -658,15 +659,16 @@ public abstract class BExpressionContext
|
|||
linenr = 1;
|
||||
minWriteIdx = variableData == null ? 0 : variableData.length;
|
||||
|
||||
// create the build-in variables
|
||||
expressionList = _parseFile( file );
|
||||
|
||||
// determine the build-in variable indices
|
||||
String[] varNames = getBuildInVariableNames();
|
||||
buildInVariableIdx = new int[varNames.length];
|
||||
for( int vi=0; vi<varNames.length; vi++ )
|
||||
{
|
||||
buildInVariableIdx[vi] = getVariableIdx( varNames[vi], true );
|
||||
buildInVariableIdx[vi] = getVariableIdx( varNames[vi], false );
|
||||
}
|
||||
|
||||
expressionList = _parseFile( file );
|
||||
float[] readOnlyData = variableData;
|
||||
variableData = new float[variableNumbers.size()];
|
||||
for( int i=0; i<minWriteIdx; i++ )
|
||||
|
|
|
@ -11,7 +11,7 @@ package btools.expressions;
|
|||
public final class BExpressionContextWay extends BExpressionContext
|
||||
{
|
||||
private static String[] buildInVariables =
|
||||
{ "costfactor", "turncost", "uphillcostfactor", "downhillcostfactor", "initialcost", "nodeaccessgranted" };
|
||||
{ "costfactor", "turncost", "uphillcostfactor", "downhillcostfactor", "initialcost", "nodeaccessgranted", "initialclassifier" };
|
||||
|
||||
protected String[] getBuildInVariableNames()
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ public final class BExpressionContextWay extends BExpressionContext
|
|||
public float getDownhillCostfactor() { return getBuildInVariable(3); }
|
||||
public float getInitialcost() { return getBuildInVariable(4); }
|
||||
public float getNodeAccessGranted() { return getBuildInVariable(5); }
|
||||
public float getInitialClassifier() { return getBuildInVariable(6); }
|
||||
|
||||
|
||||
public BExpressionContextWay( BExpressionMetaData meta )
|
||||
|
|
Loading…
Reference in a new issue