@jupytergis/schema 0.11.1 → 0.12.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.
- package/lib/_interface/project/jgis.d.ts +22 -8
- package/lib/interfaces.d.ts +4 -2
- package/lib/model.d.ts +9 -2
- package/lib/model.js +28 -13
- package/lib/schema/project/jgis.json +16 -1
- package/package.json +1 -1
|
@@ -45,6 +45,22 @@ export type IJGISLayerItem = string | IJGISLayerGroup;
|
|
|
45
45
|
*/
|
|
46
46
|
export type IJGISLayerTree = IJGISLayerItem[];
|
|
47
47
|
export type WhetherPresentationModeIsActive = boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The title of the story map
|
|
50
|
+
*/
|
|
51
|
+
export type Title = string;
|
|
52
|
+
/**
|
|
53
|
+
* The type of story map
|
|
54
|
+
*/
|
|
55
|
+
export type StoryType = "guided" | "unguided";
|
|
56
|
+
/**
|
|
57
|
+
* The background color of the story map
|
|
58
|
+
*/
|
|
59
|
+
export type PresentationBackgroundColor = string;
|
|
60
|
+
/**
|
|
61
|
+
* The text color of the story map
|
|
62
|
+
*/
|
|
63
|
+
export type PresentationTextColor = string;
|
|
48
64
|
|
|
49
65
|
export interface IJGISContent {
|
|
50
66
|
schemaVersion?: string;
|
|
@@ -52,6 +68,7 @@ export interface IJGISContent {
|
|
|
52
68
|
sources: IJGISSources;
|
|
53
69
|
layerTree?: IJGISLayerTree;
|
|
54
70
|
options?: IJGISOptions;
|
|
71
|
+
stories?: IJGISStoryMap;
|
|
55
72
|
metadata?: {
|
|
56
73
|
/**
|
|
57
74
|
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
@@ -149,16 +166,13 @@ export interface IJGISOptions {
|
|
|
149
166
|
* via the `definition` "jGISStoryMap".
|
|
150
167
|
*/
|
|
151
168
|
export interface IJGISStoryMap {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*/
|
|
155
|
-
title?: string;
|
|
156
|
-
/**
|
|
157
|
-
* The type of story map
|
|
158
|
-
*/
|
|
159
|
-
storyType?: "guided" | "unguided";
|
|
169
|
+
title?: Title;
|
|
170
|
+
storyType?: StoryType;
|
|
160
171
|
/**
|
|
161
172
|
* Array of story segments for the story map
|
|
162
173
|
*/
|
|
163
174
|
storySegments?: string[];
|
|
175
|
+
presentaionBgColor?: PresentationBackgroundColor;
|
|
176
|
+
presentaionTextColor?: PresentationTextColor;
|
|
177
|
+
[k: string]: any;
|
|
164
178
|
}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -229,13 +229,14 @@ export interface IJupyterGISModel extends DocumentRegistry.IModel {
|
|
|
229
229
|
triggerLayerUpdate(layerId: string, layer: IJGISLayer): void;
|
|
230
230
|
disposed: ISignal<any, void>;
|
|
231
231
|
getSelectedStory(): {
|
|
232
|
-
|
|
232
|
+
storyId: string;
|
|
233
233
|
story: IJGISStoryMap | undefined;
|
|
234
234
|
};
|
|
235
235
|
addStorySegment(): {
|
|
236
236
|
storySegmentId: string;
|
|
237
|
-
|
|
237
|
+
storyId: string;
|
|
238
238
|
} | null;
|
|
239
|
+
isSpectaMode(): boolean;
|
|
239
240
|
}
|
|
240
241
|
export interface IUserData {
|
|
241
242
|
userId: number;
|
|
@@ -341,4 +342,5 @@ export interface IJupyterGISSettings {
|
|
|
341
342
|
annotationsDisabled?: boolean;
|
|
342
343
|
identifyDisabled?: boolean;
|
|
343
344
|
storyMapsDisabled: boolean;
|
|
345
|
+
zoomButtonsEnabled?: boolean;
|
|
344
346
|
}
|
package/lib/model.d.ts
CHANGED
|
@@ -157,12 +157,19 @@ export declare class JupyterGISModel implements IJupyterGISModel {
|
|
|
157
157
|
itemId: string;
|
|
158
158
|
} | null>;
|
|
159
159
|
getClientId(): number;
|
|
160
|
+
/**
|
|
161
|
+
* Check if the application is running in Specta mode.
|
|
162
|
+
* Specta mode is enabled when the URL contains 'specta' AND the model has stories.
|
|
163
|
+
*
|
|
164
|
+
* @returns True if running in Specta mode
|
|
165
|
+
*/
|
|
166
|
+
isSpectaMode(): boolean;
|
|
160
167
|
/**
|
|
161
168
|
* Placeholder in case we eventually want to support multiple stories
|
|
162
169
|
* @returns First/only story
|
|
163
170
|
*/
|
|
164
171
|
getSelectedStory(): {
|
|
165
|
-
|
|
172
|
+
storyId: string;
|
|
166
173
|
story: IJGISStoryMap | undefined;
|
|
167
174
|
};
|
|
168
175
|
/**
|
|
@@ -171,7 +178,7 @@ export declare class JupyterGISModel implements IJupyterGISModel {
|
|
|
171
178
|
*/
|
|
172
179
|
addStorySegment(): {
|
|
173
180
|
storySegmentId: string;
|
|
174
|
-
|
|
181
|
+
storyId: string;
|
|
175
182
|
} | null;
|
|
176
183
|
/**
|
|
177
184
|
* Add an item in the layer tree.
|
package/lib/model.js
CHANGED
|
@@ -15,6 +15,7 @@ const DEFAULT_SETTINGS = {
|
|
|
15
15
|
annotationsDisabled: false,
|
|
16
16
|
identifyDisabled: false,
|
|
17
17
|
storyMapsDisabled: false,
|
|
18
|
+
zoomButtonsEnabled: false,
|
|
18
19
|
};
|
|
19
20
|
export class JupyterGISModel {
|
|
20
21
|
constructor(options) {
|
|
@@ -261,11 +262,12 @@ export class JupyterGISModel {
|
|
|
261
262
|
console.warn(errorMsg);
|
|
262
263
|
}
|
|
263
264
|
this.sharedModel.transact(() => {
|
|
264
|
-
var _a, _b, _c, _d, _e;
|
|
265
|
+
var _a, _b, _c, _d, _e, _f;
|
|
265
266
|
this.sharedModel.sources = (_a = jsonData.sources) !== null && _a !== void 0 ? _a : {};
|
|
266
267
|
this.sharedModel.layers = (_b = jsonData.layers) !== null && _b !== void 0 ? _b : {};
|
|
267
268
|
this.sharedModel.layerTree = (_c = jsonData.layerTree) !== null && _c !== void 0 ? _c : [];
|
|
268
|
-
this.sharedModel.
|
|
269
|
+
this.sharedModel.stories = (_d = jsonData.stories) !== null && _d !== void 0 ? _d : {};
|
|
270
|
+
this.sharedModel.options = (_e = jsonData.options) !== null && _e !== void 0 ? _e : {
|
|
269
271
|
latitude: 0,
|
|
270
272
|
longitude: 0,
|
|
271
273
|
zoom: 0,
|
|
@@ -273,7 +275,7 @@ export class JupyterGISModel {
|
|
|
273
275
|
pitch: 0,
|
|
274
276
|
projection: 'EPSG:3857',
|
|
275
277
|
};
|
|
276
|
-
this.sharedModel.metadata = (
|
|
278
|
+
this.sharedModel.metadata = (_f = jsonData.metadata) !== null && _f !== void 0 ? _f : {};
|
|
277
279
|
});
|
|
278
280
|
this.dirty = true;
|
|
279
281
|
}
|
|
@@ -485,6 +487,19 @@ export class JupyterGISModel {
|
|
|
485
487
|
getClientId() {
|
|
486
488
|
return this.sharedModel.awareness.clientID;
|
|
487
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Check if the application is running in Specta mode.
|
|
492
|
+
* Specta mode is enabled when the URL contains 'specta' AND the model has stories.
|
|
493
|
+
*
|
|
494
|
+
* @returns True if running in Specta mode
|
|
495
|
+
*/
|
|
496
|
+
isSpectaMode() {
|
|
497
|
+
var _a;
|
|
498
|
+
const hasStories = Object.keys(this.sharedModel.stories).length > 0;
|
|
499
|
+
const isSpecta = !!document.querySelector('meta[name="specta-config"]');
|
|
500
|
+
const guidedMode = ((_a = this.getSelectedStory().story) === null || _a === void 0 ? void 0 : _a.storyType) === 'guided';
|
|
501
|
+
return isSpecta && hasStories && guidedMode;
|
|
502
|
+
}
|
|
488
503
|
/**
|
|
489
504
|
* Placeholder in case we eventually want to support multiple stories
|
|
490
505
|
* @returns First/only story
|
|
@@ -493,7 +508,7 @@ export class JupyterGISModel {
|
|
|
493
508
|
const stories = this.sharedModel.stories;
|
|
494
509
|
const storyId = Object.keys(stories)[0];
|
|
495
510
|
return {
|
|
496
|
-
|
|
511
|
+
storyId: storyId,
|
|
497
512
|
story: this.sharedModel.getStoryMap(storyId),
|
|
498
513
|
};
|
|
499
514
|
}
|
|
@@ -504,11 +519,11 @@ export class JupyterGISModel {
|
|
|
504
519
|
addStorySegment() {
|
|
505
520
|
var _a;
|
|
506
521
|
const { zoom, extent } = this.getOptions();
|
|
522
|
+
const { storyId } = this.getSelectedStory();
|
|
507
523
|
if (!zoom || !extent) {
|
|
508
524
|
console.warn('No extent or zoom found');
|
|
509
525
|
return null;
|
|
510
526
|
}
|
|
511
|
-
const storyMapId = UUID.uuid4();
|
|
512
527
|
const newStorySegmentId = UUID.uuid4();
|
|
513
528
|
const layerParams = {
|
|
514
529
|
extent,
|
|
@@ -522,27 +537,27 @@ export class JupyterGISModel {
|
|
|
522
537
|
parameters: layerParams,
|
|
523
538
|
};
|
|
524
539
|
this.addLayer(newStorySegmentId, layerModel);
|
|
525
|
-
//
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (!isStoriesExist) {
|
|
540
|
+
// if story doesn't exist then add one
|
|
541
|
+
if (!storyId) {
|
|
542
|
+
const storyId = UUID.uuid4();
|
|
529
543
|
const title = 'New Story';
|
|
530
544
|
const storyType = 'guided';
|
|
531
545
|
const storySegments = [newStorySegmentId];
|
|
532
546
|
const storyMap = { title, storyType, storySegments };
|
|
533
|
-
this.sharedModel.addStoryMap(
|
|
547
|
+
this.sharedModel.addStoryMap(storyId, storyMap);
|
|
548
|
+
return { storySegmentId: newStorySegmentId, storyId };
|
|
534
549
|
}
|
|
535
550
|
else {
|
|
536
|
-
// else need to update
|
|
551
|
+
// else need to update story
|
|
537
552
|
const { story } = this.getSelectedStory();
|
|
538
553
|
if (!story) {
|
|
539
554
|
console.warn('No story found, something went wrong');
|
|
540
555
|
return null;
|
|
541
556
|
}
|
|
542
557
|
const newStory = Object.assign(Object.assign({}, story), { storySegments: [...((_a = story.storySegments) !== null && _a !== void 0 ? _a : []), newStorySegmentId] });
|
|
543
|
-
this.sharedModel.updateStoryMap(
|
|
558
|
+
this.sharedModel.updateStoryMap(storyId, newStory);
|
|
559
|
+
return { storySegmentId: newStorySegmentId, storyId };
|
|
544
560
|
}
|
|
545
|
-
return { storySegmentId: newStorySegmentId, storyMapId };
|
|
546
561
|
}
|
|
547
562
|
/**
|
|
548
563
|
* Add an item in the layer tree.
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"options": {
|
|
21
21
|
"$ref": "#/definitions/jGISOptions"
|
|
22
22
|
},
|
|
23
|
+
"stories": {
|
|
24
|
+
"$ref": "#/definitions/jGISStoryMap"
|
|
25
|
+
},
|
|
23
26
|
"metadata": {
|
|
24
27
|
"type": "object",
|
|
25
28
|
"patternProperties": {
|
|
@@ -140,14 +143,16 @@
|
|
|
140
143
|
"jGISStoryMap": {
|
|
141
144
|
"title": "IJGISStoryMap",
|
|
142
145
|
"type": "object",
|
|
143
|
-
"additionalProperties":
|
|
146
|
+
"additionalProperties": true,
|
|
144
147
|
"properties": {
|
|
145
148
|
"title": {
|
|
146
149
|
"type": "string",
|
|
150
|
+
"title": "Title",
|
|
147
151
|
"description": "The title of the story map"
|
|
148
152
|
},
|
|
149
153
|
"storyType": {
|
|
150
154
|
"type": "string",
|
|
155
|
+
"title": "Story Type",
|
|
151
156
|
"enum": ["guided", "unguided"],
|
|
152
157
|
"description": "The type of story map"
|
|
153
158
|
},
|
|
@@ -158,6 +163,16 @@
|
|
|
158
163
|
"items": {
|
|
159
164
|
"type": "string"
|
|
160
165
|
}
|
|
166
|
+
},
|
|
167
|
+
"presentaionBgColor": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"title": "Presentation Background Color",
|
|
170
|
+
"description": "The background color of the story map"
|
|
171
|
+
},
|
|
172
|
+
"presentaionTextColor": {
|
|
173
|
+
"type": "string",
|
|
174
|
+
"title": "Presentation Text Color",
|
|
175
|
+
"description": "The text color of the story map"
|
|
161
176
|
}
|
|
162
177
|
}
|
|
163
178
|
},
|