Polyline outGeometry = new Polyline(); IGeometryCollection geometryCollection = null; if(geometryCollection == null) { IGeometryBag geometryBag = new GeometryBag(); geometryCollection = (IGeometryCollection) geometryBag; geometryBag.setSpatialReferenceByRef(mySpatialRef)); } // union all your polylines for(int i=0; i<featureList.size(); i++) { geometryCollection.addGeometry(featureList.get(i).getShape(), null, null); } outGeometry.constructUnion((IEnumGeometry) geometryCollection); ((ITopologicalOperator) outGeometry).simplify(); ITopologicalOperator topo ; geometry = ((ITopologicalOperator)geometry).getBoundary(); topo = (ITopologicalOperator)geometry ; IGeometry intersects = topo.intersect((IGeometry) outGeometry, esriGeometryDimension.esriGeometry0Dimension); IPointCollection Pts = (IPointCollection)intersects; for (int j=0;j<Pts.getPointCount();j++){ tempIntersectPointList.addPoint(Pts.getPoint(j), null, null); } firstPointOnEdge = tempIntersectPointList.getPoint(0) secondPointOnEdge = tempIntersectPointList.getPoint(tempIntersectPointList.getPointCount() - 1),
Dim pOverlapGeometryCollection As ESRI.ArcGIS.Geometry.IGeometryCollection = pTopoOp.Intersect(pInGeometry, ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry0Dimension)
If pOverlapGeometryCollection IsNot Nothing Then
For j As Integer = 0 To pOverlapGeometryCollection.GeometryCount - 1
pOverlapGeometry = pOverlapGeometryCollection.Geometry(j)
pOverlapFeature = pOverlapBuffer
pOverlapFeature.Shape = pOverlapGeometry
pOverlapFeature.Value(pOverlapFeature.Fields.FindField(Field1)) = pFeature.OID
pOverlapFeature.Value(pOverlapFeature.Fields.FindField(Field2)) = pSelFeature.OID
pOverlapFCursor.InsertFeature(pOverlapBuffer)
Next
End If
I seem to get the intersecting points fine, my only issue is I cant seem to identify the point on the polygon edge. Getting the first and last point on the intersect point collection is not always the point on the edge of the polygon. That's what I'm still tryingto figure out.
Another question if someone knows the answer is why do I get so many points when I only use the polygon boundary to intersect the polyline. Shouldn�??t it just be two?
Dim pLayer As ESRI.ArcGIS.Carto.ILayer2
Dim pLayer1 As ESRI.ArcGIS.Carto.ILayer2
Dim pFLayer As ESRI.ArcGIS.Carto.IFeatureLayer
Dim pFClass As ESRI.ArcGIS.Geodatabase.IFeatureClass
Dim pFCursor As ESRI.ArcGIS.Geodatabase.IFeatureCursor
Dim pFeature As ESRI.ArcGIS.Geodatabase.IFeature
Dim pPolygonGeometry As ESRI.ArcGIS.Geometry.IGeometry
Dim pLineGeometry As ESRI.ArcGIS.Geometry.IGeometry
Dim pTopoOp As ESRI.ArcGIS.Geometry.ITopologicalOperator
Dim pOverlapGeometryCollection As ESRI.ArcGIS.Geometry.IGeometryCollection
Dim pOverlapGeometry As ESRI.ArcGIS.Geometry.IGeometry
Dim pRgbColor As New ESRI.ArcGIS.Display.RgbColor
Using releaser As New ESRI.ArcGIS.ADF.ComReleaser
releaser.ManageLifetime(pFCursor)
pLayer = My.ArcMap.Document.FocusMap.Layer(0)
pFLayer = New ESRI.ArcGIS.Carto.FeatureLayer
pFLayer = pLayer
pFClass = pFLayer.FeatureClass
pFCursor = pFClass.Search(Nothing, False)
pFeature = pFCursor.NextFeature
pLineGeometry = pFeature.Shape
pLayer1 = My.ArcMap.Document.FocusMap.Layer(1)
pFLayer = New ESRI.ArcGIS.Carto.FeatureLayer
pFLayer = pLayer1
pFClass = pFLayer.FeatureClass
pFCursor = pFClass.Search(Nothing, False)
pFeature = pFCursor.NextFeature
pPolygonGeometry = pFeature.Shape
pTopoOp = pPolygonGeometry
pOverlapGeometryCollection = pTopoOp.Intersect(pLineGeometry, ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry0Dimension)
MsgBox(pOverlapGeometryCollection.GeometryCount)
pRgbColor.Red = 255
For j As Integer = 0 To pOverlapGeometryCollection.GeometryCount - 1
pOverlapGeometry = pOverlapGeometryCollection.Geometry(j)
FlashGeometry(pOverlapGeometry, pRgbColor, My.ArcMap.Document.ActiveView.ScreenDisplay, 500) ' this is an ArcGIS snippet
Next
End Using
Dim pPolygon As ESRI.ArcGIS.Geometry.IPolygon4 = pPolygonGeometry
Dim pGeoBag As ESRI.ArcGIS.Geometry.IGeometryBag = pPolygon.ExteriorRingBag
Dim pGeoCollection As ESRI.ArcGIS.Geometry.IGeometryCollection = pGeoBag
MsgBox(pGeoCollection.GeometryCount)