public static void Run() { string gdbpath = "data\\Geometries.gdb"; Console.WriteLine(); Console.WriteLine("***** Running Read Geometries Test *****"); try { Console.WriteLine("Opening Geodatabase..."); GeodatabaseNet gdbnet = new GeodatabaseNet(); gdbnet.OpenGeodatabase(gdbpath); ReadCities(gdbnet); ReadStreets(gdbnet); ReadAdmin2000(gdbnet); Console.WriteLine("Closing geodatabase"); gdbnet.CloseGeodatabase(); Console.WriteLine("***** Finished Running Read Geometries 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\\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 SQL Test *****"); try { GeodatabaseNet gdbnet = new GeodatabaseNet(); Console.WriteLine("Opening geodatabase."); gdbnet.OpenGeodatabase(gdbpath); string sqlStatement = "SELECT NAME, Pop1996 FROM Cities WHERE TERM = 'City'"; EnumRowsNet attrQueryRows = gdbnet.ExecuteSQL(sqlStatement, true); RowNet attrQueryRow; string cityName; long cityPop; Console.WriteLine("Enumerating sql query results..."); while ((attrQueryRow = attrQueryRows.Next()) != null) { cityName = attrQueryRow.GetString("NAME"); cityPop = attrQueryRow.GetInteger("Pop1996"); Console.WriteLine("City Name: " + cityName + "\tPopulation: " + cityPop); } Console.WriteLine("Closing sql query result enumerator"); attrQueryRows.Close(); Console.WriteLine("Closing geodatabase"); gdbnet.CloseGeodatabase(); Console.WriteLine("Finished running SQL 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\\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("Getting dataset types"); List<String> datasetTypes = gdbnet.GetDatasetTypes(); if (datasetTypes == null) { Console.WriteLine("Warning - GetDatasetTypes returned a null object."); } else { Console.WriteLine("Found " + datasetTypes.Count + " dataset types:"); Console.WriteLine("\t" + string.Join(", ", datasetTypes.ToArray())); Console.WriteLine(); } Console.WriteLine("Getting dataset relationship types"); List<String> datasetRelTypes = gdbnet.GetDatasetRelationshipTypes(); if (datasetTypes == null) { Console.WriteLine("Warning - GetDatasetRelationshipTypes returned a null object."); } else { Console.WriteLine("Found " + datasetRelTypes.Count + " dataset relationship types:"); Console.WriteLine("\t" + string.Join(", ", datasetRelTypes.ToArray())); Console.WriteLine(); } Console.WriteLine("Getting all child datasets"); List<String> childDatasets = gdbnet.GetChildDatasets("\\", ""); if (childDatasets == null) { Console.WriteLine("Warning - GetChildDatasets returned a null object."); } else { Console.WriteLine("Found " + childDatasets.Count + " child datasets:"); Console.WriteLine("\t" + string.Join(", ", childDatasets.ToArray())); Console.WriteLine(); } Console.WriteLine("Getting all related datasets for Cities table"); List<String> relDatasets = gdbnet.GetRelatedDatasets("\\Cities", "", ""); if (relDatasets == null) { Console.WriteLine("Warning - GetRelatedDatasets returned a null object."); } else { Console.WriteLine("Found " + relDatasets.Count + " related datasets:"); Console.WriteLine("\t" + string.Join(", ", relDatasets.ToArray())); Console.WriteLine(); } Console.WriteLine("Getting Dataset Definition for table Cities"); string datasetDef = gdbnet.GetDatasetDefinition("\\Cities", ConstantsNet.ITEM_TYPE_FEATURE_CLASS); Console.WriteLine("Getting dataset definitions for all tables and all dataset types"); List<String> childDatasetDefs = gdbnet.GetChildDatasetDefinitions("\\", ""); if (childDatasetDefs == null) { Console.WriteLine("Warning - GetChildDatasetDefinitions returned a null object."); } else { Console.WriteLine("Found " + childDatasetDefs.Count + " child dataset definitions."); } Console.WriteLine("Getting All Related Dataset Definitions"); List<String> relDatasetDefs = gdbnet.GetRelatedDatasetDefinitions("\\", "", ""); if (relDatasetDefs == null) { Console.WriteLine("Warning - GetRelatedDatasetDefinitions returned a null object."); } else { Console.WriteLine("Found " + relDatasetDefs.Count + " related dataset definitions."); } Console.WriteLine("Getting dataset documentation"); string datasetDoc = gdbnet.GetDatasetDocumentation("\\Cities", ConstantsNet.ITEM_TYPE_FEATURE_CLASS); 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); } }