@Override public ProfilePartReader createDescriptionPartReader() { return new HdfEosDescriptionPart(); }
@Override public ProfilePartReader createTimePartReader() { return new HdfEosTimePart(); }
@Override public ProfilePartReader createBandPartReader() { return new HdfEosBandPart(); }
@Test public void testEqualProjectionsWithProjParamsNullParamsAreNotEqual() throws Exception { HdfEosGridInfo gridInfo1 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); gridInfo1.setProjectionParameter(PROJ_PARAMS); HdfEosGridInfo gridInfo2 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); gridInfo2.setProjectionParameter(null); assertFalse(gridInfo1.equalProjections(gridInfo2)); } }
@Test public void testGridInfosAreEqual() throws Exception { HdfEosGridInfo gridInfo1 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); HdfEosGridInfo gridInfo2 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); assertTrue(gridInfo1.equalProjections(gridInfo2)); }
@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 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; }
static List<HdfEosGridInfo> getCompatibleGridInfos(List<HdfEosGridInfo> allGridInfos) { List<HdfEosGridInfo> compatibleGridInfos = new ArrayList<HdfEosGridInfo>(); if (allGridInfos.isEmpty()) { return compatibleGridInfos; } HdfEosGridInfo first = allGridInfos.get(0); for (HdfEosGridInfo gridInfo : allGridInfos) { if (first.equalProjections(gridInfo)) { compatibleGridInfos.add(gridInfo); } } return compatibleGridInfos; }
private ProductData.UTC readEosTime(Element element, String dateElemName, String timeElemName) { String date = HdfEosUtils.getValue(element, "INVENTORYMETADATA", "MASTERGROUP", "RANGEDATETIME", dateElemName, "VALUE"); String time = HdfEosUtils.getValue(element, "INVENTORYMETADATA", "MASTERGROUP", "RANGEDATETIME", timeElemName, "VALUE"); if (date != null && !date.isEmpty() && time != null && !time.isEmpty()) { return TimeUtils.parseDateTime(date + " " + time); } return null; }
@Override public ProfilePartReader createGeoCodingPartReader() { return new HdfEosGeocodingPart(); }
@Override public ProfilePartReader createMetadataPartReader() { return new HdfEosMetadataPart(); }
@Override public void decode(ProfileReadContext ctx, Product p) throws IOException { Element element = (Element) ctx.getProperty(HdfEosUtils.CORE_METADATA); if (element != null) { p.setStartTime(readEosTime(element, "RANGEBEGINNINGDATE", "RANGEBEGINNINGTIME")); p.setEndTime(readEosTime(element, "RANGEENDINGDATE", "RANGEENDINGTIME")); } }
static List<HdfEosGridInfo> createGridInfos(Element eosStructElement) { List<HdfEosGridInfo> gridInfos = new ArrayList<HdfEosGridInfo>(); if (eosStructElement != null) { Element gridStructureElem = eosStructElement.getChild("GridStructure"); if (gridStructureElem != null) { for (Element gridElem : (List<Element>) gridStructureElem.getChildren()) { if (gridElem != null) { HdfEosGridInfo gridInfo = createGridInfo(gridElem); if (gridInfo != null) { gridInfos.add(gridInfo); } } } } } return gridInfos; }
static Group findGroupNested(Group parent, String name) { for (Group g : parent.getGroups()) { if (g.getShortName().equals(name)) return g; } for (Group g : parent.getGroups()) { Group result = findGroupNested(g, name); if (result != null) return result; } return null; }
private static void createMDE(String name, ProfileReadContext ctx, MetadataElement eosElem) throws IOException { Element element = (Element) ctx.getProperty(name); if (element != null) { MetadataElement metadataElement = new MetadataElement(name); addDomToMetadata(element, metadataElement); eosElem.addElement(metadataElement); } }
private void hdfDecode(ProfileReadContext ctx, Product p) throws IOException { final CfHdfEosGeoInfoExtractor cfHdfEosGeoInfoExtractor = new CfHdfEosGeoInfoExtractor( ctx.getNetcdfFile().getGlobalAttributes()); cfHdfEosGeoInfoExtractor.extractInfo(); String projection = cfHdfEosGeoInfoExtractor.getProjection(); double upperLeftLon = cfHdfEosGeoInfoExtractor.getUlLon(); double upperLeftLat = cfHdfEosGeoInfoExtractor.getUlLat(); double lowerRightLon = cfHdfEosGeoInfoExtractor.getLrLon(); double lowerRightLat = cfHdfEosGeoInfoExtractor.getLrLat(); HdfEosGeocodingPart.attachGeoCoding(p, upperLeftLon, upperLeftLat, lowerRightLon, lowerRightLat, projection, null); }
@Test public void testGridInfosWithProjParamsAreEqual() throws Exception { HdfEosGridInfo gridInfo1 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); gridInfo1.setProjectionParameter(PROJ_PARAMS); HdfEosGridInfo gridInfo2 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); gridInfo2.setProjectionParameter(PROJ_PARAMS); assertTrue(gridInfo1.equalProjections(gridInfo2)); }
@Test public void testGridInfosAreNotEqual() throws Exception { HdfEosGridInfo gridInfo1 = new HdfEosGridInfo("testName", -120, 50.1, -100, 40, "Sinusoidal"); HdfEosGridInfo gridInfo2 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); assertFalse(gridInfo1.equalProjections(gridInfo2)); }
@Override public void decode(ProfileReadContext ctx, Product p) throws IOException { Element element = (Element) ctx.getProperty(HdfEosUtils.ARCHIVE_METADATA); if (element != null) { p.setDescription(HdfEosUtils.getValue(element, "ARCHIVEDMETADATA", "MASTERGROUP", "LONGNAME", "VALUE")); } }
@Test public void testGridInfosWithProjParamsAreNotEqual() throws Exception { HdfEosGridInfo gridInfo1 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); gridInfo1.setProjectionParameter(PROJ_PARAMS); HdfEosGridInfo gridInfo2 = new HdfEosGridInfo("testName", -120, 50, -100, 40, "Sinusoidal"); double[] projParams2 = PROJ_PARAMS.clone(); projParams2[4] = 42.42; gridInfo2.setProjectionParameter(projParams2); assertFalse(gridInfo1.equalProjections(gridInfo2)); }