@jupytergis/base 0.5.0 → 0.6.0

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 (189) 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 +19 -0
  120. package/lib/shared/components/Button.d.ts +9 -0
  121. package/lib/shared/components/Button.js +20 -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 +49 -0
  148. package/lib/stacBrowser/components/StacPanelFilters.d.ts +14 -0
  149. package/lib/stacBrowser/components/StacPanelFilters.js +65 -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.js +15 -15
  167. package/lib/tools.d.ts +29 -4
  168. package/lib/tools.js +74 -69
  169. package/lib/types.d.ts +2 -0
  170. package/lib/widget.d.ts +1 -1
  171. package/lib/widget.js +5 -5
  172. package/package.json +22 -8
  173. package/style/base.css +26 -0
  174. package/style/layerBrowser.css +10 -0
  175. package/style/shared/badge.css +61 -0
  176. package/style/shared/button.css +164 -0
  177. package/style/shared/calendar.css +274 -0
  178. package/style/shared/checkbox.css +28 -0
  179. package/style/shared/dropdownMenu.css +240 -0
  180. package/style/shared/pagination.css +167 -0
  181. package/style/shared/popover.css +53 -0
  182. package/style/shared/tabs.css +57 -0
  183. package/style/shared/toggle.css +85 -0
  184. package/style/stacBrowser.css +74 -0
  185. package/style/symbologyDialog.css +0 -7
  186. package/lib/mainview/spinner.d.ts +0 -6
  187. package/lib/mainview/spinner.js +0 -5
  188. package/lib/toolbar/usertoolbaritem.d.ts +0 -19
  189. package/lib/toolbar/usertoolbaritem.js +0 -59
@@ -1,11 +1,11 @@
1
+ import { UsersItem } from '@jupyter/collaboration';
1
2
  import { CommandToolbarButton } from '@jupyterlab/apputils';
2
- import { MenuSvg, ReactWidget, ReactiveToolbar, ToolbarButton, addIcon, redoIcon, undoIcon } from '@jupyterlab/ui-components';
3
+ import { MenuSvg, ReactWidget, ReactiveToolbar, ToolbarButton, addIcon, redoIcon, undoIcon, } from '@jupyterlab/ui-components';
3
4
  import { Widget } from '@lumino/widgets';
4
5
  import * as React from 'react';
5
- import { CommandIDs } from '../constants';
6
- import { terminalToolbarIcon } from '../icons';
7
- import { rasterSubMenu, vectorSubMenu } from '../menus';
8
- import { UsersItem } from './usertoolbaritem';
6
+ import { CommandIDs } from "../constants";
7
+ import { terminalToolbarIcon } from "../icons";
8
+ import { rasterSubMenu, vectorSubMenu } from "../menus";
9
9
  export const TOOLBAR_SEPARATOR_CLASS = 'jGIS-Toolbar-Separator';
10
10
  export const TOOLBAR_GROUPNAME_CLASS = 'jGIS-Toolbar-GroupName';
11
11
  export class Separator extends Widget {
@@ -26,7 +26,7 @@ export class ToolbarWidget extends ReactiveToolbar {
26
26
  id: CommandIDs.undo,
27
27
  label: '',
28
28
  icon: undoIcon,
29
- commands: options.commands
29
+ commands: options.commands,
30
30
  });
31
31
  this.addItem('undo', undoButton);
32
32
  undoButton.node.dataset.testid = 'undo-button';
@@ -34,7 +34,7 @@ export class ToolbarWidget extends ReactiveToolbar {
34
34
  id: CommandIDs.redo,
35
35
  label: '',
36
36
  icon: redoIcon,
37
- commands: options.commands
37
+ commands: options.commands,
38
38
  });
39
39
  this.addItem('redo', redoButton);
40
40
  this.addItem('separator0', new Separator());
@@ -42,7 +42,7 @@ export class ToolbarWidget extends ReactiveToolbar {
42
42
  id: CommandIDs.toggleConsole,
43
43
  commands: options.commands,
44
44
  label: '',
45
- icon: terminalToolbarIcon
45
+ icon: terminalToolbarIcon,
46
46
  });
47
47
  this.addItem('Toggle console', toggleConsoleButton);
48
48
  toggleConsoleButton.node.dataset.testid = 'toggle-console-button';
@@ -50,7 +50,7 @@ export class ToolbarWidget extends ReactiveToolbar {
50
50
  const openLayersBrowserButton = new CommandToolbarButton({
51
51
  id: CommandIDs.openLayerBrowser,
52
52
  label: '',
53
- commands: options.commands
53
+ commands: options.commands,
54
54
  });
55
55
  this.addItem('openLayerBrowser', openLayersBrowserButton);
56
56
  openLayersBrowserButton.node.dataset.testid = 'open-layers-browser';
@@ -58,11 +58,11 @@ export class ToolbarWidget extends ReactiveToolbar {
58
58
  NewSubMenu.title.label = 'Add Layer';
59
59
  NewSubMenu.addItem({
60
60
  type: 'submenu',
61
- submenu: rasterSubMenu(options.commands)
61
+ submenu: rasterSubMenu(options.commands),
62
62
  });
63
63
  NewSubMenu.addItem({
64
64
  type: 'submenu',
65
- submenu: vectorSubMenu(options.commands)
65
+ submenu: vectorSubMenu(options.commands),
66
66
  });
67
67
  const NewEntryButton = new ToolbarButton({
68
68
  icon: addIcon,
@@ -73,7 +73,7 @@ export class ToolbarWidget extends ReactiveToolbar {
73
73
  }
74
74
  const bbox = NewEntryButton.node.getBoundingClientRect();
75
75
  NewSubMenu.open(bbox.x, bbox.bottom);
76
- }
76
+ },
77
77
  });
78
78
  NewEntryButton.node.dataset.testid = 'new-entry-button';
79
79
  this.addItem('New', NewEntryButton);
@@ -81,21 +81,21 @@ export class ToolbarWidget extends ReactiveToolbar {
81
81
  const geolocationButton = new CommandToolbarButton({
82
82
  id: CommandIDs.getGeolocation,
83
83
  commands: options.commands,
84
- label: ''
84
+ label: '',
85
85
  });
86
86
  this.addItem('Geolocation', geolocationButton);
87
87
  geolocationButton.node.dataset.testid = 'geolocation-button';
88
88
  const identifyButton = new CommandToolbarButton({
89
89
  id: CommandIDs.identify,
90
90
  label: '',
91
- commands: options.commands
91
+ commands: options.commands,
92
92
  });
93
93
  this.addItem('identify', identifyButton);
94
94
  identifyButton.node.dataset.testid = 'identify-button';
95
95
  const temporalControllerButton = new CommandToolbarButton({
96
96
  id: CommandIDs.temporalController,
97
97
  label: '',
98
- commands: options.commands
98
+ commands: options.commands,
99
99
  });
100
100
  this.addItem('temporalController', temporalControllerButton);
101
101
  temporalControllerButton.node.dataset.testid =
package/lib/tools.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { VectorTile } from '@mapbox/vector-tile';
2
- import { Contents } from '@jupyterlab/services';
3
1
  import { IDict, IJGISLayerBrowserRegistry, IJGISOptions, IJGISSource, IJupyterGISModel } from '@jupytergis/schema';
2
+ import { Contents } from '@jupyterlab/services';
3
+ import { VectorTile } from '@mapbox/vector-tile';
4
4
  export declare const debounce: (func: CallableFunction, timeout?: number) => CallableFunction;
5
5
  export declare function throttle<T extends (...args: any[]) => void>(callback: T, delay?: number): T;
6
6
  export declare function getElementFromProperty(filePath?: string | null, prop?: string | null): HTMLElement | undefined | null;
@@ -31,7 +31,7 @@ export interface IParsedStyle {
31
31
  capStyle: string;
32
32
  radius?: number;
33
33
  }
34
- export declare function parseColor(type: string, style: any): IParsedStyle | undefined;
34
+ export declare function parseColor(style: any): IParsedStyle | undefined;
35
35
  /**
36
36
  * Open or create an IndexedDB database for caching GeoTIFF files.
37
37
  *
@@ -57,6 +57,9 @@ export declare const getFromIndexedDB: (key: string) => Promise<{
57
57
  file: any;
58
58
  metadata?: any | undefined;
59
59
  } | undefined>;
60
+ export declare const isJupyterLite: () => boolean;
61
+ type ProxyStrategy = 'direct' | 'internal' | 'external';
62
+ export declare const fetchWithProxies: <T>(url: string, model: IJupyterGISModel, parseResponse: (response: Response) => Promise<T>, options?: RequestInit, strategy?: ProxyStrategy) => Promise<T | null>;
60
63
  /**
61
64
  * Load a GeoTIFF file from IndexedDB database cache or fetch it .
62
65
  *
@@ -69,7 +72,7 @@ export declare const loadGeoTiff: (sourceInfo: {
69
72
  file: any;
70
73
  metadata: any;
71
74
  sourceUrl: string;
72
- } | null>;
75
+ } | null | undefined>;
73
76
  /**
74
77
  * Generalized file reader for different source types.
75
78
  *
@@ -109,6 +112,28 @@ export declare const getMimeType: (filename: string) => string;
109
112
  * @returns An ArrayBuffer.
110
113
  */
111
114
  export declare const stringToArrayBuffer: (content: string) => Promise<ArrayBuffer>;
115
+ /**
116
+ * Get attributes of the feature which are numeric.
117
+ *
118
+ * @param featureProperties - Attributes of a feature.
119
+ * @returns - Attributes which are numeric.
120
+ */
112
121
  export declare const getNumericFeatureAttributes: (featureProperties: Record<string, Set<any>>) => Record<string, Set<number>>;
122
+ /**
123
+ * Get attributes of the feature which look like hex color codes.
124
+ *
125
+ * @param featureProperties - Attributes of a feature.
126
+ * @returns - Attributes which look like hex color codes.
127
+ */
128
+ export declare const getColorCodeFeatureAttributes: (featureProperties: Record<string, Set<any>>) => Record<string, Set<string>>;
113
129
  export declare function downloadFile(content: BlobPart, fileName: string, mimeType: string): void;
114
130
  export declare function getGeoJSONDataFromLayerSource(source: IJGISSource, model: IJupyterGISModel): Promise<string | null>;
131
+ /**
132
+ * `Object.entries`, but strongly-typed.
133
+ *
134
+ * `Object.entries` return value is always typed as `[string, any]` for type
135
+ * safety reasons, which means we need to use type assertions to have typed
136
+ * code when using it.
137
+ */
138
+ export declare const objectEntries: <T extends Record<PropertyKey, unknown>>(obj: T) => Array<{ [K in keyof T]: [K, T[K]]; }[keyof T]>;
139
+ export {};
package/lib/tools.js CHANGED
@@ -1,12 +1,11 @@
1
- import Protobuf from 'pbf';
2
- import { VectorTile } from '@mapbox/vector-tile';
1
+ import { showErrorMessage } from '@jupyterlab/apputils';
3
2
  import { PathExt, URLExt } from '@jupyterlab/coreutils';
4
3
  import { ServerConnection } from '@jupyterlab/services';
5
- import { showErrorMessage } from '@jupyterlab/apputils';
4
+ import { VectorTile } from '@mapbox/vector-tile';
6
5
  import * as d3Color from 'd3-color';
6
+ import Protobuf from 'pbf';
7
7
  import shp from 'shpjs';
8
- import { getGdal } from './gdal';
9
- import RASTER_LAYER_GALLERY from '../rasterlayer_gallery/raster_layer_gallery.json';
8
+ import RASTER_LAYER_GALLERY from "../rasterlayer_gallery/raster_layer_gallery.json";
10
9
  export const debounce = (func, timeout = 100) => {
11
10
  let timeoutId;
12
11
  return (...args) => {
@@ -161,8 +160,8 @@ export function createDefaultLayerRegistry(layerBrowserRegistry) {
161
160
  maxZoom: xyzprovider['max_zoom'] || 24,
162
161
  attribution: xyzprovider['attribution'] || '',
163
162
  provider: provider !== null && provider !== void 0 ? provider : entry,
164
- urlParameters
165
- }
163
+ urlParameters,
164
+ },
166
165
  };
167
166
  }
168
167
  }
@@ -215,38 +214,19 @@ export async function getLayerTileInfo(tileUrl, mapOptions, urlParameters) {
215
214
  const tile = new VectorTile(new Protobuf(arrayBuffer));
216
215
  return tile;
217
216
  }
218
- export function parseColor(type, style) {
217
+ export function parseColor(style) {
219
218
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
220
- if (!type || !style) {
219
+ if (!style) {
221
220
  return;
222
221
  }
223
- const type2 = type === 'circle' ? 'circle' : 'default';
224
- const shapeStyles = {
225
- circle: {
226
- radius: (_a = style['circle-radius']) !== null && _a !== void 0 ? _a : 5,
227
- fillColor: (_b = style['circle-fill-color']) !== null && _b !== void 0 ? _b : '#3399CC',
228
- strokeColor: (_c = style['circle-stroke-color']) !== null && _c !== void 0 ? _c : '#3399CC',
229
- strokeWidth: (_d = style['circle-stroke-width']) !== null && _d !== void 0 ? _d : 1.25,
230
- joinStyle: (_e = style['circle-stroke-line-join']) !== null && _e !== void 0 ? _e : 'round',
231
- capStyle: (_f = style['circle-stroke-line-cap']) !== null && _f !== void 0 ? _f : 'round'
232
- },
233
- default: {
234
- fillColor: (_g = style['fill-color']) !== null && _g !== void 0 ? _g : '[255, 255, 255, 0.4]',
235
- strokeColor: (_h = style['stroke-color']) !== null && _h !== void 0 ? _h : '#3399CC',
236
- strokeWidth: (_j = style['stroke-width']) !== null && _j !== void 0 ? _j : 1.25,
237
- capStyle: (_k = style['stroke-line-cap']) !== null && _k !== void 0 ? _k : 'round',
238
- joinStyle: (_l = style['stroke-line-join']) !== null && _l !== void 0 ? _l : 'round'
239
- }
222
+ const parsedStyle = {
223
+ radius: (_a = style['circle-radius']) !== null && _a !== void 0 ? _a : 5,
224
+ fillColor: (_c = (_b = style['circle-fill-color']) !== null && _b !== void 0 ? _b : style['fill-color']) !== null && _c !== void 0 ? _c : '#3399CC',
225
+ strokeColor: (_e = (_d = style['circle-stroke-color']) !== null && _d !== void 0 ? _d : style['stroke-color']) !== null && _e !== void 0 ? _e : '#3399CC',
226
+ strokeWidth: (_g = (_f = style['circle-stroke-width']) !== null && _f !== void 0 ? _f : style['stroke-width']) !== null && _g !== void 0 ? _g : 1.25,
227
+ joinStyle: (_j = (_h = style['circle-stroke-line-join']) !== null && _h !== void 0 ? _h : style['stroke-line-join']) !== null && _j !== void 0 ? _j : 'round',
228
+ capStyle: (_l = (_k = style['circle-stroke-line-cap']) !== null && _k !== void 0 ? _k : style['stroke-line-cap']) !== null && _l !== void 0 ? _l : 'round',
240
229
  };
241
- const parsedStyle = shapeStyles[type2];
242
- Object.assign(parsedStyle, {
243
- radius: parsedStyle.radius,
244
- fillColor: parsedStyle.fillColor,
245
- strokeColor: parsedStyle.strokeColor,
246
- strokeWidth: parsedStyle.strokeWidth,
247
- joinStyle: parsedStyle.joinStyle,
248
- capStyle: parsedStyle.capStyle
249
- });
250
230
  return parsedStyle;
251
231
  }
252
232
  /**
@@ -301,23 +281,31 @@ export const getFromIndexedDB = async (key) => {
301
281
  request.onerror = () => reject(request.error);
302
282
  });
303
283
  };
304
- const fetchWithProxies = async (url, model, parseResponse) => {
284
+ export const isJupyterLite = () => {
285
+ return document.querySelectorAll('[data-jupyter-lite-root]')[0] !== undefined;
286
+ };
287
+ export const fetchWithProxies = async (url, model, parseResponse, options, strategy) => {
305
288
  let settings = null;
306
- try {
307
- settings = await model.getSettings();
308
- }
309
- catch (e) {
310
- console.warn('Failed to get settings from model. Falling back.', e);
289
+ if (model) {
290
+ try {
291
+ settings = model.getSettings();
292
+ }
293
+ catch (e) {
294
+ console.warn('Failed to get settings from model. Falling back.', e);
295
+ }
311
296
  }
312
297
  const proxyUrl = settings && settings.proxyUrl ? settings.proxyUrl : 'https://corsproxy.io';
313
- const proxyUrls = [
314
- url, // Direct fetch
315
- `/jupytergis_core/proxy?url=${encodeURIComponent(url)}`, // Internal proxy
316
- `${proxyUrl}/?url=${encodeURIComponent(url)}` // External proxy
317
- ];
318
- for (const proxyUrl of proxyUrls) {
298
+ const strategies = {
299
+ direct: url => url,
300
+ internal: url => `/jupytergis_core/proxy?url=${encodeURIComponent(url)}`,
301
+ external: url => `${proxyUrl}/?url=${encodeURIComponent(url)}`,
302
+ };
303
+ const defaultOrder = ['direct', 'internal', 'external'];
304
+ const strategyOrder = strategy ? [strategy] : defaultOrder;
305
+ for (const strat of strategyOrder) {
306
+ const proxyUrl = strategies[strat](url);
319
307
  try {
320
- const response = await fetch(proxyUrl);
308
+ const response = await fetch(proxyUrl, options);
321
309
  if (!response.ok) {
322
310
  console.warn(`Failed to fetch from ${proxyUrl}: ${response.statusText}`);
323
311
  continue;
@@ -350,7 +338,7 @@ export const loadGeoTiff = async (sourceInfo, model, file) => {
350
338
  return {
351
339
  file: cachedData.file,
352
340
  metadata: cachedData.metadata,
353
- sourceUrl: url
341
+ sourceUrl: url,
354
342
  };
355
343
  }
356
344
  let fileBlob = null;
@@ -364,18 +352,6 @@ export const loadGeoTiff = async (sourceInfo, model, file) => {
364
352
  else {
365
353
  fileBlob = await base64ToBlob(file.content, mimeType);
366
354
  }
367
- const geotiff = new File([fileBlob], 'loaded.tif');
368
- const Gdal = await getGdal();
369
- const result = await Gdal.open(geotiff);
370
- const tifDataset = result.datasets[0];
371
- const metadata = await Gdal.gdalinfo(tifDataset, ['-stats']);
372
- Gdal.close(tifDataset);
373
- await saveToIndexedDB(url, fileBlob, metadata);
374
- return {
375
- file: fileBlob,
376
- metadata,
377
- sourceUrl: url
378
- };
379
355
  };
380
356
  /**
381
357
  * Generalized file reader for different source types.
@@ -446,7 +422,7 @@ export const loadFile = async (fileInfo) => {
446
422
  const absolutePath = PathExt.resolve(PathExt.dirname(model.filePath), filepath);
447
423
  try {
448
424
  const file = await model.contentsManager.get(absolutePath, {
449
- content: true
425
+ content: true,
450
426
  });
451
427
  if (!file.content) {
452
428
  throw new Error(`File at ${absolutePath} is empty or inaccessible.`);
@@ -668,7 +644,7 @@ export const MIME_TYPES = {
668
644
  '.xul': 'text/xul',
669
645
  '.xwd': 'image/x-xwindowdump',
670
646
  '.zip': 'application/zip',
671
- '.ipynb': 'application/json'
647
+ '.ipynb': 'application/json',
672
648
  };
673
649
  /**
674
650
  * Determine the MIME type based on the file extension.
@@ -695,19 +671,40 @@ export const stringToArrayBuffer = async (content) => {
695
671
  const base64Response = await fetch(`data:application/octet-stream;base64,${content}`);
696
672
  return await base64Response.arrayBuffer();
697
673
  };
698
- export const getNumericFeatureAttributes = (featureProperties) => {
699
- // We only want number values here
674
+ const getFeatureAttributes = (featureProperties, predicate = (key, value) => true) => {
700
675
  const filteredRecord = {};
701
676
  for (const [key, set] of Object.entries(featureProperties)) {
702
677
  const firstValue = set.values().next().value;
703
- // Check if the first value is a string that cannot be parsed as a number
704
- const isInvalidString = typeof firstValue === 'string' && isNaN(Number(firstValue));
705
- if (!isInvalidString) {
678
+ const isValid = predicate(key, firstValue);
679
+ if (isValid) {
706
680
  filteredRecord[key] = set;
707
681
  }
708
682
  }
709
683
  return filteredRecord;
710
684
  };
685
+ /**
686
+ * Get attributes of the feature which are numeric.
687
+ *
688
+ * @param featureProperties - Attributes of a feature.
689
+ * @returns - Attributes which are numeric.
690
+ */
691
+ export const getNumericFeatureAttributes = (featureProperties) => {
692
+ return getFeatureAttributes(featureProperties, (_, value) => {
693
+ return !(typeof value === 'string' && isNaN(Number(value)));
694
+ });
695
+ };
696
+ /**
697
+ * Get attributes of the feature which look like hex color codes.
698
+ *
699
+ * @param featureProperties - Attributes of a feature.
700
+ * @returns - Attributes which look like hex color codes.
701
+ */
702
+ export const getColorCodeFeatureAttributes = (featureProperties) => {
703
+ return getFeatureAttributes(featureProperties, (_, value) => {
704
+ const regex = new RegExp('^#[0-9a-f]{6}$');
705
+ return typeof value === 'string' && regex.test(value);
706
+ });
707
+ };
711
708
  export function downloadFile(content, fileName, mimeType) {
712
709
  const blob = new Blob([content], { type: mimeType });
713
710
  const url = URL.createObjectURL(blob);
@@ -732,7 +729,7 @@ export async function getGeoJSONDataFromLayerSource(source, model) {
732
729
  const fileContent = await loadFile({
733
730
  filepath: source.parameters.path,
734
731
  type: source.type,
735
- model
732
+ model,
736
733
  });
737
734
  return typeof fileContent === 'object'
738
735
  ? JSON.stringify(fileContent)
@@ -744,3 +741,11 @@ export async function getGeoJSONDataFromLayerSource(source, model) {
744
741
  console.error("Source is missing both 'path' and 'data' parameters.");
745
742
  return null;
746
743
  }
744
+ /**
745
+ * `Object.entries`, but strongly-typed.
746
+ *
747
+ * `Object.entries` return value is always typed as `[string, any]` for type
748
+ * safety reasons, which means we need to use type assertions to have typed
749
+ * code when using it.
750
+ */
751
+ export const objectEntries = Object.entries;
package/lib/types.d.ts CHANGED
@@ -12,6 +12,8 @@ export interface IControlPanelModel {
12
12
  jGISModel: IJupyterGISModel | undefined;
13
13
  sharedModel: IJupyterGISDoc | undefined;
14
14
  }
15
+ export type SymbologyTab = 'color' | 'radius';
16
+ export type VectorRenderType = 'Single Symbol' | 'Canonical' | 'Graduated' | 'Categorized' | 'Heatmap';
15
17
  /**
16
18
  * Add jupytergisMaps object to the global variables.
17
19
  */
package/lib/widget.d.ts CHANGED
@@ -3,10 +3,10 @@ import { MainAreaWidget } from '@jupyterlab/apputils';
3
3
  import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
4
4
  import { DocumentWidget } from '@jupyterlab/docregistry';
5
5
  import { IObservableMap, ObservableMap } from '@jupyterlab/observables';
6
+ import { CommandRegistry } from '@lumino/commands';
6
7
  import { JSONValue } from '@lumino/coreutils';
7
8
  import { ISignal } from '@lumino/signaling';
8
9
  import { SplitPanel } from '@lumino/widgets';
9
- import { CommandRegistry } from '@lumino/commands';
10
10
  import { ConsoleView } from './console';
11
11
  import { JupyterGISMainViewPanel } from './mainview';
12
12
  import { MainViewModel } from './mainview/mainviewmodel';
package/lib/widget.js CHANGED
@@ -12,9 +12,9 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { MainAreaWidget } from '@jupyterlab/apputils';
13
13
  import { DocumentWidget } from '@jupyterlab/docregistry';
14
14
  import { ObservableMap } from '@jupyterlab/observables';
15
+ import { MessageLoop } from '@lumino/messaging';
15
16
  import { Signal } from '@lumino/signaling';
16
17
  import { SplitPanel, Widget } from '@lumino/widgets';
17
- import { MessageLoop } from '@lumino/messaging';
18
18
  import { ConsoleView } from './console';
19
19
  import { JupyterGISMainViewPanel } from './mainview';
20
20
  import { MainViewModel } from './mainview/mainviewmodel';
@@ -79,12 +79,12 @@ export class JupyterGISPanel extends SplitPanel {
79
79
  this._mainViewModel = new MainViewModel({
80
80
  jGISModel: options.model,
81
81
  viewSetting: this._view,
82
- commands: options.commandRegistry
82
+ commands: options.commandRegistry,
83
83
  });
84
84
  }
85
85
  _initView() {
86
86
  this._jupyterGISMainViewPanel = new JupyterGISMainViewPanel({
87
- mainViewModel: this._mainViewModel
87
+ mainViewModel: this._mainViewModel,
88
88
  });
89
89
  this.addWidget(this._jupyterGISMainViewPanel);
90
90
  SplitPanel.setStretch(this._jupyterGISMainViewPanel, 1);
@@ -136,7 +136,7 @@ export class JupyterGISPanel extends SplitPanel {
136
136
  }
137
137
  async toggleConsole(jgisPath) {
138
138
  if (!this._consoleView) {
139
- const { contentFactory, manager, mimeTypeService, rendermime, commandRegistry } = this._consoleOption;
139
+ const { contentFactory, manager, mimeTypeService, rendermime, commandRegistry, } = this._consoleOption;
140
140
  if (contentFactory &&
141
141
  manager &&
142
142
  mimeTypeService &&
@@ -148,7 +148,7 @@ export class JupyterGISPanel extends SplitPanel {
148
148
  manager,
149
149
  mimeTypeService,
150
150
  rendermime,
151
- commandRegistry
151
+ commandRegistry,
152
152
  });
153
153
  const { consolePanel } = this._consoleView;
154
154
  this._consoleTracker.widgetAdded.emit(consolePanel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupytergis/base",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "A JupyterLab extension for 3D modelling.",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -27,23 +27,24 @@
27
27
  "url": "https://github.com/geojupyter/jupytergis.git"
28
28
  },
29
29
  "scripts": {
30
- "build": "tsc -b && jlpm run cp:gdal",
30
+ "build": "tspc -b && jlpm run cp:gdal",
31
31
  "build:gallery": "python rasterlayer_gallery_generator.py",
32
32
  "cp:gdal": "cp ../../node_modules/gdal3.js/dist/package/gdal3WebAssembly.data lib && cp ../../node_modules/gdal3.js/dist/package/gdal3WebAssembly.wasm lib",
33
33
  "build:prod": "jlpm run clean && jlpm run build",
34
- "build:dev": "tsc -b && jlpm run cp:gdal",
34
+ "build:dev": "tspc -b && jlpm run cp:gdal",
35
35
  "clean": "rimraf tsconfig.tsbuildinfo",
36
36
  "clean:lib": "rimraf lib tsconfig.tsbuildinfo",
37
37
  "clean:all": "jlpm run clean:lib",
38
- "watch": "tsc -w"
38
+ "watch": "tspc -w"
39
39
  },
40
40
  "dependencies": {
41
41
  "@fortawesome/fontawesome-svg-core": "^6.5.2",
42
42
  "@fortawesome/free-solid-svg-icons": "^6.5.2",
43
43
  "@fortawesome/react-fontawesome": "latest",
44
+ "@jupyter/collaboration": "^3.1.0",
44
45
  "@jupyter/react-components": "^0.16.6",
45
46
  "@jupyter/ydoc": "^2.0.0 || ^3.0.0",
46
- "@jupytergis/schema": "^0.5.0",
47
+ "@jupytergis/schema": "^0.6.0",
47
48
  "@jupyterlab/application": "^4.3.0",
48
49
  "@jupyterlab/apputils": "^4.3.0",
49
50
  "@jupyterlab/completer": "^4.3.0",
@@ -63,22 +64,33 @@
63
64
  "@lumino/widgets": "^2.0.0",
64
65
  "@mapbox/vector-tile": "^2.0.3",
65
66
  "@naisutech/react-tree": "^3.0.1",
67
+ "@radix-ui/react-checkbox": "^1.3.2",
68
+ "@radix-ui/react-dropdown-menu": "^2.1.15",
69
+ "@radix-ui/react-popover": "^1.1.14",
70
+ "@radix-ui/react-slot": "^1.2.3",
71
+ "@radix-ui/react-tabs": "^1.1.12",
72
+ "@radix-ui/react-toggle-group": "^1.1.10",
66
73
  "@rjsf/core": "^4.2.0",
67
74
  "@rjsf/validator-ajv8": "^5.23.1",
68
75
  "ajv": "^8.14.0",
76
+ "class-variance-authority": "^0.7.1",
77
+ "clsx": "^2.1.1",
69
78
  "colormap": "^2.3.2",
70
79
  "d3-color": "^3.1.0",
71
80
  "date-fns": "^4.1.0",
72
81
  "gdal3.js": "^2.8.1",
73
82
  "geojson-vt": "^4.0.2",
74
83
  "geotiff": "^2.1.3",
84
+ "lucide-react": "^0.513.0",
75
85
  "ol": "^10.1.0",
76
86
  "ol-pmtiles": "^0.5.0",
87
+ "ol-stac": "^1.0.0-rc.10",
77
88
  "pbf": "^4.0.1",
78
89
  "pmtiles": "^3.0.7",
79
- "proj4": "^2.14.0",
90
+ "proj4": "^2.19.3",
80
91
  "proj4-list": "^1.0.4",
81
92
  "react": "^18.0.1",
93
+ "react-day-picker": "^9.7.0",
82
94
  "shpjs": "^6.1.0",
83
95
  "styled-components": "^5.3.6",
84
96
  "three": "^0.135.0",
@@ -90,11 +102,13 @@
90
102
  "@types/colormap": "^2.3.4",
91
103
  "@types/d3-color": "^3.1.0",
92
104
  "@types/node": "^18.15.11",
93
- "@types/proj4": "^2.5.5",
105
+ "@types/proj4": "^2.5.6",
94
106
  "@types/shpjs": "^3.4.7",
95
107
  "@types/uuid": "^10.0.0",
96
108
  "rimraf": "^3.0.2",
97
- "typescript": "^5"
109
+ "ts-patch": "^3.3.0",
110
+ "typescript": "^5",
111
+ "typescript-transform-paths": "^3.5.5"
98
112
  },
99
113
  "sideEffects": [
100
114
  "style/*.css",
package/style/base.css CHANGED
@@ -10,7 +10,21 @@
10
10
  @import url('./symbologyDialog.css');
11
11
  @import url('./statusBar.css');
12
12
  @import url('./temporalSlider.css');
13
+ @import url('./stacBrowser.css');
13
14
  @import url('ol/ol.css');
15
+ @import url('./shared/button.css');
16
+ @import url('./shared/toggle.css');
17
+ @import url('./shared/tabs.css');
18
+ @import url('./shared/pagination.css');
19
+ @import url('./shared/calendar.css');
20
+ @import url('./shared/dropdownMenu.css');
21
+ @import url('./shared/badge.css');
22
+ @import url('./shared/checkbox.css');
23
+
24
+ .errors {
25
+ color: var(--jp-warn-color0);
26
+ font-weight: bold;
27
+ }
14
28
 
15
29
  .jGIS-Toolbar-GroupName {
16
30
  font-size: var(--jp-ui-font-size0);
@@ -59,3 +73,15 @@ button.jp-mod-styled.jp-mod-accept {
59
73
  button.jp-mod-styled.jp-mod-reject {
60
74
  background-color: var(--jp-layout-color4) !important;
61
75
  }
76
+
77
+ .sr-only {
78
+ position: absolute;
79
+ width: 1px;
80
+ height: 1px;
81
+ padding: 0;
82
+ margin: -1px;
83
+ overflow: hidden;
84
+ clip: rect(0, 0, 0, 0);
85
+ white-space: nowrap;
86
+ border-width: 0;
87
+ }
@@ -126,6 +126,16 @@
126
126
  font-weight: bold;
127
127
  }
128
128
 
129
+ .jGIS-layer-browser-category.jGIS-layer-browser-category[data-state='active']::after {
130
+ width: 100%;
131
+ background-color: var(--jp-inverse-layout-color2);
132
+ }
133
+
134
+ .jGIS-layer-browser-category.jGIS-layer-browser-category[data-state='active'] {
135
+ opacity: 1;
136
+ font-weight: bold;
137
+ }
138
+
129
139
  .jGIS-layer-browser-tile {
130
140
  display: flex;
131
141
  flex-direction: column;
@@ -0,0 +1,61 @@
1
+ .jgis-badge {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ border-radius: 9999px;
5
+ border: 1px solid transparent;
6
+ padding: 2px 0.5rem;
7
+ font-size: 0.75rem;
8
+ font-weight: 600;
9
+ outline: none;
10
+ color: var(--jp-ui-inverse-font-color1);
11
+ background-color: var(--jp-brand-color0);
12
+ width: max-content;
13
+ word-break: break-word;
14
+ max-width: 200px;
15
+ text-align: center;
16
+ }
17
+
18
+ .jgis-badge:hover {
19
+ background-color: color-mix(in srgb, var(--jp-brand-color0) 80%, transparent);
20
+ }
21
+
22
+ .jgis-badge[data-variant='secondary'] {
23
+ border: 1px solid transparent;
24
+ background-color: var(--jp-brand-color1);
25
+ color: var(--jp-ui-inverse-font-color1);
26
+ transition: background-color 0.3s ease;
27
+ }
28
+
29
+ .jgis-badge[data-variant='secondary']:focus {
30
+ border-width: 2px;
31
+ border-color: var(--jp-border-color0);
32
+ box-shadow: 0 0 0 3px var(--jp-border-color0);
33
+ }
34
+
35
+ .jgis-badge[data-variant='destructive'] {
36
+ border: 1px solid transparent;
37
+ background-color: color-mix(in srgb, var(--jp-error-color1) 90%, transparent);
38
+ color: var(--jp-ui-inverse-font-color1);
39
+ }
40
+
41
+ .jgis-badge[data-variant='destructive']:hover {
42
+ background-color: color-mix(in srgb, var(--jp-error-color1) 80%, transparent);
43
+ }
44
+
45
+ .jgis-badge[data-variant='destructive']:focus {
46
+ background-color: var(--jp-error-color1);
47
+ }
48
+
49
+ .jgis-badge[data-variant='outline'] {
50
+ color: var(--jp-ui-font-color1);
51
+ background-color: transparent;
52
+ border: 1px solid color-mix(in srgb, var(--jp-border-color1) 80%, transparent);
53
+ }
54
+
55
+ .jgis-badge[data-variant='outline']:hover {
56
+ background-color: color-mix(
57
+ in srgb,
58
+ var(--jp-ui-font-color1) 10%,
59
+ transparent
60
+ );
61
+ }