OrganisationUnitPolygonCoveringCoordinateFilter implements Filter<OrganisationUnit> { @Override public boolean retain( OrganisationUnit unit ) { Geometry geometry = unit.getGeometry(); return geometry != null && FeatureType.getTypeFromName(geometry.getGeometryType()) == FeatureType.POLYGON && GeoUtils.checkPointWithMultiPolygon( longitude, latitude, unit.getGeometry() ); } OrganisationUnitPolygonCoveringCoordinateFilter( double longitude, double latitude ); @Override boolean retain( OrganisationUnit unit );  }
@Test public void verifyFilterExcludesOrgUnitWithoutGeometry() { filter = new OrganisationUnitPolygonCoveringCoordinateFilter( 1, 1.1 ); organisationUnit.setGeometry( null ); assertFalse( filter.retain( organisationUnit ) ); }
@Test public void verifyFilterExcludesOrgUnitFallingOutsidePolygon() throws IOException { filter = new OrganisationUnitPolygonCoveringCoordinateFilter( 10.758833885192871, 59.91530028312405 ); Geometry ouGeometry = new GeometryJSON().read( DOWNTOWN_OSLO ); organisationUnit.setGeometry( ouGeometry ); assertFalse( filter.retain( organisationUnit ) ); }
@Test public void verifyFilterIncludesOrgUnitFallingInsidePolygon() throws IOException { filter = new OrganisationUnitPolygonCoveringCoordinateFilter( 10.746517181396484, 59.91080384720672 ); Geometry ouGeometry = new GeometryJSON().read( DOWNTOWN_OSLO ); organisationUnit.setGeometry( ouGeometry ); assertTrue( filter.retain( organisationUnit ) ); }