@Override protected DecodeQualification getDecodeQualification(NetcdfFile netcdfFile) { try { Element eosElement = HdfEosUtils.getEosElement(HdfEosUtils.STRUCT_METADATA, netcdfFile.getRootGroup()); // check for GRID if (!HdfEosGridInfo.createGridInfos(eosElement).isEmpty()) { return DecodeQualification.INTENDED; } } catch (Exception ignore) { } return DecodeQualification.UNABLE; }
@Override public void decode(ProfileReadContext ctx, Product p) throws IOException { Element eosElement = (Element) ctx.getProperty(HdfEosUtils.STRUCT_METADATA); List<HdfEosGridInfo> gridInfos = HdfEosGridInfo.createGridInfos(eosElement); List<HdfEosGridInfo> compatibleGridInfos = HdfEosGridInfo.getCompatibleGridInfos(gridInfos); if (!compatibleGridInfos.isEmpty()) { HdfEosGridInfo hdfEosGeocodingInfo = compatibleGridInfos.get(0); attachGeoCoding(p, hdfEosGeocodingInfo.upperLeftLon, hdfEosGeocodingInfo.upperLeftLat, hdfEosGeocodingInfo.lowerRightLon, hdfEosGeocodingInfo.lowerRightLat, hdfEosGeocodingInfo.projection, hdfEosGeocodingInfo.getProjectionParameter()); } }
@Override protected void initReadContext(ProfileReadContext ctx) throws IOException { Group eosGroup = ctx.getNetcdfFile().getRootGroup(); Element eosElement = HdfEosUtils.getEosElement(HdfEosUtils.STRUCT_METADATA, eosGroup); List<HdfEosGridInfo> gridInfos = HdfEosGridInfo.createGridInfos(eosElement); List<HdfEosGridInfo> compatibleGridInfos = HdfEosGridInfo.getCompatibleGridInfos(gridInfos); if (compatibleGridInfos.isEmpty()) { throw new ProductIOException("Could not find grids."); } List<Group> gridGroups = new ArrayList<Group>(); for (HdfEosGridInfo gridInfo : compatibleGridInfos) { gridGroups.add(HdfEosUtils.findGroupNested(eosGroup, gridInfo.gridName)); } if (gridGroups.isEmpty()) { throw new ProductIOException("Could not find grid group."); } Group[] groups = gridGroups.toArray(new Group[gridGroups.size()]); RasterDigest rasterDigest = RasterDigest.createRasterDigest(groups); ctx.setRasterDigest(rasterDigest); ctx.setProperty(HdfEosUtils.STRUCT_METADATA, eosElement); ctx.setProperty(HdfEosUtils.CORE_METADATA, HdfEosUtils.getEosElement(HdfEosUtils.CORE_METADATA, eosGroup)); ctx.setProperty(HdfEosUtils.ARCHIVE_METADATA, HdfEosUtils.getEosElement(HdfEosUtils.ARCHIVE_METADATA, eosGroup)); }