Welcome to ESRI Blogs

Developer Tips - Using geodatabase methods with conformant array parameters in .NET and Java

 This post was written by geodatabase Product Engineer James MacKay. James works on the geodatabase development team and is responsible for a lot of the geodatabase SDK that is generated.

There are several methods in the Geodatabase API that use conformant arrays: these are C-style arrays that can be dimensioned at runtime. In most cases, if you see a method with a pair of related parameters – an integer indicating capacity (or something similar) and a pointer to an integer indicating values (or something similar) – it’s a safe bet that the method is looking for a conformant array.

A method with a conformant array parameter: ISelectionSet.AddList

Unfortunately, conformant arrays and Interop don’t jive… although they may work occasionally, eventually they’re going to cause problems. There are two workarounds: the GeoDatabaseHelper class and GEN interfaces.

The GeoDatabaseHelper class implements two interfaces, IGeoDatabaseBridge and IGeoDatabaseBridge2, which implement methods that can’t be used in a straightforward way through Interop. Three of the more common methods are IFeatureClass.GetFeatures, ISelectionSet.AddList, and ISelectionSet.RemoveList. The workarounds are IGeoDatabaseBridge.GetFeatures, IGeoDatabaseBridge2.AddList, and IGeoDatabaseBridge2.RemoveList, respectively.

GEN interfaces are identical to the interfaces with methods that use conformant arrays, but with the array type defined as SAFEARRAY instead of conformant arrays; they are implemented by the same classes. There are four GEN interfaces defined in the esriGeodatabase library: INetTopologyEditGEN, IForwardStarGEN, IUtilityNetworkGEN, and IEnumNetEIDBuilderGEN.

 

Published Friday, June 06, 2008 1:19 PM by jona4440
Filed under: , , ,

Comments

No Comments
Anonymous comments are disabled