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(
16
16
if ( response . ok ) {
17
17
return response
18
18
. json ( )
19
- . then ( ( json ) => maybeAddSelfLink ( json , href . toString ( ) ) ) ;
19
+ . then ( ( json ) => maybeAddSelfLink ( json , href . toString ( ) ) )
20
+ . then ( ( json ) => maybeAddTypeField ( json ) ) ;
20
21
} else {
21
22
throw new Error ( `${ method } ${ href } : ${ response . statusText } ` ) ;
22
23
}
@@ -44,3 +45,19 @@ function maybeAddSelfLink(value: any, href: string) {
44
45
}
45
46
return value ;
46
47
}
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 () => {
22
22
. toBeVisible ( ) ;
23
23
} ) ;
24
24
25
- test ( "loads STAC API from eoapi.dev" , async ( ) => {
25
+ test ( "loads stac. eoapi.dev" , async ( ) => {
26
26
window . history . pushState ( { } , "" , "?href=https://stac.eoapi.dev/" ) ;
27
27
const app = await renderApp ( ) ;
28
28
await expect . element ( app . getByText ( / e o A P I - s t a c / i) ) . toBeVisible ( ) ;
29
29
await expect . element ( app . getByText ( / c o l l e c t i o n s / i) ) . toBeVisible ( ) ;
30
30
} ) ;
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