18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DEVELOPING WITH A RCOBJECTS<br />

COM<br />

Application<br />

7<br />

Geodatabase API<br />

2<br />

3<br />

1<br />

7<br />

8<br />

5<br />

6<br />

Database<br />

The diagram above clearly shows that the<br />

Feature, which is a COM object, has another<br />

COM object for its geometry. The Shape<br />

property of the feature simply passes the<br />

IGeometry interface pointer to this geometry<br />

object out to the caller that requested the<br />

shape. This means that if more than one client<br />

requested the shape, all clients point to the<br />

same geometry object. Hence, this geometry<br />

object must be treated as read-only. No changes<br />

should be performed on the geometry returned<br />

from this property, even if the changes are<br />

temporary. Anytime a change is to be made to a<br />

feature’s shape, the change must be made on<br />

the geometry returned by the ShapeCopy<br />

property, and the updated geometry should<br />

subsequently be assigned to the Shape property.<br />

4<br />

Shape and ShapeCopy geometry property<br />

Make use of a Feature object’s Shape and ShapeCopy properties to optimally retrieve<br />

the geometry of a feature. To better understand how these properties relate<br />

to a feature’s geometry, refer to the diagram to the left to see how features coming<br />

from a data source are instantiated into memory for use within an application.<br />

Features are instantiated from the data source using the following sequence:<br />

1. The application requests a Feature object from a data source by calling the<br />

appropriate geodatabase API method calls.<br />

2. The geodatabase makes a request to COM to create a vanilla COM object of<br />

the desired COM class (normally this class is esriGeoDatabase.Feature).<br />

3. COM creates the Feature COM object.<br />

4. The geodatabase gets attribute and geometry data from a data source.<br />

5. The vanilla Feature object is populated with appropriate attributes.<br />

6. The Geometry COM object is created, and a reference is set in the Feature<br />

object.<br />

7. The Feature object is passed to the application.<br />

8. The Feature object exists in the application until it is no longer required.<br />

USING A TYPE LIBRARY<br />

Since objects from ArcObjects do not implement IDispatch, it is essential to make<br />

use of a type library for the compiler to early-bind to the correct data types. This<br />

applies to all development environments; although, for Visual Basic, Visual C++,<br />

and .NET, there are wizards that help you set this reference.<br />

The type libraries required by ArcObjects are located within the <strong>ArcGIS</strong> install<br />

folder. For example, the COM type libraries can be found in the COM folder,<br />

while the .NET Interop assemblies are within the DotNet folder. Many different<br />

files can contain type library information, including EXEs, DLLs, OLE custom<br />

controls (OCXs), and object libraries (OLBs).<br />

COM DATA TYPES<br />

COM objects talk via their interfaces, and hence, all data types used must be<br />

supported by IDL. IDL supports a large number of data types; however, not all<br />

languages that support COM support these data types. Because of this,<br />

ArcObjects does not make use of all the data types available in IDL but limits the<br />

majority of interfaces to the data type supported by Visual Basic. The following<br />

table shows the data types supported by IDL and their corresponding types in a<br />

variety of languages.<br />

76 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!