Geometry service Relation method
The Relation method determines the pairs of geometries from the input geometry arrays that participate in the specified spatial relation.
Relation(SpatialReference SpatialReference, Geometry[] InGeometryArray1, Geometry[] InGeometryArray2, esriGeometryRelationEnum RelationName, string RelationParameter)
Parameter |
Description |
---|---|
SpatialReference |
The SpatialReference of the geometries in both input geometry arrays. Cannot be null. |
InGeometryArray1 |
Base set of geometries in the relation operation. All geometries in this array must be of the same type and are assumed to be in the coordinate system defined by InSpatialReference. |
InGeometryArray2 |
Comparison set of geometries in the relation operation. All geometries in this array must be of the same type and are assumed to be in the coordinate system defined by InSpatialReference. |
RelationName |
An esriGeometryRelationEnum to define the type of relation evaluated. |
RelationParameter |
If the RelationName enumeration is "esriGeometryRelationRelation", a Shape Comparison Language parameter string can be used. The Shape Comparison Language is based on the Calculus-Based Method (CBM), as described and defined by Clementini and Felice, but has some extensions specific to working with vertex-based geometries. Refer to the Shape Comparison Language documentation for proper syntax and available functionality. |
Return Value
An array RelationResult[] for each geometry pair for with the specified relation is true. The left index is the index of the geometry in the base array (InGeometryArray1). The right index is the index of the geometry in the comparison array (InGeometryArray2). If the specified relation is not true for a geometry pair, no RelationResult[] is returned.
Remarks
The relations are evaluated in 2D, thus Z coordinates are not used. Restrictions on the types of geometries in the base of comparison array are associated with the relation. The discussion for the esriGeometryRelationEnum provides detailed information on the relation operators and restrictions.
Examples
C#
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference.WKID = 4326;
inputSpatialReference.WKIDSpecified = true;
// First input geometry array - 1 polygon
PointN pnt1a = new PointN();
pnt1a.X = 10.0;
pnt1a.Y = 30.0;
PointN pnt2a = new PointN();
pnt2a.X = 10.0;
pnt2a.Y = 45.0;
PointN pnt3a = new PointN();
pnt3a.X = 25.0;
pnt3a.Y = 45.0;
PointN pnt4a = new PointN();
pnt4a.X = 25.0;
pnt4a.Y = 30.0;
PointN pnt5a = new PointN();
pnt5a.X = 10.0;
pnt5a.Y = 30.0;
PointN[] pnts1a = new PointN[] { pnt1a, pnt2a, pnt3a, pnt4a, pnt5a };
Ring ring1 = new Ring();
ring1.PointArray = pnts1a;
Ring[] rings = new Ring[] { ring1 };
PolygonN polygon1 = new PolygonN();
polygon1.RingArray = rings;
normal;">Geometry[] inputGeometry1 = new Geometry[] { polygon1 };
// Second input geometry array - 3 points
PointN pnt1b = new PointN();
pnt1b.X = 20.0;
pnt1b.Y = 40.0;
PointN pnt2b = new PointN();
pnt2b.X = 10.0;
pnt2b.Y = 30.0;
PointN pnt3b = new PointN();
pnt3b.X = 50.0;
pnt3b.Y = 50.0;
Geometry[] inputGeometry2 = new Geometry[3];
// Inside polygon
inputGeometry2.SetValue(pnt1b, 0);
// Edge of polygon
inputGeometry2.SetValue(pnt2b, 1);
// Outside polygon
inputGeometry2.SetValue(pnt3b, 2);
// If esriGeometryRelationRelation, define relation parameter
esriGeometryRelationEnum enumRelate = esriGeometryRelationEnum.esriGeometryRelationRelation;
// G1 = first (base) geometry array, G2 = second (comparison) geometry array
string relationParameter = "G2 INTERSECT G1.BOUNDARY";
RelationResult[] relationResults = geometryService.Relation(inputSpatialReference, inputGeometry1, inputGeometry2,enumRelate, relationParameter);
VB.NET
Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()
geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"
Dim inputSpatialReference As SpatialReference = New GeographicCoordinateSystem()
inputSpatialReference.WKID = 4326
inputSpatialReference.WKIDSpecified = True
' First input geometry array - 1 polygon
Dim pnt1a As PointN = New PointN()
pnt1a.X = 10.0
pnt1a.Y = 30.0
Dim pnt2a As PointN = New PointN()
pnt2a.X = 10.0
pnt2a.Y = 45.0
Dim pnt3a As PointN = New PointN()
pnt3a.X = 25.0
pnt3a.Y = 45.0
Dim pnt4a As PointN = New PointN()
pnt4a.X = 25.0
pnt4a.Y = 30.0
Dim pnt5a As PointN = New PointN()
pnt5a.X = 10.0
pnt5a.Y = 30.0
Dim pnts1a() As PointN = New PointN() {pnt1a, pnt2a, pnt3a, pnt4a, pnt5a}
Dim ring1 As Ring = New Ring()
ring1.PointArray = pnts1a
Dim rings() As Ring = New Ring() {ring1}
Dim polygon1 As PolygonN = New PolygonN()
polygon1.RingArray = rings
Dim inputGeomeTry1() As Geometry = New Geometry() {polygon1}
' Second input geometry array - 3 points
Dim pnt1b As PointN = New PointN()
pnt1b.X = 20.0
pnt1b.Y = 40.0
Dim pnt2b As PointN = New PointN()
pnt2b.X = 10.0
pnt2b.Y = 30.0
Dim pnt3b As PointN = New PointN()
pnt3b.X = 50.0
pnt3b.Y = 50.0
Dim inputGeomeTry2(2) As Geometry
' Inside polygon
inputGeomeTry2.SetValue(pnt1b, 0)
' Edge of polygon
inputGeomeTry2.SetValue(pnt2b, 1)
' Outside polygon
inputGeomeTry2.SetValue(pnt3b, 2)
' If esriGeometryRelationRelation, define relation parameter
Dim enumRelate As esriGeometryRelationEnum = esriGeometryRelationEnum.esriGeometryRelationRelation
' G1 = first (base) geometry array, G2 = second (comparison) geometry array
Dim relationParameter As String = "G2 INTERSECT G1.BOUNDARY"
Dim relationResults as RelationResult() = geomeTryService.Relation(inputSpatialReference,inputGeomeTry1, inputGeomeTry2,enumRelate, relationParameter)
Java
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Set the input spatial reference
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference.setWKID(4326);
//First input geometry array - 1 polygon
PointN pnt1a = new PointN();
pnt1a.setX(10.0);
pnt1a.setY(30.0);
PointN pnt2a = new PointN();
pnt2a.setX(10.0);
pnt2a.setY(45.0);
PointN pnt3a = new PointN();
pnt3a.setX(25.0);
pnt3a.setY(45.0);
PointN pnt4a = new PointN();
pnt4a.setX(25.0);
pnt4a.setY(30.0);
PointN pnt5a = new PointN();
pnt5a.setX(10.00);
pnt5a.setY(30.0);
PointN[] pnts1a = new PointN[] { pnt1a, pnt2a, pnt3a, pnt4a, pnt5a };
Ring ring1 = new Ring();
ring1.setPointArray(pnts1a);
Ring[] rings = new Ring[] { ring1 };
PolygonN polygon1 = new PolygonN();
polygon1.setRingArray(rings);
Geometry[] inputGeometry1 = new Geometry[] { polygon1 };
//Second input geometry array - 3 points
PointN pnt1b = new PointN();
pnt1b.setX(20.0);
pnt1b.setY(40.0);
PointN pnt2b = new PointN();
pnt2b.setX(10.0);
pnt2b.setY(30.0);
PointN pnt3b = new PointN();
pnt3b.setX(50.0);
pnt3b.setY(50.0);
Geometry[] inputGeometry2 = new Geometry[3];
//Inside polygon
inputGeometry2[0] = pnt1b;
//Edge of polygon
inputGeometry2[1] = pnt2b;
//Outside polygon
inputGeometry2[2] = pnt3b;
//If esriGeometryRelationRelation, define relation parameter
EsriGeometryRelationEnum enumRelate = EsriGeometryRelationEnum.esriGeometryRelationRelation;
//G1 = first (base) geometry array, G2 = second (comparison) geometry array
String relationParameter = "G2 INTERSECT G1.BOUNDARY";
RelationResult[] relationResults = geometryService.relation(
inputSpatialReference, inputGeometry1, inputGeometry2, enumRelate, relationParameter);
for (RelationResult relationResult : relationResults){
System.out.println("Left Index: " + relationResult.getLeftIndex());
System.out.println("Right Index: " + relationResult.getRightIndex());
}