@jupytergis/schema 0.15.0 → 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 +7836 -503
  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 +20 -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 +599 -5
  12. package/lib/_interface/project/layers/vectorTileLayer.d.ts +566 -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 +8 -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 +8 -2
  30. package/lib/doc.js +47 -4
  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 +212 -21
  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 +76 -21
  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 +34 -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 +73 -14
  60. package/lib/schema/project/layers/vectorTileLayer.json +14 -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 +13 -0
  74. package/lib/schema/project/symbology.json +418 -0
  75. package/lib/types.d.ts +15 -1
  76. package/lib/types.js +7 -1
  77. package/package.json +2 -1
  78. package/lib/_interface/project/layers/webGlLayer.d.ts +0 -39
@@ -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
  }
@@ -22,6 +22,14 @@ export interface IWmsTileSource {
22
22
  * Interpolate between grid cells when overzooming?
23
23
  */
24
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;
25
33
  }
26
34
  export interface ParamsForURLQuery {
27
35
  /**
@@ -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,11 +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
6
  export declare const DEFAULT_PROJECTION = "EPSG:3857";
7
7
  /** Default JSON content for a new JupyterGIS document. */
8
- 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}";
9
9
  export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> implements IJupyterGISDoc {
10
10
  constructor();
11
11
  get initialSyncReady(): Promise<void>;
@@ -20,6 +20,8 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
20
20
  get sources(): IJGISSources;
21
21
  set stories(stories: IJGISStoryMaps);
22
22
  get stories(): IJGISStoryMaps;
23
+ get viewState(): IJGISViewState;
24
+ set viewState(viewState: IJGISViewState);
23
25
  get layerTree(): IJGISLayerTree;
24
26
  set layerTree(layerTree: IJGISLayerTree);
25
27
  getLayer(id: string): IJGISLayer | undefined;
@@ -37,6 +39,7 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
37
39
  get layerTreeChanged(): ISignal<IJupyterGISDoc, IJGISLayerTreeDocChange>;
38
40
  get sourcesChanged(): ISignal<IJupyterGISDoc, IJGISSourceDocChange>;
39
41
  get storyMapsChanged(): ISignal<IJupyterGISDoc, IJGISStoryMapDocChange>;
42
+ get viewStateChanged(): ISignal<IJupyterGISDoc, MapChange>;
40
43
  get optionsChanged(): ISignal<IJupyterGISDoc, MapChange>;
41
44
  layerExists(id: string): boolean;
42
45
  removeLayer(id: string): void;
@@ -72,12 +75,14 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
72
75
  private _layerTreeObserver;
73
76
  private _sourcesObserver;
74
77
  private _storyMapsObserver;
78
+ private _viewStateObserver;
75
79
  private _optionsObserver;
76
80
  private _metaObserver;
77
81
  private _layers;
78
82
  private _layerTree;
79
83
  private _sources;
80
84
  private _stories;
85
+ private _viewState;
81
86
  private _options;
82
87
  private _metadata;
83
88
  private _optionsChanged;
@@ -85,6 +90,7 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
85
90
  private _layerTreeChanged;
86
91
  private _sourcesChanged;
87
92
  private _storyMapsChanged;
93
+ private _viewStateChanged;
88
94
  private _metadataChanged;
89
95
  private _initialSyncReadyPromise;
90
96
  private _initialSyncReadyResolve;
package/lib/doc.js CHANGED
@@ -2,12 +2,15 @@ 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';
5
6
  export const DEFAULT_PROJECTION = 'EPSG:3857';
6
7
  /** Default JSON content for a new JupyterGIS document. */
7
8
  export const DEFAULT_JGIS_DOCUMENT_CONTENT = `{
8
9
  "schemaVersion": "${SCHEMA_VERSION}",
9
10
  "layers": {},
10
11
  "sources": {},
12
+ "stories": {},
13
+ "viewState": {},
11
14
  "options": {"latitude": 0, "longitude": 0, "zoom": 0, "bearing": 0, "pitch": 0, "projection": "${DEFAULT_PROJECTION}", "storyMapPresentationMode": false},
12
15
  "layerTree": [],
13
16
  "metadata": {}
@@ -16,6 +19,17 @@ export class JupyterGISDoc extends YDocument {
16
19
  constructor() {
17
20
  super();
18
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
+ };
19
33
  this._optionsObserver = (event) => {
20
34
  const changes = new Map();
21
35
  event.changes.keys.forEach((event, key) => {
@@ -44,6 +58,7 @@ export class JupyterGISDoc extends YDocument {
44
58
  this._layerTreeChanged = new Signal(this);
45
59
  this._sourcesChanged = new Signal(this);
46
60
  this._storyMapsChanged = new Signal(this);
61
+ this._viewStateChanged = new Signal(this);
47
62
  this._metadataChanged = new Signal(this);
48
63
  this._initialSyncResolved = false;
49
64
  this._options = this.ydoc.getMap('options');
@@ -51,6 +66,7 @@ export class JupyterGISDoc extends YDocument {
51
66
  this._layerTree = this.ydoc.getArray('layerTree');
52
67
  this._sources = this.ydoc.getMap('sources');
53
68
  this._stories = this.ydoc.getMap('stories');
69
+ this._viewState = this.ydoc.getMap('viewState');
54
70
  this._metadata = this.ydoc.getMap('metadata');
55
71
  this.undoManager.addToScope(this._layers);
56
72
  this.undoManager.addToScope(this._sources);
@@ -63,6 +79,7 @@ export class JupyterGISDoc extends YDocument {
63
79
  this._layerTree.observe(this._layerTreeObserver.bind(this));
64
80
  this._sources.observeDeep(this._sourcesObserver.bind(this));
65
81
  this._stories.observeDeep(this._storyMapsObserver.bind(this));
82
+ this._viewState.observe(this._viewStateObserver.bind(this));
66
83
  this._options.observe(this._optionsObserver.bind(this));
67
84
  this._metadata.observe(this._metaObserver.bind(this));
68
85
  }
@@ -82,8 +99,17 @@ export class JupyterGISDoc extends YDocument {
82
99
  const options = this._options.toJSON();
83
100
  const sources = this._sources.toJSON();
84
101
  const stories = this._stories.toJSON();
102
+ const viewState = this._viewState.toJSON();
85
103
  const metadata = this._metadata.toJSON();
86
- return { layers, layerTree, sources, stories, options, metadata };
104
+ return {
105
+ layers,
106
+ layerTree,
107
+ sources,
108
+ stories,
109
+ viewState,
110
+ options,
111
+ metadata,
112
+ };
87
113
  }
88
114
  setSource(value) {
89
115
  if (!value) {
@@ -92,9 +118,11 @@ export class JupyterGISDoc extends YDocument {
92
118
  if (typeof value === 'string') {
93
119
  value = JSON.parse(value);
94
120
  }
95
- 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);
96
124
  this.transact(() => {
97
- var _a, _b, _c, _d, _e, _f;
125
+ var _a, _b, _c, _d, _e, _f, _g;
98
126
  const layers = (_a = value['layers']) !== null && _a !== void 0 ? _a : {};
99
127
  Object.entries(layers).forEach(([key, val]) => this._layers.set(key, val));
100
128
  const layerTree = (_b = value['layerTree']) !== null && _b !== void 0 ? _b : [];
@@ -107,7 +135,9 @@ export class JupyterGISDoc extends YDocument {
107
135
  Object.entries(sources).forEach(([key, val]) => this._sources.set(key, val));
108
136
  const stories = (_e = value['stories']) !== null && _e !== void 0 ? _e : {};
109
137
  Object.entries(stories).forEach(([key, val]) => this._stories.set(key, val));
110
- 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 : {};
111
141
  Object.entries(metadata).forEach(([key, val]) => this._metadata.set(key, val));
112
142
  });
113
143
  }
@@ -147,6 +177,16 @@ export class JupyterGISDoc extends YDocument {
147
177
  get stories() {
148
178
  return JSONExt.deepCopy(this._stories.toJSON());
149
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
+ }
150
190
  get layerTree() {
151
191
  return JSONExt.deepCopy(this._layerTree.toJSON());
152
192
  }
@@ -206,6 +246,9 @@ export class JupyterGISDoc extends YDocument {
206
246
  get storyMapsChanged() {
207
247
  return this._storyMapsChanged;
208
248
  }
249
+ get viewStateChanged() {
250
+ return this._viewStateChanged;
251
+ }
209
252
  get optionsChanged() {
210
253
  return this._optionsChanged;
211
254
  }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Conversions between existing symbology render types and IGrammarSymbologyState.
3
+ *
4
+ * Pure schema transforms with no OL or UI dependencies, usable both as a
5
+ * schema migration step and when the user switches render types in the dialog.
6
+ */
7
+ import { ClassificationMode, IGrammarSymbologyState, RGBA } from '../types';
8
+ /**
9
+ * Legacy symbology state shape — as it existed before Grammar became the sole
10
+ * render type. Used only by migration code that converts old .jGIS files.
11
+ */
12
+ export type SymbologyState = {
13
+ renderType: string;
14
+ value?: string;
15
+ fillColor?: RGBA | number[];
16
+ strokeColor?: RGBA | number[];
17
+ strokeWidth?: number;
18
+ radius?: number;
19
+ joinStyle?: string;
20
+ capStyle?: string;
21
+ colorRamp?: string;
22
+ nClasses?: number;
23
+ reverseRamp?: boolean;
24
+ mode?: ClassificationMode;
25
+ fallbackColor?: RGBA | number[];
26
+ strokeFollowsFill?: boolean;
27
+ vmin?: number;
28
+ vmax?: number;
29
+ stopsOverride?: Array<{
30
+ value?: unknown;
31
+ color?: unknown;
32
+ }>;
33
+ gradient?: string[];
34
+ blur?: number;
35
+ [key: string]: unknown;
36
+ };
37
+ /** Convert a Single Symbol state to Grammar. */
38
+ export declare function singleSymbolToGrammar(state: SymbologyState): IGrammarSymbologyState;
39
+ /**
40
+ * Convert a Graduated state to Grammar.
41
+ * The colorRamp scale stores recipe params; grammarToOLStyle computes
42
+ * classification breaks from featureValues at render time.
43
+ */
44
+ export declare function graduatedToGrammar(state: SymbologyState): IGrammarSymbologyState;
45
+ /**
46
+ * Convert a Categorized state to Grammar.
47
+ * The categorical scale stores recipe params; grammarToOLStyle enumerates
48
+ * unique values from featureValues at render time.
49
+ */
50
+ export declare function categorizedToGrammar(state: SymbologyState): IGrammarSymbologyState;