/** Tries to read all required parameter from the request. */ protected void loadRequestParameter() throws ProcessorException { getLogger().info(ProcessorConstants.LOG_MSG_LOAD_REQUEST); Parameter param = null; // database directory param = getParameter(L3Constants.DATABASE_PARAM_NAME, L3Constants.MSG_MISSING_BINDB); databaseDir = (File) param.getValue(); ensureDBLocationForLoad(databaseDir); // output product loadOutputProductFromRequest(); // keep or remove database param = getParameter(L3Constants.DELETE_DB_PARAMETER_NAME, L3Constants.MSG_MISSING_DELETE_BINDB); deleteDb = (Boolean) param.getValue(); final Parameter tailoringParam = getRequest().getParameter(L3Constants.TAILORING_PARAM_NAME); if (tailoringParam != null) { tailorOutputProduct = (Boolean) tailoringParam.getValue(); } else { tailorOutputProduct = L3Constants.TAILORING_DEFAULT_VALUE; } getLogger().info(ProcessorConstants.LOG_MSG_SUCCESS); }
private void syncLatLonWithXYParams() { final PixelPos pixelPos1 = new PixelPos( ((Number) paramX1.getValue()).intValue(), ((Number) paramY1.getValue()).intValue()); final PixelPos pixelPos2 = new PixelPos( ((Number) paramX2.getValue()).intValue(), ((Number) paramY2.getValue()).intValue()); final GeoCoding geoCoding = product.getGeoCoding(); final GeoPos geoPos1 = geoCoding.getGeoPos(pixelPos1, null); final GeoPos geoPos2 = geoCoding.getGeoPos(pixelPos2, null); paramNorthLat1.setValue(geoPos1.getLat(), null); paramWestLon1.setValue(geoPos1.getLon(), null); paramSouthLat2.setValue(geoPos2.getLat(), null); paramEastLon2.setValue(geoPos2.getLon(), null); }
private void updateLogParameter(final Request request) { Parameter param; Parameter toUpdate; param = request.getParameter(LOG_PREFIX_PARAM_NAME); final ParamGroup paramGroup = getParamGroup(); if (param != null) { toUpdate = paramGroup.getParameter(LOG_PREFIX_PARAM_NAME); toUpdate.setValue(param.getValue(), null); } param = request.getParameter(LOG_TO_OUTPUT_PARAM_NAME); if (param != null) { toUpdate = paramGroup.getParameter(LOG_TO_OUTPUT_PARAM_NAME); toUpdate.setValue(param.getValue(), null); } }
private void updateUIState(ParamChangeEvent event) { if (updatingUI.compareAndSet(false, true)) { try { if (event != null && canUseGeoCoordinates(product)) { final String parmName = event.getParameter().getName(); if (parmName.startsWith("geo_")) { final GeoPos geoPos1 = new GeoPos((Float) paramNorthLat1.getValue(), (Float) paramWestLon1.getValue()); final GeoPos geoPos2 = new GeoPos((Float) paramSouthLat2.getValue(), (Float) paramEastLon2.getValue()); updateXYParams(geoPos1, geoPos2); } else if (parmName.startsWith("source_x") || parmName.startsWith("source_y")) { syncLatLonWithXYParams(); } } int x1 = ((Number) paramX1.getValue()).intValue(); int y1 = ((Number) paramY1.getValue()).intValue(); int x2 = ((Number) paramX2.getValue()).intValue(); int y2 = ((Number) paramY2.getValue()).intValue(); int sx = ((Number) paramSX.getValue()).intValue(); int sy = ((Number) paramSY.getValue()).intValue(); updateSubsetDefRegion(x1, y1, x2, y2, sx, sy); Dimension s = productSubsetDef.getSceneRasterSize( product.getSceneRasterWidth(), product.getSceneRasterHeight()); subsetWidthLabel.setText(String.valueOf(s.getWidth())); subsetHeightLabel.setText(String.valueOf(s.getHeight())); int sliderBoxX1 = x1 / thumbNailSubSampling; int sliderBoxY1 = y1 / thumbNailSubSampling; int sliderBoxX2 = x2 / thumbNailSubSampling; int sliderBoxY2 = y2 / thumbNailSubSampling; int sliderBoxW = sliderBoxX2 - sliderBoxX1 + 1; int sliderBoxH = sliderBoxY2 - sliderBoxY1 + 1; Rectangle box = getScaledRectangle(new Rectangle(sliderBoxX1, sliderBoxY1, sliderBoxW, sliderBoxH)); imageCanvas.setSliderBoxBounds(box); } finally { updatingUI.set(false); } } }
// Creates the appropriate <code>Product</code> for the current request and assembles a list of // <code>RsBands</code> // to be processed. This method does NOT load the tie point ADS because these are product // specific. private void loadInputProduct() throws IOException, ProcessorException { Request request = getRequest(); Band band; Parameter bandParam; String[] bandNames; // clear vector of bands // --------------------- _inputBandList.clear(); // only the first product - there might be more but these will be ignored // ---------------------------------------------------------------------- _inputProduct = loadInputProduct(0); // check what product type the input is and load the appropriate tie point ADS // --------------------------------------------------------------------------- _sensorType = SmacUtils.getSensorType(_inputProduct.getProductType()); if (ObjectUtils.equalObjects(_sensorType, SensorCoefficientManager.MERIS_NAME)) { loadMerisBitmaskExpression(); loadMERIS_ADS(_inputProduct); } else if (ObjectUtils.equalObjects(_sensorType, SensorCoefficientManager.AATSR_NAME)) { loadAatsrBitmaskExpression(); loadAATSR_ADS(_inputProduct); _useMerisADS = false; // then we must set this to false anyway } else { throw new ProcessorException(SmacConstants.LOG_MSG_UNSUPPORTED_SENSOR); } // set up the bands we need for this request // ----------------------------------------- bandParam = request.getParameter(SmacConstants.BANDS_PARAM_NAME); checkParamNotNull(bandParam, "bands"); bandNames = (String[]) bandParam.getValue(); if ((bandNames == null) || (bandNames.length < 1)) { throw new ProcessorException(SmacConstants.LOG_MSG_NO_INPUT_BANDS); } for (String bandName : bandNames) { band = _inputProduct.getBand(bandName); if (band == null) { _logger.warning( "The requested band '" + bandName + "' is not contained in the input product!"); } else { if (band.getSpectralBandIndex() != -1) { _inputBandList.add(band); } else { _logger.warning( "The requested band '" + bandName + "' is not a spectral band! It is excluded from processing"); } } } }
private static void validateInputProduct( final Parameter parameter, final InputProductValidator validator) { final File file = (File) parameter.getValue(); if (file == null || "".equals(file.getPath().trim())) { return; } String msg = null; if (file.exists()) { Product product = null; try { product = ProductIO.readProduct(file); if (product != null) { if (validator != null) { final boolean valid = validator.validate(product); if (!valid) { msg = validator.getErrorMessage(); if (msg == null) { msg = "Unknown error."; } } } } else { msg = "Unknown product file format."; } } catch (IOException e) { msg = e.getMessage(); } finally { if (product != null) { product.dispose(); } } } else { msg = "File '" + file.getPath() + "' does not exists."; } if (msg != null) { JOptionPane.showMessageDialog( parameter.getEditor().getEditorComponent(), "Invalid input product file:\n" + msg, "Invalid Input Product", JOptionPane.ERROR_MESSAGE); Debug.trace(msg); } }
// Scans the current request for parameters needed by the algorithm. Sets these parameters to // fileds of the class private void loadRequestParams() throws ProcessorException { Parameter param; ProcessorUtils.setProcessorLoggingHandler( SmacConstants.DEFAULT_LOG_PREFIX, getRequest(), getName(), getVersion(), getCopyrightInformation()); // get aerosol optical depth // DELETE param = getRequest().getParameter(SmacConstants.AEROSOL_OPTICAL_DEPTH_PARAM_NAME); checkParamNotNull(param, SmacConstants.AEROSOL_OPTICAL_DEPTH_PARAM_NAME); _tau_aero_550 = (Float) (param.getValue()); // DELETE // check for MERIS ads flag // DELETE param = getRequest().getParameter(SmacConstants.USE_MERIS_ADS_PARAM_NAME); checkParamNotNull(param, SmacConstants.USE_MERIS_ADS_PARAM_NAME); _useMerisADS = (Boolean) param.getValue(); // DELETE // load the other parameters only if needed // ---------------------------------------- if (!_useMerisADS) { // DELETE // water vapour content param = getRequest().getParameter(SmacConstants.RELATIVE_HUMIDITY_PARAM_NAME); checkParamNotNull(param, SmacConstants.RELATIVE_HUMIDITY_PARAM_NAME); _u_h2o = (Float) (param.getValue()); // DELETE // DELETE // ozone content param = getRequest().getParameter(SmacConstants.OZONE_CONTENT_PARAM_NAME); checkParamNotNull(param, SmacConstants.OZONE_CONTENT_PARAM_NAME); _u_o3 = (Float) (param.getValue()); // DELETE // DELETE // surface pressure param = getRequest().getParameter(SmacConstants.SURFACE_AIR_PRESSURE_PARAM_NAME); checkParamNotNull(param, SmacConstants.SURFACE_AIR_PRESSURE_PARAM_NAME); _surf_press = (Float) (param.getValue()); // DELETE } // DELETE // get aerosol type param = getRequest().getParameter(SmacConstants.AEROSOL_TYPE_PARAM_NAME); checkParamNotNull(param, SmacConstants.AEROSOL_TYPE_PARAM_NAME); setAerosolType((String) param.getValue()); // DELETE // DELETE // get invalid pixel value param = getRequest().getParameter(SmacConstants.DEFAULT_REFLECT_FOR_INVALID_PIX_PARAM_NAME); if (param == null) { _logger.warning(ProcessorConstants.LOG_MSG_NO_INVALID_PIXEL); _logger.warning(ProcessorConstants.LOG_MSG_USING + "0.0"); _invalidPixel = 0.f; } else { _invalidPixel = (Float) param.getValue(); } // DELETE }