예제 #1
0
        public bool Export(string foldername)
        {
            try
            {
                MapAnnotationData = new MapManagerData();

                // Process lanes, intersections.
                MapAnnotationData.GetIntersections();
                MapAnnotationData.GetTrafficLanes();

                if (Calculate())
                {
                    var sb = new StringBuilder();
                    foreach (var list in ExportLists)
                    {
                        var csvFilename = list.FileName;
                        var csvHeader   = VectorMapUtility.GetCSVHeader(list.Type);

                        var filepath = Path.Combine(foldername, csvFilename);

                        if (!System.IO.Directory.Exists(foldername))
                        {
                            System.IO.Directory.CreateDirectory(foldername);
                        }

                        if (System.IO.File.Exists(filepath))
                        {
                            System.IO.File.Delete(filepath);
                        }

                        sb.Clear();
                        using (StreamWriter sw = File.CreateText(filepath))
                        {
                            sb.Append(csvHeader);
                            sb.Append("\n");

                            foreach (var e in list.List)
                            {
                                foreach (var field in list.Type.GetFields(BindingFlags.Instance | BindingFlags.Public))
                                {
                                    sb.Append(field.GetValue(e).ToString());
                                    sb.Append(",");
                                }
                                sb.Remove(sb.Length - 1, 1);
                                sb.Append("\n");
                            }
                            sw.Write(sb);
                        }
                    }
                    Debug.Log("Successfully generated and exported Autoware Vector Map!");
                    return(true);
                }
                Debug.LogError("Failed to export Autoware Map!");
            }
            catch (Exception exc)
            {
                Debug.LogError($"Autoware Map export unexpected error: {exc.Message}");
            }
            return(false);
        }
예제 #2
0
    void Export()
    {
        var sb1 = new StringBuilder();
        var sb2 = new StringBuilder();

        foreach (var list in exportLists)
        {
            var csvFilename = list.FileName;
            var csvHeader   = VectorMapUtility.GetCSVHeader(list.Type);

            sb1.Clear();
            sb1.Append(foldername);
            sb1.Append(Path.DirectorySeparatorChar);
            sb1.Append(csvFilename);

            var filepath = sb1.ToString();

            if (!System.IO.Directory.Exists(foldername))
            {
                System.IO.Directory.CreateDirectory(foldername);
            }

            if (System.IO.File.Exists(filepath))
            {
                System.IO.File.Delete(filepath);
            }

            sb2.Clear();
            using (StreamWriter sw = File.CreateText(filepath))
            {
                sb2.Append(csvHeader);
                sb2.Append("\n");

                foreach (var e in list.List)
                {
                    foreach (var field in list.Type.GetFields(BindingFlags.Instance | BindingFlags.Public))
                    {
                        sb2.Append(field.GetValue(e).ToString());
                        sb2.Append(",");
                    }
                    sb2.Remove(sb2.Length - 1, 1);
                    sb2.Append("\n");
                }
                sw.Write(sb2);
            }
        }
    }
예제 #3
0
        void Export(string foldername)
        {
            var sb = new StringBuilder();

            foreach (var list in ExportLists)
            {
                var csvFilename = list.FileName;
                var csvHeader   = VectorMapUtility.GetCSVHeader(list.Type);

                var filepath = Path.Combine(foldername, csvFilename);

                if (!System.IO.Directory.Exists(foldername))
                {
                    System.IO.Directory.CreateDirectory(foldername);
                }

                if (System.IO.File.Exists(filepath))
                {
                    System.IO.File.Delete(filepath);
                }

                sb.Clear();
                using (StreamWriter sw = File.CreateText(filepath))
                {
                    sb.Append(csvHeader);
                    sb.Append("\n");

                    foreach (var e in list.List)
                    {
                        foreach (var field in list.Type.GetFields(BindingFlags.Instance | BindingFlags.Public))
                        {
                            sb.Append(field.GetValue(e).ToString());
                            sb.Append(",");
                        }
                        sb.Remove(sb.Length - 1, 1);
                        sb.Append("\n");
                    }
                    sw.Write(sb);
                }
            }

            Debug.Log("Successfully generated and exported Autoware Vector Map!");
        }