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); }
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); } }
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); } }
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); } }
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); } }
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); }