private static boolean multiPointIntersectsMultiPoint_ ( MultiPoint _multipointA , MultiPoint _multipointB , double tolerance , ProgressTracker progress_tracker ) { MultiPoint multipoint_a ; MultiPoint multipoint_b ; if ( _multipointA . getPointCount ( ) > _multipointB . getPointCount ( ) ) { multipoint_a = _multipointB ; multipoint_b = _multipointA ; } else { multipoint_a = _multipointA ; multipoint_b = _multipointB ; } Envelope2D env_a = new Envelope2D ( ) ; Envelope2D env_b = new Envelope2D ( ) ; Envelope2D envInter = new Envelope2D ( ) ; multipoint_a . queryEnvelope2D ( env_a ) ; multipoint_b . queryEnvelope2D ( env_b ) ; env_a . inflate ( tolerance , tolerance ) ; env_b . inflate ( tolerance , tolerance ) ; envInter . setCoords ( env_a ) ; envInter . intersect ( env_b ) ; Point2D ptA = new Point2D ( ) ; Point2D ptB = new Point2D ( ) ; double tolerance_sq = tolerance * tolerance ; QuadTreeImpl quadTreeB = InternalUtils . buildQuadTree ( ( MultiPointImpl ) ( multipoint_b . _getImpl ( ) ) , envInter ) ; QuadTreeImpl . QuadTreeIteratorImpl qtIterB = quadTreeB . getIterator ( ) ; for ( int vertex_a = 0 ; vertex_a < multipoint_a . getPointCount ( ) ; vertex_a ++ ) { multipoint_a . getXY ( vertex_a , ptA ) ; if ( ! envInter . contains ( ptA ) ) continue ; env_a . setCoords ( ptA . x , ptA . y , ptA . x , ptA . y ) ; qtIterB . resetIterator ( env_a , tolerance ) ; for ( int elementHandleB = qtIterB . next ( ) ; elementHandleB != - 1 ; elementHandleB = qtIterB . next ( ) ) { int vertex_b = quadTreeB . getElement ( elementHandleB ) ; multipoint_b . getXY ( vertex_b , ptB ) ; if ( Point2D . sqrDistance ( ptA , ptB ) <= tolerance_sq ) return true ; } } return false ; }
Returns true if multipoint_a intersects multipoint_b .