BinningOp extends Operator { public BinningConfig createConfig() { final BinningConfig config = new BinningConfig(); config.setNumRows(numRows); config.setSuperSampling(superSampling); config.setMaxDistanceOnEarth(maxDistanceOnEarth); config.setMaskExpr(maskExpr); config.setVariableConfigs(variableConfigs); config.setAggregatorConfigs(aggregatorConfigs); config.setPostProcessorConfig(postProcessorConfig); config.setMinDataHour(minDataHour); config.setMetadataAggregatorName(metadataAggregatorName); config.setStartDateTime(startDateTime); config.setPeriodDuration(periodDuration); config.setTimeFilterMethod(timeFilterMethod); config.setOutputFile(outputFile); config.setRegion(region); if (planetaryGridClass != null) { config.setPlanetaryGrid(planetaryGridClass); } if (compositingType!= null) { config.setCompositingType(compositingType); } return config; } BinningOp(); Geometry getRegion(); void setRegion(Geometry region); String getStartDateTime(); void setStartDateTime(String startDateTime); Double getPeriodDuration(); void setPeriodDuration(Double periodDuration); TimeFilterMethod getTimeFilterMethod(); void setTimeFilterMethod(TimeFilterMethod timeFilterMethod); Double getMinDataHour(); void setMinDataHour(Double minDataHour); int getNumRows(); void setNumRows(int numRows); Integer getSuperSampling(); void setSuperSampling(Integer superSampling); String getMaskExpr(); void setMaskExpr(String maskExpr); void setOutputFile(String outputFile); void setOutputType(String outputType); void setOutputFormat(String outputFormat); VariableConfig[] getVariableConfigs(); void setVariableConfigs(VariableConfig... variableConfigs); AggregatorConfig[] getAggregatorConfigs(); void setAggregatorConfigs(AggregatorConfig... aggregatorConfigs); CellProcessorConfig getPostProcessorConfig(); void setPostProcessorConfig(CellProcessorConfig postProcessorConfig); void setBinWriter(BinWriter binWriter); void setOutputTargetProduct(boolean outputTargetProduct); void setMetadataAggregatorName(String metadataAggregatorName); String getOutputFile(); void setPlanetaryGridClass(String planetaryGridClass); void setCompositingType(CompositingType compositingType); @Override void initialize(); @Override void dispose(); BinningConfig createConfig(); static final String DATE_INPUT_PATTERN; static final String DATETIME_INPUT_PATTERN; static final String DATETIME_OUTPUT_PATTERN; }
@Test public void testCreateConfig() throws ParseException { final BinningOp binningOp = createBinningOp(); binningOp.setNumRows(19); binningOp.setSuperSampling(20); binningOp.setMaskExpr("twenty-one"); binningOp.setVariableConfigs(new VariableConfig("yeah", "wow")); binningOp.setAggregatorConfigs(new AggregatorMinMax.Config()); binningOp.setPostProcessorConfig(new TestCellProcessorConfig()); binningOp.setMinDataHour(25.0); binningOp.setMetadataAggregatorName("clump"); binningOp.setStartDateTime("start-me-up"); binningOp.setPeriodDuration(26.0); binningOp.setTimeFilterMethod(BinningOp.TimeFilterMethod.TIME_RANGE); binningOp.setOutputFile("a_file"); final WKTReader wktReader = new WKTReader(); binningOp.setRegion(wktReader.read("POLYGON((10 10, 15 10, 15 12, 10 12, 10 10))")); final BinningConfig config = binningOp.createConfig(); assertNotNull(config); assertEquals(19, config.getNumRows()); assertEquals(20, config.getSuperSampling().intValue()); assertEquals("twenty-one", config.getMaskExpr()); final VariableConfig[] variableConfigs = config.getVariableConfigs(); assertEquals(1, variableConfigs.length); assertEquals("wow", variableConfigs[0].getExpr()); final AggregatorConfig[] aggregatorConfigs = config.getAggregatorConfigs(); assertEquals(1, aggregatorConfigs.length); assertEquals("MIN_MAX", aggregatorConfigs[0].getName()); assertNotNull(config.getPostProcessorConfig()); assertEquals(25.0, config.getMinDataHour(), 1e-8); assertEquals("clump", config.getMetadataAggregatorName()); assertEquals("start-me-up", config.getStartDateTime()); assertEquals(26.0, config.getPeriodDuration(), 1e-8); assertEquals(BinningOp.TimeFilterMethod.TIME_RANGE, config.getTimeFilterMethod()); assertEquals("a_file", config.getOutputFile()); assertEquals("POLYGON ((10 10, 15 10, 15 12, 10 12, 10 10))", config.getRegion().toString()); }