1

Could you give an example how you’d use the IRelationalOperator ArcObjects interface with features from different feature classes stored in oracle database?

In my visual studio project I have an xml file which reference all my actual data and I have created variables in C# to hold the values of these data referenced in the xml file.

ESRI's example only works if you know the actual features and their index # e.g.

// Get the marsh and highway features from their respective classes.
IFeature marshFeature = vegFeatureClass.GetFeature(518);
IFeature highwayFeature = roadsFeatureClass.GetFeature(39);

// Get the geometries of the two features.
IGeometry marshGeometry = marshFeature.Shape;
IGeometry highwayGeometry = highwayFeature.Shape;

// Cast the highway's geometry to IRelationalOperator and determine if
// it crosses the marsh's geometry.
IRelationalOperator relationalOperator = (IRelationalOperator)highwayGeometry;
Boolean crosses = relationalOperator.Crosses(marshGeometry);
Console.WriteLine("Highway crosses marsh: {0}", crosses);

I want to be able to use this interface without knowing what the exact index value of GetFeature() function is.

  • If you don't know the ObjectID of the feature, which is generally the case then you would typically get a handle on a feature (and then it's geometry) by creating a queryfilter (or spatialfilter) and returning a featurecursor from the featurelayer. – Hornbydd Sep 3 '14 at 21:33
  • I think what you're after is a ISpatialFilter and IFeatureClass.search - creates a cursor of the intersecting features which you can step through. Many good examples of that exist... I've used IRelationalOperator for parts within a multigeometry but haven't seen the need for a whole geometry such as you have here... – Michael Stimson Sep 3 '14 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.