Exemplo n.º 1
0
 public static void GetCsvData(this Curb curb,
                               out List <CsvPoint> csvPoints,
                               out List <CsvLine> csvLines,
                               out List <CsvCurb> csvCurbs)
 {
     csvPoints = new List <CsvPoint>();
     csvLines  = new List <CsvLine>();
     csvCurbs  = new List <CsvCurb>();
     for (int i = 0; i < curb.LineRenderer.positionCount; i++)
     {
         var csvPoint = new CsvPoint()
         {
             Position = curb.LineRenderer.GetPosition(i)
         };
         csvPoints.Add(csvPoint);
         if (i > 0)
         {
             var csvLine = new CsvLine()
             {
                 PointBegin = csvPoints[i - 1], PointFinal = csvPoint
             };
             if (i > 1)
             {
                 csvLine.LineLast = csvLines.Last();
             }
             csvLines.Add(csvLine);
             csvCurbs.Add(new CsvCurb()
             {
                 Line = csvLine
             });
         }
     }
 }
Exemplo n.º 2
0
 public static void GetCsvData(this WhiteLine whiteLine,
                               out List <CsvPoint> csvPoints,
                               out List <CsvLine> csvLines,
                               out List <CsvWhiteLine> csvWhiteLines)
 {
     csvPoints     = new List <CsvPoint>();
     csvLines      = new List <CsvLine>();
     csvWhiteLines = new List <CsvWhiteLine>();
     for (int i = 0; i < whiteLine.LineRenderer.positionCount; i++)
     {
         var csvPoint = new CsvPoint()
         {
             Position = whiteLine.LineRenderer.GetPosition(i)
         };
         csvPoints.Add(csvPoint);
         if (i > 0)
         {
             var csvLine = new CsvLine()
             {
                 PointBegin = csvPoints[i - 1], PointFinal = csvPoint
             };
             if (i > 1)
             {
                 csvLine.LineLast = csvLines.Last();
             }
             csvLines.Add(csvLine);
             csvWhiteLines.Add(new CsvWhiteLine()
             {
                 Line = csvLine, Width = whiteLine.width
             });
         }
     }
 }
Exemplo n.º 3
0
        public static void GetCsvData(this StopLine stopLine,
                                      PointOctree <CsvLane> finalLanes,
                                      out List <CsvPoint> csvPoints,
                                      out List <CsvLine> csvLines,
                                      out List <CsvVector> csvVectors,
                                      out List <CsvSignalLight> csvSignalLights,
                                      out List <CsvStopLine> csvStopLines)
        {
            csvPoints    = new List <CsvPoint>();
            csvLines     = new List <CsvLine>();
            csvStopLines = new List <CsvStopLine>();
            var csvSLPoints = new List <CsvPoint>();

            csvVectors      = new List <CsvVector>();
            csvSignalLights = new List <CsvSignalLight>();
            for (int i = 0; i < stopLine.Count; i++)
            {
                var csvPoint = new CsvPoint()
                {
                    Position = stopLine.LineRenderer.GetPosition(i)
                };
                csvPoints.Add(csvPoint);
                if (i > 0)
                {
                    var csvLine = new CsvLine()
                    {
                        PointBegin = csvPoints[i - 1], PointFinal = csvPoint
                    };
                    if (i > 1)
                    {
                        csvLine.LineLast = csvLines.Last();
                    }
                    csvLines.Add(csvLine);
                    var signalLight = stopLine.signalLights[i - 1];
                    var csvSLPoint  = new CsvPoint()
                    {
                        Position = signalLight.transform.position
                    };
                    csvSLPoints.Add(csvSLPoint);
                    var csvVector = new CsvVector()
                    {
                        Point = csvSLPoint, Rotation = signalLight.transform.rotation
                    };
                    csvVectors.Add(csvVector);
                    var csvSignalLight = new CsvSignalLight()
                    {
                        Vector = csvVector
                    };
                    csvSignalLights.Add(csvSignalLight);
                    var midPoint    = (csvLine.PointBegin.Position + csvLine.PointFinal.Position) / 2;
                    var csvStopLine = new CsvStopLine()
                    {
                        Line        = csvLine,
                        SignalLight = csvSignalLight,
                        Lane        = finalLanes
                                      .GetNearby(midPoint, Vector3.Distance(csvLine.PointBegin.Position, csvLine.PointFinal.Position))
                                      ?.OrderBy(_ => Vector3.Distance(_.FinalNode.Point.Position, midPoint))?
                                      .FirstOrDefault()
                    };
                    csvStopLines.Add(csvStopLine);
                }
            }
            csvPoints.AddRange(csvSLPoints);
        }