@jupytergis/schema 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 (44) hide show
  1. package/lib/_interface/forms.json +1987 -0
  2. package/lib/_interface/geoTiffSource.d.ts +31 -0
  3. package/lib/_interface/geojsonsource.d.ts +404 -0
  4. package/lib/_interface/hillshadeLayer.d.ts +20 -0
  5. package/lib/_interface/imageLayer.d.ts +20 -0
  6. package/lib/_interface/imageSource.d.ts +20 -0
  7. package/lib/_interface/jgis.d.ts +140 -0
  8. package/lib/_interface/rasterDemSource.d.ts +28 -0
  9. package/lib/_interface/rasterlayer.d.ts +20 -0
  10. package/lib/_interface/rastersource.d.ts +43 -0
  11. package/lib/_interface/shapefileSource.d.ts +34 -0
  12. package/lib/_interface/vectorTileLayer.d.ts +32 -0
  13. package/lib/_interface/vectorlayer.d.ts +32 -0
  14. package/lib/_interface/vectortilesource.d.ts +35 -0
  15. package/lib/_interface/videoSource.d.ts +20 -0
  16. package/lib/_interface/webGlLayer.d.ts +24 -0
  17. package/lib/doc.d.ts +59 -0
  18. package/lib/doc.js +251 -0
  19. package/lib/index.d.ts +4 -0
  20. package/lib/index.js +4 -0
  21. package/lib/interfaces.d.ts +189 -0
  22. package/lib/interfaces.js +1 -0
  23. package/lib/model.d.ts +142 -0
  24. package/lib/model.js +554 -0
  25. package/lib/schema/geoTiffSource.json +37 -0
  26. package/lib/schema/geojsonsource.json +23 -0
  27. package/lib/schema/hillshadeLayer.json +18 -0
  28. package/lib/schema/imageLayer.json +21 -0
  29. package/lib/schema/imageSource.json +30 -0
  30. package/lib/schema/jgis.json +248 -0
  31. package/lib/schema/rasterDemSource.json +33 -0
  32. package/lib/schema/rasterlayer.json +21 -0
  33. package/lib/schema/rastersource.json +66 -0
  34. package/lib/schema/shapefileSource.json +37 -0
  35. package/lib/schema/vectorTileLayer.json +36 -0
  36. package/lib/schema/vectorlayer.json +36 -0
  37. package/lib/schema/vectortilesource.json +40 -0
  38. package/lib/schema/videoSource.json +33 -0
  39. package/lib/schema/webGlLayer.json +41 -0
  40. package/lib/token.d.ts +6 -0
  41. package/lib/token.js +5 -0
  42. package/lib/types.d.ts +19 -0
  43. package/lib/types.js +22 -0
  44. package/package.json +65 -0
@@ -0,0 +1,43 @@
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
+ * RasterSource
10
+ */
11
+ export interface IRasterSource {
12
+ /**
13
+ * The url to the tile provider
14
+ */
15
+ url: string;
16
+ /**
17
+ * The minimum zoom level for the raster source
18
+ */
19
+ minZoom: number;
20
+ /**
21
+ * The maximum zoom level for the raster source
22
+ */
23
+ maxZoom: number;
24
+ /**
25
+ * The attribution for the raster source
26
+ */
27
+ attribution?: string;
28
+ /**
29
+ * The html attribution for the raster source
30
+ */
31
+ htmlAttribution?: string;
32
+ /**
33
+ * The map provider
34
+ */
35
+ provider?: string;
36
+ /**
37
+ * The bounds of the source
38
+ */
39
+ bounds?: number[][];
40
+ urlParameters?: {
41
+ [k: string]: string;
42
+ };
43
+ }
@@ -0,0 +1,34 @@
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
+ * ShapefileSource
10
+ */
11
+ export interface IShapefileSource {
12
+ /**
13
+ * The path to the shapefile (.shp, .zip, or folder URL).
14
+ */
15
+ path: string;
16
+ /**
17
+ * The attribution for the shapefile source.
18
+ */
19
+ attribution?: string;
20
+ /**
21
+ * The projection information for the shapefile (optional).
22
+ */
23
+ projection?: string;
24
+ /**
25
+ * The encoding used for the shapefile's DBF (optional).
26
+ */
27
+ encoding?: string;
28
+ /**
29
+ * Additional files associated with the shapefile (e.g., .dbf, .prj, .cpg).
30
+ */
31
+ additionalFiles?: {
32
+ [k: string]: string;
33
+ };
34
+ }
@@ -0,0 +1,32 @@
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
+ * VectorTileLayer
10
+ */
11
+ export interface IVectorTileLayer {
12
+ /**
13
+ * The id of the source
14
+ */
15
+ source: string;
16
+ /**
17
+ * The type of vector layer
18
+ */
19
+ type: "circle" | "fill" | "line";
20
+ /**
21
+ * The source layer to use
22
+ */
23
+ sourceLayer?: string;
24
+ /**
25
+ * The color of the the object
26
+ */
27
+ color?: string;
28
+ /**
29
+ * The opacity of the the object
30
+ */
31
+ opacity?: number;
32
+ }
@@ -0,0 +1,32 @@
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
+ * VectorLayer
10
+ */
11
+ export interface IVectorLayer {
12
+ /**
13
+ * The id of the source
14
+ */
15
+ source: string;
16
+ /**
17
+ * The type of vector layer
18
+ */
19
+ type: "circle" | "fill" | "line";
20
+ /**
21
+ * The source layer to use
22
+ */
23
+ sourceLayer?: string;
24
+ /**
25
+ * The color of the the object
26
+ */
27
+ color?: string;
28
+ /**
29
+ * The opacity of the the object
30
+ */
31
+ opacity?: number;
32
+ }
@@ -0,0 +1,35 @@
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
+ * VectorTileSource
10
+ */
11
+ export interface IVectorTileSource {
12
+ /**
13
+ * The url to the tile provider
14
+ */
15
+ url: string;
16
+ /**
17
+ * The minimum zoom level for the vector source
18
+ */
19
+ minZoom: number;
20
+ /**
21
+ * The maximum zoom level for the vector source
22
+ */
23
+ maxZoom: number;
24
+ /**
25
+ * The attribution for the vector source
26
+ */
27
+ attribution?: string;
28
+ /**
29
+ * The map provider
30
+ */
31
+ provider?: string;
32
+ urlParameters?: {
33
+ [k: string]: string;
34
+ };
35
+ }
@@ -0,0 +1,20 @@
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
+ * VideoSource
10
+ */
11
+ export interface IVideoSource {
12
+ /**
13
+ * URLs to video content in order of preferred format
14
+ */
15
+ urls: [string, ...string[]];
16
+ /**
17
+ * Corners of video specified in longitude, latitude pairs
18
+ */
19
+ coordinates: [[number, number], [number, number], [number, number], [number, number]];
20
+ }
@@ -0,0 +1,24 @@
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
+ * WebGlLayer
10
+ */
11
+ export interface IWebGlLayer {
12
+ /**
13
+ * The id of the source
14
+ */
15
+ source: string;
16
+ /**
17
+ * The opacity of the source
18
+ */
19
+ opacity?: number;
20
+ /**
21
+ * The color of the the object
22
+ */
23
+ color?: string | (string | number | string[])[];
24
+ }
package/lib/doc.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ import { MapChange, YDocument } from '@jupyter/ydoc';
2
+ import { ISignal } from '@lumino/signaling';
3
+ import { IJGISLayer, IJGISLayerItem, IJGISLayerTree, IJGISLayers, IJGISOptions, IJGISSource, IJGISSources, IJGISTerrain } from './_interface/jgis';
4
+ import { IDict, IJGISLayerDocChange, IJGISLayerTreeDocChange, IJGISSourceDocChange, IJupyterGISDoc, IJupyterGISDocChange } from './interfaces';
5
+ export declare class JupyterGISDoc extends YDocument<IJupyterGISDocChange> implements IJupyterGISDoc {
6
+ constructor();
7
+ dispose(): void;
8
+ get version(): string;
9
+ get layers(): IJGISLayers;
10
+ set layers(layers: IJGISLayers);
11
+ set sources(sources: IJGISSources);
12
+ get sources(): IJGISSources;
13
+ get layerTree(): IJGISLayerTree;
14
+ set layerTree(layerTree: IJGISLayerTree);
15
+ get terrain(): IJGISTerrain;
16
+ set terrain(terrain: IJGISTerrain);
17
+ getLayer(id: string): IJGISLayer | undefined;
18
+ getSource(id: string): IJGISSource | undefined;
19
+ set options(options: IJGISOptions);
20
+ get options(): IJGISOptions;
21
+ get layersChanged(): ISignal<IJupyterGISDoc, IJGISLayerDocChange>;
22
+ get layerTreeChanged(): ISignal<IJupyterGISDoc, IJGISLayerTreeDocChange>;
23
+ get sourcesChanged(): ISignal<IJupyterGISDoc, IJGISSourceDocChange>;
24
+ get optionsChanged(): ISignal<IJupyterGISDoc, MapChange>;
25
+ get terrainChanged(): ISignal<IJupyterGISDoc, IJGISTerrain>;
26
+ layerExists(id: string): boolean;
27
+ removeLayer(id: string): void;
28
+ addLayer(id: string, value: IJGISLayer): void;
29
+ updateLayer(id: string, value: IJGISLayer): void;
30
+ addLayerTreeItem(index: number, item: IJGISLayerItem): void;
31
+ updateLayerTreeItem(index: number, item: IJGISLayerItem): void;
32
+ getObject(id: string): IJGISLayer | IJGISSource | undefined;
33
+ updateObjectParameters(id: string, value: IJGISLayer['parameters'] | IJGISSource['parameters']): void;
34
+ sourceExists(id: string): boolean;
35
+ removeSource(id: string): void;
36
+ addSource(id: string, value: IJGISSource): void;
37
+ updateSource(id: string, value: any): void;
38
+ getOption(key: keyof IJGISOptions): IDict | undefined;
39
+ setOption(key: keyof IJGISOptions, value: IDict): void;
40
+ static create(): IJupyterGISDoc;
41
+ editable: boolean;
42
+ private _getLayerAsYMap;
43
+ private _getSourceAsYMap;
44
+ private _layersObserver;
45
+ private _layerTreeObserver;
46
+ private _sourcesObserver;
47
+ private _terrainObserver;
48
+ private _optionsObserver;
49
+ private _layers;
50
+ private _layerTree;
51
+ private _sources;
52
+ private _options;
53
+ private _terrain;
54
+ private _optionsChanged;
55
+ private _layersChanged;
56
+ private _layerTreeChanged;
57
+ private _sourcesChanged;
58
+ private _terrainChanged;
59
+ }
package/lib/doc.js ADDED
@@ -0,0 +1,251 @@
1
+ import { YDocument } from '@jupyter/ydoc';
2
+ import { JSONExt } from '@lumino/coreutils';
3
+ import { Signal } from '@lumino/signaling';
4
+ export class JupyterGISDoc extends YDocument {
5
+ constructor() {
6
+ super();
7
+ this.editable = true;
8
+ this._optionsObserver = (event) => {
9
+ this._optionsChanged.emit(event.keys);
10
+ };
11
+ this._optionsChanged = new Signal(this);
12
+ this._layersChanged = new Signal(this);
13
+ this._layerTreeChanged = new Signal(this);
14
+ this._sourcesChanged = new Signal(this);
15
+ this._terrainChanged = new Signal(this);
16
+ this._options = this.ydoc.getMap('options');
17
+ this._layers = this.ydoc.getMap('layers');
18
+ this._layerTree = this.ydoc.getArray('layerTree');
19
+ this._sources = this.ydoc.getMap('sources');
20
+ this._terrain = this.ydoc.getMap('terrain');
21
+ this.undoManager.addToScope(this._layers);
22
+ this.undoManager.addToScope(this._sources);
23
+ this.undoManager.addToScope(this._layerTree);
24
+ this._layers.observeDeep(this._layersObserver.bind(this));
25
+ this._layerTree.observe(this._layerTreeObserver.bind(this));
26
+ this._sources.observeDeep(this._sourcesObserver.bind(this));
27
+ this._terrain.observe(this._terrainObserver.bind(this));
28
+ this._options.observe(this._optionsObserver.bind(this));
29
+ }
30
+ dispose() {
31
+ super.dispose();
32
+ }
33
+ get version() {
34
+ return '0.1.0';
35
+ }
36
+ get layers() {
37
+ return JSONExt.deepCopy(this._layers.toJSON());
38
+ }
39
+ set layers(layers) {
40
+ this.transact(() => {
41
+ for (const [key, value] of Object.entries(layers)) {
42
+ this._layers.set(key, value);
43
+ }
44
+ });
45
+ }
46
+ set sources(sources) {
47
+ this.transact(() => {
48
+ for (const [key, value] of Object.entries(sources)) {
49
+ this._sources.set(key, value);
50
+ }
51
+ });
52
+ }
53
+ get sources() {
54
+ return JSONExt.deepCopy(this._sources.toJSON());
55
+ }
56
+ get layerTree() {
57
+ return JSONExt.deepCopy(this._layerTree.toJSON());
58
+ }
59
+ set layerTree(layerTree) {
60
+ this.transact(() => {
61
+ this._layerTree.delete(0, this._layerTree.length);
62
+ this._layerTree.push(layerTree);
63
+ });
64
+ }
65
+ get terrain() {
66
+ return JSONExt.deepCopy(this._terrain.toJSON());
67
+ }
68
+ set terrain(terrain) {
69
+ this.transact(() => {
70
+ for (const [key, value] of Object.entries(terrain)) {
71
+ this._terrain.set(key, value);
72
+ }
73
+ });
74
+ }
75
+ getLayer(id) {
76
+ if (!this._layers.has(id)) {
77
+ return undefined;
78
+ }
79
+ return JSONExt.deepCopy(this._layers.get(id));
80
+ }
81
+ getSource(id) {
82
+ if (!this._sources.has(id)) {
83
+ return undefined;
84
+ }
85
+ return JSONExt.deepCopy(this._sources.get(id));
86
+ }
87
+ set options(options) {
88
+ this.transact(() => {
89
+ for (const [key, value] of Object.entries(options)) {
90
+ this._options.set(key, value);
91
+ }
92
+ });
93
+ }
94
+ get options() {
95
+ return JSONExt.deepCopy(this._options.toJSON());
96
+ }
97
+ get layersChanged() {
98
+ return this._layersChanged;
99
+ }
100
+ get layerTreeChanged() {
101
+ return this._layerTreeChanged;
102
+ }
103
+ get sourcesChanged() {
104
+ return this._sourcesChanged;
105
+ }
106
+ get optionsChanged() {
107
+ return this._optionsChanged;
108
+ }
109
+ get terrainChanged() {
110
+ return this._terrainChanged;
111
+ }
112
+ layerExists(id) {
113
+ return Boolean(this._getLayerAsYMap(id));
114
+ }
115
+ removeLayer(id) {
116
+ this.transact(() => {
117
+ this._layers.delete(id);
118
+ });
119
+ }
120
+ addLayer(id, value) {
121
+ this.transact(() => {
122
+ this._layers.set(id, value);
123
+ });
124
+ }
125
+ updateLayer(id, value) {
126
+ this.transact(() => {
127
+ this._layers.set(id, value);
128
+ });
129
+ }
130
+ addLayerTreeItem(index, item) {
131
+ this.transact(() => {
132
+ this._layerTree.insert(index, [item]);
133
+ });
134
+ }
135
+ updateLayerTreeItem(index, item) {
136
+ this.transact(() => {
137
+ this._layerTree.delete(index);
138
+ if (item) {
139
+ this._layerTree.insert(index, [item]);
140
+ }
141
+ });
142
+ }
143
+ getObject(id) {
144
+ const layer = this.getLayer(id);
145
+ if (layer) {
146
+ return layer;
147
+ }
148
+ const source = this.getSource(id);
149
+ if (source) {
150
+ return source;
151
+ }
152
+ }
153
+ updateObjectParameters(id, value) {
154
+ const layer = this.getLayer(id);
155
+ if (layer) {
156
+ layer.parameters = Object.assign(Object.assign({}, layer.parameters), value);
157
+ this.updateLayer(id, layer);
158
+ }
159
+ const source = this.getSource(id);
160
+ if (source) {
161
+ source.parameters = Object.assign(Object.assign({}, source.parameters), value);
162
+ this.updateSource(id, source);
163
+ }
164
+ }
165
+ sourceExists(id) {
166
+ return Boolean(this._getSourceAsYMap(id));
167
+ }
168
+ removeSource(id) {
169
+ this.transact(() => {
170
+ this._sources.delete(id);
171
+ });
172
+ }
173
+ addSource(id, value) {
174
+ this.transact(() => {
175
+ this._sources.set(id, value);
176
+ });
177
+ }
178
+ updateSource(id, value) {
179
+ this.transact(() => this._sources.set(id, value));
180
+ }
181
+ getOption(key) {
182
+ const content = this._options.get(key);
183
+ if (!content) {
184
+ return;
185
+ }
186
+ return JSONExt.deepCopy(content);
187
+ }
188
+ setOption(key, value) {
189
+ this.transact(() => void this._options.set(key, value));
190
+ }
191
+ static create() {
192
+ return new JupyterGISDoc();
193
+ }
194
+ _getLayerAsYMap(id) {
195
+ if (this._layers.has(id)) {
196
+ return this._layers.get(id);
197
+ }
198
+ return undefined;
199
+ }
200
+ _getSourceAsYMap(id) {
201
+ if (this._sources.has(id)) {
202
+ return this._sources.get(id);
203
+ }
204
+ return undefined;
205
+ }
206
+ _layersObserver(events) {
207
+ const changes = [];
208
+ let needEmit = false;
209
+ events.forEach(event => {
210
+ event.keys.forEach((change, key) => {
211
+ if (!needEmit) {
212
+ needEmit = true;
213
+ }
214
+ changes.push({
215
+ id: key,
216
+ newValue: JSONExt.deepCopy(event.target.toJSON()[key])
217
+ });
218
+ });
219
+ });
220
+ needEmit = changes.length === 0 ? true : needEmit;
221
+ if (needEmit) {
222
+ this._layersChanged.emit({ layerChange: changes });
223
+ }
224
+ }
225
+ _layerTreeObserver(event) {
226
+ const layerTreeChanges = event.delta;
227
+ this._layerTreeChanged.emit({ layerTreeChange: layerTreeChanges });
228
+ }
229
+ _sourcesObserver(events) {
230
+ const changes = [];
231
+ let needEmit = false;
232
+ events.forEach(event => {
233
+ event.keys.forEach((change, key) => {
234
+ if (!needEmit) {
235
+ needEmit = true;
236
+ }
237
+ changes.push({
238
+ id: key,
239
+ newValue: JSONExt.deepCopy(event.target.toJSON()[key])
240
+ });
241
+ });
242
+ });
243
+ needEmit = changes.length === 0 ? true : needEmit;
244
+ if (needEmit) {
245
+ this._sourcesChanged.emit({ sourceChange: changes });
246
+ }
247
+ }
248
+ _terrainObserver(event) {
249
+ this._terrainChanged.emit(this.terrain);
250
+ }
251
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './interfaces';
2
+ export * from './model';
3
+ export * from './token';
4
+ export * from './doc';
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './interfaces';
2
+ export * from './model';
3
+ export * from './token';
4
+ export * from './doc';