コード例 #1
0
        public static Dictionary <string, object> GetListAndCountOfCategories()        //Работает!
        {
            var guid = Guid.NewGuid();
            MgCoordinateSystemFactory            coordSysFactory = new MgCoordinateSystemFactory();
            MgCoordinateSystemCatalog            csCatalog       = coordSysFactory.GetCatalog();
            MgCoordinateSystemCategoryDictionary csDictCat       = csCatalog.GetCategoryDictionary();

            MgCoordinateSystemEnum csDictCatEnum = csDictCat.GetEnum();
            int csCatCount = csDictCat.GetSize();
            MgStringCollection csCatNames     = csDictCatEnum.NextName(csCatCount);
            string             csCategoryName = null;

            List <string> csCatNamesL = new List <string>();

            for (int i3 = 0; i3 < csCatCount; i3++)
            {
                csCategoryName = csCatNames.GetItem(i3);
                csCatNamesL.Add(csCategoryName);
            }
            return(new Dictionary <string, object>
            {
                { "CatCount", csCatCount },
                { "CatList", csCatNamesL },
            });
        }
コード例 #2
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());
            }
        }
コード例 #3
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);
        }