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); }
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;
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]); }
Solved! Go to Solution.
var wksPoint = new WKSPointZ[2]; wksPoint[0].X = fromPoint.X; wksPoint[0].Y = fromPoint.Y; wksPoint[0].Z = 0; wksPoint[1].X = toPoint.X; wksPoint[1].Y = toPoint.Y; wksPoint[1].Z = 0; var pointCollection = new PolylineClass(); IGeometryBridge2 geometryBridge = new GeometryEnvironmentClass(); geometryBridge.AddWKSPointZs(pointCollection, ref wksPoint); var polyline = (IPolyline6)pointCollection;