@jupytergis/base 0.4.5 → 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 (192) 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} +76 -319
  12. package/lib/console/consoleview.d.ts +3 -3
  13. package/lib/console/consoleview.js +5 -5
  14. package/lib/constants.d.ts +2 -51
  15. package/lib/constants.js +6 -65
  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 -2
  85. package/lib/index.js +4 -2
  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 +4 -0
  95. package/lib/menus.js +45 -0
  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 -14
  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 +28 -64
  167. package/lib/tools.d.ts +30 -5
  168. package/lib/tools.js +82 -69
  169. package/lib/types.d.ts +2 -0
  170. package/lib/widget.d.ts +2 -1
  171. package/lib/widget.js +8 -5
  172. package/package.json +22 -8
  173. package/style/base.css +26 -0
  174. package/style/layerBrowser.css +10 -0
  175. package/style/leftPanel.css +0 -1
  176. package/style/shared/badge.css +61 -0
  177. package/style/shared/button.css +164 -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 +74 -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/panelview/components/sources.d.ts +0 -10
  190. package/lib/panelview/components/sources.js +0 -147
  191. package/lib/toolbar/usertoolbaritem.d.ts +0 -19
  192. package/lib/toolbar/usertoolbaritem.js +0 -59
@@ -1,10 +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 { Menu, Widget } from '@lumino/widgets';
3
+ import { MenuSvg, ReactWidget, ReactiveToolbar, ToolbarButton, addIcon, redoIcon, undoIcon, } from '@jupyterlab/ui-components';
4
+ import { Widget } from '@lumino/widgets';
4
5
  import * as React from 'react';
5
- import { CommandIDs } from '../constants';
6
- import { rasterIcon, terminalToolbarIcon } from '../icons';
7
- import { UsersItem } from './usertoolbaritem';
6
+ import { CommandIDs } from "../constants";
7
+ import { terminalToolbarIcon } from "../icons";
8
+ import { rasterSubMenu, vectorSubMenu } from "../menus";
8
9
  export const TOOLBAR_SEPARATOR_CLASS = 'jGIS-Toolbar-Separator';
9
10
  export const TOOLBAR_GROUPNAME_CLASS = 'jGIS-Toolbar-GroupName';
10
11
  export class Separator extends Widget {
@@ -25,7 +26,7 @@ export class ToolbarWidget extends ReactiveToolbar {
25
26
  id: CommandIDs.undo,
26
27
  label: '',
27
28
  icon: undoIcon,
28
- commands: options.commands
29
+ commands: options.commands,
29
30
  });
30
31
  this.addItem('undo', undoButton);
31
32
  undoButton.node.dataset.testid = 'undo-button';
@@ -33,7 +34,7 @@ export class ToolbarWidget extends ReactiveToolbar {
33
34
  id: CommandIDs.redo,
34
35
  label: '',
35
36
  icon: redoIcon,
36
- commands: options.commands
37
+ commands: options.commands,
37
38
  });
38
39
  this.addItem('redo', redoButton);
39
40
  this.addItem('separator0', new Separator());
@@ -41,7 +42,7 @@ export class ToolbarWidget extends ReactiveToolbar {
41
42
  id: CommandIDs.toggleConsole,
42
43
  commands: options.commands,
43
44
  label: '',
44
- icon: terminalToolbarIcon
45
+ icon: terminalToolbarIcon,
45
46
  });
46
47
  this.addItem('Toggle console', toggleConsoleButton);
47
48
  toggleConsoleButton.node.dataset.testid = 'toggle-console-button';
@@ -49,64 +50,20 @@ export class ToolbarWidget extends ReactiveToolbar {
49
50
  const openLayersBrowserButton = new CommandToolbarButton({
50
51
  id: CommandIDs.openLayerBrowser,
51
52
  label: '',
52
- commands: options.commands
53
+ commands: options.commands,
53
54
  });
54
55
  this.addItem('openLayerBrowser', openLayersBrowserButton);
55
56
  openLayersBrowserButton.node.dataset.testid = 'open-layers-browser';
56
- const newRasterEntryButton = new CommandToolbarButton({
57
- id: CommandIDs.newRasterEntry,
58
- label: '',
59
- commands: options.commands
60
- });
61
- this.addItem('newRasterEntry', newRasterEntryButton);
62
- const newVectorTileEntryButton = new CommandToolbarButton({
63
- id: CommandIDs.newVectorTileEntry,
64
- label: '',
65
- commands: options.commands
66
- });
67
- this.addItem('newVectorTileEntry', newVectorTileEntryButton);
68
- newRasterEntryButton.node.dataset.testid = 'new-raster-entry-button';
69
- const geolocationButton = new CommandToolbarButton({
70
- id: CommandIDs.getGeolocation,
71
- commands: options.commands,
72
- label: ''
73
- });
74
- this.addItem('Geolocation', geolocationButton);
75
- geolocationButton.node.dataset.testid = 'geolocation-button';
76
- // vector sub menu
77
- const vectorSubMenu = new Menu({ commands: options.commands });
78
- vectorSubMenu.title.label = 'Add Vector Layer';
79
- vectorSubMenu.title.iconClass = 'fa fa-vector-square';
80
- vectorSubMenu.id = 'jp-gis-toolbar-vector-menu';
81
- vectorSubMenu.addItem({
82
- type: 'command',
83
- command: CommandIDs.newGeoJSONEntry
84
- });
85
- vectorSubMenu.addItem({
86
- type: 'command',
87
- command: CommandIDs.newShapefileLayer
88
- });
89
- //raster submenu
90
- const rasterSubMenu = new Menu({ commands: options.commands });
91
- rasterSubMenu.title.label = 'Add Raster Layer';
92
- rasterSubMenu.title.icon = rasterIcon;
93
- rasterSubMenu.id = 'jp-gis-toolbar-raster-menu';
94
- rasterSubMenu.addItem({
95
- type: 'command',
96
- command: CommandIDs.newHillshadeEntry
97
- });
98
- rasterSubMenu.addItem({
99
- type: 'command',
100
- command: CommandIDs.newImageEntry
101
- });
102
- rasterSubMenu.addItem({
103
- type: 'command',
104
- command: CommandIDs.newGeoTiffEntry
105
- });
106
57
  const NewSubMenu = new MenuSvg({ commands: options.commands });
107
58
  NewSubMenu.title.label = 'Add Layer';
108
- NewSubMenu.addItem({ type: 'submenu', submenu: rasterSubMenu });
109
- NewSubMenu.addItem({ type: 'submenu', submenu: vectorSubMenu });
59
+ NewSubMenu.addItem({
60
+ type: 'submenu',
61
+ submenu: rasterSubMenu(options.commands),
62
+ });
63
+ NewSubMenu.addItem({
64
+ type: 'submenu',
65
+ submenu: vectorSubMenu(options.commands),
66
+ });
110
67
  const NewEntryButton = new ToolbarButton({
111
68
  icon: addIcon,
112
69
  noFocusOnClick: false,
@@ -116,22 +73,29 @@ export class ToolbarWidget extends ReactiveToolbar {
116
73
  }
117
74
  const bbox = NewEntryButton.node.getBoundingClientRect();
118
75
  NewSubMenu.open(bbox.x, bbox.bottom);
119
- }
76
+ },
120
77
  });
121
78
  NewEntryButton.node.dataset.testid = 'new-entry-button';
122
79
  this.addItem('New', NewEntryButton);
123
80
  this.addItem('separator2', new Separator());
81
+ const geolocationButton = new CommandToolbarButton({
82
+ id: CommandIDs.getGeolocation,
83
+ commands: options.commands,
84
+ label: '',
85
+ });
86
+ this.addItem('Geolocation', geolocationButton);
87
+ geolocationButton.node.dataset.testid = 'geolocation-button';
124
88
  const identifyButton = new CommandToolbarButton({
125
89
  id: CommandIDs.identify,
126
90
  label: '',
127
- commands: options.commands
91
+ commands: options.commands,
128
92
  });
129
93
  this.addItem('identify', identifyButton);
130
94
  identifyButton.node.dataset.testid = 'identify-button';
131
95
  const temporalControllerButton = new CommandToolbarButton({
132
96
  id: CommandIDs.temporalController,
133
97
  label: '',
134
- commands: options.commands
98
+ commands: options.commands,
135
99
  });
136
100
  this.addItem('temporalController', temporalControllerButton);
137
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
  *
@@ -65,11 +68,11 @@ export declare const getFromIndexedDB: (key: string) => Promise<{
65
68
  */
66
69
  export declare const loadGeoTiff: (sourceInfo: {
67
70
  url?: string | undefined;
68
- }, file?: Contents.IModel | null) => Promise<{
71
+ }, model: IJupyterGISModel, file?: Contents.IModel | null) => Promise<{
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,15 +281,31 @@ export const getFromIndexedDB = async (key) => {
301
281
  request.onerror = () => reject(request.error);
302
282
  });
303
283
  };
304
- const fetchWithProxies = async (url, parseResponse) => {
305
- const proxyUrls = [
306
- url, // Direct fetch
307
- `/jupytergis_core/proxy?url=${encodeURIComponent(url)}`, // Internal proxy
308
- `https://corsproxy.io/?url=${encodeURIComponent(url)}` // External proxy
309
- ];
310
- for (const proxyUrl of proxyUrls) {
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) => {
288
+ let settings = null;
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
+ }
296
+ }
297
+ const proxyUrl = settings && settings.proxyUrl ? settings.proxyUrl : 'https://corsproxy.io';
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);
311
307
  try {
312
- const response = await fetch(proxyUrl);
308
+ const response = await fetch(proxyUrl, options);
313
309
  if (!response.ok) {
314
310
  console.warn(`Failed to fetch from ${proxyUrl}: ${response.statusText}`);
315
311
  continue;
@@ -328,7 +324,7 @@ const fetchWithProxies = async (url, parseResponse) => {
328
324
  * @param sourceInfo object containing the URL of the GeoTIFF file.
329
325
  * @returns A promise that resolves to the file as a Blob, or undefined .
330
326
  */
331
- export const loadGeoTiff = async (sourceInfo, file) => {
327
+ export const loadGeoTiff = async (sourceInfo, model, file) => {
332
328
  if (!(sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.url)) {
333
329
  return null;
334
330
  }
@@ -342,12 +338,12 @@ export const loadGeoTiff = async (sourceInfo, file) => {
342
338
  return {
343
339
  file: cachedData.file,
344
340
  metadata: cachedData.metadata,
345
- sourceUrl: url
341
+ sourceUrl: url,
346
342
  };
347
343
  }
348
344
  let fileBlob = null;
349
345
  if (!file) {
350
- fileBlob = await fetchWithProxies(url, async (response) => response.blob());
346
+ fileBlob = await fetchWithProxies(url, model, async (response) => response.blob());
351
347
  if (!fileBlob) {
352
348
  showErrorMessage('Network error', `Failed to fetch ${url}`);
353
349
  throw new Error(`Failed to fetch ${url}`);
@@ -356,18 +352,6 @@ export const loadGeoTiff = async (sourceInfo, file) => {
356
352
  else {
357
353
  fileBlob = await base64ToBlob(file.content, mimeType);
358
354
  }
359
- const geotiff = new File([fileBlob], 'loaded.tif');
360
- const Gdal = await getGdal();
361
- const result = await Gdal.open(geotiff);
362
- const tifDataset = result.datasets[0];
363
- const metadata = await Gdal.gdalinfo(tifDataset, ['-stats']);
364
- Gdal.close(tifDataset);
365
- await saveToIndexedDB(url, fileBlob, metadata);
366
- return {
367
- file: fileBlob,
368
- metadata,
369
- sourceUrl: url
370
- };
371
355
  };
372
356
  /**
373
357
  * Generalized file reader for different source types.
@@ -403,7 +387,7 @@ export const loadFile = async (fileInfo) => {
403
387
  if (cached) {
404
388
  return cached.file;
405
389
  }
406
- const geojson = await fetchWithProxies(filepath, async (response) => {
390
+ const geojson = await fetchWithProxies(filepath, model, async (response) => {
407
391
  const arrayBuffer = await response.arrayBuffer();
408
392
  return shp(arrayBuffer);
409
393
  });
@@ -419,7 +403,7 @@ export const loadFile = async (fileInfo) => {
419
403
  if (cached) {
420
404
  return cached.file;
421
405
  }
422
- const geojson = await fetchWithProxies(filepath, async (response) => response.json());
406
+ const geojson = await fetchWithProxies(filepath, model, async (response) => response.json());
423
407
  if (geojson) {
424
408
  await saveToIndexedDB(filepath, geojson);
425
409
  return geojson;
@@ -438,7 +422,7 @@ export const loadFile = async (fileInfo) => {
438
422
  const absolutePath = PathExt.resolve(PathExt.dirname(model.filePath), filepath);
439
423
  try {
440
424
  const file = await model.contentsManager.get(absolutePath, {
441
- content: true
425
+ content: true,
442
426
  });
443
427
  if (!file.content) {
444
428
  throw new Error(`File at ${absolutePath} is empty or inaccessible.`);
@@ -476,7 +460,7 @@ export const loadFile = async (fileInfo) => {
476
460
  }
477
461
  case 'GeoTiffSource': {
478
462
  if (typeof file.content === 'string') {
479
- const tiff = loadGeoTiff({ url: filepath }, file);
463
+ const tiff = loadGeoTiff({ url: filepath }, model, file);
480
464
  return tiff;
481
465
  }
482
466
  else {
@@ -660,7 +644,7 @@ export const MIME_TYPES = {
660
644
  '.xul': 'text/xul',
661
645
  '.xwd': 'image/x-xwindowdump',
662
646
  '.zip': 'application/zip',
663
- '.ipynb': 'application/json'
647
+ '.ipynb': 'application/json',
664
648
  };
665
649
  /**
666
650
  * Determine the MIME type based on the file extension.
@@ -687,19 +671,40 @@ export const stringToArrayBuffer = async (content) => {
687
671
  const base64Response = await fetch(`data:application/octet-stream;base64,${content}`);
688
672
  return await base64Response.arrayBuffer();
689
673
  };
690
- export const getNumericFeatureAttributes = (featureProperties) => {
691
- // We only want number values here
674
+ const getFeatureAttributes = (featureProperties, predicate = (key, value) => true) => {
692
675
  const filteredRecord = {};
693
676
  for (const [key, set] of Object.entries(featureProperties)) {
694
677
  const firstValue = set.values().next().value;
695
- // Check if the first value is a string that cannot be parsed as a number
696
- const isInvalidString = typeof firstValue === 'string' && isNaN(Number(firstValue));
697
- if (!isInvalidString) {
678
+ const isValid = predicate(key, firstValue);
679
+ if (isValid) {
698
680
  filteredRecord[key] = set;
699
681
  }
700
682
  }
701
683
  return filteredRecord;
702
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
+ };
703
708
  export function downloadFile(content, fileName, mimeType) {
704
709
  const blob = new Blob([content], { type: mimeType });
705
710
  const url = URL.createObjectURL(blob);
@@ -724,7 +729,7 @@ export async function getGeoJSONDataFromLayerSource(source, model) {
724
729
  const fileContent = await loadFile({
725
730
  filepath: source.parameters.path,
726
731
  type: source.type,
727
- model
732
+ model,
728
733
  });
729
734
  return typeof fileContent === 'object'
730
735
  ? JSON.stringify(fileContent)
@@ -736,3 +741,11 @@ export async function getGeoJSONDataFromLayerSource(source, model) {
736
741
  console.error("Source is missing both 'path' and 'data' parameters.");
737
742
  return null;
738
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';
@@ -53,6 +53,7 @@ export declare class JupyterGISPanel extends SplitPanel {
53
53
  dispose(): void;
54
54
  get currentViewModel(): MainViewModel;
55
55
  get consolePanel(): ConsolePanel | undefined;
56
+ get consoleOpened(): boolean;
56
57
  executeConsole(): void;
57
58
  removeConsole(): void;
58
59
  toggleConsole(jgisPath: string): Promise<void>;
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);
@@ -116,6 +116,9 @@ export class JupyterGISPanel extends SplitPanel {
116
116
  var _a;
117
117
  return (_a = this._consoleView) === null || _a === void 0 ? void 0 : _a.consolePanel;
118
118
  }
119
+ get consoleOpened() {
120
+ return this._consoleOpened;
121
+ }
119
122
  executeConsole() {
120
123
  if (this._consoleView) {
121
124
  this._consoleView.execute();
@@ -133,7 +136,7 @@ export class JupyterGISPanel extends SplitPanel {
133
136
  }
134
137
  async toggleConsole(jgisPath) {
135
138
  if (!this._consoleView) {
136
- const { contentFactory, manager, mimeTypeService, rendermime, commandRegistry } = this._consoleOption;
139
+ const { contentFactory, manager, mimeTypeService, rendermime, commandRegistry, } = this._consoleOption;
137
140
  if (contentFactory &&
138
141
  manager &&
139
142
  mimeTypeService &&
@@ -145,7 +148,7 @@ export class JupyterGISPanel extends SplitPanel {
145
148
  manager,
146
149
  mimeTypeService,
147
150
  rendermime,
148
- commandRegistry
151
+ commandRegistry,
149
152
  });
150
153
  const { consolePanel } = this._consoleView;
151
154
  this._consoleTracker.widgetAdded.emit(consolePanel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupytergis/base",
3
- "version": "0.4.5",
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.4.5",
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",