@jupytergis/schema 0.14.1 → 0.16.0-alpha.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 (78) hide show
  1. package/lib/_interface/forms.json +7834 -417
  2. package/lib/_interface/processing/clipRasterByExtent.d.ts +39 -0
  3. package/lib/_interface/processing/clipRasterByVector.d.ts +32 -0
  4. package/lib/_interface/processing/clipVectorByMaskLayer.d.ts +28 -0
  5. package/lib/_interface/processing/rasterize.d.ts +42 -0
  6. package/lib/_interface/project/jgis.d.ts +21 -4
  7. package/lib/_interface/project/layers/geoTiffLayer.d.ts +351 -0
  8. package/lib/_interface/project/layers/heatmapLayer.d.ts +8 -1
  9. package/lib/_interface/project/layers/openeoTileLayer.d.ts +20 -0
  10. package/lib/_interface/project/layers/storySegmentLayer.d.ts +6 -0
  11. package/lib/_interface/project/layers/vectorLayer.d.ts +615 -5
  12. package/lib/_interface/project/layers/vectorTileLayer.d.ts +582 -2
  13. package/lib/_interface/project/sources/geoJsonSource.d.ts +8 -0
  14. package/lib/_interface/project/sources/geoPackageRasterSource.d.ts +36 -0
  15. package/lib/_interface/project/sources/geoPackageVectorSource.d.ts +28 -0
  16. package/lib/_interface/project/sources/geoParquetSource.d.ts +8 -0
  17. package/lib/_interface/project/sources/geoTiffSource.d.ts +8 -0
  18. package/lib/_interface/project/sources/imageSource.d.ts +8 -0
  19. package/lib/_interface/project/sources/openeoTileSource.d.ts +26 -0
  20. package/lib/_interface/project/sources/rasterDemSource.d.ts +8 -0
  21. package/lib/_interface/project/sources/rasterSource.d.ts +8 -0
  22. package/lib/_interface/project/sources/shapefileSource.d.ts +8 -0
  23. package/lib/_interface/project/sources/vectorTileSource.d.ts +8 -0
  24. package/lib/_interface/project/sources/videoSource.d.ts +8 -0
  25. package/lib/_interface/project/sources/wmsTileSource.d.ts +40 -0
  26. package/lib/_interface/project/symbology.d.ts +305 -0
  27. package/lib/_interface/version.d.ts +1 -1
  28. package/lib/_interface/version.js +1 -1
  29. package/lib/doc.d.ts +9 -2
  30. package/lib/doc.js +49 -5
  31. package/lib/grammar/grammarConversions.d.ts +50 -0
  32. package/lib/grammar/grammarConversions.js +137 -0
  33. package/lib/index.d.ts +4 -0
  34. package/lib/index.js +2 -0
  35. package/lib/interfaces.d.ts +87 -19
  36. package/lib/interfaces.js +10 -1
  37. package/lib/migrations/index.d.ts +16 -0
  38. package/lib/migrations/index.js +52 -0
  39. package/lib/migrations/v0_5_to_v0_6.d.ts +11 -0
  40. package/lib/migrations/v0_5_to_v0_6.js +154 -0
  41. package/lib/model.d.ts +49 -13
  42. package/lib/model.js +214 -23
  43. package/lib/processing/ProcessingMerge.d.ts +4 -0
  44. package/lib/processing/ProcessingMerge.js +4 -0
  45. package/lib/processing/_generated/exportProcessingSchema.d.ts +7 -3
  46. package/lib/processing/_generated/exportProcessingSchema.js +7 -3
  47. package/lib/processing/_generated/processingType.d.ts +1 -1
  48. package/lib/processing/_generated/processingType.js +7 -3
  49. package/lib/processing/_generated/processing_merge.json +74 -19
  50. package/lib/schema/processing/clipRasterByExtent.json +39 -0
  51. package/lib/schema/processing/clipRasterByVector.json +33 -0
  52. package/lib/schema/processing/clipVectorByMaskLayer.json +27 -0
  53. package/lib/schema/processing/rasterize.json +45 -0
  54. package/lib/schema/project/jgis.json +35 -5
  55. package/lib/schema/project/layers/{webGlLayer.json → geoTiffLayer.json} +9 -3
  56. package/lib/schema/project/layers/heatmapLayer.json +7 -1
  57. package/lib/schema/project/layers/openeoTileLayer.json +21 -0
  58. package/lib/schema/project/layers/storySegmentLayer.json +14 -3
  59. package/lib/schema/project/layers/vectorLayer.json +93 -14
  60. package/lib/schema/project/layers/vectorTileLayer.json +34 -10
  61. package/lib/schema/project/sources/geoJsonSource.json +13 -0
  62. package/lib/schema/project/sources/geoPackageRasterSource.json +45 -0
  63. package/lib/schema/project/sources/geoPackageVectorSource.json +29 -0
  64. package/lib/schema/project/sources/geoParquetSource.json +13 -0
  65. package/lib/schema/project/sources/geoTiffSource.json +13 -0
  66. package/lib/schema/project/sources/imageSource.json +13 -0
  67. package/lib/schema/project/sources/openeoTileSource.json +23 -0
  68. package/lib/schema/project/sources/rasterDemSource.json +13 -0
  69. package/lib/schema/project/sources/rasterSource.json +13 -0
  70. package/lib/schema/project/sources/shapefileSource.json +13 -0
  71. package/lib/schema/project/sources/vectorTileSource.json +13 -0
  72. package/lib/schema/project/sources/videoSource.json +13 -0
  73. package/lib/schema/project/sources/wmsTileSource.json +48 -0
  74. package/lib/schema/project/symbology.json +418 -0
  75. package/lib/types.d.ts +16 -1
  76. package/lib/types.js +8 -1
  77. package/package.json +3 -1
  78. package/lib/_interface/project/layers/webGlLayer.d.ts +0 -39
@@ -21,4 +21,12 @@ export interface IImageSource {
21
21
  * Interpolate between grid cells when overzooming?
22
22
  */
23
23
  interpolate?: boolean;
24
+ /**
25
+ * Route requests through the Jupyter server proxy to avoid CORS issues.
26
+ */
27
+ useProxy?: boolean;
28
+ /**
29
+ * HTTP headers forwarded to the upstream server when useProxy is true.
30
+ */
31
+ httpHeaders?: string;
24
32
  }
@@ -0,0 +1,26 @@
1
+ /* tslint:disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ /**
9
+ * OpenEOTileSource
10
+ */
11
+ export interface IOpenEOTileSource {
12
+ /**
13
+ * The process graph for the OpenEO layer.
14
+ */
15
+ processGraph: {
16
+ [k: string]: any;
17
+ };
18
+ /**
19
+ * The OpenEO tile server url.
20
+ */
21
+ serverUrl?: string;
22
+ /**
23
+ * The OpenEO connection identifier.
24
+ */
25
+ authBearer?: string;
26
+ }
@@ -24,4 +24,12 @@ export interface IRasterDemSource {
24
24
  * Interpolate between grid cells when overzooming?
25
25
  */
26
26
  interpolate?: boolean;
27
+ /**
28
+ * Route tile requests through the Jupyter server proxy to avoid CORS issues.
29
+ */
30
+ useProxy?: boolean;
31
+ /**
32
+ * HTTP headers forwarded to the upstream tile server when useProxy is true.
33
+ */
34
+ httpHeaders?: string;
27
35
  }
@@ -44,6 +44,14 @@ export interface IRasterSource {
44
44
  bounds?: number[][];
45
45
  urlParameters?: URLParameters;
46
46
  interpolate?: Interpolate;
47
+ /**
48
+ * Route tile requests through the Jupyter server proxy to avoid CORS issues.
49
+ */
50
+ useProxy?: boolean;
51
+ /**
52
+ * HTTP headers forwarded to the upstream tile server when useProxy is true.
53
+ */
54
+ httpHeaders?: string;
47
55
  }
48
56
  export interface URLParameters {
49
57
  [k: string]: string;
@@ -31,4 +31,12 @@ export interface IShapefileSource {
31
31
  additionalFiles?: {
32
32
  [k: string]: string;
33
33
  };
34
+ /**
35
+ * Route requests through the Jupyter server proxy to avoid CORS issues.
36
+ */
37
+ useProxy?: boolean;
38
+ /**
39
+ * HTTP headers forwarded to the upstream server when useProxy is true.
40
+ */
41
+ httpHeaders?: string;
34
42
  }
@@ -32,4 +32,12 @@ export interface IVectorTileSource {
32
32
  urlParameters?: {
33
33
  [k: string]: string;
34
34
  };
35
+ /**
36
+ * Route tile requests through the Jupyter server proxy to avoid CORS issues.
37
+ */
38
+ useProxy?: boolean;
39
+ /**
40
+ * HTTP headers forwarded to the upstream tile server when useProxy is true.
41
+ */
42
+ httpHeaders?: string;
35
43
  }
@@ -17,4 +17,12 @@ export interface IVideoSource {
17
17
  * Corners of video specified in longitude, latitude pairs
18
18
  */
19
19
  coordinates: [[number, number], [number, number], [number, number], [number, number]];
20
+ /**
21
+ * Route requests through the Jupyter server proxy to avoid CORS issues.
22
+ */
23
+ useProxy?: boolean;
24
+ /**
25
+ * HTTP headers forwarded to the upstream server when useProxy is true.
26
+ */
27
+ httpHeaders?: string;
20
28
  }
@@ -0,0 +1,40 @@
1
+ /* tslint:disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ /**
9
+ * WmsTileSource
10
+ */
11
+ export interface IWmsTileSource {
12
+ /**
13
+ * The url to the tile provider
14
+ */
15
+ url: string;
16
+ params: ParamsForURLQuery;
17
+ /**
18
+ * The attribution for the raster source
19
+ */
20
+ attribution?: string;
21
+ /**
22
+ * Interpolate between grid cells when overzooming?
23
+ */
24
+ interpolate?: boolean;
25
+ /**
26
+ * Route tile requests through the Jupyter server proxy to avoid CORS issues.
27
+ */
28
+ useProxy?: boolean;
29
+ /**
30
+ * HTTP headers forwarded to the upstream tile server when useProxy is true.
31
+ */
32
+ httpHeaders?: string;
33
+ }
34
+ export interface ParamsForURLQuery {
35
+ /**
36
+ * WMS layer name to request
37
+ */
38
+ layers: string;
39
+ [k: string]: any;
40
+ }
@@ -0,0 +1,305 @@
1
+ /* tslint:disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ /**
9
+ * [R 0-255, G 0-255, B 0-255, A 0-1]
10
+ *
11
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
12
+ * via the `definition` "RGBA".
13
+ */
14
+ export type RGBA = [number, number, number, number];
15
+ /**
16
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
17
+ * via the `definition` "ClassificationMode".
18
+ */
19
+ export type ClassificationMode = "equal interval" | "quantile" | "jenks" | "pretty" | "logarithmic";
20
+ /**
21
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
22
+ * via the `definition` "RGBAChannel".
23
+ */
24
+ export type RGBAChannel = "fill-color" | "stroke-color" | "circle-fill-color" | "circle-stroke-color" | "pixel-color";
25
+ /**
26
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
27
+ * via the `definition` "UInt8Channel".
28
+ */
29
+ export type UInt8Channel = "fill-red" | "fill-green" | "fill-blue" | "pixel-red" | "pixel-green" | "pixel-blue";
30
+ /**
31
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
32
+ * via the `definition` "UNormChannel".
33
+ */
34
+ export type UNormChannel = "fill-alpha" | "pixel-alpha";
35
+ /**
36
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
37
+ * via the `definition` "VirtualChannel".
38
+ */
39
+ export type VirtualChannel = "pixel-rgb";
40
+ /**
41
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
42
+ * via the `definition` "PosFloatChannel".
43
+ */
44
+ export type PosFloatChannel = "stroke-width" | "circle-radius" | "circle-stroke-width";
45
+ /**
46
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
47
+ * via the `definition` "StyleChannel".
48
+ */
49
+ export type StyleChannel = RGBAChannel | UInt8Channel | UNormChannel | VirtualChannel | PosFloatChannel;
50
+ /**
51
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
52
+ * via the `definition` "ICompareOp".
53
+ */
54
+ export type ICompareOp = ">" | "<" | ">=" | "<=" | "!=";
55
+ /**
56
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
57
+ * via the `definition` "IPredicate".
58
+ */
59
+ export type IPredicate =
60
+ | {
61
+ type: "geometryType";
62
+ value: "Point" | "LineString" | "Polygon";
63
+ }
64
+ | {
65
+ type: "hasField";
66
+ field: string;
67
+ }
68
+ | {
69
+ type: "fieldEquals";
70
+ field: string;
71
+ value: string | number;
72
+ }
73
+ | {
74
+ type: "fieldCompare";
75
+ field: string;
76
+ op: ICompareOp;
77
+ value: number;
78
+ }
79
+ | {
80
+ type: "between";
81
+ field: string;
82
+ min: number;
83
+ max: number;
84
+ };
85
+ /**
86
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
87
+ * via the `definition` "ITransform".
88
+ */
89
+ export type ITransform = IKDETransform | IClusterTransform;
90
+ /**
91
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
92
+ * via the `definition` "IScale".
93
+ */
94
+ export type IScale =
95
+ | IColorRampScale
96
+ | ICategoricalScale
97
+ | IScalarScale
98
+ | IConstantRGBAScale
99
+ | IConstantNumScale
100
+ | IIdentityScale
101
+ | IExpressionScale;
102
+
103
+ /**
104
+ * SymbologyState
105
+ */
106
+ export interface ISymbologyState {
107
+ [k: string]: any;
108
+ }
109
+ /**
110
+ * KDE heatmap transform. Density output addressed as '$density'.
111
+ *
112
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
113
+ * via the `definition` "IKDETransform".
114
+ */
115
+ export interface IKDETransform {
116
+ type: "kde";
117
+ radius: number;
118
+ blur: number;
119
+ weightField?: string;
120
+ }
121
+ /**
122
+ * Cluster transform. Aggregates nearby points into centroids.
123
+ *
124
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
125
+ * via the `definition` "IClusterTransform".
126
+ */
127
+ export interface IClusterTransform {
128
+ type: "cluster";
129
+ radius: number;
130
+ }
131
+ /**
132
+ * Maps a numeric field through a named color palette to RGBA.
133
+ *
134
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
135
+ * via the `definition` "IColorRampScale".
136
+ */
137
+ export interface IColorRampScale {
138
+ scheme: "colorRamp";
139
+ params: {
140
+ name: string;
141
+ domain?: [number, number];
142
+ nShades: number;
143
+ mode: ClassificationMode;
144
+ reverse: boolean;
145
+ fallback: RGBA;
146
+ colorStops?: {
147
+ stop: number;
148
+ color: RGBA;
149
+ }[];
150
+ };
151
+ }
152
+ /**
153
+ * Maps discrete field values to colors sampled from a named palette.
154
+ *
155
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
156
+ * via the `definition` "ICategoricalScale".
157
+ */
158
+ export interface ICategoricalScale {
159
+ scheme: "categorical";
160
+ params: {
161
+ colorRamp: string;
162
+ nShades?: number;
163
+ reverse?: boolean;
164
+ fallback: RGBA;
165
+ colorStops?: {
166
+ stop: string | number;
167
+ color: RGBA;
168
+ }[];
169
+ };
170
+ }
171
+ /**
172
+ * Maps a numeric field to a numeric output (radius, width, sub-channel value).
173
+ *
174
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
175
+ * via the `definition` "IScalarScale".
176
+ */
177
+ export interface IScalarScale {
178
+ scheme: "scalar";
179
+ params: {
180
+ domain: [number, number];
181
+ range: [number, number];
182
+ mode: ClassificationMode;
183
+ nStops: number;
184
+ fallback: number;
185
+ scalarStops?: {
186
+ stop: number;
187
+ output: number;
188
+ }[];
189
+ };
190
+ }
191
+ /**
192
+ * Fixed RGBA color regardless of feature data.
193
+ *
194
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
195
+ * via the `definition` "IConstantRGBAScale".
196
+ */
197
+ export interface IConstantRGBAScale {
198
+ scheme: "constant_rgba";
199
+ params: {
200
+ value: RGBA;
201
+ };
202
+ }
203
+ /**
204
+ * Fixed numeric value regardless of feature data.
205
+ *
206
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
207
+ * via the `definition` "IConstantNumScale".
208
+ */
209
+ export interface IConstantNumScale {
210
+ scheme: "constant_num";
211
+ params: {
212
+ value: number;
213
+ };
214
+ }
215
+ /**
216
+ * Passes the field value through unchanged.
217
+ *
218
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
219
+ * via the `definition` "IIdentityScale".
220
+ */
221
+ export interface IIdentityScale {
222
+ scheme: "identity";
223
+ }
224
+ /**
225
+ * Evaluates an expression against one or more input fields (reserved).
226
+ *
227
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
228
+ * via the `definition` "IExpressionScale".
229
+ */
230
+ export interface IExpressionScale {
231
+ scheme: "expression";
232
+ params: {
233
+ expr: string;
234
+ fallback: number | RGBA;
235
+ };
236
+ }
237
+ /**
238
+ * A (scale, channels) pair: one scale drives one or more output channels.
239
+ *
240
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
241
+ * via the `definition` "IMapping".
242
+ */
243
+ export interface IMapping {
244
+ scale: IScale;
245
+ /**
246
+ * Target output channel names.
247
+ */
248
+ channels: [StyleChannel, ...StyleChannel[]];
249
+ }
250
+ /**
251
+ * Maps optional input fields to one or more (scale, channels) pairs.
252
+ *
253
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
254
+ * via the `definition` "IEncodingRule".
255
+ */
256
+ export interface IEncodingRule {
257
+ /**
258
+ * Stable UUID.
259
+ */
260
+ id: string;
261
+ /**
262
+ * Input field name(s). Absent for constant rules.
263
+ */
264
+ fields?: string[];
265
+ /**
266
+ * (scale, channels) pairs sharing these input fields.
267
+ */
268
+ mappings: [IMapping, ...IMapping[]];
269
+ /**
270
+ * Guard predicates for this rule.
271
+ */
272
+ when?: IPredicate[];
273
+ /**
274
+ * Logical combinator for when predicates. Defaults to 'all'.
275
+ */
276
+ whenOp?: "all" | "any";
277
+ }
278
+ /**
279
+ * One independent rendering pipeline on a source.
280
+ *
281
+ * This interface was referenced by `ISymbologyState`'s JSON-Schema
282
+ * via the `definition` "IGrammarLayer".
283
+ */
284
+ export interface IGrammarLayer {
285
+ /**
286
+ * Stable UUID.
287
+ */
288
+ id: string;
289
+ /**
290
+ * Render-side transforms (KDE, cluster) applied before encoding rules.
291
+ */
292
+ preprocess?: ITransform[];
293
+ /**
294
+ * Encoding rules compiled into a flat-style expression for this layer.
295
+ */
296
+ rules: IEncodingRule[];
297
+ /**
298
+ * Guard predicates applied to every rule in this layer.
299
+ */
300
+ when?: IPredicate[];
301
+ /**
302
+ * Logical combinator for when predicates. Defaults to 'all'.
303
+ */
304
+ whenOp?: "all" | "any";
305
+ }
@@ -1 +1 @@
1
- export declare const SCHEMA_VERSION = '0.5.0';
1
+ export declare const SCHEMA_VERSION = '0.6.0';
@@ -1 +1 @@
1
- export const SCHEMA_VERSION = '0.5.0';
1
+ export const SCHEMA_VERSION = '0.6.0';
package/lib/doc.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { MapChange, YDocument } from '@jupyter/ydoc';
2
2
  import { JSONObject } from '@lumino/coreutils';
3
3
  import { ISignal } from '@lumino/signaling';
4
- import { IJGISLayer, IJGISLayerItem, IJGISLayerTree, IJGISLayers, IJGISOptions, IJGISSource, IJGISSources, IJGISStoryMap } from './_interface/project/jgis';
4
+ import { IJGISLayer, IJGISLayerItem, IJGISLayerTree, IJGISLayers, IJGISOptions, IJGISSource, IJGISSources, IJGISStoryMap, IJGISViewState } from './_interface/project/jgis';
5
5
  import { IDict, IJGISLayerDocChange, IJGISLayerTreeDocChange, IJGISSourceDocChange, IJGISStoryMapDocChange, IJGISStoryMaps, IJupyterGISDoc, IJupyterGISDocChange } from './interfaces';
6
+ export declare const DEFAULT_PROJECTION = "EPSG:3857";
6
7
  /** Default JSON content for a new JupyterGIS document. */
7
- export declare const DEFAULT_JGIS_DOCUMENT_CONTENT = "{\n\t\"schemaVersion\": \"0.5.0\",\n\t\"layers\": {},\n\t\"sources\": {},\n\t\"options\": {\"latitude\": 0, \"longitude\": 0, \"zoom\": 0, \"bearing\": 0, \"pitch\": 0, \"projection\": \"EPSG:3857\", \"storyMapPresentationMode\": false},\n\t\"layerTree\": [],\n\t\"metadata\": {}\n}";
8
+ export declare const DEFAULT_JGIS_DOCUMENT_CONTENT = "{\n\t\"schemaVersion\": \"0.6.0\",\n\t\"layers\": {},\n\t\"sources\": {},\n \"stories\": {},\n \"viewState\": {},\n\t\"options\": {\"latitude\": 0, \"longitude\": 0, \"zoom\": 0, \"bearing\": 0, \"pitch\": 0, \"projection\": \"EPSG:3857\", \"storyMapPresentationMode\": false},\n\t\"layerTree\": [],\n\t\"metadata\": {}\n}";
8
9
  export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> implements IJupyterGISDoc {
9
10
  constructor();
10
11
  get initialSyncReady(): Promise<void>;
@@ -19,6 +20,8 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
19
20
  get sources(): IJGISSources;
20
21
  set stories(stories: IJGISStoryMaps);
21
22
  get stories(): IJGISStoryMaps;
23
+ get viewState(): IJGISViewState;
24
+ set viewState(viewState: IJGISViewState);
22
25
  get layerTree(): IJGISLayerTree;
23
26
  set layerTree(layerTree: IJGISLayerTree);
24
27
  getLayer(id: string): IJGISLayer | undefined;
@@ -36,6 +39,7 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
36
39
  get layerTreeChanged(): ISignal<IJupyterGISDoc, IJGISLayerTreeDocChange>;
37
40
  get sourcesChanged(): ISignal<IJupyterGISDoc, IJGISSourceDocChange>;
38
41
  get storyMapsChanged(): ISignal<IJupyterGISDoc, IJGISStoryMapDocChange>;
42
+ get viewStateChanged(): ISignal<IJupyterGISDoc, MapChange>;
39
43
  get optionsChanged(): ISignal<IJupyterGISDoc, MapChange>;
40
44
  layerExists(id: string): boolean;
41
45
  removeLayer(id: string): void;
@@ -71,12 +75,14 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
71
75
  private _layerTreeObserver;
72
76
  private _sourcesObserver;
73
77
  private _storyMapsObserver;
78
+ private _viewStateObserver;
74
79
  private _optionsObserver;
75
80
  private _metaObserver;
76
81
  private _layers;
77
82
  private _layerTree;
78
83
  private _sources;
79
84
  private _stories;
85
+ private _viewState;
80
86
  private _options;
81
87
  private _metadata;
82
88
  private _optionsChanged;
@@ -84,6 +90,7 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
84
90
  private _layerTreeChanged;
85
91
  private _sourcesChanged;
86
92
  private _storyMapsChanged;
93
+ private _viewStateChanged;
87
94
  private _metadataChanged;
88
95
  private _initialSyncReadyPromise;
89
96
  private _initialSyncReadyResolve;
package/lib/doc.js CHANGED
@@ -2,12 +2,16 @@ import { YDocument } from '@jupyter/ydoc';
2
2
  import { JSONExt } from '@lumino/coreutils';
3
3
  import { Signal } from '@lumino/signaling';
4
4
  import { SCHEMA_VERSION } from './_interface/version';
5
+ import { migrateDocument } from './migrations';
6
+ export const DEFAULT_PROJECTION = 'EPSG:3857';
5
7
  /** Default JSON content for a new JupyterGIS document. */
6
8
  export const DEFAULT_JGIS_DOCUMENT_CONTENT = `{
7
9
  "schemaVersion": "${SCHEMA_VERSION}",
8
10
  "layers": {},
9
11
  "sources": {},
10
- "options": {"latitude": 0, "longitude": 0, "zoom": 0, "bearing": 0, "pitch": 0, "projection": "EPSG:3857", "storyMapPresentationMode": false},
12
+ "stories": {},
13
+ "viewState": {},
14
+ "options": {"latitude": 0, "longitude": 0, "zoom": 0, "bearing": 0, "pitch": 0, "projection": "${DEFAULT_PROJECTION}", "storyMapPresentationMode": false},
11
15
  "layerTree": [],
12
16
  "metadata": {}
13
17
  }`;
@@ -15,6 +19,17 @@ export class JupyterGISDoc extends YDocument {
15
19
  constructor() {
16
20
  super();
17
21
  this.editable = true;
22
+ this._viewStateObserver = (event) => {
23
+ const changes = new Map();
24
+ event.changes.keys.forEach((event, key) => {
25
+ changes.set(key, {
26
+ action: event.action,
27
+ oldValue: event.oldValue,
28
+ newValue: this._viewState.get(key),
29
+ });
30
+ });
31
+ this._viewStateChanged.emit(changes);
32
+ };
18
33
  this._optionsObserver = (event) => {
19
34
  const changes = new Map();
20
35
  event.changes.keys.forEach((event, key) => {
@@ -43,6 +58,7 @@ export class JupyterGISDoc extends YDocument {
43
58
  this._layerTreeChanged = new Signal(this);
44
59
  this._sourcesChanged = new Signal(this);
45
60
  this._storyMapsChanged = new Signal(this);
61
+ this._viewStateChanged = new Signal(this);
46
62
  this._metadataChanged = new Signal(this);
47
63
  this._initialSyncResolved = false;
48
64
  this._options = this.ydoc.getMap('options');
@@ -50,6 +66,7 @@ export class JupyterGISDoc extends YDocument {
50
66
  this._layerTree = this.ydoc.getArray('layerTree');
51
67
  this._sources = this.ydoc.getMap('sources');
52
68
  this._stories = this.ydoc.getMap('stories');
69
+ this._viewState = this.ydoc.getMap('viewState');
53
70
  this._metadata = this.ydoc.getMap('metadata');
54
71
  this.undoManager.addToScope(this._layers);
55
72
  this.undoManager.addToScope(this._sources);
@@ -62,6 +79,7 @@ export class JupyterGISDoc extends YDocument {
62
79
  this._layerTree.observe(this._layerTreeObserver.bind(this));
63
80
  this._sources.observeDeep(this._sourcesObserver.bind(this));
64
81
  this._stories.observeDeep(this._storyMapsObserver.bind(this));
82
+ this._viewState.observe(this._viewStateObserver.bind(this));
65
83
  this._options.observe(this._optionsObserver.bind(this));
66
84
  this._metadata.observe(this._metaObserver.bind(this));
67
85
  }
@@ -81,8 +99,17 @@ export class JupyterGISDoc extends YDocument {
81
99
  const options = this._options.toJSON();
82
100
  const sources = this._sources.toJSON();
83
101
  const stories = this._stories.toJSON();
102
+ const viewState = this._viewState.toJSON();
84
103
  const metadata = this._metadata.toJSON();
85
- return { layers, layerTree, sources, stories, options, metadata };
104
+ return {
105
+ layers,
106
+ layerTree,
107
+ sources,
108
+ stories,
109
+ viewState,
110
+ options,
111
+ metadata,
112
+ };
86
113
  }
87
114
  setSource(value) {
88
115
  if (!value) {
@@ -91,9 +118,11 @@ export class JupyterGISDoc extends YDocument {
91
118
  if (typeof value === 'string') {
92
119
  value = JSON.parse(value);
93
120
  }
94
- value = value;
121
+ // Mirror the Python `YJGIS.set()` migration step so JupyterLite (which has
122
+ // no Python ydoc) loads legacy documents with the same shape as Lab.
123
+ value = migrateDocument(value);
95
124
  this.transact(() => {
96
- var _a, _b, _c, _d, _e, _f;
125
+ var _a, _b, _c, _d, _e, _f, _g;
97
126
  const layers = (_a = value['layers']) !== null && _a !== void 0 ? _a : {};
98
127
  Object.entries(layers).forEach(([key, val]) => this._layers.set(key, val));
99
128
  const layerTree = (_b = value['layerTree']) !== null && _b !== void 0 ? _b : [];
@@ -106,7 +135,9 @@ export class JupyterGISDoc extends YDocument {
106
135
  Object.entries(sources).forEach(([key, val]) => this._sources.set(key, val));
107
136
  const stories = (_e = value['stories']) !== null && _e !== void 0 ? _e : {};
108
137
  Object.entries(stories).forEach(([key, val]) => this._stories.set(key, val));
109
- const metadata = (_f = value['metadata']) !== null && _f !== void 0 ? _f : {};
138
+ const viewState = (_f = value['viewState']) !== null && _f !== void 0 ? _f : {};
139
+ Object.entries(viewState).forEach(([key, val]) => this._viewState.set(key, val));
140
+ const metadata = (_g = value['metadata']) !== null && _g !== void 0 ? _g : {};
110
141
  Object.entries(metadata).forEach(([key, val]) => this._metadata.set(key, val));
111
142
  });
112
143
  }
@@ -146,6 +177,16 @@ export class JupyterGISDoc extends YDocument {
146
177
  get stories() {
147
178
  return JSONExt.deepCopy(this._stories.toJSON());
148
179
  }
180
+ get viewState() {
181
+ return JSONExt.deepCopy(this._viewState.toJSON());
182
+ }
183
+ set viewState(viewState) {
184
+ this.transact(() => {
185
+ for (const [key, value] of Object.entries(viewState)) {
186
+ this._viewState.set(key, value);
187
+ }
188
+ });
189
+ }
149
190
  get layerTree() {
150
191
  return JSONExt.deepCopy(this._layerTree.toJSON());
151
192
  }
@@ -205,6 +246,9 @@ export class JupyterGISDoc extends YDocument {
205
246
  get storyMapsChanged() {
206
247
  return this._storyMapsChanged;
207
248
  }
249
+ get viewStateChanged() {
250
+ return this._viewStateChanged;
251
+ }
208
252
  get optionsChanged() {
209
253
  return this._optionsChanged;
210
254
  }