drone_view 3.0.18 → 3.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drone_view",
3
- "version": "3.0.18",
3
+ "version": "3.0.20",
4
4
  "main": "dist/droneView.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -0,0 +1,684 @@
1
+ /* eslint-disable import/no-cycle */
2
+ import type {
3
+ Cesium3DTileset,
4
+ Cartesian3,
5
+ DataSource,
6
+ Entity,
7
+ EntityCollection,
8
+ ImageryLayer,
9
+ } from "cesium";
10
+
11
+ import type CesiumView from "./droneView";
12
+
13
+ export type PinType = "Image" | "Text" | "Icon" | "Blank";
14
+
15
+ export type Anchor =
16
+ | "center"
17
+ | "top"
18
+ | "bottom"
19
+ | "left"
20
+ | "right"
21
+ | "top-left"
22
+ | "top-right"
23
+ | "bottom-left"
24
+ | "bottom-right";
25
+
26
+ export type EventType =
27
+ | "mousedown"
28
+ | "mouseup"
29
+ | "mouseMove"
30
+ | "mouseOver"
31
+ | "mouseOut"
32
+ | "click"
33
+ | "rightClick";
34
+
35
+ export type ViewerObject =
36
+ | Cesium3DTileset
37
+ | Entity
38
+ | EntityCollection
39
+ | DataSource
40
+ | ImageryLayer;
41
+
42
+ export interface Point {
43
+ /**
44
+ * Latitude
45
+ */
46
+ lat: number | string;
47
+ /**
48
+ * Longitudev
49
+ */
50
+ long: number | string;
51
+ /**
52
+ * Height in 3D view
53
+ */
54
+ height?: number | string;
55
+ }
56
+
57
+ export type BaseMapType = "mapbox" | "esri";
58
+
59
+ /**
60
+ * Generic Options for any Layer
61
+ */
62
+ export type Options = {
63
+ /** Should the bounds of the map be set to the bounds of the data in the layer */
64
+ setBounds?: boolean;
65
+ /** When setBounds is true, should the bounds be set immediately.
66
+ * If false the map will slowly pan & zoom to the bounds */
67
+ setBoundsInstant?: boolean;
68
+ /** Callback function that should be called when a feature is clicked on */
69
+ onClick?: Function;
70
+ onPinchEnd?: Function;
71
+ onHover?: Function;
72
+ clearHover?: Function;
73
+ isNoListener?: boolean
74
+ };
75
+
76
+ /**
77
+ * Type definition for Marker Icon
78
+ */
79
+ export type MarkerIcon = {
80
+ /** name of the icon */
81
+ name: string;
82
+ /** url to icon image. image must be png. If allowSVG is true then an
83
+ * svg version must exist with the same name and path.
84
+ * e.g: icons should exist for /icons/marker-icon.png /icons/marker-icon.svg
85
+ * */
86
+ src: string;
87
+ options: {
88
+ /** Does this icon support svgs. Set to false if only a png version is available */
89
+ allowSVG?: boolean;
90
+ /** The ration of pixels in the image to physical pixels on the screen. (see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addimage} ) */
91
+ pixelRatio?: number | string;
92
+ deficiency: boolean;
93
+ };
94
+ };
95
+
96
+ /**
97
+ * Type definition for Marker Layer Options, extends {@link Options}
98
+ * @see Options
99
+ * @member {Options}
100
+ */
101
+ export type MarkerOptions = Options & {
102
+ /** Array of {@link MarkerIcon} to use for the markers */
103
+ icons: MarkerIcon[];
104
+ /** Are SVG icons supported by this data layer */
105
+ allowSVGs?: boolean;
106
+ /** Rotation of the marker. Default 0 */
107
+ rotate?: number;
108
+ };
109
+
110
+ /**
111
+ * Marker Data
112
+ */
113
+ export type MarkerData = {
114
+ point: Array<number>;
115
+ properties: {
116
+ [key: string]: any;
117
+ /** ID of the feature */
118
+ id?: string | number;
119
+ /** The icon to use for the marker. Name should match to
120
+ * a {@link MarkerIcon} specified in the {@link MarkerOptions} */
121
+ label?: string;
122
+ icon: string;
123
+ };
124
+ };
125
+
126
+ export type NoteIcon = {
127
+ /** name of the icon */
128
+ name: string;
129
+ /** url to icon image. image must be png. If allowSVG is true then an
130
+ * svg version must exist with the same name and path.
131
+ * e.g: icons should exist for /icons/marker-icon.png /icons/marker-icon.svg
132
+ * */
133
+ src: string;
134
+ options: {
135
+ /** Does this icon support svgs. Set to false if only a png version is available */
136
+ allowSVG?: boolean;
137
+ /** The ration of pixels in the image to physical pixels on the screen. (see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addimage} ) */
138
+ pixelRatio?: number | string;
139
+ deficiency: boolean;
140
+ };
141
+ };
142
+
143
+
144
+ /**
145
+ * Type definition for Note Layer Options, extends {@link Options}
146
+ * @see Options
147
+ * @member {Options}
148
+ */
149
+ export type NoteOptions = Options & {
150
+ /** Array of {@link NoteIcon} to use for the Note */
151
+ icons: NoteIcon[];
152
+ /** Are SVG icons supported by this data layer */
153
+ allowSVGs?: boolean;
154
+ /** Rotation of the marker. Default 0 */
155
+ rotate?: number;
156
+ };
157
+
158
+ /**
159
+ * Marker Data
160
+ */
161
+ export type NoteData = {
162
+ point: Array<number>;
163
+ properties: {
164
+ [key: string]: any;
165
+ /** ID of the feature */
166
+ id?: string | number;
167
+ /** The icon to use for the marker. Name should match to
168
+ * a {@link NoteIcon} specified in the {@link NoteOptions} */
169
+ label?: string;
170
+ icon: string;
171
+ };
172
+ };
173
+
174
+
175
+
176
+
177
+ /**
178
+ * Annotation Data
179
+ */
180
+ export type AnnotationData = {
181
+ point: Array<number>;
182
+ properties: {
183
+ [key: string]: any;
184
+ /**
185
+ * Icon Detail
186
+ */
187
+ name: string;
188
+ /** ID of the feature */
189
+ id?: string | number;
190
+ };
191
+ };
192
+
193
+ /**
194
+ * Type definition for Line Options, extends {@link Options}
195
+ * @see Options
196
+ * @member {Options}
197
+ */
198
+ export type LineOptions = Options & {
199
+ /** should a directional arrow be rendered on the line */
200
+ arrowLine?: boolean;
201
+ };
202
+
203
+ export type EditPointOption = Options & {
204
+ /** return new position when drag end */
205
+ onDragEnd: Function | undefined
206
+ zoom: boolean;
207
+ }
208
+
209
+ /**
210
+ * LineData
211
+ */
212
+ export type LineData = {
213
+ /** Points */
214
+ points: Array<Array<number>>;
215
+ /** Properties */
216
+ properties: {
217
+ [key: string]: any;
218
+ /** ID of the feature */
219
+ id?: string | number;
220
+ /** Color of line (hex or RGB) */
221
+ color: string;
222
+ };
223
+ };
224
+
225
+ /**
226
+ * Model Data
227
+ */
228
+ export type ModelData = {
229
+ /** url of Model data main json file */
230
+ url: string;
231
+ /** Color css hex color code */
232
+ color: string;
233
+ /** Shadow */
234
+ shadow: boolean;
235
+ /** Center */
236
+ center: Point;
237
+ /** Rotation X in degree*/
238
+ rotationX: number;
239
+ /** Rotation Y in degree*/
240
+ rotationY: number;
241
+ /** Rotation Z in degree*/
242
+ rotationZ: number;
243
+ };
244
+
245
+ /**
246
+ * Polygon Data
247
+ */
248
+ export type PolygonData = {
249
+ points: Array<Array<number>>;
250
+ /** General properties of the feature, usually this is for data used code interacting with the data layers */
251
+ properties: {
252
+ [key: string]: any;
253
+ /** ID of the feature */
254
+ id?: string | number;
255
+ /** Color of polygon (hex or RGB) */
256
+ color: string;
257
+ };
258
+ };
259
+
260
+ /**
261
+ * Type definition for Polygon Layer Options, extends {@link Options}
262
+ * @see Options
263
+ * @member {Options}
264
+ */
265
+ export type PolygonOptions = Options & {
266
+ /** Opacity 0-1 */
267
+ opacity?: number;
268
+ /** Minimum zoom level to display the layer polygons */
269
+ minZoom?: number;
270
+ /** Maximum zoom level to display the layer polygons */
271
+ maxZoom?: number;
272
+ /** Minimum zoom level to display the layer labels */
273
+ minZoomLabel?: number;
274
+ /** Maximum zoom level to display the layer labels */
275
+ maxZoomLabel?: number;
276
+ };
277
+
278
+ /**
279
+ * RasterData
280
+ */
281
+ export type OrthoData = {
282
+ /* For example: tiles.php?z={z}&x={x}&y={y} */
283
+ url: string;
284
+ /** dimensions of tiles, defaults to 256px */
285
+ tileSize?: number;
286
+ /** Minimum zoom level to display the layer */
287
+ minZoom?: number;
288
+ /** Maximum zoom level to display the layer */
289
+ maxZoom?: number;
290
+ /** Credit for tile */
291
+ credit?: string;
292
+ };
293
+
294
+ /** Generic Type for Layer Options representing all types of options */
295
+ export type LayerOptions = Options | MarkerOptions | LineOptions | NoteOptions;
296
+
297
+ /** Generic Type for Layer Data representing all types of data */
298
+ export type LayerData = MarkerData | LineData | ModelData | AnnotationData | NoteData;
299
+
300
+ /**
301
+ * Interface for Drawing shape
302
+ */
303
+ interface EntityConfiguration {
304
+ id?: string;
305
+ /**
306
+ * string css hex color code
307
+ */
308
+ fillColor?: string;
309
+ /**
310
+ * string css hex color code
311
+ */
312
+ lineColor?: string;
313
+ /**
314
+ * string css hex color code
315
+ */
316
+ strokeColor?: string;
317
+ opacity?: number;
318
+ lineWidth?: number;
319
+ clamp?: boolean;
320
+ distance?: number;
321
+ measurement: boolean;
322
+ }
323
+
324
+ /** Interface for pin configuration */
325
+ export interface PinConfig {
326
+ /** Unique Id for pin other wise it will automatically generate one */
327
+ id?: string;
328
+ /** Id of layer */
329
+ layerId?: string;
330
+ /** Type of the Pin */
331
+ type: PinType;
332
+ /** url of image supports png and svg */
333
+ imageUrl?: string;
334
+ /** Words to be shown on pin when PinType is Text */
335
+ text?: string;
336
+ /** Icon name when PinType is Icon */
337
+ iconName?: string;
338
+ /** Size of pin */
339
+ size?: number;
340
+ /** string css hex color code */
341
+ color?: string;
342
+ /** Opacity number between 0-1 */
343
+ opacity?: number;
344
+ /** Scale size when zoom in or out Boolean */
345
+ scaleByDistance?: boolean;
346
+ /** Scale pin size */
347
+ scale?: number;
348
+ /** Position where to display Pin */
349
+ position?: Point;
350
+ /** Rotation of the marker. Default 0 radians */
351
+ rotate?: number;
352
+ /** anchor postion */
353
+ anchor?: Anchor;
354
+ /** Offset values in px of the icon to the center point of the marker */
355
+ iconOffset?: number[];
356
+ }
357
+
358
+ export type GeojsonFeature = {
359
+ type: "Feature";
360
+ geometry: {
361
+ type: "Point" | "Polygon" | "LineString";
362
+ coordinates: Array<number> | Array<Array<number>>;
363
+ };
364
+ properties?: { [key: string]: string };
365
+ };
366
+
367
+ /**
368
+ * For measurement mode types
369
+ */
370
+ export type Mode = "Draw" | "Edit" | "Delete";
371
+
372
+ /**
373
+ * Interface for drawing configuration of shape
374
+ */
375
+ export interface DrawingConfig extends EntityConfiguration {
376
+ type: "LineString" | "Polygon" | "Point" | "Cross-Section";
377
+ }
378
+
379
+ /**
380
+ * @typedef {function}
381
+ * @name MouseEventCallback
382
+ * @description Callback for the Mouse Event listener. Provides a single latitude and longitude of the mouse event triggered.
383
+ */
384
+ export type MouseEventCallback = (latitude: number, longitude: number) => void;
385
+
386
+ export type MouseEventOptions = {
387
+ /** Should the event only be triggered when there are no features beneath the mouse */
388
+ hasNoFeatures?: boolean;
389
+ /** Should the event be prevented from bubbling */
390
+ stopClickPropagation?: boolean;
391
+ };
392
+
393
+ /**
394
+ * Layer Listener Type
395
+ */
396
+ export type LayerListener = {
397
+ /** Event listener is triggered on */
398
+ event: string;
399
+ /** Unique name of listener */
400
+ id: string;
401
+ /** Function to call on event triggering */
402
+ fn: Function;
403
+ };
404
+
405
+ /**
406
+ * @typedef {function}
407
+ * @name EventListenerCallback
408
+ * @description Callback for the Mouse Event listener. Provides an object containing features interacted with if the listener was added to layers. Always contains the latLng of the mouse event.
409
+ */
410
+ export type EventListenerCallback = (event: EventListenerEvent) => void;
411
+
412
+ /**
413
+ * Interface to respond when converting screen coordinates to Cartesian
414
+ */
415
+ export type DrawResponse = {
416
+ id: string;
417
+ object: any;
418
+ };
419
+
420
+ export type MapCursor =
421
+ | "crosshair"
422
+ | "pointer"
423
+ | "move"
424
+ | "grabbing"
425
+ | "grab"
426
+ | "default";
427
+
428
+ export type MapStyle = "default" | "satellite" | "roadmap";
429
+
430
+ export type MapOptions = {
431
+ /** Token from cesium ion */
432
+ token: string;
433
+ /** Map box access token to load road/ street map (Required for roadMap mapstyle) */
434
+ mapboxToken: string;
435
+ /** Which base map style should be initialized with */
436
+ style?: MapStyle;
437
+ /** Initial center of the map [longitude, latitude] */
438
+ center?: Array<number>;
439
+ /** Initial zoom level of the map */
440
+ zoom?: number;
441
+ /** The maximum zoom level the map can go to */
442
+ maxZoomLevel?: number;
443
+ /** The minimum zoom level the map can go to */
444
+ minZoomLevel?: number;
445
+ /** id of the map element to add the canvas to */
446
+ mapElementId: string;
447
+ };
448
+
449
+ /**
450
+ * Callback function while interacting with mouse
451
+ */
452
+ export type CallBack = (position: Point) => void;
453
+
454
+ /**
455
+ * A Generic Feature comprised of a single location
456
+ */
457
+ export type SingleLocationFeature = {
458
+ /** Geometry type */
459
+ geometry: any;
460
+ /** Latitude */
461
+ lat: number | string;
462
+ /** Longitude */
463
+ long: number | string;
464
+ /** Height */
465
+ height: number | string;
466
+ /** General properties of the feature, usually this is for data used
467
+ * code interacting with the data layers */
468
+ properties: {
469
+ [key: string]: any;
470
+ /** ID of the feature */
471
+ id?: string | number;
472
+ };
473
+ };
474
+
475
+ /**
476
+ * `EventListenerEvent` is a class used the EventListenerCallback
477
+ * when a mouse event is triggered on the map.
478
+ * See https://docs.mapbox.com/mapbox-gl-js/api/map/#map#on
479
+ */
480
+ export type EventListenerEvent = {
481
+ /**
482
+ * The type of originating event. For a full list of available events,
483
+ * see [`Map` events](/mapbox-gl-js/api/map/#map-events).
484
+ */
485
+ type:
486
+ | "mousedown"
487
+ | "mouseup"
488
+ | "preclick"
489
+ | "click"
490
+ | "dblclick"
491
+ | "mousemove"
492
+ | "mouseover"
493
+ | "mouseenter"
494
+ | "mouseleave"
495
+ | "mouseout"
496
+ | "contextmenu";
497
+
498
+ /**
499
+ * The `Map` object that fired the event.
500
+ */
501
+ target: CesiumView;
502
+
503
+ /**
504
+ * The DOM event which caused the map event.
505
+ */
506
+ originalEvent?: MouseEvent;
507
+
508
+ /**
509
+ * The pixel coordinates of the mouse cursor, relative to the map and measured
510
+ * from the top left corner.
511
+ */
512
+ point: {
513
+ x: number;
514
+ y: number;
515
+ };
516
+
517
+ /**
518
+ * The geographic location on the map of the mouse cursor.
519
+ */
520
+ lngLat: {
521
+ lng: number;
522
+ lat: number;
523
+ height?: number;
524
+ };
525
+ /**
526
+ * If a single `layerId`(as a single string) or multiple `layerIds`
527
+ * (as an array of strings) were specified when adding the event listener with {@link Map#on},
528
+ * `features` will be an array of [GeoJSON](http://geojson.org/) [Feature objects](https://tools.ietf.org/html/rfc7946#section-3.2).
529
+ * The array will contain all features from that layer that are rendered at the event's point,
530
+ * in the order that they are rendered with the topmost feature being at the start of the array.
531
+ * The `features` are identical to those returned by {@link Map#queryRenderedFeatures}.
532
+ *
533
+ * If no `layerId` was specified when adding the event listener, `features` will be `undefined`.
534
+ * You can get the features at the point with `map.queryRenderedFeatures(e.point)`.
535
+ *
536
+ * @example
537
+ * // logging features for a specific layer (with `e.features`)
538
+ * map.on('click', 'myLayerId', (e) => {
539
+ * console.log(`There are ${e.features.length} features at point ${e.point}`);
540
+ * });
541
+ *
542
+ * @example
543
+ * // logging features for two layers (with `e.features`)
544
+ * map.on('click', ['layer1', 'layer2'], (e) => {
545
+ * console.log(`There are ${e.features.length} features at point ${e.point}`);
546
+ * });
547
+ *
548
+ * @example
549
+ * // logging all features for all layers (without `e.features`)
550
+ * map.on('click', (e) => {
551
+ * const features = map.queryRenderedFeatures(e.point);
552
+ * console.log(`There are ${features.length} features at point ${e.point}`);
553
+ * });
554
+ */
555
+ // eslint-disable-next-line @typescript-eslint/ban-types
556
+ features: Array<SingleLocationFeature>;
557
+
558
+ /**
559
+ * Prevents subsequent default processing of the event by the map.
560
+ *
561
+ * @example
562
+ * map.on('click', (e) => {
563
+ * e.preventDefault();
564
+ * });
565
+ */
566
+ preventDefault?: Function;
567
+
568
+ /**
569
+ * `true` if `preventDefault` has been called.
570
+ * @private
571
+ */
572
+ defaultPrevented?: Function;
573
+
574
+ _defaultPrevented?: boolean;
575
+ };
576
+
577
+ /**
578
+ * Feature Properties Base Type
579
+ */
580
+ export type FeatureProperties = {
581
+ [key: string]: any;
582
+ /** ID of the feature */
583
+ id?: string | number;
584
+ };
585
+
586
+ /**
587
+ * Supported map types to send data to
588
+ */
589
+ export type MapType = 'default' | 'compare' | 'all';
590
+
591
+ /**
592
+ * Supported layer types
593
+ */
594
+ export type LayerType =
595
+ | "polygon"
596
+ | "line"
597
+ | "marker"
598
+ | "marker3d"
599
+ | "model"
600
+ | "ortho"
601
+ | "droneImage"
602
+ | "editPolygon"
603
+ | "editLine"
604
+ | "editPoint"
605
+ | "annotation"
606
+ | "note";
607
+
608
+ /**
609
+ * Interface for label configuration
610
+ */
611
+ interface LabelConfig {
612
+ /**
613
+ * Id should be unique
614
+ * If not provided API will generate one
615
+ */
616
+ id?: string;
617
+ /**
618
+ * Name for this label
619
+ */
620
+ name?: string;
621
+ /**
622
+ * string css hex color code
623
+ */
624
+ fillColor?: string;
625
+ /**
626
+ * number Font size
627
+ */
628
+ size?: number;
629
+ /**
630
+ * To set background
631
+ */
632
+ isBackground?: boolean;
633
+ /**
634
+ * string css hex color code
635
+ */
636
+ backgroundColor?: string;
637
+ /**
638
+ * number between 0 to 1
639
+ */
640
+ opacity?: number;
641
+ /**
642
+ * Callback function to get ID after addition
643
+ */
644
+ getId?: (id: string) => void;
645
+ }
646
+
647
+ /**
648
+ * Label configuration when position is in latitude and longitude
649
+ */
650
+ export interface LabelConfigByLatLng extends LabelConfig {
651
+ text: string;
652
+ /**
653
+ * Position where to display tooltip
654
+ */
655
+ position: Point;
656
+ }
657
+
658
+ /**
659
+ * Label configuration when position is in Cartesian
660
+ */
661
+ export interface LabelConfigByCartesian extends LabelConfig {
662
+ /**
663
+ * Text that will appear on label
664
+ */
665
+ text: string;
666
+ /**
667
+ * Position in cartesian3
668
+ */
669
+ position: Cartesian3;
670
+ }
671
+
672
+ /**
673
+ * Interface for tooltip configuration
674
+ */
675
+ export interface TooltipConfigByLatLng extends LabelConfig {
676
+ /**
677
+ * Property json
678
+ */
679
+ data?: { [key: string]: string };
680
+ /**
681
+ * Position where to display tooltip
682
+ */
683
+ position: Cartesian3;
684
+ }