static boolean linearPathIntersectsPoint_ ( MultiPath multipathA , Point2D ptB , double tolerance ) { Point2D closest = new Point2D ( ) ; double toleranceSq = tolerance * tolerance ; SegmentIteratorImpl segIterA = ( ( MultiPathImpl ) multipathA . _getImpl ( ) ) . querySegmentIterator ( ) ; GeometryAccelerators accel = ( ( MultiPathImpl ) multipathA . _getImpl ( ) ) . _getAccelerators ( ) ; if ( accel != null ) { QuadTreeImpl quadTreeA = accel . getQuadTree ( ) ; if ( quadTreeA != null ) { Envelope2D env_b = new Envelope2D ( ) ; env_b . setCoords ( ptB ) ; QuadTreeImpl . QuadTreeIteratorImpl qt_iter = quadTreeA . getIterator ( env_b , tolerance ) ; for ( int e = qt_iter . next ( ) ; e != - 1 ; e = qt_iter . next ( ) ) { segIterA . resetToVertex ( quadTreeA . getElement ( e ) ) ; if ( segIterA . hasNextSegment ( ) ) { Segment segmentA = segIterA . nextSegment ( ) ; double t = segmentA . getClosestCoordinate ( ptB , false ) ; segmentA . getCoord2D ( t , closest ) ; if ( Point2D . sqrDistance ( ptB , closest ) <= toleranceSq ) { return true ; } } } return false ; } } Envelope2D env_a = new Envelope2D ( ) ; while ( segIterA . nextPath ( ) ) { while ( segIterA . hasNextSegment ( ) ) { Segment segmentA = segIterA . nextSegment ( ) ; segmentA . queryEnvelope2D ( env_a ) ; env_a . inflate ( tolerance , tolerance ) ; if ( ! env_a . contains ( ptB ) ) { continue ; } double t = segmentA . getClosestCoordinate ( ptB , false ) ; segmentA . getCoord2D ( t , closest ) ; if ( Point2D . sqrDistance ( ptB , closest ) <= toleranceSq ) { return true ; } } } return false ; }
Returns true if a segment of multipathA intersects point_b .