Skip to content

Commit

Permalink
remove BoundingRectangles if GPolygon appears
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen, David (398B-Affiliate) committed Sep 28, 2022
1 parent b096383 commit 7e5abec
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -210,14 +206,64 @@ 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);
AdapterLogger.LogInfo(this.className + " CMR String after appending Footprint:" + spatialExtentStr);
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<GPolygonType> gPolygonTypeSet = geometryType.getGPolygons();
Set<LineType> 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<BoundingRectangleType> boundingRectangleTypeSet = geometryType.getBoundingRectangles();
if (boundingRectangleTypeSet!=null && !boundingRectangleTypeSet.isEmpty()) {
boundingRectangleTypeSet.clear();
}
}
}
}
return spatialExtentType;
}

/**
* A single geometry
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7e5abec

Please sign in to comment.