@jupytergis/base 0.1.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 (108) hide show
  1. package/lib/commands.d.ts +11 -0
  2. package/lib/commands.js +809 -0
  3. package/lib/console/consoleview.d.ts +24 -0
  4. package/lib/console/consoleview.js +55 -0
  5. package/lib/console/index.d.ts +1 -0
  6. package/lib/console/index.js +1 -0
  7. package/lib/constants.d.ts +57 -0
  8. package/lib/constants.js +89 -0
  9. package/lib/dialogs/components/symbology/BandRendering.d.ts +4 -0
  10. package/lib/dialogs/components/symbology/BandRendering.js +29 -0
  11. package/lib/dialogs/components/symbology/BandRow.d.ts +10 -0
  12. package/lib/dialogs/components/symbology/BandRow.js +43 -0
  13. package/lib/dialogs/components/symbology/SingleBandPseudoColor.d.ts +20 -0
  14. package/lib/dialogs/components/symbology/SingleBandPseudoColor.js +281 -0
  15. package/lib/dialogs/components/symbology/StopRow.d.ts +11 -0
  16. package/lib/dialogs/components/symbology/StopRow.js +58 -0
  17. package/lib/dialogs/formdialog.d.ts +31 -0
  18. package/lib/dialogs/formdialog.js +68 -0
  19. package/lib/dialogs/layerBrowserDialog.d.ts +25 -0
  20. package/lib/dialogs/layerBrowserDialog.js +141 -0
  21. package/lib/dialogs/symbologyDialog.d.ts +23 -0
  22. package/lib/dialogs/symbologyDialog.js +68 -0
  23. package/lib/dialogs/terrainDialog.d.ts +21 -0
  24. package/lib/dialogs/terrainDialog.js +60 -0
  25. package/lib/formbuilder/creationform.d.ts +56 -0
  26. package/lib/formbuilder/creationform.js +117 -0
  27. package/lib/formbuilder/editform.d.ts +24 -0
  28. package/lib/formbuilder/editform.js +60 -0
  29. package/lib/formbuilder/formselectors.d.ts +5 -0
  30. package/lib/formbuilder/formselectors.js +38 -0
  31. package/lib/formbuilder/index.d.ts +6 -0
  32. package/lib/formbuilder/index.js +6 -0
  33. package/lib/formbuilder/objectform/baseform.d.ts +79 -0
  34. package/lib/formbuilder/objectform/baseform.js +167 -0
  35. package/lib/formbuilder/objectform/geojsonsource.d.ts +19 -0
  36. package/lib/formbuilder/objectform/geojsonsource.js +80 -0
  37. package/lib/formbuilder/objectform/hillshadeLayerForm.d.ts +8 -0
  38. package/lib/formbuilder/objectform/hillshadeLayerForm.js +12 -0
  39. package/lib/formbuilder/objectform/layerform.d.ts +19 -0
  40. package/lib/formbuilder/objectform/layerform.js +17 -0
  41. package/lib/formbuilder/objectform/tilesourceform.d.ts +7 -0
  42. package/lib/formbuilder/objectform/tilesourceform.js +60 -0
  43. package/lib/formbuilder/objectform/vectorlayerform.d.ts +15 -0
  44. package/lib/formbuilder/objectform/vectorlayerform.js +88 -0
  45. package/lib/formbuilder/objectform/webGlLayerForm.d.ts +8 -0
  46. package/lib/formbuilder/objectform/webGlLayerForm.js +10 -0
  47. package/lib/icons.d.ts +6 -0
  48. package/lib/icons.js +31 -0
  49. package/lib/index.d.ts +10 -0
  50. package/lib/index.js +10 -0
  51. package/lib/mainview/index.d.ts +3 -0
  52. package/lib/mainview/index.js +3 -0
  53. package/lib/mainview/mainView.d.ts +113 -0
  54. package/lib/mainview/mainView.js +743 -0
  55. package/lib/mainview/mainviewmodel.d.ts +24 -0
  56. package/lib/mainview/mainviewmodel.js +34 -0
  57. package/lib/mainview/mainviewwidget.d.ts +14 -0
  58. package/lib/mainview/mainviewwidget.js +18 -0
  59. package/lib/mainview/spinner.d.ts +6 -0
  60. package/lib/mainview/spinner.js +5 -0
  61. package/lib/panelview/components/filter-panel/Filter.d.ts +19 -0
  62. package/lib/panelview/components/filter-panel/Filter.js +223 -0
  63. package/lib/panelview/components/filter-panel/FilterRow.d.ts +9 -0
  64. package/lib/panelview/components/filter-panel/FilterRow.js +61 -0
  65. package/lib/panelview/components/layers.d.ts +13 -0
  66. package/lib/panelview/components/layers.js +275 -0
  67. package/lib/panelview/components/sources.d.ts +10 -0
  68. package/lib/panelview/components/sources.js +147 -0
  69. package/lib/panelview/header.d.ts +11 -0
  70. package/lib/panelview/header.js +20 -0
  71. package/lib/panelview/index.d.ts +5 -0
  72. package/lib/panelview/index.js +5 -0
  73. package/lib/panelview/leftpanel.d.ts +51 -0
  74. package/lib/panelview/leftpanel.js +125 -0
  75. package/lib/panelview/model.d.ts +19 -0
  76. package/lib/panelview/model.js +30 -0
  77. package/lib/panelview/objectproperties.d.ts +17 -0
  78. package/lib/panelview/objectproperties.js +92 -0
  79. package/lib/panelview/rightpanel.d.ts +19 -0
  80. package/lib/panelview/rightpanel.js +45 -0
  81. package/lib/toolbar/index.d.ts +2 -0
  82. package/lib/toolbar/index.js +2 -0
  83. package/lib/toolbar/usertoolbaritem.d.ts +19 -0
  84. package/lib/toolbar/usertoolbaritem.js +57 -0
  85. package/lib/toolbar/widget.d.ts +22 -0
  86. package/lib/toolbar/widget.js +104 -0
  87. package/lib/tools.d.ts +25 -0
  88. package/lib/tools.js +215 -0
  89. package/lib/types.d.ts +11 -0
  90. package/lib/types.js +1 -0
  91. package/lib/widget.d.ts +49 -0
  92. package/lib/widget.js +144 -0
  93. package/package.json +95 -0
  94. package/style/base.css +55 -0
  95. package/style/colorExpression.css +36 -0
  96. package/style/dialog.css +8 -0
  97. package/style/filterPanel.css +70 -0
  98. package/style/icons/geojson.svg +12 -0
  99. package/style/icons/mound.svg +9 -0
  100. package/style/icons/nonvisibility.svg +8 -0
  101. package/style/icons/raster.svg +5 -0
  102. package/style/icons/visibility.svg +7 -0
  103. package/style/index.css +6 -0
  104. package/style/index.js +6 -0
  105. package/style/layerBrowser.css +256 -0
  106. package/style/leftPanel.css +150 -0
  107. package/style/symbologyDialog.css +86 -0
  108. package/style/terrainDialog.css +14 -0
@@ -0,0 +1,17 @@
1
+ import { BaseForm } from './baseform';
2
+ export class LayerPropertiesForm extends BaseForm {
3
+ constructor(props) {
4
+ super(props);
5
+ this.sourceFormChangedSignal = props.sourceFormChangedSignal;
6
+ }
7
+ processSchema(data, schema, uiSchema) {
8
+ super.processSchema(data, schema, uiSchema);
9
+ if (!schema.properties.source) {
10
+ return;
11
+ }
12
+ // Replace the source text box by a dropdown menu
13
+ const availableSources = this.props.model.getSourcesByType(this.props.sourceType);
14
+ schema.properties.source.enumNames = Object.values(availableSources);
15
+ schema.properties.source.enum = Object.keys(availableSources);
16
+ }
17
+ }
@@ -0,0 +1,7 @@
1
+ import { IDict } from '@jupytergis/schema';
2
+ import { BaseForm } from './baseform';
3
+ export declare class TileSourcePropertiesForm extends BaseForm {
4
+ private _urlParameters;
5
+ protected processSchema(data: IDict<any> | undefined, schema: IDict, uiSchema: IDict): void;
6
+ protected onFormBlur(id: string, value: any): void;
7
+ }
@@ -0,0 +1,60 @@
1
+ import { BaseForm } from './baseform';
2
+ export class TileSourcePropertiesForm extends BaseForm {
3
+ constructor() {
4
+ super(...arguments);
5
+ this._urlParameters = [];
6
+ }
7
+ processSchema(data, schema, uiSchema) {
8
+ super.processSchema(data, schema, uiSchema);
9
+ if (!schema.properties || !data) {
10
+ return;
11
+ }
12
+ // Grep all url-parameters from the url
13
+ const regex = /\{([^}]+)\}/g;
14
+ const matches = [];
15
+ let match;
16
+ while ((match = regex.exec(data.url)) !== null) {
17
+ if (['max_zoom', 'min_zoom', 'x', 'y', 'z'].includes(match[1])) {
18
+ continue;
19
+ }
20
+ matches.push(match[1]);
21
+ }
22
+ this._urlParameters = matches;
23
+ if (matches.length === 0) {
24
+ this.removeFormEntry('urlParameters', data, schema, uiSchema);
25
+ return;
26
+ }
27
+ // Dynamically inject url parameters schema based of the url
28
+ const propertiesSchema = {};
29
+ schema.properties.urlParameters = {
30
+ type: 'object',
31
+ required: this._urlParameters,
32
+ properties: propertiesSchema
33
+ };
34
+ for (const parameterName of this._urlParameters) {
35
+ switch (parameterName) {
36
+ // Special case for "time" where a date picker widget is nicer
37
+ case 'time':
38
+ propertiesSchema[parameterName] = {
39
+ type: 'string',
40
+ format: 'date'
41
+ };
42
+ break;
43
+ default:
44
+ propertiesSchema[parameterName] = {
45
+ type: 'string'
46
+ };
47
+ break;
48
+ }
49
+ }
50
+ }
51
+ onFormBlur(id, value) {
52
+ super.onFormBlur(id, value);
53
+ // Is there a better way to spot the url text entry?
54
+ if (!id.endsWith('_url')) {
55
+ return;
56
+ }
57
+ // Force a rerender on url change, as it probably changes the schema
58
+ this.forceUpdate();
59
+ }
60
+ }
@@ -0,0 +1,15 @@
1
+ import { IDict, IVectorLayer } from '@jupytergis/schema';
2
+ import { IChangeEvent } from '@rjsf/core';
3
+ import { ILayerProps, LayerPropertiesForm } from './layerform';
4
+ /**
5
+ * The form to modify a vector layer.
6
+ */
7
+ export declare class VectorLayerPropertiesForm extends LayerPropertiesForm {
8
+ protected currentFormData: IVectorLayer;
9
+ private sourceLayers;
10
+ private currentSourceId;
11
+ constructor(props: ILayerProps);
12
+ protected onFormChange(e: IChangeEvent): void;
13
+ protected processSchema(data: IVectorLayer | undefined, schema: IDict, uiSchema: IDict): void;
14
+ private fetchSourceLayers;
15
+ }
@@ -0,0 +1,88 @@
1
+ import { getSourceLayerNames } from '../../tools';
2
+ import { LayerPropertiesForm } from './layerform';
3
+ /**
4
+ * The form to modify a vector layer.
5
+ */
6
+ export class VectorLayerPropertiesForm extends LayerPropertiesForm {
7
+ constructor(props) {
8
+ super(props);
9
+ this.sourceLayers = [];
10
+ this.fetchSourceLayers(this.props.sourceData);
11
+ // If there is a source form attached, we listen to its changes
12
+ if (this.sourceFormChangedSignal) {
13
+ this.sourceFormChangedSignal.connect((sender, sourceData) => {
14
+ if (this.props.sourceType === 'VectorTileSource') {
15
+ this.fetchSourceLayers(this.currentFormData, sourceData);
16
+ }
17
+ });
18
+ }
19
+ props.model.clientStateChanged.connect(() => {
20
+ var _a;
21
+ if (!((_a = props.model.localState) === null || _a === void 0 ? void 0 : _a.selected.value)) {
22
+ return;
23
+ }
24
+ const l = this.props.model.getLayer(Object.keys(props.model.localState.selected.value)[0]);
25
+ const source = this.props.model.getSource(l === null || l === void 0 ? void 0 : l.parameters.source);
26
+ if (!source || source.type !== 'VectorTileSource') {
27
+ return;
28
+ }
29
+ const sourceData = source.parameters;
30
+ this.fetchSourceLayers(this.currentFormData, sourceData);
31
+ });
32
+ }
33
+ onFormChange(e) {
34
+ super.onFormChange(e);
35
+ // We only force update if we just updated the source
36
+ if (this.currentSourceId === e.formData.source) {
37
+ return;
38
+ }
39
+ const source = this.props.model.getSource(e.formData.source);
40
+ if (!source || source.type !== 'VectorTileSource') {
41
+ return;
42
+ }
43
+ this.fetchSourceLayers(this.currentFormData, source.parameters);
44
+ }
45
+ processSchema(data, schema, uiSchema) {
46
+ super.processSchema(data, schema, uiSchema);
47
+ uiSchema['color'] = {
48
+ 'ui:widget': 'color'
49
+ };
50
+ if (!data) {
51
+ return;
52
+ }
53
+ // Show a dropdown for available sourceLayers if available
54
+ // And automatically select one
55
+ if (this.sourceLayers.length !== 0) {
56
+ if (!data.sourceLayer || !this.sourceLayers.includes(data.sourceLayer)) {
57
+ data.sourceLayer = this.sourceLayers[0];
58
+ }
59
+ schema.properties.sourceLayer.enum = this.sourceLayers;
60
+ }
61
+ }
62
+ async fetchSourceLayers(data, sourceData) {
63
+ if (data && data.source) {
64
+ this.currentSourceId = data.source;
65
+ if (!sourceData) {
66
+ const currentSource = this.props.model.getSource(data.source);
67
+ if (!currentSource || currentSource.type !== 'VectorTileSource') {
68
+ this.sourceLayers = [];
69
+ this.forceUpdate();
70
+ return;
71
+ }
72
+ sourceData = currentSource.parameters;
73
+ }
74
+ try {
75
+ this.sourceLayers = await getSourceLayerNames(sourceData.url, sourceData.urlParameters);
76
+ this.forceUpdate();
77
+ }
78
+ catch (e) {
79
+ console.error(e);
80
+ }
81
+ }
82
+ else {
83
+ this.currentSourceId = '';
84
+ this.sourceLayers = [];
85
+ this.forceUpdate();
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,8 @@
1
+ import { IDict } from '@jupytergis/schema';
2
+ import { LayerPropertiesForm } from './layerform';
3
+ /**
4
+ * The form to modify a hillshade layer.
5
+ */
6
+ export declare class WebGlLayerPropertiesForm extends LayerPropertiesForm {
7
+ protected processSchema(data: IDict<any> | undefined, schema: IDict, uiSchema: IDict): void;
8
+ }
@@ -0,0 +1,10 @@
1
+ import { LayerPropertiesForm } from './layerform';
2
+ /**
3
+ * The form to modify a hillshade layer.
4
+ */
5
+ export class WebGlLayerPropertiesForm extends LayerPropertiesForm {
6
+ processSchema(data, schema, uiSchema) {
7
+ this.removeFormEntry('color', data, schema, uiSchema);
8
+ super.processSchema(data, schema, uiSchema);
9
+ }
10
+ }
package/lib/icons.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { LabIcon } from '@jupyterlab/ui-components';
2
+ export declare const rasterIcon: LabIcon;
3
+ export declare const visibilityIcon: LabIcon;
4
+ export declare const nonVisibilityIcon: LabIcon;
5
+ export declare const geoJSONIcon: LabIcon;
6
+ export declare const moundIcon: LabIcon;
package/lib/icons.js ADDED
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ // This file is based on iconimports.ts in @jupyterlab/ui-components, but is manually generated.
6
+ import { LabIcon } from '@jupyterlab/ui-components';
7
+ import rasterSvgStr from '../style/icons/raster.svg';
8
+ import visibilitySvgStr from '../style/icons/visibility.svg';
9
+ import nonVisibilitySvgStr from '../style/icons/nonvisibility.svg';
10
+ import geoJsonSvgStr from '../style/icons/geojson.svg';
11
+ import moundSvgStr from '../style/icons/mound.svg';
12
+ export const rasterIcon = new LabIcon({
13
+ name: 'jupytergis::raster',
14
+ svgstr: rasterSvgStr
15
+ });
16
+ export const visibilityIcon = new LabIcon({
17
+ name: 'jupytergis::visibility',
18
+ svgstr: visibilitySvgStr
19
+ });
20
+ export const nonVisibilityIcon = new LabIcon({
21
+ name: 'jupytergis::nonVisibility',
22
+ svgstr: nonVisibilitySvgStr
23
+ });
24
+ export const geoJSONIcon = new LabIcon({
25
+ name: 'jupytergis::geoJSON',
26
+ svgstr: geoJsonSvgStr
27
+ });
28
+ export const moundIcon = new LabIcon({
29
+ name: 'jupytergis::mound',
30
+ svgstr: moundSvgStr
31
+ });
package/lib/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export * from './commands';
2
+ export * from './constants';
3
+ export * from './dialogs/formdialog';
4
+ export * from './mainview';
5
+ export * from './tools';
6
+ export * from './types';
7
+ export * from './widget';
8
+ export * from './formbuilder/objectform/baseform';
9
+ export * from './panelview';
10
+ export * from './toolbar';
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export * from './commands';
2
+ export * from './constants';
3
+ export * from './dialogs/formdialog';
4
+ export * from './mainview';
5
+ export * from './tools';
6
+ export * from './types';
7
+ export * from './widget';
8
+ export * from './formbuilder/objectform/baseform';
9
+ export * from './panelview';
10
+ export * from './toolbar';
@@ -0,0 +1,3 @@
1
+ export * from './mainView';
2
+ export * from './mainviewwidget';
3
+ export * from './mainviewmodel';
@@ -0,0 +1,3 @@
1
+ export * from './mainView';
2
+ export * from './mainviewwidget';
3
+ export * from './mainviewmodel';
@@ -0,0 +1,113 @@
1
+ import { IJGISLayer, IJGISSource } from '@jupytergis/schema';
2
+ import { User } from '@jupyterlab/services';
3
+ import { FeatureLike } from 'ol/Feature';
4
+ import BaseLayer from 'ol/layer/Base';
5
+ import { Style } from 'ol/style';
6
+ import * as React from 'react';
7
+ import { MainViewModel } from './mainviewmodel';
8
+ interface IProps {
9
+ viewModel: MainViewModel;
10
+ }
11
+ interface IStates {
12
+ id: string;
13
+ loading: boolean;
14
+ lightTheme: boolean;
15
+ remoteUser?: User.IIdentity | null;
16
+ firstLoad: boolean;
17
+ }
18
+ export declare class MainView extends React.Component<IProps, IStates> {
19
+ constructor(props: IProps);
20
+ componentDidMount(): Promise<void>;
21
+ componentWillUnmount(): void;
22
+ generateScene(): Promise<void>;
23
+ /**
24
+ * Add a source in the map.
25
+ *
26
+ * @param id - the source id.
27
+ * @param source - the source object.
28
+ */
29
+ addSource(id: string, source: IJGISSource): Promise<void>;
30
+ private computeSourceUrl;
31
+ /**
32
+ * Update a source in the map.
33
+ *
34
+ * @param id - the source id.
35
+ * @param source - the source object.
36
+ */
37
+ updateSource(id: string, source: IJGISSource): Promise<void>;
38
+ /**
39
+ * Remove a source from the map.
40
+ *
41
+ * @param id - the source id.
42
+ */
43
+ removeSource(id: string): void;
44
+ /**
45
+ * Add or move the layers of the map.
46
+ *
47
+ * @param layerIds - the list of layers in the depth order (beneath first).
48
+ */
49
+ updateLayers(layerIds: string[]): void;
50
+ private _updateLayersImpl;
51
+ /**
52
+ * Add a layer to the map.
53
+ *
54
+ * @param id - id of the layer.
55
+ * @param layer - the layer object.
56
+ * @param index - expected index of the layer.
57
+ */
58
+ addLayer(id: string, layer: IJGISLayer, index: number): Promise<void>;
59
+ vectorLayerStyleFunc: (currentFeature: FeatureLike, layer: IJGISLayer) => Style | undefined;
60
+ /**
61
+ * Taken from https://openlayers.org/en/latest/examples/webgl-shaded-relief.html
62
+ * @returns
63
+ */
64
+ private hillshadeMath;
65
+ /**
66
+ * Move a layer in the stack.
67
+ *
68
+ * @param id - id of the layer.
69
+ * @param index - expected index of the layer.
70
+ */
71
+ moveLayer(id: string, index: number | undefined): void;
72
+ /**
73
+ * Update a layer of the map.
74
+ *
75
+ * @param id - id of the layer.
76
+ * @param layer - the layer object.
77
+ */
78
+ updateLayer(id: string, layer: IJGISLayer, mapLayer: BaseLayer): Promise<void>;
79
+ /**
80
+ * Remove a layer from the map.
81
+ *
82
+ * @param id - the id of the layer.
83
+ */
84
+ removeLayer(id: string): void;
85
+ private _onClientSharedStateChanged;
86
+ private _onSharedOptionsChanged;
87
+ private updateOptions;
88
+ private _onViewChanged;
89
+ /**
90
+ * Convenience method to get a specific layer from OpenLayers Map
91
+ * @param id Layer to retrieve
92
+ */
93
+ private getLayer;
94
+ /**
95
+ * Convenience method to get list layer IDs from the OpenLayers Map
96
+ */
97
+ private getLayers;
98
+ private _onLayersChanged;
99
+ private _onLayerTreeChange;
100
+ private _onSourcesChange;
101
+ private _handleThemeChange;
102
+ private _handleWindowResize;
103
+ render(): JSX.Element;
104
+ private _initializedPosition;
105
+ private divRef;
106
+ private _Map;
107
+ private _model;
108
+ private _mainViewModel;
109
+ private _ready;
110
+ private _sources;
111
+ private _sourceToLayerMap;
112
+ }
113
+ export {};