Skip to content

Commit 92cbac8

Browse files
WV-3220 Smaller Extent BBox For Finding High-Resolution Imagery (#5347)
* Added smallerExtent * Added getSmallerExtent reusable function
1 parent ed339aa commit 92cbac8

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

web/js/components/layer/settings/imagery-search.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function ImagerySearch({ layer }) {
3737

3838
const conceptID = layer?.conceptIds?.[0]?.value || layer?.collectionConceptID;
3939

40-
const getOlderGranules = async (layer, refDate = selectedDate, pageNum = 1) => {
40+
const getSmallerExtent = () => {
4141
// clamp extent to maximum extent allowed by the CMR api
4242
const extent = map.extent.map((coord, i) => {
4343
const condition = i <= 1 ? coord > maxExtent[i] : coord < maxExtent[i];
@@ -46,8 +46,22 @@ export default function ImagerySearch({ layer }) {
4646
}
4747
return maxExtent[i];
4848
});
49+
const xDiff = Math.abs(extent[0] - extent[2]);
50+
const yDiff = Math.abs(extent[1] - extent[3]);
51+
// Reduce width by 40% and height by 20%, to show only centered data
52+
const smallerExtent = [
53+
extent[0] + (xDiff * 0.2),
54+
extent[1] + (yDiff * 0.1),
55+
extent[2] - (xDiff * 0.2),
56+
extent[3] - (yDiff * 0.1),
57+
];
58+
return smallerExtent;
59+
};
60+
61+
const getOlderGranules = async (layer, refDate = selectedDate, pageNum = 1) => {
62+
const smallerExtent = getSmallerExtent();
4963
try {
50-
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}`;
64+
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}`;
5165
const olderResponse = await fetch(olderUrl, { headers });
5266
const olderGranules = await olderResponse.json();
5367
const olderDates = olderGranules.feed.entry.map(parseGranuleTimestamp);
@@ -59,16 +73,9 @@ export default function ImagerySearch({ layer }) {
5973
};
6074

6175
const getNewerGranules = async (layer, refDate = selectedDate, pageNum = 1) => {
62-
// clamp extent to maximum extent allowed by the CMR api
63-
const extent = map.extent.map((coord, i) => {
64-
const condition = i <= 1 ? coord > maxExtent[i] : coord < maxExtent[i];
65-
if (condition) {
66-
return coord;
67-
}
68-
return maxExtent[i];
69-
});
76+
const smallerExtent = getSmallerExtent();
7077
try {
71-
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}`;
78+
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}`;
7279
const newerResponse = await fetch(newerUrl, { headers });
7380
const newerGranules = await newerResponse.json();
7481
const newerDates = newerGranules.feed.entry.map(parseGranuleTimestamp);

0 commit comments

Comments
 (0)