static int calculateSceneRasterHeight(DSD dsdGeoLocationAds, int numMDSR) { final int linesFromADS = (dsdGeoLocationAds.getNumRecords() - 1) * EnvisatConstants.AATSR_LOC_TIE_POINT_SUBSAMPLING_Y; if (numMDSR > linesFromADS) { return numMDSR; } return linesFromADS; }
/** * This method is called after the main product header has been read in successfully. * * <p> * * <p>Sub-classes should set product specific parameters in the <code>parameters</code> argument. * The parameters can be referenced in DDDB in order to implement dynamic field length, such as * 'LINE_WIDTH'. * * <p> * * <p>When this method is called, the <code>getMPH()</code> method returns a non-null value. * * <p> * * <p>The default implementation is empty. * * @param parameters product specific parameters (possibly referenced within in the DDDB */ @Override protected void postProcessSPH(Map parameters) throws IOException { DSD[] mdsDsds = getValidDSDs(EnvisatConstants.DS_TYPE_MEASUREMENT); int numMDSR; if (mdsDsds.length == 0) { // throw new ProductIOException("no valid measurements datasets found in this AATSR product"); // /*I18N*/ numMDSR = 0; } else { numMDSR = mdsDsds[0].getNumRecords(); } DSD dsdGeoLocationAds = getDSD("GEOLOCATION_ADS"); if (dsdGeoLocationAds == null) { throw new IllegalFileFormatException( "invalid product: missing DSD for dataset 'GEOLOCATION_ADS'"); /*I18N*/ } DSD dsdNadirViewSolarAnglesAds = getDSD("NADIR_VIEW_SOLAR_ANGLES_ADS"); if (dsdNadirViewSolarAnglesAds == null) { throw new IllegalFileFormatException( "invalid product: missing DSD for dataset 'NADIR_VIEW_SOLAR_ANGLES_ADS'"); /*I18N*/ } _sceneRasterHeight = calculateSceneRasterHeight(dsdGeoLocationAds, numMDSR); int sceneRasterWidth = EnvisatConstants.AATSR_SCENE_RASTER_WIDTH; int locTiePointGridWidth = EnvisatConstants.AATSR_LOC_TIE_POINT_GRID_WIDTH; int locTiePointGridHeight = dsdGeoLocationAds.getNumRecords(); _locTiePointGridOffsetX = EnvisatConstants.AATSR_LOC_TIE_POINT_OFFSET_X; _locTiePointGridOffsetY = EnvisatConstants.AATSR_TIE_POINT_OFFSET_Y; _locTiePointSubSamplingX = EnvisatConstants.AATSR_LOC_TIE_POINT_SUBSAMPLING_X; _locTiePointSubSamplingY = EnvisatConstants.AATSR_LOC_TIE_POINT_SUBSAMPLING_Y; _solTiePointGridWidth = EnvisatConstants.AATSR_SOL_TIE_POINT_GRID_WIDTH; int solTiePointGridHeight = dsdNadirViewSolarAnglesAds.getNumRecords(); _solTiePointGridOffsetX = EnvisatConstants.AATSR_SOL_TIE_POINT_OFFSET_X; _solTiePointGridOffsetY = EnvisatConstants.AATSR_TIE_POINT_OFFSET_Y; _solTiePointSubSamplingX = EnvisatConstants.AATSR_SOL_TIE_POINT_SUBSAMPLING_X; _solTiePointSubSamplingY = EnvisatConstants.AATSR_SOL_TIE_POINT_SUBSAMPLING_Y; // _locTiePointSubSamplingX = sceneRasterWidth / (locTiePointGridWidth - 1); // _locTiePointSubSamplingY = sceneRasterHeight / (locTiePointGridHeight - 1); // _solTiePointSubSamplingX = sceneRasterWidth / (_solTiePointGridWidth - 1); // _solTiePointSubSamplingY = sceneRasterHeight / (solTiePointGridHeight - 1); // Note: the following parameters are NOT used in the DDDB anymore // They are provided here for debugging purposes only. // parameters.put("sceneRasterWidth", sceneRasterWidth); parameters.put("sceneRasterHeight", _sceneRasterHeight); parameters.put("locTiePointGridWidth", locTiePointGridWidth); parameters.put("locTiePointGridHeight", locTiePointGridHeight); parameters.put("locTiePointGridOffsetX", _locTiePointGridOffsetX); parameters.put("locTiePointGridOffsetY", _locTiePointGridOffsetY); parameters.put("locTiePointSubSamplingX", _locTiePointSubSamplingX); parameters.put("locTiePointSubSamplingY", _locTiePointSubSamplingY); parameters.put("solTiePointGridWidth", _solTiePointGridWidth); parameters.put("solTiePointGridHeight", solTiePointGridHeight); parameters.put("solTiePointGridOffsetX", _solTiePointGridOffsetX); parameters.put("solTiePointGridOffsetY", _solTiePointGridOffsetY); parameters.put("solTiePointSubSamplingX", _solTiePointSubSamplingX); parameters.put("solTiePointSubSamplingY", _solTiePointSubSamplingY); if (_sceneRasterHeight > numMDSR) { mdsMapIndex = new int[getSceneRasterHeight()]; final RecordReader recordReader = getRecordReader("GEOLOCATION_ADS"); final int records = recordReader.getNumRecords() - 1; int mdsIndex = 0; for (int geoADSIndex = 0; geoADSIndex < records; geoADSIndex++) { final Record record = recordReader.readRecord(geoADSIndex); final int attachFlag = record.getField("attach_flag").getElemInt(0); for (int line = 0; line < 32; line++) { final int i = geoADSIndex * 32 + line; if (attachFlag == 0) { mdsMapIndex[i] = mdsIndex; ++mdsIndex; } else { mdsMapIndex[i] = -1; } } } } }