File Geodatabase API
|
File Geodatabase API
The File Geodatabase API provides a non-ArcObjects based means by which advanced developers can work with File Geodatabases. The File Geodatabase API is C++ based and can perform the following tasks:
This API is targeted for advanced developers who require access to the File Geodatabase without an ArcObjects license for purposes of interoperability. A commonly requested user scenario is to open File Geodatabase tables outside of an ArcObjects based application to view or modify data. This API does not replace ArcObjects as the recommended approach to interacting with the geodatabase.
The File Geodatabase API leverages the work done in ArcGIS 10 to simplify the Geodatabase system tables. Therefore, the File Geodatabase API only supports file geodatabases from release 10 or later.
Limitations of the File Geodatabase API
While the File Geodatabase API supports reading the schema and data of complex geodatabase types, the API does not honor geodatabase behavior on inserts, deletes or updates to the following dataset types:
In most cases the API will prevent users from attempting to edit objects with complex behavior, but the onus is on the developer to understand what they should and should not edit through the API and avoid editing datasets that have geodatabase behavior. There is a method called Table::IsEditable which will provide developers with the ability to determine whether a dataset can be safely edited.
Other limitations of the File Geodatabase API:
Spatial References
Pre-defined GCS, PCS, Unknown and Custom coordinate systems are supported. Vertical Datums are not supported.Supported GCS & PCS When uaing pre-defined GCS and PCS you must set WKT (Well Known Text) string and the WKID via the SpatialReference::SetSpatialRegerenceText and the SpatialReference::SetSpatialReferenceID functions. All other parameters will set defaults. Optional functions allow you to set the Origin, Resolution and Tolerance for the XY, Z, and M dimensions. When using custom coordinate systems you set the SetSpatialReferenceID to zero and modify the SetSpatialRegerenceText to meet your needs.
Factory Codes
The Geographic coordinate systems table on page 26 of the Geographic Coordinate Systems  document contains the factory codes for Geographic Coordinates Systems (GCS) supported at ArcGIS 10.0.
The Projected Coordinate System Name table on page 7 of the Projected Coordinate Systems  document contains the factory codes for Projected Coordinate Systems (PCS) supported at ArcGIS 10.0.
XML in the File Geodatabase API
Incoming table, feature dataset, field, index, domain, and subtype definitions are xml documents conforming to the XML Schema of the Geodatabase. Table, Feature Dataset, field, index, domain, and subtype XML are validated using a version of the xsd derived from the GDBExchange. xsd documented in the XML Schema of the Geodatabase. XML extracted from the geodatabase (Table::GetDefintion for example) is in a similar, but different dialect. When creating a table, feature dataset, domain, subtype or adding a field it is important to closely follow the sample XML found in samples\XMLsamples and elsewhere in the sample code. Not doing so can cause unexpected results. You can validate your XML using the FileGDBAPI.xsd included with the API.
When creating feature classes you should set the GridSize0 element equal to zero and leave out the two other grid size elements. Setting LoadOnlyIO to TRUE before inserting any geometries and setting LoadOnlyIO to FALSE when finished will automatically calculate the grid size based on the features present in the feature class.
Domains should be assigned to fields using Table.AlterField. Domain definitions contained in table definition XML will be ignored.
The XML definition for a table includes a CongigurationKeyword element. When you create a dataset in a file geodatabase, you can choose a configuration keyword to customize how the data is stored. Each keyword optimizes storage for a particular type of data, improving storage efficiency and performance. If the element is empty the keyword defaults to DEFAULT. There are currently seven keywords available. These keywords cannot be customized.
Configuration Keywords Creating Tables and Feature Classes
Tables, Feature Classes and Feature Datasets can be created either by using XML or through the use of function calls. Tables and feature classes are defined using a FieldDef object. A SpatialReference object must be defined for feature classes (tables) that include a spatial column. Feature Datasets can be created by defining a spatial reference and calling CreateFeatureDataset. It is recommended to use the non-XML method to create tables, feature classes and feature datasets.
string and wstring
In general wstring is used for all character parameters in the API. This implies that we are using wchar_t. But in addition to that, we are using UTF-16 encoded characters in the wchar array. Our contract is that the wstrings that we provide as output are always UTF-16 encoded characters, and we require that developers supply the same for input strings that they use in any API function call.
The exception is XML data. For XML, we use std::string, not wstring. The reason is that our XML is required to use UTF-8 encoded characters. XML is general supplied in UTF-8, and the std::string class is a better fit for working with UTF-8. We have found that using std::string to contain UTF-8 encoded XML strings is very commonly done in the C++ development community.