private static void ReadAdmin2000(GeodatabaseNet gdbnet)
        {
            Console.WriteLine("Opening Admin2000 table.");
            TableNet table = gdbnet.OpenTable("\\Admin2000");

            Console.WriteLine("Executing table search.");
            EnumRowsNet queryRows = table.Search("*", "", true);

            Console.WriteLine("Enumerating polygon results (first 10 results only)...");
            int i = 0;
            RowNet row;
            MultiPartShapeBufferNet mpsb;
            PointNet[] pts;
            EnvelopeNet extent;

            while ((row = queryRows.Next()) != null && i++ < 10)
            {
                mpsb = (MultiPartShapeBufferNet)row.GetGeometry();
                mpsb.GetPoints(out pts);
                extent = mpsb.GetExtent();

                Console.WriteLine(String.Format("Polygon extent: {0}, {1}, {2}, {3}", extent.XMin, extent.YMin, extent.XMax, extent.YMax));
                Console.WriteLine(String.Format("Number of Parts: {0}  Number of Points: {1}", mpsb.GetNumParts(), mpsb.GetNumPoints()));
            }

            Console.WriteLine("Closing enumerator.");
            queryRows.Close();

            Console.WriteLine("Closing Admin2000 Table");
            gdbnet.CloseTable(table);
        }
        private static void ReadCities(GeodatabaseNet gdbnet)
        {
            Console.WriteLine("Opening Cities table");
            TableNet table = gdbnet.OpenTable("\\Cities");

            Console.WriteLine("Executing table search.");
            EnumRowsNet queryRows = table.Search("*", "", true);

            RowNet row;
            PointShapeBufferNet psb;

            Console.WriteLine("Enumerating point results (first 10 results only)...");
            int i = 0;
            PointNet[] pts;
            while ((row = queryRows.Next()) != null && i++ < 10)
            {
                psb = (PointShapeBufferNet)row.GetGeometry();
                psb.GetPoints(out pts);

                Console.WriteLine(String.Format("X: {0}  Y: {1}", pts[0].x, pts[0].y));
            }

            Console.WriteLine("Closing enumerator.");
            queryRows.Close();

            Console.WriteLine("Closing Cities Table");
            gdbnet.CloseTable(table);
        }
        public static void Run()
        {
            string gdbpath = "data\\ExecuteSQL.gdb";

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

            try
            {
                GeodatabaseNet gdbnet = new GeodatabaseNet();

                Console.WriteLine("Opening database");
                gdbnet.OpenGeodatabase(gdbpath);

                Console.WriteLine("Opening table");
                TableNet table = gdbnet.OpenTable("\\Cities");

                Console.WriteLine("Getting Table Definition");
                string tableDef = table.GetDefinition();

                Console.WriteLine("Getting table docutmentation");
                string tableDoc = table.GetDocumentation();

                Console.WriteLine("Setting table documentation");
                table.SetDocumentation(tableDoc);

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

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

                Console.WriteLine("***** Finished Table Schema Info 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);
            }
        }
Ejemplo n.º 4
0
        public static void Run()
        {
            string gdbpath = "data\\Editing.gdb";

            Console.WriteLine();
            Console.WriteLine("***** Running Editing Test *****");

            try
            {
                Console.WriteLine("Opening Geodatabase...");
                GeodatabaseNet gdbnet = new GeodatabaseNet();
                gdbnet.OpenGeodatabase(gdbpath);

                Console.WriteLine("Opening table");
                TableNet table = gdbnet.OpenTable("\\Cities");

                Console.WriteLine("Getting IsEditable property for the table");
                bool isEditable = table.IsEditable();
                if (!isEditable)
                {
                    Console.WriteLine("Cities table is not editable, exiting...");
                    return;
                }

                Console.WriteLine("Getting table row count.");
                int rowCount = table.GetRowCount();
                Console.WriteLine("Table has " + rowCount + " rows");

                Console.WriteLine("Getting table extent.");
                EnvelopeNet extent = table.GetExtent();
                Console.WriteLine(String.Format("Table Extent: {0}, {1}, {2}, {3}", extent.XMin, extent.YMin, extent.XMax, extent.YMax));

                Console.WriteLine("Query table for AREANAME='Apple Valley' records");
                EnumRowsNet avQueryResult = table.Search("*", "AREANAME = 'Apple Valley'", false);

                Console.WriteLine("Getting the first row from the result");
                RowNet avRow = avQueryResult.Next();

                if (avRow == null)
                {
                    Console.WriteLine("Error - Query completed successfully but no rows were returned.");
                    return;
                }

                Console.WriteLine("Setting CLASS attribute to 'city'");
                avRow.SetString("CLASS", "city");

                Console.WriteLine("Updating table to persist the edit.");
                table.Update(avRow);

                Console.WriteLine("Closing enumerator");
                avQueryResult.Close();

                Console.WriteLine("Performing a spatial query");
                EnvelopeNet envelope = new EnvelopeNet(-117.4, -116.8, 33.64, 33.86);
                EnumRowsNet deleteRows = table.Search("*", "", envelope, false);

                Console.WriteLine("Enumerating spatial query result");
                RowNet deleteRow;
                string areaName;
                bool isNull;

                while ((deleteRow = deleteRows.Next()) != null)
                {
                    Console.WriteLine("Getting string and isnull properties for current row");
                    areaName = deleteRow.GetString("AREANAME");
                    isNull = deleteRow.IsNull("ELEVATION");

                    if (isNull)
                    {
                        Console.WriteLine("ELEVATION attribute is null, deleting row");
                        table.Delete(deleteRow);
                    }
                }

                Console.WriteLine("Closing enumerator");
                deleteRows.Close();

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

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

                Console.WriteLine("***** Finished Running Geodatabase Management 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);
            }
        }