I want to go through each red feature and test it against the blue layer(which will contain multiple features). The tests to carry out for each feature are:
- Wholly Outside
- Wholly outside but with a touching boundary
- Crosses
- Wholly inside but common boundary
- Encloses
- Wholly inside with no touching boundary
I have written the following code protected override void OnClick() {
genericFunctions generic = new genericFunctions(); IDataset StopUpDS = generic.getDatasets("suTest"); IDataset HighwaysDS = generic.getDatasets("highwaysTest"); //create featureclass for the stop up object IFeatureLayer StopUpFL = (IFeatureLayer)StopUpDS; IFeatureClass StopUpFC = StopUpFL.FeatureClass; //create featureclass for the highways object IFeatureLayer highwaysFL = (IFeatureLayer)HighwaysDS; IFeatureClass highwaysFC = highwaysFL.FeatureClass; IFeatureCursor StopUpCur = StopUpFC.Search(null, true); IFeature stopUpFeature = StopUpCur.NextFeature(); while (stopUpFeature != null) { //zoom to feature IEnvelope env = stopUpFeature.Extent.Envelope; env.Expand(2.0, 2.0, true); mxdoc.ActiveView.Extent = env; mxdoc.ActiveView.Refresh(); MessageBox.Show(""); spatialVal(stopUpFeature, StopUpFC, highwaysFC, "****T****", "SHARES A BOUNDARY"); // SHARES A BOUNDARY //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "F***F****", "WHOLLY OUTSIDE"); // WHOLLY OUTSIDE //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "FFFFFFFF*", "WHOLLY OUTSIDE"); // WHOLLY OUTSIDE //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "FF*FF****", "WHOLLY OUTSIDE"); // WHOLLY OUTSIDE //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "F**F****", "DO NOT INTERSECT"); // DO NOT INTERSECT //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "FFFTTTTTT", "WHOLLY OUTSIDE"); // WHOLLY OUTSIDE //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "FFFFTFFF*", "WHOLLY OUTSIDE BUT COMMON BOUNDARY"); // WHOLLY OUTSIDE BUT COMMON BOUNDARY //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "F***T****", "WHOLLY OUTSIDE BUT COMMON BOUNDARY"); // WHOLLY OUTSIDE BUT COMMON BOUNDARY //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "TT*T*****", "CROSSES"); // CROSSES //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "T***T****", "CROSSES"); // CROSSES //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "T***T****", "WHOLLY INSIDE BUT COMMON BOUNDARY"); // WHOLLY INSIDE BUT COMMON BOUNDARY //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "T***T****", "WHOLLY INSIDE BUT COMMON BOUNDARY"); // WHOLLY INSIDE BUT COMMON BOUNDARY //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "T*T******","ENCLOSES" ); // ENCLOSES //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "T*****T**", "WHAT WE NEED"); // WHAT WE NEED //spatialVal(stopUpFeature, StopUpFC, highwaysFC, "*********", "WHAT WE NEED"); // EVERYTHING SHOULD COME UP ONCE ONLY, WHICH IS DOES!!!!! stopUpFeature = StopUpCur.NextFeature(); } } public void spatialVal(IFeature inFeature,IFeatureClass inFC, IFeatureClass highwaysFC, string spatialDesc, string spatialTestType) { ISpatialFilter spaFil = new SpatialFilterClass(); spaFil.Geometry = inFeature.Shape; spaFil.GeometryField = highwaysFC.ShapeFieldName; spaFil.SpatialRel = esriSpatialRelEnum.esriSpatialRelRelation; //spaFil.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin; spaFil.SpatialRelDescription = spatialDesc; //query the results from the spatial filter IFeatureCursor geomCursor = inFC.Search(spaFil, true); IFeature geomFeat = geomCursor.NextFeature(); while (geomFeat != null) { DialogResult result = MessageBox.Show("WARNING! would you like to continue?", spatialTestType, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (result == DialogResult.No) { MessageBox.Show("You will need to fix the polygon before you can move it"); } geomFeat = geomCursor.NextFeature(); } mxdoc.ActiveView.Refresh(); } The problem that I am getting is that no matter what spatialDescription I am using, it always loops through each feature, for example using spatialVal(stopUpFeature, StopUpFC, highwaysFC, "****T****", "SHARES A BOUNDARY"); it will still show the warning message for the outer most polygon (the circle) even though it does not share a boundary with the blue layer it is also showing the warning message for the feature that is wholly in the blue area, but the boundary do not match.
I posted a similar'ish question as Spatial relationships that do not match, but i think this is a different problem, hence a new question.
