fixed node-costs in csv
This commit is contained in:
parent
0fe5d5144a
commit
4b084bd033
3 changed files with 79 additions and 37 deletions
48
brouter-core/src/main/java/btools/router/MessageData.java
Normal file
48
brouter-core/src/main/java/btools/router/MessageData.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* Information on matched way point
|
||||
*
|
||||
* @author ab
|
||||
*/
|
||||
package btools.router;
|
||||
|
||||
import btools.expressions.BExpressionContext;
|
||||
|
||||
|
||||
final class MessageData
|
||||
{
|
||||
int linkdist = 0;
|
||||
int linkelevationcost = 0;
|
||||
int linkturncost = 0;
|
||||
int linknodecost = 0;
|
||||
int linkinitcost = 0;
|
||||
|
||||
float costfactor;
|
||||
String wayKeyValues;
|
||||
String nodeKeyValues;
|
||||
|
||||
int lon;
|
||||
int lat;
|
||||
short ele;
|
||||
|
||||
String toMessage()
|
||||
{
|
||||
if ( wayKeyValues == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int iCost = (int)(costfactor*1000 + 0.5f);
|
||||
return (lon-180000000) + "\t"
|
||||
+ (lat-90000000) + "\t"
|
||||
+ ele/4 + "\t"
|
||||
+ linkdist + "\t"
|
||||
+ iCost + "\t"
|
||||
+ linkelevationcost
|
||||
+ "\t" + linkturncost
|
||||
+ "\t" + linknodecost
|
||||
+ "\t" + linkinitcost
|
||||
+ "\t" + wayKeyValues
|
||||
+ "\t" + ( nodeKeyValues == null ? "" : nodeKeyValues );
|
||||
}
|
||||
|
||||
}
|
|
@ -84,15 +84,11 @@ final class OsmPath implements OsmLinkHolder
|
|||
short ele1 = origin.selev;
|
||||
|
||||
int linkdisttotal = 0;
|
||||
int linkdist = 0;
|
||||
int linkelevationcost = 0;
|
||||
int linkturncost = 0;
|
||||
int linknodecost = 0;
|
||||
int linkinitcost = 0;
|
||||
|
||||
MessageData msgData = new MessageData();
|
||||
|
||||
OsmTransferNode transferNode = link.decodeFirsttransfer();
|
||||
OsmNode targetNode = link.targetNode;
|
||||
String lastMessage = null;
|
||||
for(;;)
|
||||
{
|
||||
originLon = lon1;
|
||||
|
@ -124,14 +120,10 @@ final class OsmPath implements OsmLinkHolder
|
|||
boolean sameData = rc.expctxWay.evaluate( link.counterLinkWritten, description, rc.messageHandler );
|
||||
|
||||
// if way description changed, store message
|
||||
if ( lastMessage != null && !sameData )
|
||||
if ( msgData.wayKeyValues != null && !sameData )
|
||||
{
|
||||
originElement.message = lastMessage;
|
||||
linkdist = 0;
|
||||
linkelevationcost = 0;
|
||||
linkturncost = 0;
|
||||
linknodecost = 0;
|
||||
linkinitcost = 0;
|
||||
originElement.message = msgData.toMessage();
|
||||
msgData = new MessageData();
|
||||
}
|
||||
|
||||
int dist = rc.calcDistance( lon1, lat1, lon2, lat2 );
|
||||
|
@ -165,7 +157,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
}
|
||||
}
|
||||
|
||||
linkdist += dist;
|
||||
msgData.linkdist += dist;
|
||||
linkdisttotal += dist;
|
||||
|
||||
|
||||
|
@ -176,7 +168,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
double cos = rc.calcCosAngle( lon0, lat0, lon1, lat1, lon2, lat2 );
|
||||
int turncost = (int)(cos * rc.expctxWay.getTurncost() + 0.2 ); // e.g. turncost=90 -> 90 degree = 90m penalty
|
||||
cost += turncost;
|
||||
linkturncost += turncost;
|
||||
msgData.linkturncost += turncost;
|
||||
}
|
||||
|
||||
// *** penalty for elevation (penalty is for descend! in a way that slow descends give no penalty)
|
||||
|
@ -212,7 +204,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
{
|
||||
int elevationCost = reduce/rc.downhillcostdiv;
|
||||
cost += elevationCost;
|
||||
linkelevationcost += elevationCost;
|
||||
msgData.linkelevationcost += elevationCost;
|
||||
}
|
||||
}
|
||||
else if ( ehbd < 0 )
|
||||
|
@ -242,7 +234,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
{
|
||||
int elevationCost = reduce/rc.uphillcostdiv;
|
||||
cost += elevationCost;
|
||||
linkelevationcost += elevationCost;
|
||||
msgData.linkelevationcost += elevationCost;
|
||||
}
|
||||
}
|
||||
else if ( ehbu < 0 )
|
||||
|
@ -276,23 +268,17 @@ final class OsmPath implements OsmLinkHolder
|
|||
lastCostfactor = newcostfactor;
|
||||
float initialcost = rc.expctxWay.getInitialcost();
|
||||
int iicost = (int)initialcost;
|
||||
linkinitcost += iicost;
|
||||
msgData.linkinitcost += iicost;
|
||||
cost += iicost;
|
||||
}
|
||||
|
||||
if ( recordTransferNodes )
|
||||
{
|
||||
int iCost = (int)(costfactor*1000 + 0.5f);
|
||||
lastMessage = (lon2-180000000) + "\t"
|
||||
+ (lat2-90000000) + "\t"
|
||||
+ ele2/4 + "\t"
|
||||
+ linkdist + "\t"
|
||||
+ iCost + "\t"
|
||||
+ linkelevationcost
|
||||
+ "\t" + linkturncost
|
||||
+ "\t" + linknodecost
|
||||
+ "\t" + linkinitcost
|
||||
+ rc.expctxWay.getKeyValueDescription( link.counterLinkWritten, description );
|
||||
msgData.costfactor = costfactor;
|
||||
msgData.lon = lon2;
|
||||
msgData.lat = lat2;
|
||||
msgData.ele = ele2;
|
||||
msgData.wayKeyValues = rc.expctxWay.getKeyValueDescription( link.counterLinkWritten, description );
|
||||
}
|
||||
|
||||
if ( stopAtEndpoint )
|
||||
|
@ -301,7 +287,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
{
|
||||
originElement = new OsmPathElement( rc.ilonshortest, rc.ilatshortest, ele2, originElement );
|
||||
originElement.cost = cost;
|
||||
originElement.message = lastMessage;
|
||||
originElement.message = msgData.toMessage();
|
||||
}
|
||||
if ( rc.nogomatch )
|
||||
{
|
||||
|
@ -318,7 +304,6 @@ final class OsmPath implements OsmLinkHolder
|
|||
int reftrackcost = linkdisttotal;
|
||||
cost += reftrackcost;
|
||||
}
|
||||
message = lastMessage;
|
||||
selev = ele2;
|
||||
break;
|
||||
}
|
||||
|
@ -347,8 +332,9 @@ final class OsmPath implements OsmLinkHolder
|
|||
// finally add node-costs for target node
|
||||
if ( targetNode.nodeDescription != null )
|
||||
{
|
||||
boolean nodeAccessGranted = rc.expctxWay.getNodeAccessGranted() != 0.;
|
||||
rc.messageHandler.setCurrentPos( targetNode.ilon, targetNode.ilat );
|
||||
rc.expctxNode.evaluate( rc.expctxWay.getNodeAccessGranted() != 0. , targetNode.nodeDescription, rc.messageHandler );
|
||||
rc.expctxNode.evaluate( nodeAccessGranted , targetNode.nodeDescription, rc.messageHandler );
|
||||
float initialcost = rc.expctxNode.getInitialcost();
|
||||
if ( initialcost >= 1000000. )
|
||||
{
|
||||
|
@ -356,11 +342,20 @@ final class OsmPath implements OsmLinkHolder
|
|||
return;
|
||||
}
|
||||
int iicost = (int)initialcost;
|
||||
linknodecost += iicost;
|
||||
msgData.linknodecost += iicost;
|
||||
|
||||
cost += iicost;
|
||||
|
||||
if ( recordTransferNodes )
|
||||
{
|
||||
msgData.nodeKeyValues = rc.expctxNode.getKeyValueDescription( nodeAccessGranted, targetNode.nodeDescription );
|
||||
}
|
||||
}
|
||||
|
||||
message = msgData.toMessage();
|
||||
|
||||
}
|
||||
|
||||
public int elevationCorrection( RoutingContext rc )
|
||||
{
|
||||
return ( rc.downhillcostdiv > 0 ? ehbd/rc.downhillcostdiv : 0 )
|
||||
|
|
|
@ -281,9 +281,6 @@ public final class BExpressionContext
|
|||
|
||||
public String getKeyValueDescription( boolean inverseDirection, byte[] ab )
|
||||
{
|
||||
int inverseBitByteIndex = meta.readVarLength ? 0 : 7;
|
||||
// int abLen = ab.length;
|
||||
|
||||
StringBuilder sb = new StringBuilder( 200 );
|
||||
decode( lookupData, inverseDirection, ab );
|
||||
for( int inum = 0; inum < lookupValues.size(); inum++ ) // loop over lookup names
|
||||
|
@ -292,7 +289,8 @@ public final class BExpressionContext
|
|||
String value = va[lookupData[inum]].toString();
|
||||
if ( value != null && value.length() > 0 )
|
||||
{
|
||||
sb.append( " " + lookupNames.get( inum ) + "=" + value );
|
||||
if ( sb.length() > 0 ) sb.append( ' ' );
|
||||
sb.append(lookupNames.get( inum ) + "=" + value );
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -571,6 +569,7 @@ public final class BExpressionContext
|
|||
lookupData[inum] = valueIndex;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* special hack for yes/proposed relations:
|
||||
* add a lookup value if not yet a smaller, >1 value was added
|
||||
|
|
Loading…
Reference in a new issue