private static boolean polygonContainsEnvelope_ ( Polygon polygon_a , Envelope envelope_b , double tolerance , ProgressTracker progress_tracker ) { // Quick envelope rejection test Envelope2D env_a = new Envelope2D ( ) , env_b = new Envelope2D ( ) ; polygon_a . queryEnvelope2D ( env_a ) ; envelope_b . queryEnvelope2D ( env_b ) ; if ( ! envelopeInfContainsEnvelope_ ( env_a , env_b , tolerance ) ) return false ; // 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 || relation == Relation . within ) return false ; if ( relation == Relation . contains ) return true ; if ( env_b . getWidth ( ) <= tolerance && env_b . getHeight ( ) <= tolerance ) { // treat // as // point Point2D pt_b = envelope_b . getCenterXY ( ) ; return polygonContainsPointImpl_ ( polygon_a , pt_b , tolerance , progress_tracker ) ; } if ( env_b . getWidth ( ) <= tolerance || env_b . getHeight ( ) <= tolerance ) { // treat // as // polyline Polyline polyline_b = new Polyline ( ) ; Point p = new Point ( ) ; envelope_b . queryCornerByVal ( 0 , p ) ; polyline_b . startPath ( p ) ; envelope_b . queryCornerByVal ( 2 , p ) ; polyline_b . lineTo ( p ) ; return polygonContainsPolylineImpl_ ( polygon_a , polyline_b , tolerance , null ) ; } // treat as polygon Polygon polygon_b = new Polygon ( ) ; polygon_b . addEnvelope ( envelope_b , false ) ; return polygonContainsPolygonImpl_ ( polygon_a , polygon_b , tolerance , null ) ; }
Returns true if polygon_a contains envelope_b .