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 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, TriangleStrip, or Triangle. | |
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 a 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, Triangle, TriangleFan, or TriangleStrip. | |
InsertSegments |
Inserts references to the input segments. | |
InsertWKSPointZs |
Inserts new vertices/points into this Path, Ring, Polyline, Polygon, Multipoint, TriangleFan, Triangle, 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, TriangleStrip or Triangle 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, Triangle, 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, TriangleStrip, or Triangle. |
IPointCollection4.QueryWKSPoints* |
QueryWKSPoints |
Inserts new vertices/points into this Path, Ring, Polyline, Polygon, Multipoint, TriangleFan, TriangleStrip, Triangle, or MultiPatch. |
IPointCollection4.SetWKSPoints* |
SetWKSPoints |
Copies vertices and point 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, TriangleStrip, or Triangle 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#:
[C#] IGeometryBridge2 pGeomBridge=new GeometryEnvironmentClass();
IPointCollection4 pPointCollection=new MultipointClass();
IPoint[] pPoints=new IPoint[3];
for (int i=0; i < 3; i++)
{
pPoints[i]=new PointClass();
pPoints[i].PutCoords(i, 2 * i);
}
pGeomBridge.AddPoints(pPointCollection, ref pPoints);
[VB.NET] Dim pGeomBridge As IGeometryBridge2=New GeometryEnvironmentClass
Dim pPointCollection As IPointCollection4=New MultipointClass
Dim pPoints(3) As IPoint
Dim i As Integer
For i=0 To 2
pPoints(i)=New PointClass
pPoints(i).PutCoords(i, 2 * i)
Next i
pGeomBridge.AddPoints(pPointCollection, pPoints)
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#:
[C#] IGeometryBridge2 pGeomBridge=new GeometryEnvironmentClass();
ISegment pSegment=new LineClass();
IPoint pPoint=new PointClass();
pPoint.PutCoords(0, 0);
pSegment.FromPoint=pPoint;
pPoint.PutCoords(100, 100);
pSegment.ToPoint=pPoint;
ISegment[] segArray=new ISegment[3];
int teger;
pGeomBridge.SplitDivideLength(pSegment, 0, 50, false, out teger, ref segArray);
[VB.NET] Dim pGeomBridge As IGeometryBridge2=New GeometryEnvironmentClass
Dim pSegment As ISegment=New LineClass
Dim pPoint As IPoint=New PointClass
pPoint.PutCoords(0, 0)
pSegment.FromPoint=pPoint
pPoint.PutCoords(100, 100)
pSegment.ToPoint=pPoint
Dim segArray(3) As ISegment
Dim teger As Integer
pGeomBridge.SplitDivideLength(pSegment, 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 do not include 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.
Development licensing | Deployment licensing |
---|---|
ArcGIS Desktop Basic | ArcGIS Desktop Basic |
ArcGIS Desktop Standard | ArcGIS Desktop Standard |
ArcGIS Desktop Advanced | ArcGIS Desktop Advanced |
Engine Developer Kit | Engine |