iaminsu12

ISpatialFilter problem.

Discussion created by iaminsu12 on May 23, 2012
Latest reply on May 28, 2012 by Hornbydd
Hello,

I have two featureclass.
   1. fcSelectedConvexLind (line)
   2. fcSelectedPoints (point)

What I want to do is

   1. Select 1 line from fcSelectedConvexLine
   2. Select points from fcSelectedPoints which interset with line (1), that is, either end point of selected line(1)
   3. Read id of points(2)

When I run following code, my problem was there was only 1 selected point from fcSelected.

However, it should select 2 points from fcSelectedPoints, because those points are vertices of fcConvexLine.


                IFeatureClass fcSelectedConvexLine = gpUtils.OpenFeatureClassFromString(selectedConvexLine);
                IFeature featSelectedLine = null;
                IFeatureCursor cursorSelectedLine;
                IFeatureCursor cursorSelectedPoints;
                
                IPolyline liSelectedLine;
                cursorSelectedLine = fcSelectedConvexLine.Search(null, false);
                
                while ((featSelectedLine = cursorSelectedLine.NextFeature()) != null)
                {
                    liSelectedLine = new PolylineClass();
                
                    if (fcSelectedConvexLine.ShapeType == esriGeometryType.esriGeometryPolyline)
                    {
                        liSelectedLine = (IPolyline)featSelectedLine.ShapeCopy;
                    }
                    ITopologicalOperator5 topoOperator = (ITopologicalOperator5)liSelectedLine;
                    ISpatialFilter spatialFilter = new SpatialFilterClass();

                    spatialFilter.GeometryField = fcSelectedPoints.ShapeFieldName;
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    spatialFilter.Geometry = (IGeometry)liSelectedLine;
                    IQueryFilter queryFilter = new QueryFilterClass();
                    queryFilter = (IQueryFilter)spatialFilter;
                    cursorSelectedPoints = fcSelectedPoints.Search(queryFilter, false);

                    List<string> tempNode = new List<string>();
                    int idY = cursorSelectedPoints.Fields.FindField("id_f");
                    while ((featureSelPoints = cursorSelectedPoints.NextFeature()) != null)
                    {
                        string nID = featureSelPoints.get_Value(idY).ToString();
                        
                        graph.AddNode(nID);
                        
                        tempNode.Add(nID);
                    }
                    graph.AddConnection(tempNode[0], tempNode[1], Convert.ToInt32(featSelectedLine.get_Value((featSelectedLine.Fields.FindField("Shape_Length"))).ToString()), true);
                }




What's the problem of my code?


Thank you

Outcomes