@holoviz/geoviews 1.9.6-a.2

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.
@@ -0,0 +1,597 @@
1
+ /*!
2
+ * Copyright (c) 2012 - 2022, Anaconda, Inc., and Bokeh Contributors
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification,
6
+ * are permitted provided that the following conditions are met:
7
+ *
8
+ * Redistributions of source code must retain the above copyright notice,
9
+ * this list of conditions and the following disclaimer.
10
+ *
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ * this list of conditions and the following disclaimer in the documentation
13
+ * and/or other materials provided with the distribution.
14
+ *
15
+ * Neither the name of Anaconda nor the names of any contributors
16
+ * may be used to endorse or promote products derived from this software
17
+ * without specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29
+ * THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+ (function(root, factory) {
32
+ factory(root["Bokeh"], undefined);
33
+ })(this, function(Bokeh, version) {
34
+ let define;
35
+ return (function(modules, entry, aliases, externals) {
36
+ const bokeh = typeof Bokeh !== "undefined" && (version != null ? Bokeh[version] : Bokeh);
37
+ if (bokeh != null) {
38
+ return bokeh.register_plugin(modules, entry, aliases);
39
+ } else {
40
+ throw new Error("Cannot find Bokeh " + version + ". You have to load it prior to loading plugins.");
41
+ }
42
+ })
43
+ ({
44
+ "c764d38756": /* index.js */ function _(require, module, exports, __esModule, __esExport) {
45
+ __esModule();
46
+ const tslib_1 = require("tslib");
47
+ const GeoViews = (0, tslib_1.__importStar)(require("b4555bea44") /* ./models */);
48
+ exports.GeoViews = GeoViews;
49
+ const base_1 = require("@bokehjs/base");
50
+ (0, base_1.register_models)(GeoViews);
51
+ },
52
+ "b4555bea44": /* models/index.js */ function _(require, module, exports, __esModule, __esExport) {
53
+ __esModule();
54
+ var checkpoint_tool_1 = require("fc272d6e02") /* ./checkpoint_tool */;
55
+ __esExport("CheckpointTool", checkpoint_tool_1.CheckpointTool);
56
+ var clear_tool_1 = require("eddee4057c") /* ./clear_tool */;
57
+ __esExport("ClearTool", clear_tool_1.ClearTool);
58
+ var poly_draw_1 = require("8288feb407") /* ./poly_draw */;
59
+ __esExport("PolyVertexDrawTool", poly_draw_1.PolyVertexDrawTool);
60
+ var poly_edit_1 = require("5e7ea505ce") /* ./poly_edit */;
61
+ __esExport("PolyVertexEditTool", poly_edit_1.PolyVertexEditTool);
62
+ var restore_tool_1 = require("e81e0595cf") /* ./restore_tool */;
63
+ __esExport("RestoreTool", restore_tool_1.RestoreTool);
64
+ },
65
+ "fc272d6e02": /* models/checkpoint_tool.js */ function _(require, module, exports, __esModule, __esExport) {
66
+ __esModule();
67
+ const tslib_1 = require("tslib");
68
+ const p = (0, tslib_1.__importStar)(require("@bokehjs/core/properties"));
69
+ const array_1 = require("@bokehjs/core/util/array");
70
+ const action_tool_1 = require("@bokehjs/models/tools/actions/action_tool");
71
+ class CheckpointToolView extends action_tool_1.ActionToolView {
72
+ doit() {
73
+ const sources = this.model.sources;
74
+ for (const source of sources) {
75
+ if (!source.buffer) {
76
+ source.buffer = [];
77
+ }
78
+ let data_copy = {};
79
+ for (const key in source.data) {
80
+ const column = source.data[key];
81
+ const new_column = [];
82
+ for (const arr of column) {
83
+ if (Array.isArray(arr) || (ArrayBuffer.isView(arr))) {
84
+ new_column.push((0, array_1.copy)(arr));
85
+ }
86
+ else {
87
+ new_column.push(arr);
88
+ }
89
+ }
90
+ data_copy[key] = new_column;
91
+ }
92
+ source.buffer.push(data_copy);
93
+ }
94
+ }
95
+ }
96
+ exports.CheckpointToolView = CheckpointToolView;
97
+ CheckpointToolView.__name__ = "CheckpointToolView";
98
+ class CheckpointTool extends action_tool_1.ActionTool {
99
+ constructor(attrs) {
100
+ super(attrs);
101
+ this.tool_name = "Checkpoint";
102
+ this.icon = "bk-tool-icon-save";
103
+ }
104
+ static init_CheckpointTool() {
105
+ this.prototype.default_view = CheckpointToolView;
106
+ this.define({
107
+ sources: [p.Array, []],
108
+ });
109
+ }
110
+ }
111
+ exports.CheckpointTool = CheckpointTool;
112
+ CheckpointTool.__name__ = "CheckpointTool";
113
+ CheckpointTool.__module__ = "geoviews.models.custom_tools";
114
+ CheckpointTool.init_CheckpointTool();
115
+ },
116
+ "eddee4057c": /* models/clear_tool.js */ function _(require, module, exports, __esModule, __esExport) {
117
+ __esModule();
118
+ const tslib_1 = require("tslib");
119
+ const p = (0, tslib_1.__importStar)(require("@bokehjs/core/properties"));
120
+ const action_tool_1 = require("@bokehjs/models/tools/actions/action_tool");
121
+ class ClearToolView extends action_tool_1.ActionToolView {
122
+ doit() {
123
+ for (var source of this.model.sources) {
124
+ for (const column in source.data) {
125
+ source.data[column] = [];
126
+ }
127
+ source.change.emit();
128
+ source.properties.data.change.emit();
129
+ }
130
+ }
131
+ }
132
+ exports.ClearToolView = ClearToolView;
133
+ ClearToolView.__name__ = "ClearToolView";
134
+ class ClearTool extends action_tool_1.ActionTool {
135
+ constructor(attrs) {
136
+ super(attrs);
137
+ this.tool_name = "Clear data";
138
+ this.icon = "bk-tool-icon-reset";
139
+ }
140
+ static init_ClearTool() {
141
+ this.prototype.default_view = ClearToolView;
142
+ this.define({
143
+ sources: [p.Array, []],
144
+ });
145
+ }
146
+ }
147
+ exports.ClearTool = ClearTool;
148
+ ClearTool.__name__ = "ClearTool";
149
+ ClearTool.__module__ = "geoviews.models.custom_tools";
150
+ ClearTool.init_ClearTool();
151
+ },
152
+ "8288feb407": /* models/poly_draw.js */ function _(require, module, exports, __esModule, __esExport) {
153
+ __esModule();
154
+ const tslib_1 = require("tslib");
155
+ const p = (0, tslib_1.__importStar)(require("@bokehjs/core/properties"));
156
+ const object_1 = require("@bokehjs/core/util/object");
157
+ const types_1 = require("@bokehjs/core/util/types");
158
+ const poly_draw_tool_1 = require("@bokehjs/models/tools/edit/poly_draw_tool");
159
+ class PolyVertexDrawToolView extends poly_draw_tool_1.PolyDrawToolView {
160
+ _split_path(x, y) {
161
+ for (let r = 0; r < this.model.renderers.length; r++) {
162
+ const renderer = this.model.renderers[r];
163
+ const glyph = renderer.glyph;
164
+ const cds = renderer.data_source;
165
+ const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];
166
+ const xpaths = cds.data[xkey];
167
+ const ypaths = cds.data[ykey];
168
+ for (let index = 0; index < xpaths.length; index++) {
169
+ let xs = xpaths[index];
170
+ if (!(0, types_1.isArray)(xs)) {
171
+ xs = Array.from(xs);
172
+ cds.data[xkey][index] = xs;
173
+ }
174
+ let ys = ypaths[index];
175
+ if (!(0, types_1.isArray)(ys)) {
176
+ ys = Array.from(ys);
177
+ cds.data[ykey][index] = ys;
178
+ }
179
+ for (let i = 0; i < xs.length; i++) {
180
+ if ((xs[i] == x) && (ys[i] == y) && (i != 0) && (i != (xs.length - 1))) {
181
+ xpaths.splice(index + 1, 0, xs.slice(i));
182
+ ypaths.splice(index + 1, 0, ys.slice(i));
183
+ xs.splice(i + 1);
184
+ ys.splice(i + 1);
185
+ for (const column of cds.columns()) {
186
+ if ((column !== xkey) && (column != ykey))
187
+ cds.data[column].splice(index + 1, 0, cds.data[column][index]);
188
+ }
189
+ return;
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ _snap_to_vertex(ev, x, y) {
196
+ if (this.model.vertex_renderer) {
197
+ // If an existing vertex is hit snap to it
198
+ const vertex_selected = this._select_event(ev, "replace", [this.model.vertex_renderer]);
199
+ const point_ds = this.model.vertex_renderer.data_source;
200
+ // Type once dataspecs are typed
201
+ const point_glyph = this.model.vertex_renderer.glyph;
202
+ const [pxkey, pykey] = [point_glyph.x.field, point_glyph.y.field];
203
+ if (vertex_selected.length) {
204
+ // If existing vertex is hit split path at that location
205
+ // converting to feature vertex
206
+ const index = point_ds.selected.indices[0];
207
+ if (pxkey)
208
+ x = point_ds.data[pxkey][index];
209
+ if (pykey)
210
+ y = point_ds.data[pykey][index];
211
+ if (ev.type != 'mousemove')
212
+ this._split_path(x, y);
213
+ point_ds.selection_manager.clear();
214
+ }
215
+ }
216
+ return [x, y];
217
+ }
218
+ _set_vertices(xs, ys, styles) {
219
+ const point_glyph = this.model.vertex_renderer.glyph;
220
+ const point_cds = this.model.vertex_renderer.data_source;
221
+ const [pxkey, pykey] = [point_glyph.x.field, point_glyph.y.field];
222
+ if (pxkey) {
223
+ if ((0, types_1.isArray)(xs))
224
+ point_cds.data[pxkey] = xs;
225
+ else
226
+ point_glyph.x = { value: xs };
227
+ }
228
+ if (pykey) {
229
+ if ((0, types_1.isArray)(ys))
230
+ point_cds.data[pykey] = ys;
231
+ else
232
+ point_glyph.y = { value: ys };
233
+ }
234
+ if (styles != null) {
235
+ for (const key of (0, object_1.keys)(styles)) {
236
+ point_cds.data[key] = styles[key];
237
+ point_glyph[key] = { field: key };
238
+ }
239
+ }
240
+ else {
241
+ for (const col of point_cds.columns()) {
242
+ point_cds.data[col] = [];
243
+ }
244
+ }
245
+ this._emit_cds_changes(point_cds, true, true, false);
246
+ }
247
+ _show_vertices() {
248
+ if (!this.model.active) {
249
+ return;
250
+ }
251
+ const xs = [];
252
+ const ys = [];
253
+ const styles = {};
254
+ for (const key of (0, object_1.keys)(this.model.end_style))
255
+ styles[key] = [];
256
+ for (let i = 0; i < this.model.renderers.length; i++) {
257
+ const renderer = this.model.renderers[i];
258
+ const cds = renderer.data_source;
259
+ const glyph = renderer.glyph;
260
+ const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];
261
+ for (const array of cds.get_array(xkey)) {
262
+ Array.prototype.push.apply(xs, array);
263
+ for (const key of (0, object_1.keys)(this.model.end_style))
264
+ styles[key].push(this.model.end_style[key]);
265
+ for (const key of (0, object_1.keys)(this.model.node_style)) {
266
+ for (let index = 0; index < (array.length - 2); index++) {
267
+ styles[key].push(this.model.node_style[key]);
268
+ }
269
+ }
270
+ for (const key of (0, object_1.keys)(this.model.end_style))
271
+ styles[key].push(this.model.end_style[key]);
272
+ }
273
+ for (const array of cds.get_array(ykey))
274
+ Array.prototype.push.apply(ys, array);
275
+ if (this._drawing && (i == (this.model.renderers.length - 1))) {
276
+ // Skip currently drawn vertex
277
+ xs.splice(xs.length - 1, 1);
278
+ ys.splice(ys.length - 1, 1);
279
+ for (const key of (0, object_1.keys)(styles))
280
+ styles[key].splice(styles[key].length - 1, 1);
281
+ }
282
+ }
283
+ this._set_vertices(xs, ys, styles);
284
+ }
285
+ _remove() {
286
+ const renderer = this.model.renderers[0];
287
+ const cds = renderer.data_source;
288
+ const glyph = renderer.glyph;
289
+ const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];
290
+ if (xkey) {
291
+ const xidx = cds.data[xkey].length - 1;
292
+ const xs = cds.get_array(xkey)[xidx];
293
+ xs.splice(xs.length - 1, 1);
294
+ if (xs.length == 1)
295
+ cds.data[xkey].splice(xidx, 1);
296
+ }
297
+ if (ykey) {
298
+ const yidx = cds.data[ykey].length - 1;
299
+ const ys = cds.get_array(ykey)[yidx];
300
+ ys.splice(ys.length - 1, 1);
301
+ if (ys.length == 1)
302
+ cds.data[ykey].splice(yidx, 1);
303
+ }
304
+ this._emit_cds_changes(cds);
305
+ this._drawing = false;
306
+ this._show_vertices();
307
+ }
308
+ }
309
+ exports.PolyVertexDrawToolView = PolyVertexDrawToolView;
310
+ PolyVertexDrawToolView.__name__ = "PolyVertexDrawToolView";
311
+ class PolyVertexDrawTool extends poly_draw_tool_1.PolyDrawTool {
312
+ constructor(attrs) {
313
+ super(attrs);
314
+ }
315
+ static init_PolyVertexDrawTool() {
316
+ this.prototype.default_view = PolyVertexDrawToolView;
317
+ this.define({
318
+ end_style: [p.Any, {}],
319
+ node_style: [p.Any, {}],
320
+ });
321
+ }
322
+ }
323
+ exports.PolyVertexDrawTool = PolyVertexDrawTool;
324
+ PolyVertexDrawTool.__name__ = "PolyVertexDrawTool";
325
+ PolyVertexDrawTool.__module__ = "geoviews.models.custom_tools";
326
+ PolyVertexDrawTool.init_PolyVertexDrawTool();
327
+ },
328
+ "5e7ea505ce": /* models/poly_edit.js */ function _(require, module, exports, __esModule, __esExport) {
329
+ __esModule();
330
+ const tslib_1 = require("tslib");
331
+ const p = (0, tslib_1.__importStar)(require("@bokehjs/core/properties"));
332
+ const object_1 = require("@bokehjs/core/util/object");
333
+ const types_1 = require("@bokehjs/core/util/types");
334
+ const poly_edit_tool_1 = require("@bokehjs/models/tools/edit/poly_edit_tool");
335
+ class PolyVertexEditToolView extends poly_edit_tool_1.PolyEditToolView {
336
+ deactivate() {
337
+ this._hide_vertices();
338
+ if (!this._selected_renderer) {
339
+ return;
340
+ }
341
+ else if (this._drawing) {
342
+ this._remove_vertex();
343
+ this._drawing = false;
344
+ }
345
+ this._emit_cds_changes(this._selected_renderer.data_source, false, true, false);
346
+ }
347
+ _pan(ev) {
348
+ if (this._basepoint == null)
349
+ return;
350
+ const points = this._drag_points(ev, [this.model.vertex_renderer]);
351
+ if (!ev.shiftKey) {
352
+ this._move_linked(points);
353
+ }
354
+ if (this._selected_renderer)
355
+ this._selected_renderer.data_source.change.emit();
356
+ }
357
+ _pan_end(ev) {
358
+ if (this._basepoint == null)
359
+ return;
360
+ const points = this._drag_points(ev, [this.model.vertex_renderer]);
361
+ if (!ev.shiftKey) {
362
+ this._move_linked(points);
363
+ }
364
+ this._emit_cds_changes(this.model.vertex_renderer.data_source, false, true, true);
365
+ if (this._selected_renderer) {
366
+ this._emit_cds_changes(this._selected_renderer.data_source);
367
+ }
368
+ this._basepoint = null;
369
+ }
370
+ _drag_points(ev, renderers) {
371
+ if (this._basepoint == null)
372
+ return [];
373
+ const [bx, by] = this._basepoint;
374
+ const points = [];
375
+ for (const renderer of renderers) {
376
+ const basepoint = this._map_drag(bx, by, renderer);
377
+ const point = this._map_drag(ev.sx, ev.sy, renderer);
378
+ if (point == null || basepoint == null) {
379
+ continue;
380
+ }
381
+ const [x, y] = point;
382
+ const [px, py] = basepoint;
383
+ const [dx, dy] = [x - px, y - py];
384
+ // Type once dataspecs are typed
385
+ const glyph = renderer.glyph;
386
+ const cds = renderer.data_source;
387
+ const [xkey, ykey] = [glyph.x.field, glyph.y.field];
388
+ for (const index of cds.selected.indices) {
389
+ const point = [];
390
+ if (xkey) {
391
+ point.push(cds.data[xkey][index]);
392
+ cds.data[xkey][index] += dx;
393
+ }
394
+ if (ykey) {
395
+ point.push(cds.data[ykey][index]);
396
+ cds.data[ykey][index] += dy;
397
+ }
398
+ point.push(dx);
399
+ point.push(dy);
400
+ points.push(point);
401
+ }
402
+ cds.change.emit();
403
+ }
404
+ this._basepoint = [ev.sx, ev.sy];
405
+ return points;
406
+ }
407
+ _set_vertices(xs, ys, styles) {
408
+ const point_glyph = this.model.vertex_renderer.glyph;
409
+ const point_cds = this.model.vertex_renderer.data_source;
410
+ const [pxkey, pykey] = [point_glyph.x.field, point_glyph.y.field];
411
+ if (pxkey) {
412
+ if ((0, types_1.isArray)(xs))
413
+ point_cds.data[pxkey] = xs;
414
+ else
415
+ point_glyph.x = { value: xs };
416
+ }
417
+ if (pykey) {
418
+ if ((0, types_1.isArray)(ys))
419
+ point_cds.data[pykey] = ys;
420
+ else
421
+ point_glyph.y = { value: ys };
422
+ }
423
+ if (styles != null) {
424
+ for (const key of (0, object_1.keys)(styles)) {
425
+ point_cds.data[key] = styles[key];
426
+ point_glyph[key] = { field: key };
427
+ }
428
+ }
429
+ else {
430
+ for (const col of point_cds.columns()) {
431
+ point_cds.data[col] = [];
432
+ }
433
+ }
434
+ this._emit_cds_changes(point_cds, true, true, false);
435
+ }
436
+ _move_linked(points) {
437
+ if (!this._selected_renderer)
438
+ return;
439
+ const renderer = this._selected_renderer;
440
+ const glyph = renderer.glyph;
441
+ const cds = renderer.data_source;
442
+ const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];
443
+ const xpaths = cds.data[xkey];
444
+ const ypaths = cds.data[ykey];
445
+ for (const point of points) {
446
+ const [x, y, dx, dy] = point;
447
+ for (let index = 0; index < xpaths.length; index++) {
448
+ const xs = xpaths[index];
449
+ const ys = ypaths[index];
450
+ for (let i = 0; i < xs.length; i++) {
451
+ if ((xs[i] == x) && (ys[i] == y)) {
452
+ xs[i] += dx;
453
+ ys[i] += dy;
454
+ }
455
+ }
456
+ }
457
+ }
458
+ }
459
+ _tap(ev) {
460
+ const renderer = this.model.vertex_renderer;
461
+ const point = this._map_drag(ev.sx, ev.sy, renderer);
462
+ if (point == null)
463
+ return;
464
+ else if (this._drawing && this._selected_renderer) {
465
+ let [x, y] = point;
466
+ const cds = renderer.data_source;
467
+ // Type once dataspecs are typed
468
+ const glyph = renderer.glyph;
469
+ const [xkey, ykey] = [glyph.x.field, glyph.y.field];
470
+ const indices = cds.selected.indices;
471
+ [x, y] = this._snap_to_vertex(ev, x, y);
472
+ const index = indices[0];
473
+ cds.selected.indices = [index + 1];
474
+ if (xkey) {
475
+ const xs = cds.get_array(xkey);
476
+ const nx = xs[index];
477
+ xs[index] = x;
478
+ xs.splice(index + 1, 0, nx);
479
+ }
480
+ if (ykey) {
481
+ const ys = cds.get_array(ykey);
482
+ const ny = ys[index];
483
+ ys[index] = y;
484
+ ys.splice(index + 1, 0, ny);
485
+ }
486
+ cds.change.emit();
487
+ this._emit_cds_changes(this._selected_renderer.data_source, true, false, true);
488
+ return;
489
+ }
490
+ this._select_event(ev, this._select_mode(ev), [renderer]);
491
+ }
492
+ _show_vertices(ev) {
493
+ if (!this.model.active)
494
+ return;
495
+ const renderers = this._select_event(ev, "replace", this.model.renderers);
496
+ if (!renderers.length) {
497
+ this._hide_vertices();
498
+ this._selected_renderer = null;
499
+ this._drawing = false;
500
+ return;
501
+ }
502
+ const renderer = renderers[0];
503
+ const glyph = renderer.glyph;
504
+ const cds = renderer.data_source;
505
+ const index = cds.selected.indices[0];
506
+ const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];
507
+ let xs;
508
+ let ys;
509
+ if (xkey) {
510
+ xs = cds.data[xkey][index];
511
+ if (!(0, types_1.isArray)(xs))
512
+ cds.data[xkey][index] = xs = Array.from(xs);
513
+ }
514
+ else {
515
+ xs = glyph.xs.value;
516
+ }
517
+ if (ykey) {
518
+ ys = cds.data[ykey][index];
519
+ if (!(0, types_1.isArray)(ys))
520
+ cds.data[ykey][index] = ys = Array.from(ys);
521
+ }
522
+ else {
523
+ ys = glyph.ys.value;
524
+ }
525
+ const styles = {};
526
+ for (const key of (0, object_1.keys)(this.model.end_style))
527
+ styles[key] = [this.model.end_style[key]];
528
+ for (const key of (0, object_1.keys)(this.model.node_style)) {
529
+ for (let index = 0; index < (xs.length - 2); index++) {
530
+ styles[key].push(this.model.node_style[key]);
531
+ }
532
+ }
533
+ for (const key of (0, object_1.keys)(this.model.end_style))
534
+ styles[key].push(this.model.end_style[key]);
535
+ this._selected_renderer = renderer;
536
+ this._set_vertices(xs, ys, styles);
537
+ }
538
+ }
539
+ exports.PolyVertexEditToolView = PolyVertexEditToolView;
540
+ PolyVertexEditToolView.__name__ = "PolyVertexEditToolView";
541
+ class PolyVertexEditTool extends poly_edit_tool_1.PolyEditTool {
542
+ constructor(attrs) {
543
+ super(attrs);
544
+ }
545
+ static init_PolyVertexEditTool() {
546
+ this.prototype.default_view = PolyVertexEditToolView;
547
+ this.define({
548
+ node_style: [p.Any, {}],
549
+ end_style: [p.Any, {}],
550
+ });
551
+ }
552
+ }
553
+ exports.PolyVertexEditTool = PolyVertexEditTool;
554
+ PolyVertexEditTool.__name__ = "PolyVertexEditTool";
555
+ PolyVertexEditTool.__module__ = "geoviews.models.custom_tools";
556
+ PolyVertexEditTool.init_PolyVertexEditTool();
557
+ },
558
+ "e81e0595cf": /* models/restore_tool.js */ function _(require, module, exports, __esModule, __esExport) {
559
+ __esModule();
560
+ const tslib_1 = require("tslib");
561
+ const p = (0, tslib_1.__importStar)(require("@bokehjs/core/properties"));
562
+ const action_tool_1 = require("@bokehjs/models/tools/actions/action_tool");
563
+ class RestoreToolView extends action_tool_1.ActionToolView {
564
+ doit() {
565
+ const sources = this.model.sources;
566
+ for (const source of sources) {
567
+ if (!source.buffer || (source.buffer.length == 0)) {
568
+ continue;
569
+ }
570
+ source.data = source.buffer.pop();
571
+ source.change.emit();
572
+ source.properties.data.change.emit();
573
+ }
574
+ }
575
+ }
576
+ exports.RestoreToolView = RestoreToolView;
577
+ RestoreToolView.__name__ = "RestoreToolView";
578
+ class RestoreTool extends action_tool_1.ActionTool {
579
+ constructor(attrs) {
580
+ super(attrs);
581
+ this.tool_name = "Restore";
582
+ this.icon = "bk-tool-icon-undo";
583
+ }
584
+ static init_RestoreTool() {
585
+ this.prototype.default_view = RestoreToolView;
586
+ this.define({
587
+ sources: [p.Array, []]
588
+ });
589
+ }
590
+ }
591
+ exports.RestoreTool = RestoreTool;
592
+ RestoreTool.__name__ = "RestoreTool";
593
+ RestoreTool.__module__ = "geoviews.models.custom_tools";
594
+ RestoreTool.init_RestoreTool();
595
+ },
596
+ }, "c764d38756", {"index":"c764d38756","models/index":"b4555bea44","models/checkpoint_tool":"fc272d6e02","models/clear_tool":"eddee4057c","models/poly_draw":"8288feb407","models/poly_edit":"5e7ea505ce","models/restore_tool":"e81e0595cf"}, {});});
597
+ //# sourceMappingURL=geoviews.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@@/geoviews/dist/lib/index.js","@@/geoviews/dist/lib/models/index.js","@@/geoviews/dist/lib/models/checkpoint_tool.js","@@/geoviews/dist/lib/models/clear_tool.js","@@/geoviews/dist/lib/models/poly_draw.js","@@/geoviews/dist/lib/models/poly_edit.js","@@/geoviews/dist/lib/models/restore_tool.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,ACnDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,ACtOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"generated.js","sourceRoot":"","sourcesContent":["/* index.js */ function _(require, module, exports, __esModule, __esExport) {\n __esModule();\n const tslib_1 = require(\"tslib\");\n const GeoViews = (0, tslib_1.__importStar)(require(\"b4555bea44\") /* ./models */);\n exports.GeoViews = GeoViews;\n const base_1 = require(\"@bokehjs/base\");\n (0, base_1.register_models)(GeoViews);\n}\n","/* models/index.js */ function _(require, module, exports, __esModule, __esExport) {\n __esModule();\n var checkpoint_tool_1 = require(\"fc272d6e02\") /* ./checkpoint_tool */;\n __esExport(\"CheckpointTool\", checkpoint_tool_1.CheckpointTool);\n var clear_tool_1 = require(\"eddee4057c\") /* ./clear_tool */;\n __esExport(\"ClearTool\", clear_tool_1.ClearTool);\n var poly_draw_1 = require(\"8288feb407\") /* ./poly_draw */;\n __esExport(\"PolyVertexDrawTool\", poly_draw_1.PolyVertexDrawTool);\n var poly_edit_1 = require(\"5e7ea505ce\") /* ./poly_edit */;\n __esExport(\"PolyVertexEditTool\", poly_edit_1.PolyVertexEditTool);\n var restore_tool_1 = require(\"e81e0595cf\") /* ./restore_tool */;\n __esExport(\"RestoreTool\", restore_tool_1.RestoreTool);\n}\n","/* models/checkpoint_tool.js */ function _(require, module, exports, __esModule, __esExport) {\n __esModule();\n const tslib_1 = require(\"tslib\");\n const p = (0, tslib_1.__importStar)(require(\"@bokehjs/core/properties\"));\n const array_1 = require(\"@bokehjs/core/util/array\");\n const action_tool_1 = require(\"@bokehjs/models/tools/actions/action_tool\");\n class CheckpointToolView extends action_tool_1.ActionToolView {\n doit() {\n const sources = this.model.sources;\n for (const source of sources) {\n if (!source.buffer) {\n source.buffer = [];\n }\n let data_copy = {};\n for (const key in source.data) {\n const column = source.data[key];\n const new_column = [];\n for (const arr of column) {\n if (Array.isArray(arr) || (ArrayBuffer.isView(arr))) {\n new_column.push((0, array_1.copy)(arr));\n }\n else {\n new_column.push(arr);\n }\n }\n data_copy[key] = new_column;\n }\n source.buffer.push(data_copy);\n }\n }\n }\n exports.CheckpointToolView = CheckpointToolView;\n CheckpointToolView.__name__ = \"CheckpointToolView\";\n class CheckpointTool extends action_tool_1.ActionTool {\n constructor(attrs) {\n super(attrs);\n this.tool_name = \"Checkpoint\";\n this.icon = \"bk-tool-icon-save\";\n }\n static init_CheckpointTool() {\n this.prototype.default_view = CheckpointToolView;\n this.define({\n sources: [p.Array, []],\n });\n }\n }\n exports.CheckpointTool = CheckpointTool;\n CheckpointTool.__name__ = \"CheckpointTool\";\n CheckpointTool.__module__ = \"geoviews.models.custom_tools\";\n CheckpointTool.init_CheckpointTool();\n}\n","/* models/clear_tool.js */ function _(require, module, exports, __esModule, __esExport) {\n __esModule();\n const tslib_1 = require(\"tslib\");\n const p = (0, tslib_1.__importStar)(require(\"@bokehjs/core/properties\"));\n const action_tool_1 = require(\"@bokehjs/models/tools/actions/action_tool\");\n class ClearToolView extends action_tool_1.ActionToolView {\n doit() {\n for (var source of this.model.sources) {\n for (const column in source.data) {\n source.data[column] = [];\n }\n source.change.emit();\n source.properties.data.change.emit();\n }\n }\n }\n exports.ClearToolView = ClearToolView;\n ClearToolView.__name__ = \"ClearToolView\";\n class ClearTool extends action_tool_1.ActionTool {\n constructor(attrs) {\n super(attrs);\n this.tool_name = \"Clear data\";\n this.icon = \"bk-tool-icon-reset\";\n }\n static init_ClearTool() {\n this.prototype.default_view = ClearToolView;\n this.define({\n sources: [p.Array, []],\n });\n }\n }\n exports.ClearTool = ClearTool;\n ClearTool.__name__ = \"ClearTool\";\n ClearTool.__module__ = \"geoviews.models.custom_tools\";\n ClearTool.init_ClearTool();\n}\n","/* models/poly_draw.js */ function _(require, module, exports, __esModule, __esExport) {\n __esModule();\n const tslib_1 = require(\"tslib\");\n const p = (0, tslib_1.__importStar)(require(\"@bokehjs/core/properties\"));\n const object_1 = require(\"@bokehjs/core/util/object\");\n const types_1 = require(\"@bokehjs/core/util/types\");\n const poly_draw_tool_1 = require(\"@bokehjs/models/tools/edit/poly_draw_tool\");\n class PolyVertexDrawToolView extends poly_draw_tool_1.PolyDrawToolView {\n _split_path(x, y) {\n for (let r = 0; r < this.model.renderers.length; r++) {\n const renderer = this.model.renderers[r];\n const glyph = renderer.glyph;\n const cds = renderer.data_source;\n const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];\n const xpaths = cds.data[xkey];\n const ypaths = cds.data[ykey];\n for (let index = 0; index < xpaths.length; index++) {\n let xs = xpaths[index];\n if (!(0, types_1.isArray)(xs)) {\n xs = Array.from(xs);\n cds.data[xkey][index] = xs;\n }\n let ys = ypaths[index];\n if (!(0, types_1.isArray)(ys)) {\n ys = Array.from(ys);\n cds.data[ykey][index] = ys;\n }\n for (let i = 0; i < xs.length; i++) {\n if ((xs[i] == x) && (ys[i] == y) && (i != 0) && (i != (xs.length - 1))) {\n xpaths.splice(index + 1, 0, xs.slice(i));\n ypaths.splice(index + 1, 0, ys.slice(i));\n xs.splice(i + 1);\n ys.splice(i + 1);\n for (const column of cds.columns()) {\n if ((column !== xkey) && (column != ykey))\n cds.data[column].splice(index + 1, 0, cds.data[column][index]);\n }\n return;\n }\n }\n }\n }\n }\n _snap_to_vertex(ev, x, y) {\n if (this.model.vertex_renderer) {\n // If an existing vertex is hit snap to it\n const vertex_selected = this._select_event(ev, \"replace\", [this.model.vertex_renderer]);\n const point_ds = this.model.vertex_renderer.data_source;\n // Type once dataspecs are typed\n const point_glyph = this.model.vertex_renderer.glyph;\n const [pxkey, pykey] = [point_glyph.x.field, point_glyph.y.field];\n if (vertex_selected.length) {\n // If existing vertex is hit split path at that location\n // converting to feature vertex\n const index = point_ds.selected.indices[0];\n if (pxkey)\n x = point_ds.data[pxkey][index];\n if (pykey)\n y = point_ds.data[pykey][index];\n if (ev.type != 'mousemove')\n this._split_path(x, y);\n point_ds.selection_manager.clear();\n }\n }\n return [x, y];\n }\n _set_vertices(xs, ys, styles) {\n const point_glyph = this.model.vertex_renderer.glyph;\n const point_cds = this.model.vertex_renderer.data_source;\n const [pxkey, pykey] = [point_glyph.x.field, point_glyph.y.field];\n if (pxkey) {\n if ((0, types_1.isArray)(xs))\n point_cds.data[pxkey] = xs;\n else\n point_glyph.x = { value: xs };\n }\n if (pykey) {\n if ((0, types_1.isArray)(ys))\n point_cds.data[pykey] = ys;\n else\n point_glyph.y = { value: ys };\n }\n if (styles != null) {\n for (const key of (0, object_1.keys)(styles)) {\n point_cds.data[key] = styles[key];\n point_glyph[key] = { field: key };\n }\n }\n else {\n for (const col of point_cds.columns()) {\n point_cds.data[col] = [];\n }\n }\n this._emit_cds_changes(point_cds, true, true, false);\n }\n _show_vertices() {\n if (!this.model.active) {\n return;\n }\n const xs = [];\n const ys = [];\n const styles = {};\n for (const key of (0, object_1.keys)(this.model.end_style))\n styles[key] = [];\n for (let i = 0; i < this.model.renderers.length; i++) {\n const renderer = this.model.renderers[i];\n const cds = renderer.data_source;\n const glyph = renderer.glyph;\n const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];\n for (const array of cds.get_array(xkey)) {\n Array.prototype.push.apply(xs, array);\n for (const key of (0, object_1.keys)(this.model.end_style))\n styles[key].push(this.model.end_style[key]);\n for (const key of (0, object_1.keys)(this.model.node_style)) {\n for (let index = 0; index < (array.length - 2); index++) {\n styles[key].push(this.model.node_style[key]);\n }\n }\n for (const key of (0, object_1.keys)(this.model.end_style))\n styles[key].push(this.model.end_style[key]);\n }\n for (const array of cds.get_array(ykey))\n Array.prototype.push.apply(ys, array);\n if (this._drawing && (i == (this.model.renderers.length - 1))) {\n // Skip currently drawn vertex\n xs.splice(xs.length - 1, 1);\n ys.splice(ys.length - 1, 1);\n for (const key of (0, object_1.keys)(styles))\n styles[key].splice(styles[key].length - 1, 1);\n }\n }\n this._set_vertices(xs, ys, styles);\n }\n _remove() {\n const renderer = this.model.renderers[0];\n const cds = renderer.data_source;\n const glyph = renderer.glyph;\n const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];\n if (xkey) {\n const xidx = cds.data[xkey].length - 1;\n const xs = cds.get_array(xkey)[xidx];\n xs.splice(xs.length - 1, 1);\n if (xs.length == 1)\n cds.data[xkey].splice(xidx, 1);\n }\n if (ykey) {\n const yidx = cds.data[ykey].length - 1;\n const ys = cds.get_array(ykey)[yidx];\n ys.splice(ys.length - 1, 1);\n if (ys.length == 1)\n cds.data[ykey].splice(yidx, 1);\n }\n this._emit_cds_changes(cds);\n this._drawing = false;\n this._show_vertices();\n }\n }\n exports.PolyVertexDrawToolView = PolyVertexDrawToolView;\n PolyVertexDrawToolView.__name__ = \"PolyVertexDrawToolView\";\n class PolyVertexDrawTool extends poly_draw_tool_1.PolyDrawTool {\n constructor(attrs) {\n super(attrs);\n }\n static init_PolyVertexDrawTool() {\n this.prototype.default_view = PolyVertexDrawToolView;\n this.define({\n end_style: [p.Any, {}],\n node_style: [p.Any, {}],\n });\n }\n }\n exports.PolyVertexDrawTool = PolyVertexDrawTool;\n PolyVertexDrawTool.__name__ = \"PolyVertexDrawTool\";\n PolyVertexDrawTool.__module__ = \"geoviews.models.custom_tools\";\n PolyVertexDrawTool.init_PolyVertexDrawTool();\n}\n","/* models/poly_edit.js */ function _(require, module, exports, __esModule, __esExport) {\n __esModule();\n const tslib_1 = require(\"tslib\");\n const p = (0, tslib_1.__importStar)(require(\"@bokehjs/core/properties\"));\n const object_1 = require(\"@bokehjs/core/util/object\");\n const types_1 = require(\"@bokehjs/core/util/types\");\n const poly_edit_tool_1 = require(\"@bokehjs/models/tools/edit/poly_edit_tool\");\n class PolyVertexEditToolView extends poly_edit_tool_1.PolyEditToolView {\n deactivate() {\n this._hide_vertices();\n if (!this._selected_renderer) {\n return;\n }\n else if (this._drawing) {\n this._remove_vertex();\n this._drawing = false;\n }\n this._emit_cds_changes(this._selected_renderer.data_source, false, true, false);\n }\n _pan(ev) {\n if (this._basepoint == null)\n return;\n const points = this._drag_points(ev, [this.model.vertex_renderer]);\n if (!ev.shiftKey) {\n this._move_linked(points);\n }\n if (this._selected_renderer)\n this._selected_renderer.data_source.change.emit();\n }\n _pan_end(ev) {\n if (this._basepoint == null)\n return;\n const points = this._drag_points(ev, [this.model.vertex_renderer]);\n if (!ev.shiftKey) {\n this._move_linked(points);\n }\n this._emit_cds_changes(this.model.vertex_renderer.data_source, false, true, true);\n if (this._selected_renderer) {\n this._emit_cds_changes(this._selected_renderer.data_source);\n }\n this._basepoint = null;\n }\n _drag_points(ev, renderers) {\n if (this._basepoint == null)\n return [];\n const [bx, by] = this._basepoint;\n const points = [];\n for (const renderer of renderers) {\n const basepoint = this._map_drag(bx, by, renderer);\n const point = this._map_drag(ev.sx, ev.sy, renderer);\n if (point == null || basepoint == null) {\n continue;\n }\n const [x, y] = point;\n const [px, py] = basepoint;\n const [dx, dy] = [x - px, y - py];\n // Type once dataspecs are typed\n const glyph = renderer.glyph;\n const cds = renderer.data_source;\n const [xkey, ykey] = [glyph.x.field, glyph.y.field];\n for (const index of cds.selected.indices) {\n const point = [];\n if (xkey) {\n point.push(cds.data[xkey][index]);\n cds.data[xkey][index] += dx;\n }\n if (ykey) {\n point.push(cds.data[ykey][index]);\n cds.data[ykey][index] += dy;\n }\n point.push(dx);\n point.push(dy);\n points.push(point);\n }\n cds.change.emit();\n }\n this._basepoint = [ev.sx, ev.sy];\n return points;\n }\n _set_vertices(xs, ys, styles) {\n const point_glyph = this.model.vertex_renderer.glyph;\n const point_cds = this.model.vertex_renderer.data_source;\n const [pxkey, pykey] = [point_glyph.x.field, point_glyph.y.field];\n if (pxkey) {\n if ((0, types_1.isArray)(xs))\n point_cds.data[pxkey] = xs;\n else\n point_glyph.x = { value: xs };\n }\n if (pykey) {\n if ((0, types_1.isArray)(ys))\n point_cds.data[pykey] = ys;\n else\n point_glyph.y = { value: ys };\n }\n if (styles != null) {\n for (const key of (0, object_1.keys)(styles)) {\n point_cds.data[key] = styles[key];\n point_glyph[key] = { field: key };\n }\n }\n else {\n for (const col of point_cds.columns()) {\n point_cds.data[col] = [];\n }\n }\n this._emit_cds_changes(point_cds, true, true, false);\n }\n _move_linked(points) {\n if (!this._selected_renderer)\n return;\n const renderer = this._selected_renderer;\n const glyph = renderer.glyph;\n const cds = renderer.data_source;\n const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];\n const xpaths = cds.data[xkey];\n const ypaths = cds.data[ykey];\n for (const point of points) {\n const [x, y, dx, dy] = point;\n for (let index = 0; index < xpaths.length; index++) {\n const xs = xpaths[index];\n const ys = ypaths[index];\n for (let i = 0; i < xs.length; i++) {\n if ((xs[i] == x) && (ys[i] == y)) {\n xs[i] += dx;\n ys[i] += dy;\n }\n }\n }\n }\n }\n _tap(ev) {\n const renderer = this.model.vertex_renderer;\n const point = this._map_drag(ev.sx, ev.sy, renderer);\n if (point == null)\n return;\n else if (this._drawing && this._selected_renderer) {\n let [x, y] = point;\n const cds = renderer.data_source;\n // Type once dataspecs are typed\n const glyph = renderer.glyph;\n const [xkey, ykey] = [glyph.x.field, glyph.y.field];\n const indices = cds.selected.indices;\n [x, y] = this._snap_to_vertex(ev, x, y);\n const index = indices[0];\n cds.selected.indices = [index + 1];\n if (xkey) {\n const xs = cds.get_array(xkey);\n const nx = xs[index];\n xs[index] = x;\n xs.splice(index + 1, 0, nx);\n }\n if (ykey) {\n const ys = cds.get_array(ykey);\n const ny = ys[index];\n ys[index] = y;\n ys.splice(index + 1, 0, ny);\n }\n cds.change.emit();\n this._emit_cds_changes(this._selected_renderer.data_source, true, false, true);\n return;\n }\n this._select_event(ev, this._select_mode(ev), [renderer]);\n }\n _show_vertices(ev) {\n if (!this.model.active)\n return;\n const renderers = this._select_event(ev, \"replace\", this.model.renderers);\n if (!renderers.length) {\n this._hide_vertices();\n this._selected_renderer = null;\n this._drawing = false;\n return;\n }\n const renderer = renderers[0];\n const glyph = renderer.glyph;\n const cds = renderer.data_source;\n const index = cds.selected.indices[0];\n const [xkey, ykey] = [glyph.xs.field, glyph.ys.field];\n let xs;\n let ys;\n if (xkey) {\n xs = cds.data[xkey][index];\n if (!(0, types_1.isArray)(xs))\n cds.data[xkey][index] = xs = Array.from(xs);\n }\n else {\n xs = glyph.xs.value;\n }\n if (ykey) {\n ys = cds.data[ykey][index];\n if (!(0, types_1.isArray)(ys))\n cds.data[ykey][index] = ys = Array.from(ys);\n }\n else {\n ys = glyph.ys.value;\n }\n const styles = {};\n for (const key of (0, object_1.keys)(this.model.end_style))\n styles[key] = [this.model.end_style[key]];\n for (const key of (0, object_1.keys)(this.model.node_style)) {\n for (let index = 0; index < (xs.length - 2); index++) {\n styles[key].push(this.model.node_style[key]);\n }\n }\n for (const key of (0, object_1.keys)(this.model.end_style))\n styles[key].push(this.model.end_style[key]);\n this._selected_renderer = renderer;\n this._set_vertices(xs, ys, styles);\n }\n }\n exports.PolyVertexEditToolView = PolyVertexEditToolView;\n PolyVertexEditToolView.__name__ = \"PolyVertexEditToolView\";\n class PolyVertexEditTool extends poly_edit_tool_1.PolyEditTool {\n constructor(attrs) {\n super(attrs);\n }\n static init_PolyVertexEditTool() {\n this.prototype.default_view = PolyVertexEditToolView;\n this.define({\n node_style: [p.Any, {}],\n end_style: [p.Any, {}],\n });\n }\n }\n exports.PolyVertexEditTool = PolyVertexEditTool;\n PolyVertexEditTool.__name__ = \"PolyVertexEditTool\";\n PolyVertexEditTool.__module__ = \"geoviews.models.custom_tools\";\n PolyVertexEditTool.init_PolyVertexEditTool();\n}\n","/* models/restore_tool.js */ function _(require, module, exports, __esModule, __esExport) {\n __esModule();\n const tslib_1 = require(\"tslib\");\n const p = (0, tslib_1.__importStar)(require(\"@bokehjs/core/properties\"));\n const action_tool_1 = require(\"@bokehjs/models/tools/actions/action_tool\");\n class RestoreToolView extends action_tool_1.ActionToolView {\n doit() {\n const sources = this.model.sources;\n for (const source of sources) {\n if (!source.buffer || (source.buffer.length == 0)) {\n continue;\n }\n source.data = source.buffer.pop();\n source.change.emit();\n source.properties.data.change.emit();\n }\n }\n }\n exports.RestoreToolView = RestoreToolView;\n RestoreToolView.__name__ = \"RestoreToolView\";\n class RestoreTool extends action_tool_1.ActionTool {\n constructor(attrs) {\n super(attrs);\n this.tool_name = \"Restore\";\n this.icon = \"bk-tool-icon-undo\";\n }\n static init_RestoreTool() {\n this.prototype.default_view = RestoreToolView;\n this.define({\n sources: [p.Array, []]\n });\n }\n }\n exports.RestoreTool = RestoreTool;\n RestoreTool.__name__ = \"RestoreTool\";\n RestoreTool.__module__ = \"geoviews.models.custom_tools\";\n RestoreTool.init_RestoreTool();\n}\n"]}