vbothello

Polyline intersect on polygon edge

Discussion created by vbothello on Aug 16, 2012
Latest reply on Aug 16, 2012 by kenbuja
I have a polyline that passes through a polygon, I???m trying to get the two intersect points on the polygon edge. If I try to get the fist and last of what is returned for the intersect point collection I get inconsistent results.

Does anyone have some input as what I might be doing wrong?  I have my code block below.

Appreciate the help
vb
 
 
  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),

Outcomes