コード例 #1
0
        public static void Run()
        {
            string gdbpath = "data\\fdsdemo.gdb";
            string transitpath = "data\\TransitFD.xml";
            string busstopspath = "data\\BusStopsTable.xml";

            Console.WriteLine();
            Console.WriteLine("***** Running Feature Dataset Test *****");

            try
            {
                GeodatabaseNet gdbnet = new GeodatabaseNet();

                if (Directory.Exists(gdbpath))
                {
                    Console.WriteLine("Geodatabase already exists, attempting to delete.");
                    gdbnet.DeleteGeodatabase(gdbpath);
                }

                Console.WriteLine("Creating geodatabase.");
                gdbnet.CreateGeodatabase(gdbpath);

                Console.WriteLine("Reading Dataset Definition");
                string featureDatasetDef;
                using (StreamReader sr = new StreamReader(transitpath))
                    featureDatasetDef = sr.ReadToEnd();

                Console.WriteLine("Creating feature dataset");
                gdbnet.CreateFeatureDataset(featureDatasetDef);

                string tableDef;
                using (StreamReader sr = new StreamReader(busstopspath))
                    tableDef = sr.ReadToEnd();

                Console.WriteLine("Creating table with Transit dataset as parent");
                TableNet table = gdbnet.CreateTable(tableDef, "\\Transit");

                Console.WriteLine("Closing Transit table");
                gdbnet.CloseTable(table);

                Console.WriteLine("Closing Geodatabase");
                gdbnet.CloseGeodatabase();

                Console.WriteLine("***** Finished Running Feature Dataset Test *****");
            }
            catch (FGDBException exc)
            {
                Console.WriteLine("Exception caught while running test.");
                Console.WriteLine("Code: " + exc.ErrorCode);
                Console.WriteLine("Message: " + exc);
                Console.WriteLine("Description: " + exc.ErrorDescription);
            }
        }
コード例 #2
0
        public static void Run()
        {
            string gdbpath = "data\\tableschematest.gdb";
            string fcdefpath = "data\\Table.xml";

            Console.WriteLine();
            Console.WriteLine("***** Running Table Schema Test *****");

            try
            {
                GeodatabaseNet gdbnet = new GeodatabaseNet();

                if (Directory.Exists(gdbpath))
                {
                    Console.WriteLine("Geodatabase already exists, attempting to delete.");
                    gdbnet.DeleteGeodatabase(gdbpath);
                }

                Console.WriteLine("Creating Geodatabase...");
                gdbnet.CreateGeodatabase(gdbpath);

                if (!Directory.Exists(gdbpath))
                {
                    Console.WriteLine("ERROR - Geodatabase creation reported no errors but no geodatabase found.  Exiting...");
                    return;
                }

                Console.WriteLine("Creating a domain definition.");
                gdbnet.CreateDomain(DOMAIN_DEFINITION);

                Console.WriteLine("Reading XML Feature Class Definition");
                string tableDef;
                using (StreamReader sr = new StreamReader(fcdefpath))
                    tableDef = sr.ReadToEnd();

                Console.WriteLine("Creating Feature Class");
                // Create the table with no parent
                TableNet streetsTable = gdbnet.CreateTable(tableDef, "");

                Console.WriteLine("Adding StreetType field");
                streetsTable.AddField(STREET_TYPE_FIELD);

                Console.WriteLine("Deleting Width field");
                streetsTable.DeleteField("Width");

                Console.WriteLine("Creating StreetTypeIndex");
                streetsTable.AddIndex(STREET_TYPE_INDEX);

                Console.WriteLine("Creating a new subtype");
                streetsTable.EnableSubtypes("StreetType", SUBTYPE_DEFINITION);

                Console.WriteLine("Getting the default subtype code");
                int defaultCode = streetsTable.GetDefaultSubtypeCode();
                Console.WriteLine("The default subtype code is: " + defaultCode);

                Console.WriteLine("Setting the default subtype code to 87");
                defaultCode = 87;
                streetsTable.SetDefaultSubtypeCode(defaultCode);

                Console.WriteLine("Getting the default subtype code again");
                defaultCode = streetsTable.GetDefaultSubtypeCode();
                Console.WriteLine("The new default subtype code is: " + defaultCode);

                Console.WriteLine("Altering subtype definition");
                streetsTable.AlterSubtype(SUBTYPE_DEFINITION_ALTERED);

                Console.WriteLine("Deleting Local Streets subtype");
                streetsTable.DeleteSubtype("Local Streets");

                Console.WriteLine("Closing table");
                gdbnet.CloseTable(streetsTable);

                Console.WriteLine("Closing geodatabase");
                gdbnet.CloseGeodatabase();

                Console.WriteLine("***** Finished Running Table Schema Test *****");
            }
            catch (FGDBException exc)
            {
                Console.WriteLine("Exception caught while running test.");
                Console.WriteLine("Code: " + exc.ErrorCode);
                Console.WriteLine("Message: " + exc);
                Console.WriteLine("Description: " + exc.ErrorDescription);
            }
        }