Using IGeometryBridge or IGeometryBridge2


Summary
IGeometryBridge and IGeometryBridge2, which are implemented by GeometryEnvironmentClass, allow developers to access methods that create or use C-style arrays in all supported languages. This applies specifically to those languages that use safe arrays such as the .NET family and Java.

In this topic


About using IGeometryBridge or IGeometryBridge2

IGeometryBridge and IGeometryBridge2 act as a connection to allow methods to be accessed in all supported languages. Both are implemented by GeometryEnvironmentClass. This implementation circumvents limitations placed on Component Object Model (COM) objects in the Java and .NET environments.
 
In Java and .NET, it is not possible to directly call certain methods on the original interfaces, since the original interfaces were implemented using C-style arrays. Java and the .NET Framework languages do not support C-style arrays. Only safe arrays are permissible in these languages.
 

How IGeometryBridge works

IGeometryBridge works in one of two ways. In the first case, it takes a collection object interface, such as IPointCollection, and a safe array. The safe array is then populated with references from the collection object. The collection object is built with a C-style array. This is why a new interface is needed to complete the method call instead of calling the corresponding method on the collection object interface directly. IGeometryBridge can also take an interface to an object that is not a collection along with a safe array. The original object, such as a segment, is then broken down into several new segments. Method calls like this add these new references of objects created from the original object into the safe array. 
 
Interfaces and methods
Use IGeometryBridge if you want to call any of the interfaces and methods in the following table using Java or a .NET language:
 
Interfaces and methods
IGeometryBridge
             or IGeometryBridge2
Description
AddGeometries
Adds references to the specified geometries.
AddPoints
Adds copies of the input points as vertices to this Path, Ring, Polyline, or Polygon or references to the input points to this Multipoint, TriangleFan, or TriangleStrip.
AddSegments
Adds references to segments.
AddWKSPointZs
Adds vertices/points to this Path, Ring, Polyline, Polygon, Multipoint, TriangleFan, Triangles, TriangleStrip, or MultiPatch.
ConstructBuffers
Constructs a set of buffers at various distances; more efficient than calling Buffer repeatedly on the same geometry.
Densify
Densifies segment into the specified number of smaller segments.
GetPoints
Populates an array with references to points in the Multipoint. The QueryPoints method on IPointCollection makes copies of the points.
InsertGeometries
Inserts at the specified index references to some number of geometries in the input array.
InsertPoints
Inserts copies of the input points as vertices into a Path, Ring, Polyline, or Polygon or references to the input points into a Multipoint, TriangleFan, or TriangleStrip.
InsertSegments
Inserts references to the input segments.
InsertWKSPointZs
Inserts new vertices/points into this Path, Ring, Polyline, Polygon, Multipoint, TriangleFan, Triangles, TriangleStrip, or MultiPatch.
QueryBeginningRings
Populates an array with references to all beginning rings of the specified types.
QueryFollowingRings
Populates an array with references to following rings that are in the ring group that starts with the specified beginning ring.
QueryGeometries
Populates the array with references to a subsequence of geometries.
QueryPoints
Copies some points to an existing array of points.
QuerySegments
Returns references to some of the input segments.
QueryWKSPointZs
Copies vertices/points coordinates to the array of point structures.
ReplacePoints
Replaces vertices/points in a PointCollection.
ReplaceSegments
Removes and inserts from segments.
SetGeometries
Replaces all geometries in the collection with the specified number of references to those in the input array.
SetPoints
Replaces all existing vertices of this Path, Ring, Polyline, or Polygon with copies of the input points or all existing points of this Multipoint, TriangleFan, or TriangleStrip with references to the input points.
SetSegments
Replaces all segments with references to the input segments.
IPointCollection4.AddWKSPoints*
AddWKSPoints
Replaces all vertices/points of this Path, Ring, Polyline, Polygon, Multipoint, TriangleFan, Triangles, TriangleStrip, or MultiPatch with new ones.
IPointCollection4.InsertWKSPoints*
InsertWKSPoints
Adds vertices to this Path, Ring, Polyline, or Polygon or adds new points to this Multipoint, TriangleFan, or TriangleStrip.
IPointCollection4.QueryWKSPoints*
QueryWKSPoints
Inserts new vertices/points into this Path, Ring, Polyline, Polygon, Multipoint, TriangleFan, TriangleStrip, or MultiPatch.
IPointCollection4.SetWKSPoints*
SetWKSPoints
Copies vertices and points coordinates to the array of point structures.
SplitAtDistances
Replaces all vertices of this Path, Ring, Polyline, or Polygon with new ones or replaces all points of this Multipoint, TriangleFan, or TriangleStrip with new ones.
SplitDivideLength
Introduces new vertices into this polyline at specified distances from the beginning of the polyline.
*These methods, while similar to those on IPointCollection4, do not have exact analogs on that interface.
 
The majority of calls to methods on IGeometryBridge and IGeometryBridge2 complete the first process of adding references of objects in safe arrays to some collection interface that is C-style array based. Usually these calls take a form similar to the following code example in C#:
 
[Java]
IGeometryBridge2 geomBridge = new GeometryEnvironment();
IPointCollection4 pointCollection = new Multipoint();
IPoint[] points = new IPoint[3];
for (int i = 0; i < 3; i++){
    points[i] = new Point();
    points[i].putCoords(i, 2 * i);
}

geomBridge.addPoints(pointCollection, points);
While the previous code example is not a real-life example, it is not hard to imagine a situation where a developer wants to add an array of type IPoint to an IPointCollection object.
 
Methods on IGeometryBridge that populate safe arrays with references to objects created from a single object are fewer in number but no less important. The original method creates C-style arrays and is not compatible with all supported languages. The following code example is this form of method call in C#:
 
[Java]
IGeometryBridge2 geomBridge = new GeometryEnvironment();
ISegment segment = new Line();
IPoint point = new Point();
point.putCoords(0, 0);
segment.setFromPoint(point);
point.putCoords(100, 100);
segment.setToPoint(point);
ISegment[][] segArray = new ISegment[1][3];
int[] teger = new int[1];
geomBridge.splitDivideLength(segment, 0, 50, false, teger, segArray);
Both examples are simple but will run with the correct using namespaces. There are some finer points about calls to IGeometryBridge that you should note. Calling a method that originally required a count parameter for how many references to put into the array no longer includes the count parameter; examples include IPointCollection.QueryPoints and ISegmentCollection.QuerySegments
 
There is no parameter count in the IGeometryBridge call because the length of the array passed as a parameter is taken as the value of count. This means that the safe array that is passed in will be filled with references. It also requires that the array passed in as a parameter to IGeometryBridge cannot be longer than the length of the collection object minus the index parameter. An exception results if the passed in array in the call is too long.






Additional Requirements
  • The code in this task requires that your project include references to the System and Geometry assemblies.

Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine