Skip to content

Commit

Permalink
code cleanup up and more comment for further refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen, David (398B-Affiliate) committed Dec 8, 2023
1 parent 4d1ee54 commit e1a285c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@
<targetPackage>gov.nasa.cumulus.metadata.umm.generated</targetPackage>
<sourceType>jsonschema</sourceType>
<annotationStyle>GSON</annotationStyle>
<includeConstructors>true</includeConstructors>
<includeConstructors>false</includeConstructors>
<targetVersion>11</targetVersion>
<includeGeneratedAnnotation>false</includeGeneratedAnnotation>
<formatDateTimes>true</formatDateTimes>
<formatDates>true</formatDates>
<formatDateTimes>true</formatDateTimes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import javax.xml.bind.DatatypeConverter;
import javax.xml.parsers.DocumentBuilder;
Expand Down Expand Up @@ -486,7 +485,6 @@ public IsoGranule readIsoMendsMetadataFile(String s3Location, Document doc, XPat

((IsoGranule) granule).setOrbit(MENDsISOXmlUtiils.extractXPathValueSwallowException(doc, xpath, IsoMendsXPath.ORBIT, "IsoMendsXPath.ORBIT"));
((IsoGranule) granule).setSwotTrack(MENDsISOXmlUtiils.extractXPathValueSwallowException(doc, xpath, IsoMendsXPath.SWOT_TRACK, "IsoMendsXPath.SWOT_TRACK"));
AdapterLogger.LogDebug("1 SWOT track is set as" + ((IsoGranule) granule).getSwotTrack());
Source source = new Source();
source.setSourceShortName(MENDsISOXmlUtiils.extractXPathValueSwallowException(doc, xpath, IsoMendsXPath.PLATFORM, "IsoMendsXPath.PLATFORM"));

Expand Down Expand Up @@ -818,7 +816,6 @@ private void readIsoSmapMetadataFile(String s3Location, Document doc, XPath xpat
((IsoGranule) granule).setOrbit(xpath.evaluate(IsoSmapXPath.ORBIT, doc));

((IsoGranule) granule).setSwotTrack(xpath.evaluate(IsoSmapXPath.SWOT_TRACK, doc));
AdapterLogger.LogDebug("2 SWOT track is set as" + ((IsoGranule) granule).getSwotTrack());
((IsoGranule) granule).setPolygon(xpath.evaluate(IsoSmapXPath.POLYGON, doc));

Source source = new Source();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,7 @@ private JSONObject exportTemporal() {
*/
private boolean shouldAddBBx(Granule granule) {
boolean shouldAddBBx = false;
if(granule.getIsoType() == null) {
AdapterLogger.LogInfo(this.className + " shouldAddBBx detect UMMGranule Object");
}

if(granule !=null && granule.getIsoType() == null) {
shouldAddBBx = true;
}
Expand All @@ -444,7 +442,6 @@ private JSONObject exportSpatial() throws ParseException{
Boolean foundOrbitalData = false;
boolean isoBBoxAlreadyProcessed = false;
spatialExtent.put("HorizontalSpatialDomain", horizontalSpatialDomain);
boolean isIsoXMLSpatialProcessed = false;

if (granule instanceof IsoGranule) {
/**
Expand All @@ -453,7 +450,6 @@ private JSONObject exportSpatial() throws ParseException{
* (during MetatdataFilesToEcho.readIsoxxxx()) is not empty or null
*/
if(this.isoXMLSpatialTypeEnumHashSet.contains(MENDsIsoXMLSpatialTypeEnum.FOOTPRINT)) {
isIsoXMLSpatialProcessed =true;
AdapterLogger.LogDebug(this.className + "UMMGranuleFile.exportSpatial FOOTPRINT Processing");
String polygon = ((IsoGranule) granule).getPolygon();
AdapterLogger.LogInfo(this.className + " nc.iso.xml footprint processing ... ");
Expand All @@ -462,7 +458,6 @@ private JSONObject exportSpatial() throws ParseException{
horizontalSpatialDomain.put("Geometry", geometry);
}
if(this.isoXMLSpatialTypeEnumHashSet.contains(MENDsIsoXMLSpatialTypeEnum.ORBIT)) {
isIsoXMLSpatialProcessed =true;
AdapterLogger.LogDebug(this.className + "UMMGranuleFile.exportSpatial ORBIT Processing");
String orbitStr = ((IsoGranule) granule).getOrbit();
if (!StringUtils.isEmpty(orbitStr)) {
Expand All @@ -481,14 +476,16 @@ private JSONObject exportSpatial() throws ParseException{
}
}
if(this.isoXMLSpatialTypeEnumHashSet.contains(MENDsIsoXMLSpatialTypeEnum.BBOX)) {
isIsoXMLSpatialProcessed =true;
// Extract the stored IsoGranule bounding box and put into SpatialExtent
AdapterLogger.LogDebug(this.className + "UMMGranuleFile.exportSpatial BBOX Processing");
isoBBoxAlreadyProcessed = true;
horizontalSpatialDomain = this.appendBoundingRectangles(geometry, horizontalSpatialDomain);
}
// Export track
AdapterLogger.LogDebug(this.className + "Swot track string" + ((IsoGranule) granule).getSwotTrack());
// Export track for isoXML SMAP
// look into : IsoSmapXPath.SWOT_TRACK and how we use it to grab and store coordinate string to granule's
// swotTrack string. We also store swotTrack to MENDs granule and IsoXPath.SWOT_TRACK and IsoMendsXPath.CYCLE_PASS_TILE_SCENE
// these 2 values are being used to "extrac" cycle pass string from eith MENDs or SMAP. However, smap cycle and pass
// are being processed below
if (((IsoGranule) granule).getSwotTrack() != "" && granule.getIsoType() == IsoType.SMAP) {
JSONObject track = new JSONObject();
horizontalSpatialDomain.put("Track", track);
Expand Down Expand Up @@ -521,18 +518,15 @@ private JSONObject exportSpatial() throws ParseException{
}
} // end of processing IsoGranule

AdapterLogger.LogInfo(this.className + " granule isoType:" + granule.getIsoType());
// following is a large block code to deal with None IsoXML (MENDs or SMAP) bounding box
// We can only include orbital or bounding-box data, not both
// if iso Bounding Box already processed in logic above, then don't enter this block
if (foundOrbitalData == false && !isoBBoxAlreadyProcessed) {
AdapterLogger.LogInfo(this.className + " Second block");
horizontalSpatialDomain.put("Geometry", geometry);

JSONArray boundingRectangles = new JSONArray();

double north = 0, south = 0, east = 0, west = 0;
if(granule !=null && granule.getIsoType() == null) {
AdapterLogger.LogInfo(this.className + " Unexpected block");
east = ((UMMGranule) granule).getBbxEasternLongitude() != null ?
((UMMGranule) granule).getBbxEasternLongitude() : 0;
west = ((UMMGranule) granule).getBbxWesternLongitude() != null?
Expand All @@ -542,7 +536,6 @@ private JSONObject exportSpatial() throws ParseException{
south = ((UMMGranule) granule).getBbxSouthernLatitude() != null?
((UMMGranule) granule).getBbxSouthernLatitude() : 0;
} else {
AdapterLogger.LogInfo(this.className + " BBX Else");
Set<GranuleReal> grs = granule.getGranuleRealSet();

for (GranuleReal gr : grs) {
Expand Down Expand Up @@ -578,7 +571,6 @@ private JSONObject exportSpatial() throws ParseException{
// and make sure we turn off the rangeIs360 flag
this.rangeIs360 = false;
}
AdapterLogger.LogInfo(this.className + " BBX BigDecimal Processing");
BigDecimal nrth = new BigDecimal(north);
BigDecimal sth = new BigDecimal(south);
nrth = nrth.setScale(3, RoundingMode.HALF_UP);
Expand Down Expand Up @@ -627,9 +619,13 @@ private JSONObject exportSpatial() throws ParseException{
geometry.put("BoundingRectangles", boundingRectangles);
}
}

// Export track if cycle and pass exists
if (granule.getIsoType() == IsoType.MENDS) {
// Export TrackType
// MENDS : ISO
// Or Non-iso track : such as MODIS_A and Sentinel-6
// for instance, iso MENDS and Sentinel-6 and MODIS_A are having TrackType created within MetadataFilesToEcho class
// if cycle and pass exists. MENDs is taking adavangate of UMMG generated pojo : TrackType
// which is stored within the UMMGranule
if (granule instanceof UMMGranule) {
/**
* Track include cycle and passes(array).
*/
Expand Down

0 comments on commit e1a285c

Please sign in to comment.