Exemplo n.º 1
0
        private static void InsertNodeSegments(RoadTopology topology, IReadOnlyDictionary <RoadTopologyEdge, StraightRoadSegment> edgeSegments)
        {
            foreach (var node in topology.Nodes)
            {
                foreach (var edgesPerTemplate in node.Edges.GroupBy(e => e.Template))
                {
                    var template = edgesPerTemplate.Key;
                    // possible optimization: only compute angles if necessary?
                    var incomingRoadData = ComputeRoadAngles(node, edgesPerTemplate);

                    switch (edgesPerTemplate.Count())
                    {
                    // TODO support end caps
                    case 1:     // end point
                        break;

                    case 2:
                        CurvedRoadSegment.CreateCurve(incomingRoadData, node.Position, template, edgeSegments);
                        break;

                    case 3:
                    case 4:
                        CrossingRoadSegment.CreateCrossing(incomingRoadData, node.Position, template, edgeSegments);
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
 private static void InsertCurveSegments(RoadTopology topology, IReadOnlyDictionary <RoadTopologyEdge, StraightRoadSegment> edgeSegments)
 {
     foreach (var node in topology.Nodes)
     {
         foreach (var edgesPerTemplate in node.Edges.GroupBy(e => e.Template))
         {
             var connectedEdges = edgesPerTemplate.Count();
             if (connectedEdges == 2)
             {
                 var incomingRoadData = ComputeRoadAngles(node, edgesPerTemplate, edgeSegments);
                 CurvedRoadSegment.CreateCurve(incomingRoadData, node.Position, edgesPerTemplate.Key, edgeSegments);
             }
         }
     }
 }
Exemplo n.º 3
0
        private static void InsertNodeSegments(RoadTopology topology, IReadOnlyDictionary <RoadTopologyEdge, StraightRoadSegment> edgeSegments)
        {
            foreach (var node in topology.Nodes)
            {
                foreach (var edgesPerTemplate in node.Edges.GroupBy(e => e.Template))
                {
                    var template         = edgesPerTemplate.Key;
                    var incomingRoadData = ComputeRoadAngles(node, edgesPerTemplate);

                    switch (edgesPerTemplate.Count())
                    {
                    case 2:
                        CurvedRoadSegment.CreateCurve(incomingRoadData, node.Position, template, edgeSegments);
                        break;

                    case 3:
                    case 4:
                        CrossingRoadSegment.CreateCrossing(incomingRoadData, node.Position, template, edgeSegments);
                        break;
                    }
                }
            }
        }