Skip to content
Snippets Groups Projects
Commit db229353 authored by Knuiman, Bart's avatar Knuiman, Bart
Browse files

Fixes routelinks that contain duplicate points (points 1 mtr from each other are removed).

parent 8e44f2ee
No related branches found
No related tags found
No related merge requests found
......@@ -388,6 +388,44 @@ namespace OVAPI.Code.OVParsers
kvp.Value.line.destination = kvp.Value.destination;
}
// Validate links.
foreach( var kvp in routeLinks)
{
var link = kvp.Value;
if (link.points.Count != 0 )
{
Debug.Assert( link.points.Count >= 2 );
for (int j = 0; j < link.points.Count-1; j++)
{
var p0 = link.points[j];
var p1 = link.points[j+1];
var dir = new Vector2( p0.rdx, p0.rdy ) - new Vector2 ( p1.rdx, p1.rdy );
var len = dir.Length();
if ( len < 1 )
{
// Remove points less than a meter apart from eachother.
link.points.RemoveAt( j );
j--;
continue;
}
}
if ( link.points.Count == 1 )
{
link.points.Clear();
}
}
// Because of points too close together, may end up with no in between points. Always check from-to distance. Must not be sane value.
{
var p0 = link.from;
var p1 = link.to;
var dir = new Vector2( p0.rdx, p0.rdy ) - new Vector2 ( p1.rdx, p1.rdy );
Debug.Assert( Sane( dir.Length() ) );
Debug.Assert( Sane( dir/dir.Length() ) );
}
}
// Fixup routes (concat routelinks).
foreach (var kvp in routes)
{
......
......@@ -42,7 +42,7 @@ class App
// Update the active simulation with new vehicle updates.
if( vehicleUpdates != null )
{
var varFilteredList = vehicleUpdates.Where( vhi => vhi.infos[0]=="RET" ).ToList();
var varFilteredList = vehicleUpdates.Where( vhi => vhi.infos[0]=="HTM" ).ToList();
activeOV.UpdateVehicles( varFilteredList );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment