Skip to content

Commit

Permalink
compiled version
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen, David (398B-Affiliate) committed Oct 17, 2022
1 parent fde7df7 commit e671af0
Show file tree
Hide file tree
Showing 14 changed files with 1,686 additions and 288 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.285</version>
<version>1.12.321</version>
</dependency>
<!-- For AWS Secret Manager -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-secretsmanager</artifactId>
<version>1.12.285</version>
<version>1.12.321</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gov.nasa.cumulus.metadata.aggregator;

public final class IsoSwotXPath extends IsoXPath {
public static final String POLYGON = "/gmd:DS_Series/gmd:composedOf/gmd:DS_DataSet/gmd:has/gmi:MI_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:Polygon/gml:exterior/gml:LinearRing/gml:posList";
public static final String CYCLE_PASS_TILE_SCENE = "/gmi:MI_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicDescription[@id=\"SWOTTrack\"]/gmd:geographicIdentifier/gmd:MD_Identifier/gmd:code/gco:CharacterString";
public static final String CREATION_DATE_TIME = "/gmi:MI_Metadata/gmd:dateStamp/gco:DateTime";
public static final String BEGINNING_DATE_TIME = "/gmi:MI_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition";
public static final String ENDING_DATE_TIME = "/gmi:MI_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition";

}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ public final class SwotArchiveXmlXPath {

public static final String DATA_FILE_FILE_NAME = "/GranuleMetaDataFile/GranuleURMetaData/ECSDataGranule/LocalGranuleID";
public static final String DATA_FILE_FILE_DESCRIPTION = "/GranuleMetaDataFile/GranuleURMetaData/ECSDataGranule/Description";
public static final String ARCHIVE_CYCLE="/GranuleMetaDataFile/GranuleURMetaData/ECSDataGranule/CycleID";
public static final String ARCHIVE_PASS="/GranuleMetaDataFile/GranuleURMetaData/ECSDataGranule/PassID";
public static final String ARCHIVE_TILE="/GranuleMetaDataFile/GranuleURMetaData/ECSDataGranule/TileID";
public static final String archiveScene="/GranuleMetaDataFile/GranuleURMetaData/ECSDataGranule/SceneID";
}

73 changes: 56 additions & 17 deletions src/main/java/gov/nasa/cumulus/metadata/aggregator/UMMGranule.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
package gov.nasa.cumulus.metadata.aggregator;


import gov.nasa.cumulus.metadata.umm.generated.AdditionalAttributeType;
import gov.nasa.cumulus.metadata.umm.generated.TrackPassTileType;
import gov.nasa.cumulus.metadata.umm.generated.TrackType;
import gov.nasa.podaac.inventory.model.Granule;

import java.math.BigDecimal;
import java.util.List;

public class UMMGranule extends Granule {
private Integer cycle;
private Integer pass;
//private Integer cycle;
// private Integer pass;
/**
* A generated type which represents the cycle and pass
*/
private TrackType trackType;
/**
* A generated type which represents the pass and associate Tiles under Track
*/
private TrackPassTileType trackPassTileType;
private List<AdditionalAttributeType> additionalAttributeTypes;
private Integer orbitNumber;
private Integer startOrbit;
private Integer endOrbit;
private String tile;
/* Bounding Box 4 points */
private Double bbxNorthernLatitude;
private Double bbxSouthernLatitude;
Expand All @@ -19,21 +33,21 @@ public class UMMGranule extends Granule {
private BigDecimal equatorCrossingLongitude;
private String equatorCrossingDateTime;

public Integer getPass() {
return pass;
}

public void setPass(Integer pass) {
this.pass = pass;
}

public Integer getCycle() {
return cycle;
}

public void setCycle(Integer cycle) {
this.cycle = cycle;
}
// public Integer getPass() {
// return pass;
// }
//
// public void setPass(Integer pass) {
// this.pass = pass;
// }

// public Integer getCycle() {
// return cycle;
// }
//
// public void setCycle(Integer cycle) {
// this.cycle = cycle;
// }

public Integer getOrbitNumber() {
return orbitNumber;
Expand All @@ -57,6 +71,31 @@ public Integer getEndOrbit() {
public void setEndOrbit(Integer endOrbit) {
this.endOrbit = endOrbit;
}

public String getTile() {
return tile;
}

public void setTile(String tile) {
this.tile = tile;
}

public TrackType getTrackType() {
return trackType;
}

public void setTrackType(TrackType trackType) {
this.trackType = trackType;
}

public List<AdditionalAttributeType> getAdditionalAttributeTypes() {
return additionalAttributeTypes;
}

public void setAdditionalAttributeTypes(List<AdditionalAttributeType> additionalAttributeTypes) {
this.additionalAttributeTypes = additionalAttributeTypes;
}

public Double getBbxNorthernLatitude() {
return bbxNorthernLatitude;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package gov.nasa.cumulus.metadata.aggregator;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.vividsolutions.jts.geom.*;
import com.vividsolutions.jts.algorithm.CGAlgorithms;
import cumulus_message_adapter.message_parser.AdapterLogger;
import gov.nasa.cumulus.metadata.umm.adapter.UMMGCollectionAdapter;
import gov.nasa.cumulus.metadata.umm.adapter.UMMGListAdapter;
import gov.nasa.cumulus.metadata.umm.adapter.UMMGMapAdapter;
import gov.nasa.cumulus.metadata.util.BoundingTools;
import gov.nasa.cumulus.metadata.util.JSONUtils;
import gov.nasa.cumulus.metadata.util.TimeConversion;
import gov.nasa.cumulus.metadata.exception.GEOProcessException;
import gov.nasa.cumulus.metadata.umm.model.UMMGranuleArchive;
Expand All @@ -22,6 +29,7 @@
import java.math.RoundingMode;
import java.net.URISyntaxException;
import java.util.*;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -93,6 +101,9 @@ public JSONObject defineGranule()
// Populate the Spatial metadata
granuleJson.put("SpatialExtent", exportSpatial());

// Populate the tile into AdditionalAttributes
// granule.put


/**
* Populate the Orbital Metadata
Expand Down Expand Up @@ -366,7 +377,7 @@ private boolean shouldAddBBx(Granule granule) {
return shouldAddBBx;
}

private JSONObject exportSpatial() {
private JSONObject exportSpatial() throws ParseException{
JSONObject spatialExtent = new JSONObject();
JSONObject geometry = new JSONObject();
JSONObject horizontalSpatialDomain = new JSONObject();
Expand Down Expand Up @@ -528,17 +539,29 @@ private JSONObject exportSpatial() {

// Export track if cycle and pass exists
if (granule instanceof UMMGranule) {
UMMGranule ummGranule = (UMMGranule) granule;
if (ummGranule.getCycle() != null && ummGranule.getPass() != null) {
JSONObject track = new JSONObject();
horizontalSpatialDomain.put("Track", track);
track.put("Cycle", ummGranule.getCycle());
JSONArray passes = new JSONArray();
track.put("Passes", passes);
JSONObject pass = new JSONObject();
pass.put("Pass", ummGranule.getPass());
passes.add(pass);
// Gson gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
// .registerTypeHierarchyAdapter(Collection.class, new UMMGCollectionAdapter())
// .registerTypeHierarchyAdapter(List.class, new UMMGListAdapter())
// .registerTypeHierarchyAdapter(Map.class, new UMMGMapAdapter())
// .create();
// JsonObject trackJsonObj = gsonBuilder.toJsonTree(((UMMGranule) granule).getTrackType()).getAsJsonObject();
// JSONObject track = JSONUtils.GsonToJSONObj(trackJsonObj);
/**
* Track include cycle and passes(array).
*/
if(((UMMGranule) granule).getTrackType() != null ) {
horizontalSpatialDomain.put("Track", createUMMGTrack((UMMGranule) granule));
}
// if (ummGranule.getCycle() != null && ummGranule.getPass() != null) {
// JSONObject track = new JSONObject();
// horizontalSpatialDomain.put("Track", track);
// track.put("Cycle", ummGranule.getCycle());
// JSONArray passes = new JSONArray();
// track.put("Passes", passes);
// JSONObject pass = new JSONObject();
// pass.put("Pass", ummGranule.getPass());
// passes.add(pass);
// }
}

// Export footprint if it exists
Expand All @@ -550,10 +573,21 @@ private JSONObject exportSpatial() {
break;
}
}

return spatialExtent;
}

public JSONObject createUMMGTrack(UMMGranule ummGranule) throws ParseException {
Gson gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
.registerTypeHierarchyAdapter(Collection.class, new UMMGCollectionAdapter())
.registerTypeHierarchyAdapter(List.class, new UMMGListAdapter())
.registerTypeHierarchyAdapter(Map.class, new UMMGMapAdapter())
.create();
JsonObject trackJsonObj = gsonBuilder.toJsonTree(ummGranule.getTrackType()).getAsJsonObject();
JSONObject track = JSONUtils.GsonToJSONObj(trackJsonObj);
AdapterLogger.LogInfo("TrackType:" + track.toString());
return track;
}

/**
* This function will first translate the line string to a List<Coordinates>
* and add BoundingRectangles to geometry object when
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package gov.nasa.cumulus.metadata.aggregator.factory;

import gov.nasa.cumulus.metadata.umm.generated.AdditionalAttributeType;
import gov.nasa.cumulus.metadata.umm.generated.TrackPassTileType;
import gov.nasa.cumulus.metadata.umm.generated.TrackType;

import java.util.ArrayList;
import java.util.List;

public class UmmgPojoFactory {
private static UmmgPojoFactory _self = null;

private UmmgPojoFactory(){}

public static UmmgPojoFactory getInstance() {
if (_self == null){
_self = new UmmgPojoFactory();
}
return _self;
}

/**
* create a single pass -> tiles:[] association
* @param pass
* @param tiles
* @return
*/
public TrackPassTileType createTrackPassTileType(Integer pass, List<String> tiles) {
TrackPassTileType trackPassTileType = new TrackPassTileType();
trackPassTileType.setPass(pass);
if(tiles !=null && tiles.size() >0) {
trackPassTileType.setTiles(tiles);
}
return trackPassTileType;
}

/**
* Create the TrackType POJO which represents the cycle and passes array
* each pass is a combination of Pass and Tiles Array
* @return
*/
public TrackType createTrackType(Integer cycle, List<TrackPassTileType> trackPassTileTypes) {
TrackType trackType = new TrackType();
trackType.setCycle(cycle);
trackType.setPasses(trackPassTileTypes);
return trackType;
}

public List<AdditionalAttributeType> trackTypeToAdditionalAttributeType(TrackType trackType) {
List<TrackPassTileType> trackPassTileTypes = trackType.getPasses();
ArrayList<AdditionalAttributeType> additionalAttributeTypes = new ArrayList<>();
trackPassTileTypes.stream().forEach(trackPassTileType -> {
AdditionalAttributeType additionalAttributeType = new AdditionalAttributeType();
List<String> tilesStrs = trackPassTileType.getTiles();
additionalAttributeType.setName("TILE");
additionalAttributeType.setValues(tilesStrs);
additionalAttributeTypes.add(additionalAttributeType);
});
return additionalAttributeTypes;
}
}
Loading

0 comments on commit e671af0

Please sign in to comment.