Skip to content

Commit

Permalink
Add support for direct SMAP bounding box information
Browse files Browse the repository at this point in the history
Support for retrieving and setting the bounding box information
available in SMAP meta data via the `EX_GeographicBoundingBox`
element was missing. This change adds that support.
  • Loading branch information
colecu committed Jan 13, 2024
1 parent e018ffa commit eb359a8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public final class IsoSmapXPath extends IsoXPath {
public static final String BEGINNING_DATE_TIME = BASE + "/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 = BASE + "/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition";

public static final String BOUNDING_BOX = BASE + "/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox";
public static final String WEST_BOUNDING_COORDINATE = BASE + "/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:westBoundLongitude/gco:Decimal";
public static final String SOUTH_BOUNDING_COORDINATE = BASE + "/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:southBoundLongitude/gco:Decimal";
public static final String EAST_BOUNDING_COORDINATE = BASE + "/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:eastBoundLongitude/gco:Decimal";
public static final String NORTH_BOUNDING_COORDINATE = BASE + "/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:northBoundLongitude/gco:Decimal";

public static final String PRODUCER_GRANULE_ID = BASE + CI_CITATION + "/gmd:title/gmx:FileName";
public static final String CRID = BASE + CI_CITATION + "/gmd:identifier[0]/gmd:MD_Identifier/gmd:code/gco:CharacterString";
public static final String IDENTIFIERS = BASE + CI_CITATION + "/gmd:identifier[1]/gmd:MD_Identifier/gmd:code/gco:CharacterString";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,24 @@ private void readIsoSmapMetadataFile(String s3Location, Document doc, XPath xpat
AdapterLogger.LogInfo("Couldn't find orbit information from " + IsoSmapXPath.OrbitCalculatedSpatialDomains);
}

String boundingBoxInformation = xpath.evaluate(IsoSmapXPath.BOUNDING_BOX, doc);
if (boundingBoxInformation != null) {
String north = xpath.evaluate(IsoSmapXPath.NORTH_BOUNDING_COORDINATE, doc);
String south = xpath.evaluate(IsoSmapXPath.SOUTH_BOUNDING_COORDINATE, doc);
String east = xpath.evaluate(IsoSmapXPath.EAST_BOUNDING_COORDINATE, doc);
String west = xpath.evaluate(IsoSmapXPath.WEST_BOUNDING_COORDINATE, doc);

try {
setGranuleBoundingBox(Double.parseDouble(north),
Double.parseDouble(south),
Double.parseDouble(east),
Double.parseDouble(west));
} catch (NullPointerException | NumberFormatException exception) {
throw new IllegalArgumentException(String.format("Failed to parse bbox N=%s S=%s E=%s W=%s",
north, south, east, west), exception);
}
}

((IsoGranule) granule).setProducerGranuleId(xpath.evaluate(IsoSmapXPath.PRODUCER_GRANULE_ID, doc));
((IsoGranule) granule).setCrid(xpath.evaluate(IsoSmapXPath.CRID, doc));
((IsoGranule) granule).setParameterName("Parameter name placeholder");
Expand Down

0 comments on commit eb359a8

Please sign in to comment.