Skip to content

Commit

Permalink
fix/hitide-ui-33: fix scaling of collections resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
jbyrne committed Oct 3, 2023
1 parent 602c3d9 commit 4b8bec4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
2 changes: 2 additions & 0 deletions src/jpl/dijit/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ define([
if (keys[i] === "DatasetCoverage-StartTimeLong" ||
keys[i] === "DatasetCoverage-StopTimeLong") {
value = value ? moment.utc(parseInt(value)) : moment.utc();
} else if (keys[i] === "Dataset-Resolution") {
value = valueArr
}
formattedObjs[keys[i]] = value;
}
Expand Down
29 changes: 24 additions & 5 deletions src/jpl/dijit/ui/MetadataDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,31 @@ define([

/* Set long name */
domAttr.set(this.metadataDatasetLongName, "innerHTML", metadata["Dataset-LongName"]);

/* Set along/across-track resolution */
var alongTrackResolution = metadata["Dataset-AlongTrackResolution"];
var acrossTrackResolution = metadata["Dataset-AcrossTrackResolution"];
if(alongTrackResolution && acrossTrackResolution)
domAttr.set(this.metadataAlongAcrossRes, "innerHTML", parseInt(metadata["Dataset-AlongTrackResolution"]) / 1000 + "km x " + parseInt(metadata["Dataset-AcrossTrackResolution"]) / 1000 + "km");
var datasetResolution = metadata["Dataset-Resolution"]
if(datasetResolution) {
// Set the resolution to display. Allow for multiple resolutions of one collection.
var unit = "km"
var multiplier = 0.001
var resolutionString = ""
var datasetResolutionToUse = datasetResolution[0]

// if Dataset-ShortName starts with SWOT_L2_NALT, then use the second value instead of the first
if (metadata["Dataset-ShortName"].includes("SWOT_L2_NALT")) {
datasetResolutionToUse = datasetResolution[1]
}

// if meters, convert to km unless less than 1000
// if kilometers, keep as km
if (datasetResolutionToUse["Unit"] === "Meters" && datasetResolutionToUse["Dataset-AlongTrackResolution"] < 1000) {
unit = "m"
multiplier = 1
} else if (datasetResolutionToUse["Unit"] === "Kilometers") {
multiplier = 1
}
resolutionString += parseInt(datasetResolutionToUse["Dataset-AlongTrackResolution"]) * multiplier + unit + " x " + parseInt(datasetResolutionToUse["Dataset-AcrossTrackResolution"]) * multiplier + unit
domAttr.set(this.metadataAlongAcrossRes, "innerHTML", resolutionString);
}
else
domAttr.set(this.metadataAlongAcrossRes, "innerHTML", "Not Available");

Expand Down
32 changes: 9 additions & 23 deletions src/jpl/utils/SearchDatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ define([

function getCmrSpatialExtent(datasetObject){
var conceptId = datasetObject["Dataset-PersistentId"]
// var url = config.hitide.externalConfigurables.cmrVariableService;
// var customQuery = "{\n collection (conceptId: \"" + conceptId + "\") {\n spatialExtent \n} \n}"
var secondURL = config.hitide.externalConfigurables.cmrCollectionSearchService + "/" + conceptId + ".umm_json"
return request(secondURL, {
handleAs: 'json',
Expand All @@ -138,31 +136,19 @@ define([
}).then(function(response) {
var resolutionAndCoordinateSystemObject = response.SpatialExtent.HorizontalSpatialDomain.ResolutionAndCoordinateSystem
if (resolutionAndCoordinateSystemObject) {
var resolutionObject = resolutionAndCoordinateSystemObject.HorizontalDataResolution.GenericResolutions[0]
if (resolutionObject) {
datasetObject["Dataset-AcrossTrackResolution"] = resolutionObject.XDimension
datasetObject["Dataset-AlongTrackResolution"] = resolutionObject.YDimension
var resolutionObjects = resolutionAndCoordinateSystemObject.HorizontalDataResolution.GenericResolutions
if (resolutionObjects) {
datasetObject["Dataset-Resolution"] = []
resolutionObjects.forEach(function(resolutionObject) {
var acrossTrack = resolutionObject.XDimension
var alongTrack = resolutionObject.YDimension
var unit = resolutionObject.Unit
datasetObject["Dataset-Resolution"].push({"Dataset-AcrossTrackResolution": acrossTrack, "Dataset-AlongTrackResolution": alongTrack, "Unit": unit})
});
}
}
return datasetObject
})
// NOTE: Example of Graphql implementation of above query
// return request.post(url, {
// handleAs: 'json',
// withCredentials: config.hitide.externalConfigurables.crossOriginCmrCookies,
// headers: { "X-Requested-With": null, "Content-Type": "application/json" },
// data: JSON.stringify({ query: customQuery })
// }).then(function(response) {
// var resolutionAndCoordinateSystemObject = response.data.collection.spatialExtent.horizontalSpatialDomain.resolutionAndCoordinateSystem
// if (resolutionAndCoordinateSystemObject) {
// var resolutionObject = resolutionAndCoordinateSystemObject.horizontalDataResolution.genericResolutions[0]
// if (resolutionObject) {
// datasetObject["Dataset-AcrossTrackResolution"] = resolutionObject.xDimension
// datasetObject["Dataset-AlongTrackResolution"] = resolutionObject.yDimension
// }
// }
// return datasetObject
// })
}

function getAdditionalCmrMetadata(collectionObjectArray) {
Expand Down

0 comments on commit 4b8bec4

Please sign in to comment.