Select to view content in your preferred language

FileGDB_1.3_2010 C++ API: How to get GeometryDef and SpatialReference objects

2138
3
Jump to solution
05-07-2013 10:42 PM
ViksitAgarwal
Emerging Contributor
The C++ API FileGDB_1.3_2010 delivers a header file "Util.h" that contains utility classes for GeometryDef, SpatialReference etc.  But there are no examples that explains the usage of these utility classes.  We can very easily get the XML table definition, but it is very difficult and error prone to parse the XML file to get GeometryDef and SpatialReference information.  When API delivers these utility classes, I believe API should have given utility functions that populates these objects by parsing XML table definition.  This will make the life of developers easy and the code will be less error prone.  Let me know if such utility functions already exists or if somebody has coded, please share.
0 Kudos
1 Solution

Accepted Solutions
LanceShipman
Esri Regular Contributor
These classes are for public use, but are not complete with the 1.3 release. It is not possible to create a table or feature class using these classes. We will not be dropping them from the API and hope to fill out the rest of the functionality in a future release. They will documented in the next release.

View solution in original post

0 Kudos
3 Replies
DanFoster
Deactivated User
std::vector<wstring> feature_classes;
hr = geodatabase.GetChildDatasets(L"\\", L"Feature Class", feature_classes));


for (i = 0; i < feature_classes.size(); i++)
{
  wstring this_table = feature_classes;
  Table table;
  hr = geodatabase.OpenTable(this_table, table);

  // Get the field type and name from the row enumerator.
  FieldInfo fieldInfo;
  table.GetFieldInformation(fieldInfo);

  int       fieldCount;
  FieldType fieldType;
  wstring wstrFieldName;
  wstring wstrLabelField;

  std::vector<FieldDef> fieldDefs;
  hr = table.GetFields( fieldDefs );

  fieldInfo.GetFieldCount(fieldCount);
  for (long fieldNumber = 0; fieldNumber < fieldCount; fieldNumber++)
  {
   fieldInfo.GetFieldType(fieldNumber, fieldType);
   fieldInfo.GetFieldName(fieldNumber, wstrFieldName);

   if (fieldTypeGeometry == fieldType)
   {
    FieldDef fieldDef = fieldDefs[fieldNumber];
    GeometryDef geometryDef;
    hr = fieldDef.GetGeometryDef( geometryDef );
    SpatialReference spatialReference;
    hr = geometryDef.GetSpatialReference(spatialReference);
    wstring wstrSpatialReferenceText;
    hr = spatialReference.GetSpatialReferenceText( wstrSpatialReferenceText );
    int wkid;
    hr = spatialReference.GetSpatialReferenceID( wkid );
   }
0 Kudos
ViksitAgarwal
Emerging Contributor
Thanks a lot Dan for sharing the code that shows the usage of the classes defined in Utils.h.  Couple of follow-up questions:

  1. Since these C++ classes are not documented in the doxygen help, are these classes private in nature?  Since in C++, all header files need to be supplied for compilation, there is no clear access specifier that tells whether a class is public or private. The only way I understand to distinguish is the documentation, public classes are documented and private ones are not documented to discourage their usage.  If we use these un-documented classes, are they prone to change in future, what is the intention behind not providing documentation of these classes?

  2. The code snippet will work for reading the data, can you please share a similar code snippet for writing FGDB data like defining schema of a feature class or table?  Constructing XML for FGDB schema creation is cumbersome and error prone.

0 Kudos
LanceShipman
Esri Regular Contributor
These classes are for public use, but are not complete with the 1.3 release. It is not possible to create a table or feature class using these classes. We will not be dropping them from the API and hope to fill out the rest of the functionality in a future release. They will documented in the next release.
0 Kudos