OSMEdge.cs:
+ GetWeight() + override toString() fixed maxSpeedValue 255 -> returns now empty
This commit is contained in:
parent
aceecee07e
commit
e57912c589
@ -134,7 +134,11 @@ public class OsmEdge
|
|||||||
case "maxspeed":
|
case "maxspeed":
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new KeyValuePair<tagType, object>(tagType.maxspeed, Convert.ToByte(value));
|
byte speed = Convert.ToByte(value);
|
||||||
|
if(speed == 255)
|
||||||
|
return new KeyValuePair<tagType, object>(tagType.EMPTY, 0);
|
||||||
|
else
|
||||||
|
return new KeyValuePair<tagType, object>(tagType.maxspeed, speed);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -193,4 +197,30 @@ public class OsmEdge
|
|||||||
{
|
{
|
||||||
return this.tags.ContainsKey(tagType.forward) && (bool)this.tags[tagType.forward];
|
return this.tags.ContainsKey(tagType.forward) && (bool)this.tags[tagType.forward];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double GetWeight(OsmNode parentNode, speedType vehicle)
|
||||||
|
{
|
||||||
|
double distance = Utils.DistanceBetween(parentNode, neighborCoordinates);
|
||||||
|
byte? speedByte = GetMaxSpeed(vehicle);
|
||||||
|
if (speedByte != null && speedByte > 0)
|
||||||
|
{
|
||||||
|
double speed = Convert.ToDouble(speedByte);
|
||||||
|
return distance / (speed * 1000 / 360);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return double.MaxValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string tagsString = "";
|
||||||
|
foreach (KeyValuePair<tagType, object> tag in tags)
|
||||||
|
{
|
||||||
|
tagsString += string.Format("\n\t{0}: {1}", tag.Key, tag.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("EDGE neighborCoordinates: {0} {1}", neighborCoordinates.ToString(), tagsString);
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user