File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ export async function fetchStac(
1616 if ( response . ok ) {
1717 return response
1818 . json ( )
19- . then ( ( json ) => maybeAddSelfLink ( json , href . toString ( ) ) ) ;
19+ . then ( ( json ) => maybeAddSelfLink ( json , href . toString ( ) ) )
20+ . then ( ( json ) => maybeAddTypeField ( json ) ) ;
2021 } else {
2122 throw new Error ( `${ method } ${ href } : ${ response . statusText } ` ) ;
2223 }
@@ -44,3 +45,19 @@ function maybeAddSelfLink(value: any, href: string) {
4445 }
4546 return value ;
4647}
48+
49+ // eslint-disable-next-line
50+ function maybeAddTypeField ( value : any ) {
51+ if ( ! value . type ) {
52+ if ( value . features && Array . isArray ( value . features ) ) {
53+ value . type = "FeatureCollection" ;
54+ } else if ( value . extent ) {
55+ value . type = "Collection" ;
56+ } else if ( value . geometry && value . properties ) {
57+ value . type = "Feature" ;
58+ } else if ( value . stac_version ) {
59+ value . type = "Catalog" ;
60+ }
61+ }
62+ return value ;
63+ }
Original file line number Diff line number Diff line change @@ -22,9 +22,22 @@ test("renders example button", async () => {
2222 . toBeVisible ( ) ;
2323} ) ;
2424
25- test ( "loads STAC API from eoapi.dev" , async ( ) => {
25+ test ( "loads stac. eoapi.dev" , async ( ) => {
2626 window . history . pushState ( { } , "" , "?href=https://stac.eoapi.dev/" ) ;
2727 const app = await renderApp ( ) ;
2828 await expect . element ( app . getByText ( / e o A P I - s t a c / i) ) . toBeVisible ( ) ;
2929 await expect . element ( app . getByText ( / c o l l e c t i o n s / i) ) . toBeVisible ( ) ;
3030} ) ;
31+
32+ test ( "loads CSDA Planet" , async ( ) => {
33+ // https://github.com/developmentseed/stac-map/issues/96
34+ window . history . pushState (
35+ { } ,
36+ "" ,
37+ "?href=https://csdap.earthdata.nasa.gov/stac/collections/planet" ,
38+ ) ;
39+ const app = await renderApp ( ) ;
40+ await expect
41+ . element ( app . getByRole ( "heading" , { hasText : "Planet" } ) )
42+ . toBeVisible ( ) ;
43+ } ) ;
You can’t perform that action at this time.
0 commit comments