AnsweredAssumed Answered

Problem with create new ILine or IPolyLine

Question asked by iaminsu12 on Jun 22, 2012
Latest reply on Jun 22, 2012 by iaminsu12
Hello,

I'm trying to create polyline object and then want to do some geoprocessing with that polyline with other featureclass.

this is process

1. Create point object from other IFeatureClass object by select by attribute
                        IGeometry geo = new MultipointClass();                         IPointCollection5 mtpCollection = geo as IPointCollection5;                          ISpatialFilter sFilter1 = new SpatialFilterClass();                         sFilter1.GeometryField = fcMerged.ShapeFieldName;                         sFilter1.WhereClause = "id_f = '" + tempPair.getOri + "' OR id_f = '" + tempPair.getDes + "'";                         IFeatureCursor curMerged3 = fcMerged.Search(sFilter1, false);                         IFeature ifMerged = null;                         while ((ifMerged = curMerged3.NextFeature()) != null)                         {                             IPoint ptIn = new PointClass();                             ptIn = (IPoint)ifMerged.ShapeCopy;                             mtpCollection.AddPoint(ptIn);                         } 



2. Create ILine or IPolyline from Point (1) : ilPairLine

                        IPoint fromPoint = new PointClass();                         IPoint toPoint = new PointClass();                         fromPoint = mtpCollection.get_Point(0);                         toPoint = mtpCollection.get_Point(1);                         ILine ilPairLine = new LineClass();                         ilPairLine.FromPoint = fromPoint;                         ilPairLine.ToPoint = toPoint;



3. Do some operation like this: (fcBoundary is Ifeatureclass Polygon)

                        IFeature ifBaseMap = fcBoundary.GetFeature(1);                          IGeometry igPairLine = (IGeometry)ilPairLine;                         IGeometry igBaseMap = ifBaseMap.Shape;                          IRelationalOperator relOperatore = (IRelationalOperator)igBaseMap;                         Boolean contain = relOperatore.Contains(igPairLine);                                                  if (contain)                         {                             vgDict[tempPair] = Convert.ToDouble(ilPairLine.Length.ToString());                             Console.WriteLine("contained: {0}",vgDict[tempPair]);                         } 




with above codes, operation was failed.

What's the problem?

I need to make polyline from give two points, and then with that line need to do several geoprocessing.

Currently, I create IFeatureClass line using geoprocessing tool 'Create line from points', but calling geoprocessing object is to slow.

So I want to use ILine or IPolyline for newly generated line for my process. I can make line object, but that line can be applied to other operation like spatialFilter or TopologicalOperator.


Thnks.

Outcomes