private static boolean polygonDisjointEnvelope_ ( Polygon polygon_a , Envelope envelope_b , double tolerance , ProgressTracker progress_tracker ) { // Quick rasterize test to see whether the the geometries are disjoint, // or if one is contained in the other. int relation = tryRasterizedContainsOrDisjoint_ ( polygon_a , envelope_b , tolerance , false ) ; if ( relation == Relation . disjoint ) return true ; if ( relation == Relation . contains || relation == Relation . within ) return false ; Envelope2D env_a = new Envelope2D ( ) , env_b = new Envelope2D ( ) ; polygon_a . queryEnvelope2D ( env_a ) ; envelope_b . queryEnvelope2D ( env_b ) ; if ( envelopeInfContainsEnvelope_ ( env_b , env_a , tolerance ) ) return false ; PolygonUtils . PiPResult pipres ; Point2D pt_b = new Point2D ( ) ; env_b . queryLowerLeft ( pt_b ) ; pipres = PolygonUtils . isPointInPolygon2D ( polygon_a , pt_b , tolerance ) ; if ( pipres != PolygonUtils . PiPResult . PiPOutside ) return false ; env_b . queryLowerRight ( pt_b ) ; pipres = PolygonUtils . isPointInPolygon2D ( polygon_a , pt_b , tolerance ) ; if ( pipres != PolygonUtils . PiPResult . PiPOutside ) return false ; env_b . queryUpperRight ( pt_b ) ; pipres = PolygonUtils . isPointInPolygon2D ( polygon_a , pt_b , tolerance ) ; if ( pipres != PolygonUtils . PiPResult . PiPOutside ) return false ; env_b . queryUpperLeft ( pt_b ) ; pipres = PolygonUtils . isPointInPolygon2D ( polygon_a , pt_b , tolerance ) ; if ( pipres != PolygonUtils . PiPResult . PiPOutside ) return false ; MultiPathImpl mimpl_a = ( MultiPathImpl ) polygon_a . _getImpl ( ) ; AttributeStreamOfDbl pos = ( AttributeStreamOfDbl ) ( mimpl_a . getAttributeStreamRef ( VertexDescription . Semantics . POSITION ) ) ; Envelope2D env_b_inflated = new Envelope2D ( ) ; env_b_inflated . setCoords ( env_b ) ; env_b_inflated . inflate ( tolerance , tolerance ) ; for ( int ptIndex = 0 , n = mimpl_a . getPointCount ( ) ; ptIndex < n ; ptIndex ++ ) { double x = pos . read ( 2 * ptIndex ) ; double y = pos . read ( 2 * ptIndex + 1 ) ; if ( env_b_inflated . contains ( x , y ) ) return false ; } return ! linearPathIntersectsEnvelope_ ( polygon_a , env_b , tolerance , progress_tracker ) ; }
Returns true if polygon_a is disjoint from envelope_b .