Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-3220 Smaller Extent BBox For Finding High-Resolution Imagery (#5347)

christof-wittreich92cbac876161
diff --git a/web/js/components/layer/settings/imagery-search.js b/web/js/components/layer/settings/imagery-search.js
index 3668f4811..7d43f71a6 100644
--- a/web/js/components/layer/settings/imagery-search.js
+++ b/web/js/components/layer/settings/imagery-search.js
@@ -37,7 +37,7 @@ export default function ImagerySearch({ layer }) {
const conceptID = layer?.conceptIds?.[0]?.value || layer?.collectionConceptID;
- const getOlderGranules = async (layer, refDate = selectedDate, pageNum = 1) => {
+ const getSmallerExtent = () => {
// clamp extent to maximum extent allowed by the CMR api
const extent = map.extent.map((coord, i) => {
const condition = i <= 1 ? coord > maxExtent[i] : coord < maxExtent[i];
@@ -46,8 +46,22 @@ export default function ImagerySearch({ layer }) {
}
return maxExtent[i];
});
+ const xDiff = Math.abs(extent[0] - extent[2]);
+ const yDiff = Math.abs(extent[1] - extent[3]);
+ // Reduce width by 40% and height by 20%, to show only centered data
+ const smallerExtent = [
+ extent[0] + (xDiff * 0.2),
+ extent[1] + (yDiff * 0.1),
+ extent[2] - (xDiff * 0.2),
+ extent[3] - (yDiff * 0.1),
+ ];
+ return smallerExtent;
+ };
+
+ const getOlderGranules = async (layer, refDate = selectedDate, pageNum = 1) => {
+ const smallerExtent = getSmallerExtent();
try {
- const olderUrl = `https://cmr.earthdata.nasa.gov/search/granules.json?collection_concept_id=${conceptID}&bounding_box=${extent.join(',')}&temporal=,${refDate.toISOString()}&sort_key=-start_date&pageSize=25&page_num=${pageNum}`;
+ const olderUrl = `https://cmr.earthdata.nasa.gov/search/granules.json?collection_concept_id=${conceptID}&bounding_box=${smallerExtent.join(',')}&temporal=,${refDate.toISOString()}&sort_key=-start_date&pageSize=25&page_num=${pageNum}`;
const olderResponse = await fetch(olderUrl, { headers });
const olderGranules = await olderResponse.json();
const olderDates = olderGranules.feed.entry.map(parseGranuleTimestamp);
@@ -59,16 +73,9 @@ export default function ImagerySearch({ layer }) {
};
const getNewerGranules = async (layer, refDate = selectedDate, pageNum = 1) => {
- // clamp extent to maximum extent allowed by the CMR api
- const extent = map.extent.map((coord, i) => {
- const condition = i <= 1 ? coord > maxExtent[i] : coord < maxExtent[i];
- if (condition) {
- return coord;
- }
- return maxExtent[i];
- });
+ const smallerExtent = getSmallerExtent();
try {
- const newerUrl = `https://cmr.earthdata.nasa.gov/search/granules.json?collection_concept_id=${conceptID}&bounding_box=${extent.join(',')}&temporal=${refDate.toISOString()},&sort_key=start_date&pageSize=25&page_num=${pageNum}`;
+ const newerUrl = `https://cmr.earthdata.nasa.gov/search/granules.json?collection_concept_id=${conceptID}&bounding_box=${smallerExtent.join(',')}&temporal=${refDate.toISOString()},&sort_key=start_date&pageSize=25&page_num=${pageNum}`;
const newerResponse = await fetch(newerUrl, { headers });
const newerGranules = await newerResponse.json();
const newerDates = newerGranules.feed.entry.map(parseGranuleTimestamp);