int main() { fgdbError hr; wstring errorText; // create geodatabase Geodatabase geodatabase; if ((hr = CreateGeodatabase(L"c:\\testing.gdb", geodatabase)) != S_OK) { wcout << "Geodatabase create error" << endl; ErrorInfo::GetErrorDescription(hr, errorText); wcout << errorText << "(" << hr << ")." << endl; return -1; } // load XML table def string tableDef; string defLine; ifstream defFile("C:\\create-chris1.xml"); while (getline(defFile,defLine)) tableDef.append(defLine+"\n"); defFile.close(); // create table from XML def Table table; if ((hr = geodatabase.CreateTable(tableDef,L"",table)) != S_OK) { wcout << "CreateTable error" << endl; ErrorInfo::GetErrorDescription(hr, errorText); wcout << errorText << "(" << hr << ")." << endl; return -1; } if ((hr = geodatabase.CloseTable(table)) != S_OK) { wcout << "CloseTable error" << endl; ErrorInfo::GetErrorDescription(hr, errorText); wcout << errorText << "(" << hr << ")." << endl; return -1; } // Close the geodatabase if ((hr = CloseGeodatabase(geodatabase)) != S_OK) { wcout << "An error occurred while closing the geodatabase." << endl; ErrorInfo::GetErrorDescription(hr, errorText); wcout << errorText << "(" << hr << ")." << endl; return -1; } return 0; }
It isn't particularly wise to leave the coordinate system undefined. Using an impossibly large
spatial reference does more harm than good, and origin and scale parameters cannot be
adjusted later with the coordsys.
Unfortunately, when you set out to use the FileGDB API to create new tables, you are choosing to
take over ArcGIS' role in feature class creation. Using generic parameters for table creation may
be possible, but it's unlikely to generate high quality datasets -- if you don't know, at a minimum,
the spatial units being used and the range of possible values (and alter the spatial reference to
correspond to them) then I'd argue that it's not really worth the effort of loading the data.