@jupytergis/schema 0.1.6 → 0.1.7

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.
@@ -344,6 +344,53 @@
344
344
  "multipleOf": 0.1,
345
345
  "minimum": 0,
346
346
  "maximum": 1
347
+ },
348
+ "symbologyState": {
349
+ "type": "object",
350
+ "description": "The state of the symbology panel options",
351
+ "required": [
352
+ "renderType"
353
+ ],
354
+ "properties": {
355
+ "renderType": {
356
+ "type": "string",
357
+ "enum": [
358
+ "Single Symbol",
359
+ "Graduated",
360
+ "Categorized"
361
+ ]
362
+ },
363
+ "value": {
364
+ "type": "string"
365
+ },
366
+ "method": {
367
+ "type": "string",
368
+ "enum": [
369
+ "color",
370
+ "radius"
371
+ ]
372
+ },
373
+ "colorRamp": {
374
+ "type": "string",
375
+ "default": "cool"
376
+ },
377
+ "nClasses": {
378
+ "type": "string",
379
+ "default": "9"
380
+ },
381
+ "mode": {
382
+ "type": "string",
383
+ "default": "equal interval",
384
+ "enum": [
385
+ "quantile",
386
+ "equal interval",
387
+ "jenks",
388
+ "pretty",
389
+ "logarithmic"
390
+ ]
391
+ }
392
+ },
393
+ "additionalProperties": false
347
394
  }
348
395
  }
349
396
  },
@@ -491,6 +538,52 @@
491
538
  }
492
539
  ],
493
540
  "description": "The color of the the object"
541
+ },
542
+ "symbologyState": {
543
+ "type": "object",
544
+ "description": "The state of the symbology panel options",
545
+ "required": [
546
+ "renderType",
547
+ "band",
548
+ "interpolation",
549
+ "colorRamp",
550
+ "nClasses",
551
+ "mode"
552
+ ],
553
+ "properties": {
554
+ "renderType": {
555
+ "type": "string"
556
+ },
557
+ "band": {
558
+ "type": "number"
559
+ },
560
+ "interpolation": {
561
+ "type": "string",
562
+ "enum": [
563
+ "discrete",
564
+ "linear",
565
+ "exact"
566
+ ]
567
+ },
568
+ "colorRamp": {
569
+ "type": "string",
570
+ "default": "cool"
571
+ },
572
+ "nClasses": {
573
+ "type": "string",
574
+ "default": "9"
575
+ },
576
+ "mode": {
577
+ "type": "string",
578
+ "default": "equal interval",
579
+ "enum": [
580
+ "continuous",
581
+ "equal interval",
582
+ "quantile"
583
+ ]
584
+ }
585
+ },
586
+ "additionalProperties": false
494
587
  }
495
588
  }
496
589
  },
@@ -31,4 +31,15 @@ export interface IVectorLayer {
31
31
  * The opacity of the the object
32
32
  */
33
33
  opacity?: number;
34
+ /**
35
+ * The state of the symbology panel options
36
+ */
37
+ symbologyState?: {
38
+ renderType: "Single Symbol" | "Graduated" | "Categorized";
39
+ value?: string;
40
+ method?: "color" | "radius";
41
+ colorRamp?: string;
42
+ nClasses?: string;
43
+ mode?: "quantile" | "equal interval" | "jenks" | "pretty" | "logarithmic";
44
+ };
34
45
  }
@@ -21,4 +21,15 @@ export interface IWebGlLayer {
21
21
  * The color of the the object
22
22
  */
23
23
  color?: string | number | (string | number | (number | string | (number | string)[])[])[];
24
+ /**
25
+ * The state of the symbology panel options
26
+ */
27
+ symbologyState?: {
28
+ renderType: string;
29
+ band: number;
30
+ interpolation: "discrete" | "linear" | "exact";
31
+ colorRamp: string;
32
+ nClasses: string;
33
+ mode: "continuous" | "equal interval" | "quantile";
34
+ };
24
35
  }
package/lib/doc.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import { MapChange, YDocument } from '@jupyter/ydoc';
2
+ import { JSONObject } from '@lumino/coreutils';
2
3
  import { ISignal } from '@lumino/signaling';
3
4
  import { IJGISLayer, IJGISLayerItem, IJGISLayerTree, IJGISLayers, IJGISOptions, IJGISSource, IJGISSources } from './_interface/jgis';
4
5
  import { IDict, IJGISLayerDocChange, IJGISLayerTreeDocChange, IJGISSourceDocChange, IJupyterGISDoc, IJupyterGISDocChange } from './interfaces';
5
6
  export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> implements IJupyterGISDoc {
6
7
  constructor();
8
+ getSource(): JSONObject;
9
+ setSource(value: JSONObject): void;
7
10
  dispose(): void;
8
11
  get version(): string;
9
12
  get layers(): IJGISLayers;
@@ -13,7 +16,7 @@ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> imple
13
16
  get layerTree(): IJGISLayerTree;
14
17
  set layerTree(layerTree: IJGISLayerTree);
15
18
  getLayer(id: string): IJGISLayer | undefined;
16
- getSource(id: string): IJGISSource | undefined;
19
+ getLayerSource(id: string): IJGISSource | undefined;
17
20
  set options(options: IJGISOptions);
18
21
  get options(): IJGISOptions;
19
22
  get layersChanged(): ISignal<IJupyterGISDoc, IJGISLayerDocChange>;
package/lib/doc.js CHANGED
@@ -24,6 +24,31 @@ export class JupyterGISDoc extends YDocument {
24
24
  this._sources.observeDeep(this._sourcesObserver.bind(this));
25
25
  this._options.observe(this._optionsObserver.bind(this));
26
26
  }
27
+ getSource() {
28
+ const layers = this._layers.toJSON();
29
+ const layerTree = this._layerTree.toJSON();
30
+ const options = this._options.toJSON();
31
+ const sources = this._sources.toJSON();
32
+ return { layers, layerTree, sources, options };
33
+ }
34
+ setSource(value) {
35
+ if (!value) {
36
+ return;
37
+ }
38
+ this.transact(() => {
39
+ var _a, _b, _c, _d;
40
+ const layers = (_a = value['layers']) !== null && _a !== void 0 ? _a : {};
41
+ Object.entries(layers).forEach(([key, val]) => this._layers.set(key, val));
42
+ const layerTree = (_b = value['layerTree']) !== null && _b !== void 0 ? _b : [];
43
+ layerTree.forEach(layer => {
44
+ this._layerTree.push([layer]);
45
+ });
46
+ const options = (_c = value['options']) !== null && _c !== void 0 ? _c : {};
47
+ Object.entries(options).forEach(([key, val]) => this._options.set(key, val));
48
+ const sources = (_d = value['sources']) !== null && _d !== void 0 ? _d : {};
49
+ Object.entries(sources).forEach(([key, val]) => this._sources.set(key, val));
50
+ });
51
+ }
27
52
  dispose() {
28
53
  super.dispose();
29
54
  }
@@ -65,7 +90,7 @@ export class JupyterGISDoc extends YDocument {
65
90
  }
66
91
  return JSONExt.deepCopy(this._layers.get(id));
67
92
  }
68
- getSource(id) {
93
+ getLayerSource(id) {
69
94
  if (!this._sources.has(id)) {
70
95
  return undefined;
71
96
  }
@@ -129,7 +154,7 @@ export class JupyterGISDoc extends YDocument {
129
154
  if (layer) {
130
155
  return layer;
131
156
  }
132
- const source = this.getSource(id);
157
+ const source = this.getLayerSource(id);
133
158
  if (source) {
134
159
  return source;
135
160
  }
@@ -140,7 +165,7 @@ export class JupyterGISDoc extends YDocument {
140
165
  layer.parameters = Object.assign(Object.assign({}, layer.parameters), value);
141
166
  this.updateLayer(id, layer);
142
167
  }
143
- const source = this.getSource(id);
168
+ const source = this.getLayerSource(id);
144
169
  if (source) {
145
170
  source.parameters = Object.assign(Object.assign({}, source.parameters), value);
146
171
  this.updateSource(id, source);
@@ -1,4 +1,4 @@
1
- import { ICollaborativeDrive } from '@jupyter/docprovider';
1
+ import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
2
2
  import { Delta, DocumentChange, MapChange, StateChange, YDocument } from '@jupyter/ydoc';
3
3
  import { IWidgetTracker } from '@jupyterlab/apputils';
4
4
  import { IChangedArgs } from '@jupyterlab/coreutils';
@@ -58,7 +58,7 @@ export interface IJupyterGISDoc extends YDocument<IJupyterGISDocChange> {
58
58
  addLayer(id: string, value: IJGISLayer, groupName?: string, position?: number): void;
59
59
  updateLayer(id: string, value: IJGISLayer): void;
60
60
  sourceExists(id: string): boolean;
61
- getSource(id: string): IJGISSource | undefined;
61
+ getLayerSource(id: string): IJGISSource | undefined;
62
62
  removeSource(id: string): void;
63
63
  addSource(id: string, value: IJGISSource): void;
64
64
  updateSource(id: string, value: IJGISSource): void;
package/lib/model.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICollaborativeDrive } from '@jupyter/docprovider';
1
+ import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
2
2
  import { MapChange } from '@jupyter/ydoc';
3
3
  import { IChangedArgs } from '@jupyterlab/coreutils';
4
4
  import { DocumentRegistry } from '@jupyterlab/docregistry';
@@ -10,7 +10,7 @@ import { IJGISLayerDocChange, IJGISLayerTreeDocChange, IJGISSourceDocChange, IJu
10
10
  export declare class JupyterGISModel implements IJupyterGISModel {
11
11
  constructor(options: DocumentRegistry.IModelOptions<IJupyterGISDoc>);
12
12
  private _onSharedModelChanged;
13
- readonly collaborative = true;
13
+ readonly collaborative: boolean;
14
14
  get sharedModel(): IJupyterGISDoc;
15
15
  get isDisposed(): boolean;
16
16
  get contentChanged(): ISignal<this, void>;
package/lib/model.js CHANGED
@@ -12,7 +12,7 @@ export class JupyterGISModel {
12
12
  this.dirty = true;
13
13
  }
14
14
  };
15
- this.collaborative = true;
15
+ this.collaborative = document.querySelectorAll('[data-jupyter-lite-root]')[0] === undefined;
16
16
  this._onClientStateChanged = (changed) => {
17
17
  const clients = this.sharedModel.awareness.getStates();
18
18
  this._clientStateChanged.emit(clients);
@@ -127,11 +127,11 @@ export class JupyterGISModel {
127
127
  const validate = ajv.compile(jgisSchema);
128
128
  const valid = validate(jsonData);
129
129
  if (!valid) {
130
- let errorMsg = 'File format errors:\n';
130
+ let errorMsg = 'JupyterGIS format errors:\n';
131
131
  for (const error of validate.errors || []) {
132
132
  errorMsg = `${errorMsg}- ${error.instancePath} ${error.message}\n`;
133
133
  }
134
- throw Error(errorMsg);
134
+ console.warn(errorMsg);
135
135
  }
136
136
  this.sharedModel.transact(() => {
137
137
  var _a, _b, _c, _d;
@@ -186,7 +186,7 @@ export class JupyterGISModel {
186
186
  return this.sharedModel.getLayer(id);
187
187
  }
188
188
  getSource(id) {
189
- return this.sharedModel.getSource(id);
189
+ return this.sharedModel.getLayerSource(id);
190
190
  }
191
191
  /**
192
192
  * Get a {[key: id]: name} dictionary of sources for a given source type
@@ -30,6 +30,44 @@
30
30
  "multipleOf": 0.1,
31
31
  "minimum": 0,
32
32
  "maximum": 1
33
+ },
34
+ "symbologyState": {
35
+ "type": "object",
36
+ "description": "The state of the symbology panel options",
37
+ "required": ["renderType"],
38
+ "properties": {
39
+ "renderType": {
40
+ "type": "string",
41
+ "enum": ["Single Symbol", "Graduated", "Categorized"]
42
+ },
43
+ "value": {
44
+ "type": "string"
45
+ },
46
+ "method": {
47
+ "type": "string",
48
+ "enum": ["color", "radius"]
49
+ },
50
+ "colorRamp": {
51
+ "type": "string",
52
+ "default": "cool"
53
+ },
54
+ "nClasses": {
55
+ "type": "string",
56
+ "default": "9"
57
+ },
58
+ "mode": {
59
+ "type": "string",
60
+ "default": "equal interval",
61
+ "enum": [
62
+ "quantile",
63
+ "equal interval",
64
+ "jenks",
65
+ "pretty",
66
+ "logarithmic"
67
+ ]
68
+ }
69
+ },
70
+ "additionalProperties": false
33
71
  }
34
72
  }
35
73
  }
@@ -47,6 +47,44 @@
47
47
  }
48
48
  ],
49
49
  "description": "The color of the the object"
50
+ },
51
+ "symbologyState": {
52
+ "type": "object",
53
+ "description": "The state of the symbology panel options",
54
+ "required": [
55
+ "renderType",
56
+ "band",
57
+ "interpolation",
58
+ "colorRamp",
59
+ "nClasses",
60
+ "mode"
61
+ ],
62
+ "properties": {
63
+ "renderType": {
64
+ "type": "string"
65
+ },
66
+ "band": {
67
+ "type": "number"
68
+ },
69
+ "interpolation": {
70
+ "type": "string",
71
+ "enum": ["discrete", "linear", "exact"]
72
+ },
73
+ "colorRamp": {
74
+ "type": "string",
75
+ "default": "cool"
76
+ },
77
+ "nClasses": {
78
+ "type": "string",
79
+ "default": "9"
80
+ },
81
+ "mode": {
82
+ "type": "string",
83
+ "default": "equal interval",
84
+ "enum": ["continuous", "equal interval", "quantile"]
85
+ }
86
+ },
87
+ "additionalProperties": false
50
88
  }
51
89
  }
52
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupytergis/schema",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "A JupyterGIS schema package.",
5
5
  "keywords": [
6
6
  "jupytergis"
@@ -25,12 +25,12 @@
25
25
  "url": "https://github.com/geojupyter/jupytergis.git"
26
26
  },
27
27
  "scripts": {
28
- "build": "jlpm build:schema && jlpm run build:lib",
28
+ "build": "jlpm build:schema && jlpm build:lib",
29
29
  "build:schema": "jlpm build:schema:js && jlpm build:schema:py",
30
30
  "build:schema:js": "json2ts -i src/schema -o src/_interface --no-unknownAny --unreachableDefinitions --cwd ./src/schema && cd src/schema && node ../../schema.js",
31
31
  "build:schema:py": "datamodel-codegen --input ./src/schema --output ../../python/jupytergis_lab/jupytergis_lab/notebook/objects/_schema --output-model-type pydantic_v2.BaseModel --input-file-type jsonschema",
32
32
  "build:prod": "jlpm run clean && jlpm build:schema && jlpm run build:lib",
33
- "build:lib": "tsc",
33
+ "build:lib": "tsc -b",
34
34
  "build:dev": "jlpm run build",
35
35
  "clean": "rimraf tsconfig.tsbuildinfo",
36
36
  "clean:lib": "rimraf lib tsconfig.tsbuildinfo",
@@ -39,13 +39,13 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@apidevtools/json-schema-ref-parser": "^9.0.9",
42
- "@jupyter/docprovider": "^2.0.0",
43
- "@jupyter/ydoc": "^1.0.0",
44
- "@jupyterlab/apputils": "^4.0.0",
45
- "@jupyterlab/coreutils": "^6.0.0",
46
- "@jupyterlab/docregistry": "^4.0.0",
47
- "@jupyterlab/services": "^7.0.0",
48
- "@jupyterlab/ui-components": "^4.0.0",
42
+ "@jupyter/collaborative-drive": "^3.0.0",
43
+ "@jupyter/ydoc": "^2.0.0 || ^3.0.0",
44
+ "@jupyterlab/apputils": "^4.3.0",
45
+ "@jupyterlab/coreutils": "^6.3.0",
46
+ "@jupyterlab/docregistry": "^4.3.0",
47
+ "@jupyterlab/services": "^7.3.0",
48
+ "@jupyterlab/ui-components": "^4.3.0",
49
49
  "@lumino/coreutils": "^2.0.0",
50
50
  "@lumino/signaling": "^2.0.0",
51
51
  "ajv": "8.16.0",