diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c0dd82..8ba3dd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - **PODAAC-2796** - remove all OPeNDAP URL object from RelatedUrls before doing dmrpp file generator processing +- **PODAAC-4832** + - remove BoundingRectangles structure from SpatialExtent if GPolygon appears ### Security ## [8.0.0] - 2022-06-06 diff --git a/src/main/java/gov/nasa/cumulus/metadata/aggregator/processor/FootprintProcessor.java b/src/main/java/gov/nasa/cumulus/metadata/aggregator/processor/FootprintProcessor.java index 0dfb7b9..d3fcabe 100644 --- a/src/main/java/gov/nasa/cumulus/metadata/aggregator/processor/FootprintProcessor.java +++ b/src/main/java/gov/nasa/cumulus/metadata/aggregator/processor/FootprintProcessor.java @@ -20,11 +20,7 @@ import java.math.BigInteger; import java.nio.charset.Charset; import java.nio.file.Paths; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Collection; -import java.util.ArrayList; +import java.util.*; /** * Example footprint file content (downloaded from bucket where footprint is written by forge) @@ -210,7 +206,9 @@ public String geometryToUMMG(Geometry geometry, String cmrStr) { if (lineTypes.size() > 0) geometryType.setLines(lineTypes); if (gPolygonTypes.size() > 0) geometryType.setGPolygons(gPolygonTypes); + spatialExtentType = removeBBX(spatialExtentType); String spatialExtentStr = gsonBuilder.toJson(spatialExtentType); + //TODO : This area actually output both footprint/GPolygon and BoundingRectangle AdapterLogger.LogInfo(this.className + " SpatialExtent:" + spatialExtentStr); cmrJsonObj.add("SpatialExtent", gsonBuilder.toJsonTree(spatialExtentType).getAsJsonObject()); String outputCMRStr = gsonBuilder.toJson(cmrJsonObj); @@ -218,6 +216,54 @@ public String geometryToUMMG(Geometry geometry, String cmrStr) { return outputCMRStr; } + private SpatialExtentType removeBBX(SpatialExtentType spatialExtentType) { + // SpqtialExtent requires (could be none of the following): + // "anyOf": [{ + // "required": ["GranuleLocalities"] + // }, { + // "required": ["HorizontalSpatialDomain"] + // }, { + // "required": ["VerticalSpatialDomains"]GranuleLocalities + ////// and + // HorizontalSpatialDomain requires + // "oneOf": [{ + // "required": ["Geometry"] + // }, { + // "required": ["Orbit"] + // }] + /// and + // Geometry requires + // "anyOf": [{ + // "required": ["Points"] + // }, { + // "required": ["BoundingRectangles"] + // }, { + // "required": ["GPolygons"] + // }, { + // "required": ["Lines"] + // }] + HorizontalSpatialDomainType horizontalSpatialDomainType = spatialExtentType.getHorizontalSpatialDomain(); + if(horizontalSpatialDomainType != null) { + GeometryType geometryType = horizontalSpatialDomainType.getGeometry(); + if (geometryType !=null) { + // Either GPolygon has greater than 0 appearance or Lines has greater than 0 appearance + // then remove the BoundRectangles. + Set gPolygonTypeSet = geometryType.getGPolygons(); + Set lineTypeSet = geometryType.getLines(); + if((gPolygonTypeSet!=null && !gPolygonTypeSet.isEmpty()) + || + (lineTypeSet!=null && !lineTypeSet.isEmpty())) { + //since gPolygon is not null or an empty set them remove bounding rectangle here + Set boundingRectangleTypeSet = geometryType.getBoundingRectangles(); + if (boundingRectangleTypeSet!=null && !boundingRectangleTypeSet.isEmpty()) { + boundingRectangleTypeSet.clear(); + } + } + } + } + return spatialExtentType; + } + /** * A single geometry * diff --git a/src/main/java/gov/nasa/cumulus/metadata/aggregator/processor/ProcessorBase.java b/src/main/java/gov/nasa/cumulus/metadata/aggregator/processor/ProcessorBase.java index 249d473..42881bb 100644 --- a/src/main/java/gov/nasa/cumulus/metadata/aggregator/processor/ProcessorBase.java +++ b/src/main/java/gov/nasa/cumulus/metadata/aggregator/processor/ProcessorBase.java @@ -87,7 +87,7 @@ protected long uploadCMRJson( String cmrBucket, String cmrBaseDir, String collec String newCMRStr) throws IOException { // create a new working directory - AdapterLogger.LogError(this.className + " bucket:" + cmrBucket + " dir:" + cmrBaseDir + + AdapterLogger.LogInfo(this.className + " bucket:" + cmrBucket + " dir:" + cmrBaseDir + " collectionName:"+ collectionName + " cmrFileName:"+ cmrFileName); String cmrFileWorkDir = this.createWorkDir(); try {