public IWorkspace CreateOutput() { // create the file geodatabase for the derived geocoding data var output = EsriHelper.CreateFileGdbWorkspace(_options.OutputGeodatabase, "RoadGrinder"); // releaser.ManageLifetime(output); var outputFeatureWorkspace = (IFeatureWorkspace)output; var outputWorkspace2 = (IWorkspace2)output; // check if the feature class and table exist in the file geodatabase - if so rename them before adding new data if (EsriHelper.NameExists(outputWorkspace2, GeocodeRoadsFeatureClassName, esriDatasetType.esriDTFeatureClass)) { // rename existing fc var renameFeatureClass = outputFeatureWorkspace.OpenFeatureClass(GeocodeRoadsFeatureClassName); // releaser.ManageLifetime(renameFeatureClass); var outputDataset = (IDataset)renameFeatureClass; outputDataset.Rename(string.Format("{0}{1}{2:yyyyMMdd}", GeocodeRoadsFeatureClassName, "ReplacedOn", DateTime.Now)); } if (EsriHelper.NameExists(outputWorkspace2, GeocodeRoadsTableName + "Roads", esriDatasetType.esriDTTable)) { // rename existing table var renameTable = outputFeatureWorkspace.OpenTable(GeocodeRoadsTableName + "Roads"); // releaser.ManageLifetime(renameTable); var outputDataset = (IDataset)renameTable; outputDataset.Rename(string.Format("{0}{1}{2}", GeocodeRoadsTableName + "Roads", "ReplacedOn", DateTime.Now.ToString("yyyyMMdd"))); } if (EsriHelper.NameExists(outputWorkspace2, GeocodeRoadsTableName + "AddrPnts", esriDatasetType.esriDTTable)) { // rename existing table var renameTable = outputFeatureWorkspace.OpenTable(GeocodeRoadsTableName + "AddrPnts"); // releaser.ManageLifetime(renameTable); var outputDataset = (IDataset)renameTable; outputDataset.Rename(string.Format("{0}{1}{2}", GeocodeRoadsTableName + "AddrPnts", "ReplacedOn", DateTime.Now.ToString("yyyyMMdd"))); } // create a feature class in the newly-created file geodatabase _geocodeRoads = EsriHelper.CreateFeatureClass(GeocodeRoadsFeatureClassName, null, outputFeatureWorkspace); // create a roads altnames table in the newly-created file geodatabase _altnameTableRoads = EsriHelper.CreateTable(GeocodeRoadsTableName + "Roads", null, outputFeatureWorkspace); // create a address points altnames table in the newly-created file geodatabase _altnameTableAddrPnts = EsriHelper.CreateTable(GeocodeRoadsTableName + "AddrPnts", null, outputFeatureWorkspace); // Create the scratch geodatabase for the temp data CreateScratchFgdWorkspace(); return(output); }
public void CreateScratchFgdWorkspace() { // create the file geodatabase for the derived geocoding data _scratchFGDB = EsriHelper.CreateFileGdbWorkspace(_options.OutputGeodatabase, "RoadGrinderScratchWS"); var scratchOutputFeatureWorkspace = (IFeatureWorkspace)_scratchFGDB; var outputWorkspace2 = (IWorkspace2)_scratchFGDB; var outputFeatureWorkspace = (IFeatureWorkspace)scratchOutputFeatureWorkspace; //if (EsriHelper.NameExists(outputWorkspace2, GeocodeRoadsTableName + "RoadsScratchData", esriDatasetType.esriDTTable)) //{ // // rename existing table // var renameTable = outputFeatureWorkspace.OpenTable(GeocodeRoadsTableName + "RoadsScratchData"); // // releaser.ManageLifetime(renameTable); // var outputDataset = (IDataset)renameTable; // outputDataset.Rename(string.Format("{0}{1}{2}", GeocodeRoadsTableName + "RoadsScratchData", "ReplacedOn", DateTime.Now.ToString("yyyyMMdd"))); //} _scratchRoadsFC = EsriHelper.CreateFeatureClass(GeocodeRoadsScratchFeatureClassName, null, scratchOutputFeatureWorkspace); }