Exemplo n.º 1
0
        /// <summary>
        /// Node GetListOfMAPCSLIBRAR for export to LSP file naming of coordinate systems (all library)
        /// </summary>
        /// <param name="CS_value">Name of type "CoordinateSystem"</param>
        /// <param name="CS_Agree">Permit to add other associated definitions</param>
        /// <param name="Folder_Path">Directory path to save LSP file</param>
        public static void GetAllOfMAPCSLIBRARY(string Folder_Path, string CS_value, string CS_Agree)
        {
            StringBuilder sb        = new StringBuilder();
            var           guid      = Guid.NewGuid();
            string        writePath = $@"{Folder_Path}\{guid}.lsp";

            MgCoordinateSystemFactory    coordSysFactory = new MgCoordinateSystemFactory();
            MgCoordinateSystemCatalog    csCatalog       = coordSysFactory.GetCatalog();
            MgCoordinateSystemDictionary csDict          = csCatalog.GetCoordinateSystemDictionary();

            MgCoordinateSystemEnum csDictEnum = csDict.GetEnum();
            int csCount = csDict.GetSize();

            sb.AppendLine(@"(command ""MAPCSLIBRARYEXPORT""");

            MgStringCollection csNames = csDictEnum.NextName(csCount);
            string             csName  = null;

            for (int i = 0; i < csCount; i++)
            {
                csName = csNames.GetItem(i);
                sb.AppendLine($@"""{csName.ToString()}""" + " " + $"\"{CS_value}\"");
            }
            string space = " ";

            sb.AppendLine(" " + $@"""{space}""" + " " + $@"""{CS_Agree}""" + " " + @"""""" + ")");
            using (StreamWriter export_file = new StreamWriter(writePath, true, Encoding.UTF8))
            {
                export_file.Write(sb.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Node GetCSList returns an external txt file that Contains strings with CS's names
        /// </summary>
        /// <param name="Folder_Path">Directory path to save TXT file</param>
        /// <param name="selection">If = true, export all CS in Library, if false - only Users collection</param>
        public static string GetCSList(string Folder_Path, bool selection)
        {
            StringBuilder sb        = new StringBuilder();
            var           guid      = Guid.NewGuid();
            string        writePath = $@"{Folder_Path}\{guid}CS_List.txt";

            MgCoordinateSystemFactory    coordSysFactory = new MgCoordinateSystemFactory();
            MgCoordinateSystemCatalog    csCatalog       = coordSysFactory.GetCatalog();
            MgCoordinateSystemDictionary csDict          = csCatalog.GetCoordinateSystemDictionary();

            MgCoordinateSystemEnum csDictEnum = csDict.GetEnum();
            int csCount = csDict.GetSize();


            MgStringCollection csNames = csDictEnum.NextName(csCount);
            string             csName  = null;

            MgCoordinateSystem cs = null;
            bool csProtect;

            for (int i = 0; i < csCount; i++)
            {
                csName    = csNames.GetItem(i);
                cs        = csDict.GetCoordinateSystem(csName);
                csProtect = cs.IsProtected();

                if (csProtect == selection)
                {
                    sb.AppendLine(csName.ToString());
                }
            }
            using (StreamWriter export_file = new StreamWriter(writePath, true, Encoding.UTF8))
            {
                export_file.Write(sb.ToString());
            }
            return(writePath);
        }