public static Bson geoWithinPolygon ( final String fieldName , final List < List < Double > > points ) { BsonArray pointsArray = new BsonArray ( ) ; for ( List < Double > point : points ) { pointsArray . add ( new BsonArray ( asList ( new BsonDouble ( point . get ( 0 ) ) , new BsonDouble ( point . get ( 1 ) ) ) ) ) ; } BsonDocument polygon = new BsonDocument ( "$polygon" , pointsArray ) ; return new OperatorFilter < BsonDocument > ( "$geoWithin" , fieldName , polygon ) ; }
Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified polygon .