@jupytergis/base 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/lib/annotations/components/Annotation.d.ts +2 -2
  2. package/lib/annotations/components/Annotation.js +3 -3
  3. package/lib/annotations/components/AnnotationFloater.d.ts +1 -1
  4. package/lib/annotations/components/AnnotationFloater.js +2 -2
  5. package/lib/annotations/components/Message.d.ts +2 -1
  6. package/lib/annotations/components/Message.js +3 -3
  7. package/lib/annotations/model.js +5 -5
  8. package/lib/commands/BaseCommandIDs.d.ts +32 -0
  9. package/lib/commands/BaseCommandIDs.js +43 -0
  10. package/lib/{commands.d.ts → commands/index.d.ts} +1 -1
  11. package/lib/{commands.js → commands/index.js} +59 -99
  12. package/lib/console/consoleview.d.ts +3 -3
  13. package/lib/console/consoleview.js +5 -5
  14. package/lib/constants.d.ts +2 -36
  15. package/lib/constants.js +5 -47
  16. package/lib/dialogs/ProcessingFormDialog.d.ts +4 -4
  17. package/lib/dialogs/ProcessingFormDialog.js +9 -11
  18. package/lib/dialogs/layerBrowserDialog.d.ts +1 -1
  19. package/lib/dialogs/layerBrowserDialog.js +7 -7
  20. package/lib/dialogs/layerCreationFormDialog.d.ts +4 -4
  21. package/lib/dialogs/layerCreationFormDialog.js +6 -6
  22. package/lib/dialogs/symbology/components/color_ramp/CanvasSelectComponent.d.ts +1 -1
  23. package/lib/dialogs/symbology/components/color_ramp/CanvasSelectComponent.js +3 -3
  24. package/lib/dialogs/symbology/components/color_ramp/ColorRamp.d.ts +3 -2
  25. package/lib/dialogs/symbology/components/color_ramp/ColorRamp.js +6 -7
  26. package/lib/dialogs/symbology/components/color_ramp/ColorRampEntry.d.ts +1 -1
  27. package/lib/dialogs/symbology/components/color_ramp/ColorRampEntry.js +1 -1
  28. package/lib/dialogs/symbology/components/color_ramp/ModeSelectRow.d.ts +1 -1
  29. package/lib/dialogs/symbology/components/color_ramp/ModeSelectRow.js +1 -1
  30. package/lib/dialogs/symbology/components/color_stops/StopContainer.d.ts +2 -2
  31. package/lib/dialogs/symbology/components/color_stops/StopContainer.js +4 -4
  32. package/lib/dialogs/symbology/components/color_stops/StopRow.d.ts +3 -3
  33. package/lib/dialogs/symbology/components/color_stops/StopRow.js +2 -2
  34. package/lib/dialogs/symbology/hooks/useGetBandInfo.js +5 -5
  35. package/lib/dialogs/symbology/hooks/useGetProperties.d.ts +1 -1
  36. package/lib/dialogs/symbology/hooks/useGetProperties.js +4 -4
  37. package/lib/dialogs/symbology/symbologyDialog.d.ts +8 -0
  38. package/lib/dialogs/symbology/symbologyDialog.js +1 -1
  39. package/lib/dialogs/symbology/symbologyUtils.js +38 -31
  40. package/lib/dialogs/symbology/tiff_layer/TiffRendering.d.ts +2 -2
  41. package/lib/dialogs/symbology/tiff_layer/TiffRendering.js +2 -2
  42. package/lib/dialogs/symbology/tiff_layer/components/BandRow.d.ts +2 -2
  43. package/lib/dialogs/symbology/tiff_layer/components/BandRow.js +4 -4
  44. package/lib/dialogs/symbology/tiff_layer/types/MultibandColor.d.ts +2 -2
  45. package/lib/dialogs/symbology/tiff_layer/types/MultibandColor.js +30 -20
  46. package/lib/dialogs/symbology/tiff_layer/types/SingleBandPseudoColor.d.ts +2 -2
  47. package/lib/dialogs/symbology/tiff_layer/types/SingleBandPseudoColor.js +23 -21
  48. package/lib/dialogs/symbology/vector_layer/VectorRendering.d.ts +2 -2
  49. package/lib/dialogs/symbology/vector_layer/VectorRendering.js +81 -39
  50. package/lib/dialogs/symbology/vector_layer/components/ValueSelect.d.ts +1 -1
  51. package/lib/dialogs/symbology/vector_layer/components/ValueSelect.js +1 -1
  52. package/lib/dialogs/symbology/vector_layer/types/Canonical.d.ts +4 -0
  53. package/lib/dialogs/symbology/vector_layer/types/Canonical.js +66 -0
  54. package/lib/dialogs/symbology/vector_layer/types/Categorized.d.ts +2 -2
  55. package/lib/dialogs/symbology/vector_layer/types/Categorized.js +142 -47
  56. package/lib/dialogs/symbology/vector_layer/types/Graduated.d.ts +2 -2
  57. package/lib/dialogs/symbology/vector_layer/types/Graduated.js +193 -99
  58. package/lib/dialogs/symbology/vector_layer/types/Heatmap.d.ts +2 -2
  59. package/lib/dialogs/symbology/vector_layer/types/Heatmap.js +7 -6
  60. package/lib/dialogs/symbology/vector_layer/types/SimpleSymbol.d.ts +2 -2
  61. package/lib/dialogs/symbology/vector_layer/types/SimpleSymbol.js +33 -30
  62. package/lib/formbuilder/creationform.js +3 -3
  63. package/lib/formbuilder/editform.js +3 -3
  64. package/lib/formbuilder/formselectors.d.ts +1 -1
  65. package/lib/formbuilder/formselectors.js +2 -2
  66. package/lib/formbuilder/objectform/baseform.d.ts +5 -4
  67. package/lib/formbuilder/objectform/baseform.js +16 -14
  68. package/lib/formbuilder/objectform/fileselectorwidget.d.ts +1 -1
  69. package/lib/formbuilder/objectform/fileselectorwidget.js +5 -5
  70. package/lib/formbuilder/objectform/layer/heatmapLayerForm.js +2 -2
  71. package/lib/formbuilder/objectform/layer/hillshadeLayerForm.js +1 -1
  72. package/lib/formbuilder/objectform/layer/layerform.d.ts +1 -1
  73. package/lib/formbuilder/objectform/layer/layerform.js +3 -2
  74. package/lib/formbuilder/objectform/process/dissolveProcessForm.d.ts +1 -1
  75. package/lib/formbuilder/objectform/process/dissolveProcessForm.js +5 -5
  76. package/lib/formbuilder/objectform/source/geojsonsource.js +4 -4
  77. package/lib/formbuilder/objectform/source/geotiffsource.js +4 -4
  78. package/lib/formbuilder/objectform/source/pathbasedsource.js +6 -6
  79. package/lib/formbuilder/objectform/source/sourceform.d.ts +1 -1
  80. package/lib/formbuilder/objectform/source/sourceform.js +1 -1
  81. package/lib/formbuilder/objectform/source/tilesourceform.js +3 -3
  82. package/lib/gdal.js +2 -2
  83. package/lib/icons.js +29 -29
  84. package/lib/index.d.ts +4 -3
  85. package/lib/index.js +4 -3
  86. package/lib/mainview/CollaboratorPointers.d.ts +1 -1
  87. package/lib/mainview/CollaboratorPointers.js +5 -5
  88. package/lib/mainview/FollowIndicator.d.ts +2 -2
  89. package/lib/mainview/FollowIndicator.js +3 -3
  90. package/lib/mainview/TemporalSlider.d.ts +1 -1
  91. package/lib/mainview/TemporalSlider.js +7 -7
  92. package/lib/mainview/mainView.d.ts +4 -2
  93. package/lib/mainview/mainView.js +232 -137
  94. package/lib/menus.d.ts +1 -1
  95. package/lib/menus.js +7 -7
  96. package/lib/panelview/annotationPanel.d.ts +2 -2
  97. package/lib/panelview/annotationPanel.js +1 -1
  98. package/lib/panelview/components/filter-panel/Filter.d.ts +2 -2
  99. package/lib/panelview/components/filter-panel/Filter.js +5 -5
  100. package/lib/panelview/components/filter-panel/FilterRow.d.ts +2 -2
  101. package/lib/panelview/components/identify-panel/IdentifyPanel.d.ts +1 -1
  102. package/lib/panelview/components/identify-panel/IdentifyPanel.js +5 -5
  103. package/lib/panelview/components/layers.d.ts +1 -1
  104. package/lib/panelview/components/layers.js +12 -12
  105. package/lib/panelview/leftpanel.d.ts +4 -2
  106. package/lib/panelview/leftpanel.js +24 -6
  107. package/lib/panelview/model.d.ts +1 -1
  108. package/lib/panelview/objectproperties.d.ts +1 -1
  109. package/lib/panelview/objectproperties.js +3 -3
  110. package/lib/panelview/rightpanel.d.ts +2 -1
  111. package/lib/panelview/rightpanel.js +13 -5
  112. package/lib/{processing.d.ts → processing/index.d.ts} +4 -4
  113. package/lib/{processing.js → processing/index.js} +19 -24
  114. package/lib/processing/processingCommands.d.ts +6 -0
  115. package/lib/processing/processingCommands.js +47 -0
  116. package/lib/processing/processingFormToParam.d.ts +2 -0
  117. package/lib/processing/processingFormToParam.js +15 -0
  118. package/lib/shared/components/Badge.d.ts +7 -0
  119. package/lib/shared/components/Badge.js +20 -0
  120. package/lib/shared/components/Button.d.ts +9 -0
  121. package/lib/shared/components/Button.js +21 -0
  122. package/lib/shared/components/Calendar.d.ts +47 -0
  123. package/lib/shared/components/Calendar.js +184 -0
  124. package/lib/shared/components/Checkbox.d.ts +4 -0
  125. package/lib/shared/components/Checkbox.js +25 -0
  126. package/lib/shared/components/DropdownMenu.d.ts +27 -0
  127. package/lib/shared/components/DropdownMenu.js +92 -0
  128. package/lib/shared/components/Pagination.d.ts +25 -0
  129. package/lib/shared/components/Pagination.js +68 -0
  130. package/lib/shared/components/Popover.d.ts +7 -0
  131. package/lib/shared/components/Popover.js +32 -0
  132. package/lib/shared/components/Tabs.d.ts +7 -0
  133. package/lib/shared/components/Tabs.js +31 -0
  134. package/lib/shared/components/ToggleGroup.d.ts +12 -0
  135. package/lib/shared/components/ToggleGroup.js +52 -0
  136. package/lib/shared/components/loading.d.ts +12 -0
  137. package/lib/shared/components/loading.js +6 -0
  138. package/lib/shared/components/utils.d.ts +2 -0
  139. package/lib/shared/components/utils.js +4 -0
  140. package/lib/shared/hooks/useIsFirstRender.d.ts +2 -0
  141. package/lib/shared/hooks/useIsFirstRender.js +10 -0
  142. package/lib/stacBrowser/StacBrowser.d.ts +7 -0
  143. package/lib/stacBrowser/StacBrowser.js +16 -0
  144. package/lib/stacBrowser/StacPanel.d.ts +14 -0
  145. package/lib/stacBrowser/StacPanel.js +16 -0
  146. package/lib/stacBrowser/components/StacFilterSection.d.ts +23 -0
  147. package/lib/stacBrowser/components/StacFilterSection.js +59 -0
  148. package/lib/stacBrowser/components/StacPanelFilters.d.ts +14 -0
  149. package/lib/stacBrowser/components/StacPanelFilters.js +81 -0
  150. package/lib/stacBrowser/components/StacPanelResults.d.ts +13 -0
  151. package/lib/stacBrowser/components/StacPanelResults.js +48 -0
  152. package/lib/stacBrowser/components/StacPanelView.d.ts +7 -0
  153. package/lib/stacBrowser/components/StacPanelView.js +20 -0
  154. package/lib/stacBrowser/constants.d.ts +25 -0
  155. package/lib/stacBrowser/constants.js +197 -0
  156. package/lib/stacBrowser/hooks/useStacSearch.d.ts +30 -0
  157. package/lib/stacBrowser/hooks/useStacSearch.js +221 -0
  158. package/lib/stacBrowser/index.d.ts +1 -0
  159. package/lib/stacBrowser/index.js +1 -0
  160. package/lib/stacBrowser/types/types.d.ts +124 -0
  161. package/lib/stacBrowser/types/types.js +1 -0
  162. package/lib/statusbar/StatusBar.d.ts +1 -1
  163. package/lib/statusbar/StatusBar.js +3 -3
  164. package/lib/toolbar/index.d.ts +0 -1
  165. package/lib/toolbar/index.js +0 -1
  166. package/lib/toolbar/widget.d.ts +1 -0
  167. package/lib/toolbar/widget.js +37 -16
  168. package/lib/tools.d.ts +29 -4
  169. package/lib/tools.js +74 -69
  170. package/lib/types.d.ts +2 -0
  171. package/lib/widget.d.ts +1 -1
  172. package/lib/widget.js +5 -5
  173. package/package.json +22 -8
  174. package/style/base.css +26 -0
  175. package/style/layerBrowser.css +10 -0
  176. package/style/shared/badge.css +61 -0
  177. package/style/shared/button.css +169 -0
  178. package/style/shared/calendar.css +274 -0
  179. package/style/shared/checkbox.css +28 -0
  180. package/style/shared/dropdownMenu.css +240 -0
  181. package/style/shared/pagination.css +167 -0
  182. package/style/shared/popover.css +53 -0
  183. package/style/shared/tabs.css +57 -0
  184. package/style/shared/toggle.css +85 -0
  185. package/style/stacBrowser.css +91 -0
  186. package/style/symbologyDialog.css +0 -7
  187. package/lib/mainview/spinner.d.ts +0 -6
  188. package/lib/mainview/spinner.js +0 -5
  189. package/lib/toolbar/usertoolbaritem.d.ts +0 -19
  190. package/lib/toolbar/usertoolbaritem.js +0 -59
@@ -0,0 +1,197 @@
1
+ export const datasets = [
2
+ { collection: 'Sentinel 1', datasets: ['PEPS_S1_L1', 'PEPS_S1_L2'] },
3
+ {
4
+ collection: 'Sentinel 2',
5
+ datasets: [
6
+ 'PEPS_S2_L1C',
7
+ 'MUSCATE_SENTINEL2_SENTINEL2_L2A',
8
+ 'MUSCATE_Snow_SENTINEL2_L2B-SNOW',
9
+ 'MUSCATE_WaterQual_SENTINEL2_L2B-WATER',
10
+ 'MUSCATE_SENTINEL2_SENTINEL2_L3A',
11
+ ],
12
+ },
13
+ {
14
+ collection: 'Venus',
15
+ datasets: [
16
+ 'MUSCATE_VENUS_VM1_L1C',
17
+ 'MUSCATE_VENUSVM05_VM5_L1C',
18
+ 'MUSCATE_VENUS_VM1_L2A',
19
+ 'MUSCATE_VENUSVM05_VM5_L2A',
20
+ 'MUSCATE_VENUS_VM1_L3A',
21
+ 'MUSCATE_VENUSVM05_VM5_L3A',
22
+ ],
23
+ },
24
+ {
25
+ collection: 'Spot',
26
+ datasets: [
27
+ 'MUSCATE_SPOTWORLDHERITAGE_SPOT1_L1C',
28
+ 'MUSCATE_SPOTWORLDHERITAGE_SPOT2_L1C',
29
+ 'MUSCATE_SPOTWORLDHERITAGE_SPOT3_L1C',
30
+ 'TAKE5_SPOT4_L1C',
31
+ 'MUSCATE_SPOTWORLDHERITAGE_SPOT4_L1C',
32
+ 'TAKE5_SPOT4_L2A',
33
+ 'TAKE5_SPOT5_L2A',
34
+ 'TAKE5_SPOT5_L1C',
35
+ 'MUSCATE_SPOTWORLDHERITAGE_SPOT5_L1C',
36
+ 'MUSCATE_Spirit_SPOT5_L1A',
37
+ 'SWH_SPOT123_L1',
38
+ 'SWH_SPOT4_L1',
39
+ 'SWH_SPOT5_L1',
40
+ ],
41
+ },
42
+ {
43
+ collection: 'Landsat',
44
+ datasets: [
45
+ 'MUSCATE_Landsat57_LANDSAT5_N2A',
46
+ 'MUSCATE_Landsat57_LANDSAT7_N2A',
47
+ 'MUSCATE_LANDSAT_LANDSAT8_L2A',
48
+ 'MUSCATE_Snow_LANDSAT8_L2B-SNOW',
49
+ ],
50
+ },
51
+ {
52
+ collection: 'OSO',
53
+ datasets: ['MUSCATE_OSO_RASTER_L3B-OSO', 'MUSCATE_OSO_VECTOR_L3B-OSO'],
54
+ },
55
+ {
56
+ collection: 'Postel',
57
+ datasets: [
58
+ 'POSTEL_VEGETATION_LAI',
59
+ 'POSTEL_VEGETATION_FCOVER',
60
+ 'POSTEL_VEGETATION_FAPAR',
61
+ 'POSTEL_VEGETATION_NDVI',
62
+ 'POSTEL_VEGETATION_SURFACEREFLECTANCE',
63
+ 'POSTEL_RADIATION_BRDF',
64
+ 'POSTEL_RADIATION_DLR',
65
+ 'POSTEL_RADIATION_SURFACEREFLECTANCE',
66
+ 'POSTEL_RADIATION_SURFACEALBEDO',
67
+ 'POSTEL_WATER_SOILMOISTURE',
68
+ 'POSTEL_WATER_SWI',
69
+ 'POSTEL_WATER_SURFWET',
70
+ 'POSTEL_WATER_PRECIP',
71
+ 'POSTEL_LANDCOVER_GLOBCOVER',
72
+ ],
73
+ },
74
+ {
75
+ collection: 'GEOV2 AVHRR',
76
+ datasets: [
77
+ 'POSTEL_VEGETATION_LAI',
78
+ 'POSTEL_VEGETATION_FCOVER',
79
+ 'POSTEL_VEGETATION_FAPAR',
80
+ 'POSTEL_VEGETATION_NDVI',
81
+ ],
82
+ },
83
+ ];
84
+ // map collection names to available platforms
85
+ export const platforms = {
86
+ 'Sentinel 1': ['S1A', 'S1B'],
87
+ 'Sentinel 2': ['S2A', 'S2B', 'S2X'],
88
+ Venus: ['VM1', 'VM5'],
89
+ Spot: [
90
+ 'SPOT1',
91
+ 'SPOT2',
92
+ 'SPOT3',
93
+ 'SPOT4',
94
+ 'SPOT5',
95
+ 'SPOT4_TAKE5',
96
+ 'SPOT5_TAKE5',
97
+ ],
98
+ Landsat: ['LANDSAT5', 'LANDSAT7', 'LANDSAT8'],
99
+ // OSO, Postel, and GEOV2 don't have platforms
100
+ };
101
+ export const products = [
102
+ {
103
+ productCode: 'SLC',
104
+ productType: ['SLC'],
105
+ processingLevel: 'L1',
106
+ collections: ['Sentinel 1'],
107
+ },
108
+ {
109
+ productCode: 'GRD',
110
+ productType: ['GRD'],
111
+ processingLevel: 'L1',
112
+ collections: ['Sentinel 1'],
113
+ },
114
+ {
115
+ productCode: 'OCN',
116
+ productType: ['OCN'],
117
+ processingLevel: 'L2',
118
+ collections: ['Sentinel 1'],
119
+ },
120
+ {
121
+ productCode: 'L1C',
122
+ productType: ['REFLECTANCE', 'REFLECTANCETOA', 'S2MSI1C'],
123
+ processingLevel: 'L1C',
124
+ collections: ['Sentinel 2', 'Venus', 'Spot'],
125
+ },
126
+ {
127
+ productCode: 'L2A',
128
+ productType: ['REFLECTANCE'],
129
+ processingLevel: 'L2A',
130
+ collections: ['Sentinel 2', 'Venus', 'Spot', 'Landsat'],
131
+ },
132
+ {
133
+ productCode: 'L2B SNOW',
134
+ productType: ['SNOW_MASK'],
135
+ processingLevel: 'L2B-SNOW',
136
+ collections: ['Sentinel 2', 'Landsat'],
137
+ },
138
+ {
139
+ productCode: 'L2B WATER',
140
+ productType: ['REFLECTANCE'],
141
+ processingLevel: 'L2B-WATER',
142
+ collections: ['Sentinel 2'],
143
+ },
144
+ {
145
+ productCode: 'L3A',
146
+ productType: ['REFLECTANCE'],
147
+ processingLevel: 'L3A',
148
+ collections: ['Sentinel 2', 'Venus'],
149
+ },
150
+ {
151
+ productCode: 'L1A',
152
+ productType: [
153
+ 'DEM',
154
+ 'REFLECTANCETOA',
155
+ 'DEM9V20',
156
+ 'DEMS9V20',
157
+ 'DEMS09V20',
158
+ 'DEMSV20',
159
+ 'DEPS9V20',
160
+ 'SPOTDEM',
161
+ ],
162
+ processingLevel: 'L1A',
163
+ collections: ['Spot'],
164
+ },
165
+ {
166
+ productCode: 'N2A',
167
+ productType: ['REFLECTANCE'],
168
+ processingLevel: 'N2A',
169
+ collections: ['Landsat'],
170
+ },
171
+ {
172
+ productCode: 'L3B-OSO',
173
+ productType: ['REFLECTANCE'],
174
+ processingLevel: 'L3B-OSO',
175
+ collections: ['OSO'],
176
+ },
177
+ {
178
+ productCode: 'Vegetation',
179
+ productType: ['Vegetation'],
180
+ collections: ['Postel', 'GEOV2 AVHRR'],
181
+ },
182
+ {
183
+ productCode: 'Radiation',
184
+ productType: ['Radiation'],
185
+ collections: ['Postel'],
186
+ },
187
+ {
188
+ productCode: 'Water',
189
+ productType: ['Water'],
190
+ collections: ['Postel'],
191
+ },
192
+ {
193
+ productCode: 'LandCover',
194
+ productType: ['LandCover'],
195
+ collections: ['Postel'],
196
+ },
197
+ ];
@@ -0,0 +1,30 @@
1
+ import { IJupyterGISModel } from '@jupytergis/schema';
2
+ import { IStacItem, StacFilterState, StacFilterSetters } from "../types/types";
3
+ interface IUseStacSearchProps {
4
+ model: IJupyterGISModel | undefined;
5
+ }
6
+ interface IUseStacSearchReturn {
7
+ filterState: StacFilterState;
8
+ filterSetters: StacFilterSetters;
9
+ results: IStacItem[];
10
+ startTime: Date | undefined;
11
+ setStartTime: (date: Date | undefined) => void;
12
+ endTime: Date | undefined;
13
+ setEndTime: (date: Date | undefined) => void;
14
+ totalPages: number;
15
+ currentPage: number;
16
+ totalResults: number;
17
+ handlePaginationClick: (page: number) => Promise<void>;
18
+ handleResultClick: (id: string) => Promise<void>;
19
+ formatResult: (item: IStacItem) => string;
20
+ isLoading: boolean;
21
+ useWorldBBox: boolean;
22
+ setUseWorldBBox: (val: boolean) => void;
23
+ }
24
+ /**
25
+ * Custom hook for managing STAC search functionality
26
+ * @param props - Configuration object containing datasets, platforms, products, and model
27
+ * @returns Object containing state and handlers for STAC search
28
+ */
29
+ declare function useStacSearch({ model }: IUseStacSearchProps): IUseStacSearchReturn;
30
+ export default useStacSearch;
@@ -0,0 +1,221 @@
1
+ var _a;
2
+ import { UUID } from '@lumino/coreutils';
3
+ import { startOfYesterday } from 'date-fns';
4
+ import { useEffect, useState } from 'react';
5
+ import useIsFirstRender from "../../shared/hooks/useIsFirstRender";
6
+ import { products } from "../constants";
7
+ import { GlobalStateDbManager } from "../../store";
8
+ import { fetchWithProxies } from "../../tools";
9
+ const API_URL = 'https://geodes-portal.cnes.fr/api/stac/search';
10
+ const XSRF_TOKEN = (_a = document.cookie.match(/_xsrf=([^;]+)/)) === null || _a === void 0 ? void 0 : _a[1];
11
+ const STAC_FILTERS_KEY = 'jupytergis:stac-filters';
12
+ /**
13
+ * Custom hook for managing STAC search functionality
14
+ * @param props - Configuration object containing datasets, platforms, products, and model
15
+ * @returns Object containing state and handlers for STAC search
16
+ */
17
+ function useStacSearch({ model }) {
18
+ const isFirstRender = useIsFirstRender();
19
+ const stateDb = GlobalStateDbManager.getInstance().getStateDb();
20
+ const [results, setResults] = useState([]);
21
+ const [isLoading, setIsLoading] = useState(false);
22
+ const [totalPages, setTotalPages] = useState(1);
23
+ const [currentPage, setCurrentPage] = useState(1);
24
+ const [totalResults, setTotalResults] = useState(0);
25
+ const [startTime, setStartTime] = useState(undefined);
26
+ const [endTime, setEndTime] = useState(undefined);
27
+ const [currentBBox, setCurrentBBox] = useState([-180, -90, 180, 90]);
28
+ const [useWorldBBox, setUseWorldBBox] = useState(false);
29
+ const [filterState, setFilterState] = useState({
30
+ collections: new Set(),
31
+ datasets: new Set(),
32
+ platforms: new Set(),
33
+ products: new Set(),
34
+ });
35
+ const filterSetters = {
36
+ collections: val => setFilterState(s => (Object.assign(Object.assign({}, s), { collections: new Set(val) }))),
37
+ datasets: val => setFilterState(s => (Object.assign(Object.assign({}, s), { datasets: new Set(val) }))),
38
+ platforms: val => setFilterState(s => (Object.assign(Object.assign({}, s), { platforms: new Set(val) }))),
39
+ products: val => setFilterState(s => (Object.assign(Object.assign({}, s), { products: new Set(val) }))),
40
+ };
41
+ // On mount, fetch filterState and times from StateDB (if present)
42
+ useEffect(() => {
43
+ async function loadStacStateFromDb() {
44
+ var _a, _b, _c, _d;
45
+ const savedFilterState = (await (stateDb === null || stateDb === void 0 ? void 0 : stateDb.fetch(STAC_FILTERS_KEY)));
46
+ setFilterState({
47
+ collections: new Set((_a = savedFilterState === null || savedFilterState === void 0 ? void 0 : savedFilterState.collections) !== null && _a !== void 0 ? _a : []),
48
+ datasets: new Set((_b = savedFilterState === null || savedFilterState === void 0 ? void 0 : savedFilterState.datasets) !== null && _b !== void 0 ? _b : []),
49
+ platforms: new Set((_c = savedFilterState === null || savedFilterState === void 0 ? void 0 : savedFilterState.platforms) !== null && _c !== void 0 ? _c : []),
50
+ products: new Set((_d = savedFilterState === null || savedFilterState === void 0 ? void 0 : savedFilterState.products) !== null && _d !== void 0 ? _d : []),
51
+ });
52
+ }
53
+ loadStacStateFromDb();
54
+ }, [stateDb]);
55
+ // Save filterState to StateDB on change
56
+ useEffect(() => {
57
+ async function saveStacFilterStateToDb() {
58
+ await (stateDb === null || stateDb === void 0 ? void 0 : stateDb.save(STAC_FILTERS_KEY, {
59
+ collections: Array.from(filterState.collections),
60
+ datasets: Array.from(filterState.datasets),
61
+ platforms: Array.from(filterState.platforms),
62
+ products: Array.from(filterState.products),
63
+ }));
64
+ }
65
+ saveStacFilterStateToDb();
66
+ }, [filterState, stateDb]);
67
+ // Handle search when filters change
68
+ useEffect(() => {
69
+ if (model && !isFirstRender && filterState.datasets.size > 0) {
70
+ setCurrentPage(1);
71
+ fetchResults(1);
72
+ }
73
+ }, [filterState, startTime, endTime, currentBBox]);
74
+ // Listen for model updates to get current bounding box
75
+ useEffect(() => {
76
+ const listenToModel = (sender, bBoxIn4326) => {
77
+ if (useWorldBBox) {
78
+ setCurrentBBox([-180, -90, 180, 90]);
79
+ }
80
+ else {
81
+ setCurrentBBox(bBoxIn4326);
82
+ }
83
+ };
84
+ model === null || model === void 0 ? void 0 : model.updateBboxSignal.connect(listenToModel);
85
+ return () => {
86
+ model === null || model === void 0 ? void 0 : model.updateBboxSignal.disconnect(listenToModel);
87
+ };
88
+ }, [model, useWorldBBox]);
89
+ const fetchResults = async (page = 1) => {
90
+ const processingLevel = new Set();
91
+ const productType = new Set();
92
+ filterState.products.forEach(productCode => {
93
+ products
94
+ .filter(product => product.productCode === productCode)
95
+ .forEach(product => {
96
+ if (product.processingLevel) {
97
+ processingLevel.add(product.processingLevel);
98
+ }
99
+ if (product.productType) {
100
+ product.productType.forEach(type => productType.add(type));
101
+ }
102
+ });
103
+ });
104
+ const body = {
105
+ bbox: currentBBox,
106
+ limit: 12,
107
+ page,
108
+ query: Object.assign(Object.assign(Object.assign(Object.assign({ latest: { eq: true }, dataset: { in: Array.from(filterState.datasets) }, end_datetime: {
109
+ gte: startTime
110
+ ? startTime.toISOString()
111
+ : startOfYesterday().toISOString(),
112
+ } }, (endTime && {
113
+ start_datetime: { lte: endTime.toISOString() },
114
+ })), (filterState.platforms.size > 0 && {
115
+ platform: { in: Array.from(filterState.platforms) },
116
+ })), (processingLevel.size > 0 && {
117
+ 'processing:level': { in: Array.from(processingLevel) },
118
+ })), (productType.size > 0 && {
119
+ 'product:type': { in: Array.from(productType) },
120
+ })),
121
+ sortBy: [{ direction: 'desc', field: 'start_datetime' }],
122
+ };
123
+ try {
124
+ setIsLoading(true);
125
+ const options = {
126
+ method: 'POST',
127
+ headers: {
128
+ 'Content-Type': 'application/json',
129
+ 'X-XSRFToken': XSRF_TOKEN,
130
+ credentials: 'include',
131
+ },
132
+ body: JSON.stringify(body),
133
+ };
134
+ if (!model) {
135
+ return;
136
+ }
137
+ const data = (await fetchWithProxies(API_URL, model, async (response) => await response.json(),
138
+ //@ts-expect-error Jupyter requires X-XSRFToken header
139
+ options, 'internal'));
140
+ if (!data) {
141
+ console.log('No Results found');
142
+ setResults([]);
143
+ setTotalPages(1);
144
+ setTotalResults(0);
145
+ return;
146
+ }
147
+ setResults(data.features);
148
+ const pages = data.context.matched / data.context.limit;
149
+ setTotalPages(Math.ceil(pages));
150
+ setTotalResults(data.context.matched);
151
+ }
152
+ catch (error) {
153
+ console.error('Error fetching data:', error);
154
+ setResults([]);
155
+ setTotalPages(1);
156
+ setTotalResults(0);
157
+ }
158
+ finally {
159
+ setIsLoading(false);
160
+ }
161
+ };
162
+ /**
163
+ * Handles clicking on a result item
164
+ * @param id - ID of the clicked result
165
+ */
166
+ const handleResultClick = async (id) => {
167
+ var _a;
168
+ if (!results) {
169
+ return;
170
+ }
171
+ const layerId = UUID.uuid4();
172
+ const stacData = results.find(item => item.id === id);
173
+ if (!stacData) {
174
+ console.error('Result not found:', id);
175
+ return;
176
+ }
177
+ const layerModel = {
178
+ type: 'StacLayer',
179
+ parameters: { data: stacData },
180
+ visible: true,
181
+ name: (_a = stacData.properties.title) !== null && _a !== void 0 ? _a : stacData.id,
182
+ };
183
+ model && model.addLayer(layerId, layerModel);
184
+ };
185
+ /**
186
+ * Handles pagination clicks
187
+ * @param page - Page number to navigate to
188
+ */
189
+ const handlePaginationClick = async (page) => {
190
+ setCurrentPage(page);
191
+ model && fetchResults(page);
192
+ };
193
+ /**
194
+ * Formats a result item for display
195
+ * @param item - STAC item to format
196
+ * @returns Formatted string representation of the item
197
+ */
198
+ const formatResult = (item) => {
199
+ var _a;
200
+ return (_a = item.properties.title) !== null && _a !== void 0 ? _a : item.id;
201
+ };
202
+ return {
203
+ filterState,
204
+ filterSetters,
205
+ results,
206
+ startTime,
207
+ setStartTime,
208
+ endTime,
209
+ setEndTime,
210
+ totalPages,
211
+ currentPage,
212
+ totalResults,
213
+ handlePaginationClick,
214
+ handleResultClick,
215
+ formatResult,
216
+ isLoading,
217
+ useWorldBBox,
218
+ setUseWorldBBox,
219
+ };
220
+ }
221
+ export default useStacSearch;
@@ -0,0 +1 @@
1
+ export * from './StacBrowser';
@@ -0,0 +1 @@
1
+ export * from './StacBrowser';
@@ -0,0 +1,124 @@
1
+ export interface IStacCollection {
2
+ type: 'Collection';
3
+ stac_version: string;
4
+ stac_extensions?: string[];
5
+ id: string;
6
+ title?: string;
7
+ description: string;
8
+ keywords?: string[];
9
+ license: string;
10
+ providers?: IStacProvider[];
11
+ extent: IStacExtent;
12
+ summaries?: {
13
+ [key: string]: IStacRange | JSON;
14
+ };
15
+ links: IStacLink[];
16
+ assets?: {
17
+ [key: string]: IStacAsset;
18
+ };
19
+ }
20
+ export interface IStacRange {
21
+ minimum: number | string;
22
+ maximum: number | string;
23
+ }
24
+ export interface IStacExtent {
25
+ spatial: IStacSpacialExtent;
26
+ temporal: IStacTemporalExtent;
27
+ }
28
+ export interface IStacTemporalExtent {
29
+ interval: Array<[string | null, string | null]>;
30
+ }
31
+ export interface IStacSpacialExtent {
32
+ bbox: number[][];
33
+ }
34
+ export interface IStacProvider {
35
+ name: string;
36
+ description?: string;
37
+ roles?: ['licensor' | 'producer' | 'processor' | 'host'];
38
+ url?: string;
39
+ }
40
+ export interface IStacLink {
41
+ rel: string;
42
+ href: string;
43
+ type?: string;
44
+ title?: string;
45
+ }
46
+ export interface IStacAsset {
47
+ href: string;
48
+ title?: string;
49
+ description?: string;
50
+ type?: string;
51
+ roles?: string[];
52
+ }
53
+ export interface IStacItem {
54
+ type: 'Feature';
55
+ stac_version: string;
56
+ stac_extensions?: string[];
57
+ id: string;
58
+ geometry: {
59
+ type: 'Polygon';
60
+ coordinates: number[];
61
+ } | null;
62
+ bbox: [number, number, number, number] | null;
63
+ properties: {
64
+ title: string;
65
+ description: string;
66
+ datetime: null | string;
67
+ start_datetime: string;
68
+ end_datetime: string;
69
+ created: string;
70
+ updated: string;
71
+ platform: string;
72
+ instruments: string[];
73
+ constellation: string;
74
+ mission: string;
75
+ gsd: number;
76
+ [key: string]: any;
77
+ };
78
+ links: IStacLink[];
79
+ assets: Record<string, IStacAsset>;
80
+ collection: string;
81
+ }
82
+ export interface IStacSearchResult {
83
+ context: {
84
+ returned: number;
85
+ limit: number;
86
+ matched: number;
87
+ };
88
+ features: IStacItem[];
89
+ links: IStacLink[];
90
+ stac_extensions: string[];
91
+ stac_version: string;
92
+ type: 'FeatureCollection';
93
+ }
94
+ export interface IStacQueryBody {
95
+ bbox: [number, number, number, number];
96
+ limit?: number;
97
+ page?: number;
98
+ query: {
99
+ dataset: {
100
+ in: string[];
101
+ };
102
+ end_datetime: {
103
+ gte: string;
104
+ };
105
+ latest: {
106
+ eq: true;
107
+ };
108
+ platform?: {
109
+ in: string[];
110
+ };
111
+ };
112
+ sortBy: [
113
+ {
114
+ direction: 'desc';
115
+ field: 'start_datetime';
116
+ }
117
+ ];
118
+ }
119
+ export type StacFilterKey = 'collections' | 'datasets' | 'platforms' | 'products';
120
+ export type StacFilterState = Record<StacFilterKey, Set<string>>;
121
+ export type StacFilterStateStateDb = {
122
+ [K in keyof StacFilterState]: string[];
123
+ };
124
+ export type StacFilterSetters = Record<StacFilterKey, (val: Set<string>) => void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -9,5 +9,5 @@ interface IStatusBarProps {
9
9
  };
10
10
  scale: number;
11
11
  }
12
- declare const StatusBar: ({ jgisModel, loading, projection, scale }: IStatusBarProps) => React.JSX.Element;
12
+ declare const StatusBar: React.FC<IStatusBarProps>;
13
13
  export default StatusBar;
@@ -1,9 +1,9 @@
1
- import { faGlobe, faLocationDot, faRuler } from '@fortawesome/free-solid-svg-icons';
1
+ import { faGlobe, faLocationDot, faRuler, } from '@fortawesome/free-solid-svg-icons';
2
2
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
3
  import { Progress } from '@jupyter/react-components';
4
4
  import React, { useEffect, useState } from 'react';
5
- import { version } from '../../package.json'; // Adjust the path as necessary
6
- const StatusBar = ({ jgisModel, loading, projection, scale }) => {
5
+ import { version } from "../../package.json";
6
+ const StatusBar = ({ jgisModel, loading, projection, scale, }) => {
7
7
  var _a;
8
8
  const [coords, setCoords] = useState({ x: 0, y: 0 });
9
9
  useEffect(() => {
@@ -1,2 +1 @@
1
- export * from './usertoolbaritem';
2
1
  export * from './widget';
@@ -1,2 +1 @@
1
- export * from './usertoolbaritem';
2
1
  export * from './widget';
@@ -11,6 +11,7 @@ export declare class Separator extends Widget {
11
11
  constructor();
12
12
  }
13
13
  export declare class ToolbarWidget extends ReactiveToolbar {
14
+ private _model;
14
15
  constructor(options: ToolbarWidget.IOptions);
15
16
  }
16
17
  export declare namespace ToolbarWidget {