@sswroom/sswr 1.5.4 → 1.5.5

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/Changelog CHANGED
@@ -1,3 +1,16 @@
1
+ 1.5.5
2
+ -Fixed web.Dialog in iframe
3
+ -Fixed GeolocationFilter when using minDistMeter
4
+ -Added data.ByteReader
5
+ -Added media.StaticImage
6
+ -Added media.EXIFData
7
+ -Added media.loadImageFromBlob
8
+ -Added text.u8Arr2Hex
9
+ -Added web.propertiesToHTML
10
+ -Support parsing JPG file
11
+ -Support parsing WEBP file
12
+ -web.openData Support Blob
13
+
1
14
  1.5.4
2
15
  -Added geometry.Vector2D.getBounds
3
16
  -Added kml.Feature.getBounds
package/data.d.ts CHANGED
@@ -176,3 +176,30 @@ export class Timestamp {
176
176
  toTimeValue(): TimeValue;
177
177
  roundToS(): Timestamp;
178
178
  }
179
+
180
+ export class ByteReader
181
+ {
182
+ view: DataView;
183
+
184
+ constructor(arr: ArrayBuffer);
185
+ getLength(): number;
186
+ getArrayBuffer(ofst: number, size: number): ArrayBuffer;
187
+
188
+ readUInt8(ofst: number): number;
189
+ readUInt16(ofst: number, lsb: boolean): number;
190
+ readUInt32(ofst: number, lsb: boolean): number;
191
+ readInt8(ofst: number): number;
192
+ readInt16(ofst: number, lsb: boolean): number;
193
+ readInt32(ofst: number, lsb: boolean): number;
194
+ readFloat64(ofst: number, lsb: boolean): number;
195
+ readUTF8(ofst: number, len: number): string;
196
+ readUTF8Z(ofst: number, maxSize?: number): string;
197
+
198
+ readUInt8Arr(ofst: number, cnt: number): number[];
199
+ readUInt16Arr(ofst: number, lsb: boolean, cnt: number): number[];
200
+ readUInt32Arr(ofst: number, lsb: boolean, cnt: number): number[];
201
+ readInt8Arr(ofst: number, cnt: number): number[];
202
+ readInt16Arr(ofst: number, lsb: boolean, cnt: number): number[];
203
+ readInt32Arr(ofst: number, lsb: boolean, cnt: number): number[];
204
+ readFloat64Arr(ofst: number, lsb: boolean, cnt: number): number[];
205
+ }
package/data.js CHANGED
@@ -2292,3 +2292,163 @@ export class Timestamp
2292
2292
  return new Timestamp(this.inst.roundToS(), this.tzQhr);
2293
2293
  }
2294
2294
  }
2295
+
2296
+ export class ByteReader
2297
+ {
2298
+ constructor(arr)
2299
+ {
2300
+ this.view = new DataView(arr);
2301
+ }
2302
+
2303
+ getLength()
2304
+ {
2305
+ return this.view.byteLength;
2306
+ }
2307
+
2308
+ getArrayBuffer(ofst, size)
2309
+ {
2310
+ if (ofst == null)
2311
+ ofst = 0;
2312
+ if (size == null)
2313
+ size = this.view.byteLength - ofst;
2314
+ return this.view.buffer.slice(this.view.byteOffset + ofst, this.view.byteOffset + ofst + size);
2315
+ }
2316
+
2317
+ readUInt8(ofst)
2318
+ {
2319
+ return this.view.getUint8(ofst);
2320
+ }
2321
+
2322
+ readUInt16(ofst, lsb)
2323
+ {
2324
+ return this.view.getUint16(ofst, lsb);
2325
+ }
2326
+
2327
+ readUInt32(ofst, lsb)
2328
+ {
2329
+ return this.view.getUint32(ofst, lsb);
2330
+ }
2331
+
2332
+ readInt8(ofst)
2333
+ {
2334
+ return this.view.getInt8(ofst);
2335
+ }
2336
+
2337
+ readInt16(ofst, lsb)
2338
+ {
2339
+ return this.view.getInt16(ofst, lsb);
2340
+ }
2341
+
2342
+ readInt32(ofst, lsb)
2343
+ {
2344
+ return this.view.getInt32(ofst, lsb);
2345
+ }
2346
+
2347
+ readFloat64(ofst, lsb)
2348
+ {
2349
+ return this.view.getFloat64(ofst, lsb);
2350
+ }
2351
+
2352
+ readUTF8(ofst, len)
2353
+ {
2354
+ let dec = new TextDecoder();
2355
+ return dec.decode(this.getArrayBuffer(ofst, len));
2356
+ }
2357
+
2358
+ readUTF8Z(ofst, maxSize)
2359
+ {
2360
+ let end = ofst;
2361
+ let maxEnd;
2362
+ if (maxSize)
2363
+ {
2364
+ maxEnd = ofst + maxSize;
2365
+ if (maxEnd > this.view.byteLength)
2366
+ maxEnd = this.view.byteLength;
2367
+ }
2368
+ else
2369
+ {
2370
+ maxEnd = this.view.byteLength;
2371
+ }
2372
+ while (end < maxEnd && this.view.getUint8(end) != 0)
2373
+ end++;
2374
+ let dec = new TextDecoder();
2375
+ return dec.decode(this.view.buffer.slice(this.view.byteOffset + ofst, this.view.byteOffset + end));
2376
+ }
2377
+
2378
+ readUInt8Arr(ofst, cnt)
2379
+ {
2380
+ let ret = [];
2381
+ while (cnt-- > 0)
2382
+ {
2383
+ ret.push(this.readUInt8(ofst));
2384
+ ofst++;
2385
+ }
2386
+ return ret;
2387
+ }
2388
+
2389
+ readUInt16Arr(ofst, lsb, cnt)
2390
+ {
2391
+ let ret = [];
2392
+ while (cnt-- > 0)
2393
+ {
2394
+ ret.push(this.readUInt16(ofst, lsb));
2395
+ ofst += 2;
2396
+ }
2397
+ return ret;
2398
+ }
2399
+
2400
+ readUInt32Arr(ofst, lsb, cnt)
2401
+ {
2402
+ let ret = [];
2403
+ while (cnt-- > 0)
2404
+ {
2405
+ ret.push(this.readUInt32(ofst, lsb));
2406
+ ofst += 4;
2407
+ }
2408
+ return ret;
2409
+ }
2410
+
2411
+ readInt8Arr(ofst, cnt)
2412
+ {
2413
+ let ret = [];
2414
+ while (cnt-- > 0)
2415
+ {
2416
+ ret.push(this.readInt8(ofst));
2417
+ ofst++;
2418
+ }
2419
+ return ret;
2420
+ }
2421
+
2422
+ readInt16Arr(ofst, lsb, cnt)
2423
+ {
2424
+ let ret = [];
2425
+ while (cnt-- > 0)
2426
+ {
2427
+ ret.push(this.readInt16(ofst, lsb));
2428
+ ofst += 2;
2429
+ }
2430
+ return ret;
2431
+ }
2432
+
2433
+ readInt32Arr(ofst, lsb, cnt)
2434
+ {
2435
+ let ret = [];
2436
+ while (cnt-- > 0)
2437
+ {
2438
+ ret.push(this.readInt32(ofst, lsb));
2439
+ ofst += 4;
2440
+ }
2441
+ return ret;
2442
+ }
2443
+
2444
+ readFloat64Arr(ofst, lsb, cnt)
2445
+ {
2446
+ let ret = [];
2447
+ while (cnt-- > 0)
2448
+ {
2449
+ ret.push(this.readFloat64(ofst, lsb));
2450
+ ofst += 8;
2451
+ }
2452
+ return ret;
2453
+ }
2454
+ }
package/kml.d.ts CHANGED
@@ -41,6 +41,21 @@ export enum HotSpotUnit
41
41
  InsetPixels
42
42
  };
43
43
 
44
+ export enum RefreshMode
45
+ {
46
+ OnChange,
47
+ OnInterval,
48
+ OnExpire
49
+ };
50
+
51
+ export enum ViewRefreshMode
52
+ {
53
+ Never,
54
+ OnStop,
55
+ OnRequest,
56
+ OnRegion
57
+ };
58
+
44
59
  export class Element
45
60
  {
46
61
  getUsedNS(ns: object): void;
@@ -215,6 +230,7 @@ export class Feature extends Element
215
230
  visibility: boolean;
216
231
  open: boolean;
217
232
  author: string;
233
+ authorName: string;
218
234
  link: string;
219
235
  address: string;
220
236
  //AddressDetails: ?;
@@ -229,6 +245,7 @@ export class Feature extends Element
229
245
  setVisibility(visibility: boolean): void;
230
246
  setOpen(open: boolean): void;
231
247
  setAuthor(author: string): void;
248
+ setAuthorName(authorName: string): void;
232
249
  setLink(link: string): void;
233
250
  setAddress(address: string): void;
234
251
  setPhoneNumber(phoneNumber: string): void;
@@ -271,7 +288,19 @@ export class Folder extends Container
271
288
 
272
289
  export class NetworkLink extends Feature
273
290
  {
274
- constructor();
291
+ networkLink: string;
292
+ refreshVisibility: boolean;
293
+ flyToView: boolean;
294
+ refreshMode: RefreshMode;
295
+ refreshInterval: number;
296
+ viewRefreshMode: ViewRefreshMode;
297
+
298
+ constructor(networkLink: string);
299
+ setRefreshVisibility(refreshVisibility: boolean): void;
300
+ setFlyToView(flyToView: boolean): void;
301
+ setRefreshMode(refreshMode: RefreshMode): void;
302
+ setRefreshInterval(refreshInterval: number): void;
303
+ setViewRefreshMode(viewRefreshMode: ViewRefreshMode): void;
275
304
 
276
305
  getBounds(): math.RectArea | null;
277
306
  getUsedNS(ns: object): void;
package/kml.js CHANGED
@@ -35,6 +35,19 @@ export const HotSpotUnit = {
35
35
  InsetPixels: "insetPixels"
36
36
  }
37
37
 
38
+ export const RefreshMode = {
39
+ OnChange: "onChange",
40
+ OnInterval: "onInterval",
41
+ OnExpire: "onExpire"
42
+ };
43
+
44
+ export const ViewRefreshMode = {
45
+ Never: "never",
46
+ OnStop: "onStop",
47
+ OnRequest: "onRequest",
48
+ OnRegion: "onRegion"
49
+ };
50
+
38
51
  export class Element
39
52
  {
40
53
  }
@@ -655,6 +668,11 @@ export class Feature extends Element
655
668
  this.author = author;
656
669
  }
657
670
 
671
+ setAuthorName(authorName)
672
+ {
673
+ this.authorName = authorName;
674
+ }
675
+
658
676
  setLink(link)
659
677
  {
660
678
  this.link = link;
@@ -698,8 +716,12 @@ export class Feature extends Element
698
716
  strs.push("\t".repeat(level)+"<visibility>"+(this.visibility?"1":"0")+"</visibility>");
699
717
  if (this.open != null)
700
718
  strs.push("\t".repeat(level)+"<open>"+(this.open?"1":"0")+"</open>");
701
- if (this.author)
719
+ if (this.author && this.authorName)
720
+ strs.push("\t".repeat(level)+"<atom:author>"+text.toXMLText(this.author)+"<atom:name>"+text.toXMLText(this.authorName)+"</atom:name></atom:author>");
721
+ else if (this.author)
702
722
  strs.push("\t".repeat(level)+"<atom:author>"+text.toXMLText(this.author)+"</atom:author>");
723
+ else if (this.authorName)
724
+ strs.push("\t".repeat(level)+"<atom:author><atom:name>"+text.toXMLText(this.authorName)+"</atom:name></atom:author>");
703
725
  if (this.link)
704
726
  strs.push("\t".repeat(level)+"<atom:link href="+text.toAttrText(this.link)+"/>");
705
727
  if (this.address)
@@ -868,6 +890,70 @@ export class Folder extends Container
868
890
  }
869
891
  }
870
892
 
893
+ export class NetworkLink extends Feature
894
+ {
895
+ constructor(networkLink)
896
+ {
897
+ super();
898
+ this.networkLink = networkLink;
899
+ }
900
+
901
+ setRefreshVisibility(refreshVisibility)
902
+ {
903
+ this.refreshVisibility = refreshVisibility;
904
+ }
905
+
906
+ setFlyToView(flyToView)
907
+ {
908
+ this.flyToView = flyToView;
909
+ }
910
+
911
+ setRefreshMode(refreshMode)
912
+ {
913
+ this.refreshMode = refreshMode;
914
+ }
915
+
916
+ setRefreshInterval(refreshInterval)
917
+ {
918
+ this.refreshInterval = refreshInterval;
919
+ }
920
+
921
+ setViewRefreshMode(viewRefreshMode)
922
+ {
923
+ this.viewRefreshMode = viewRefreshMode;
924
+ }
925
+
926
+ getBounds()
927
+ {
928
+ return null;
929
+ }
930
+
931
+ getUsedNS(ns)
932
+ {
933
+ }
934
+
935
+ appendOuterXML(strs, level)
936
+ {
937
+ strs.push("\t".repeat(level)+"<NetworkLink>");
938
+ this.appendInnerXML(strs, level + 1);
939
+ if (this.refreshVisibility != null)
940
+ strs.push("\t".repeat(level + 1)+"<refreshVisibility>"+(this.refreshVisibility?"1":"0")+"</refreshVisibility>");
941
+ if (this.flyToView != null)
942
+ strs.push("\t".repeat(level + 1)+"<flyToView>"+(this.flyToView?"1":"0")+"</flyToView>");
943
+
944
+ strs.push("\t".repeat(level + 1)+"<Link>");
945
+ strs.push("\t".repeat(level + 2)+"<href>"+text.toXMLText(this.networkLink)+"</href>");
946
+ if (this.refreshMode)
947
+ strs.push("\t".repeat(level + 2)+"<refreshMode>"+text.toXMLText(this.refreshMode)+"</refreshMode>");
948
+ if (this.refreshInterval)
949
+ strs.push("\t".repeat(level + 2)+"<refreshInterval>"+this.refreshInterval+"</refreshInterval>");
950
+ if (this.viewRefreshMode)
951
+ strs.push("\t".repeat(level + 2)+"<viewRefreshMode>"+text.toXMLText(this.viewRefreshMode)+"</viewRefreshMode>");
952
+ strs.push("\t".repeat(level + 1)+"</Link>");
953
+ strs.push("\t".repeat(level)+"</NetworkLink>");
954
+ }
955
+ }
956
+
871
957
  export class Placemark extends Feature
872
958
  {
873
959
  constructor(vec)
@@ -1011,6 +1097,10 @@ export class Placemark extends Feature
1011
1097
 
1012
1098
  getUsedNS(ns)
1013
1099
  {
1100
+ if (this.author || this.link || this.authorName)
1101
+ {
1102
+ ns.atom = "http://www.w3.org/2005/Atom";
1103
+ }
1014
1104
  }
1015
1105
 
1016
1106
  appendOuterXML(strs, level)
package/leaflet.d.ts CHANGED
@@ -27,6 +27,16 @@ export function createKMLLookAt(map: L.Map): kml.LookAt;
27
27
  export function toKMLFeature(layer: L.Layer, doc?: kml.Document): kml.Feature | null;
28
28
  export function toKMLString(layer: L.Layer): string | null;
29
29
 
30
+ export class KMLNetworkLink
31
+ {
32
+ feature: kml.NetworkLink;
33
+ container: L.FeatureGroup;
34
+
35
+ constructor(feature: kml.NetworkLink);
36
+ reload(): void;
37
+ addTo(container: L.FeatureGroup): KMLNetworkLink;
38
+ }
39
+
30
40
  export class LeafletMap extends map.MapControl
31
41
  {
32
42
  constructor(divId: string);
package/leaflet.js CHANGED
@@ -4,6 +4,7 @@ import * as kml from "./kml.js";
4
4
  import * as math from "./math.js";
5
5
  import * as map from "./map.js";
6
6
  import * as osm from "./osm.js";
7
+ import * as parser from "./parser.js";
7
8
  import * as text from "./text.js";
8
9
  import * as web from "./web.js";
9
10
 
@@ -137,6 +138,10 @@ export function createFromKMLFeature(feature, options)
137
138
  }
138
139
  return layer;
139
140
  }
141
+ else if (feature instanceof kml.NetworkLink)
142
+ {
143
+ return new KMLNetworkLink(feature);
144
+ }
140
145
  else
141
146
  {
142
147
  console.log("Unknown KML feature type", feature);
@@ -441,6 +446,48 @@ export function toKMLString(layer)
441
446
  return null;
442
447
  }
443
448
 
449
+ export class KMLNetworkLink
450
+ {
451
+ constructor(feature)
452
+ {
453
+ if (feature instanceof kml.NetworkLink)
454
+ {
455
+ this.feature = feature;
456
+ this.container = L.featureGroup();
457
+ this.reload();
458
+ }
459
+ else
460
+ {
461
+ throw new Error("Feature is not NetworkLink");
462
+ }
463
+ }
464
+
465
+ reload()
466
+ {
467
+ fetch(this.feature.networkLink).then((resp)=>{
468
+ console.log(resp);
469
+ if (resp.ok)
470
+ {
471
+ parser.parseFile(resp).then((val)=>{
472
+ console.log(val);
473
+ if (val instanceof kml.Feature)
474
+ {
475
+ this.container.clearLayers();
476
+ let layer = createFromKMLFeature(val);
477
+ if (layer)
478
+ layer.addTo(this.container);
479
+ }
480
+ })
481
+ }
482
+ })
483
+ }
484
+
485
+ addTo(container)
486
+ {
487
+ this.container.addTo(container);
488
+ }
489
+ }
490
+
444
491
  export class LeafletMap extends map.MapControl
445
492
  {
446
493
  constructor(divId)
package/map.js CHANGED
@@ -134,7 +134,7 @@ export class GeolocationFilter
134
134
  }
135
135
  if (this.minDistMeter)
136
136
  {
137
- if (this.csys.calcSurfaceDistance(pos.coords.longitude, pos.coords.latitude, this.lastPos.longitude, this.lastPos.latitude, unit.Distance.Unit.METER) < this.minDistMeter)
137
+ if (this.csys.calcSurfaceDistance(pos.coords.longitude, pos.coords.latitude, this.lastPos.coords.longitude, this.lastPos.coords.latitude, unit.Distance.Unit.METER) < this.minDistMeter)
138
138
  return false;
139
139
  }
140
140
 
package/media.d.ts ADDED
@@ -0,0 +1,119 @@
1
+ import * as data from "./data";
2
+
3
+ export enum EXIFMaker
4
+ {
5
+ Standard,
6
+ Panasonic,
7
+ Canon,
8
+ Olympus,
9
+ Casio1,
10
+ Casio2,
11
+ FLIR,
12
+ Nikon3,
13
+ Sanyo,
14
+ Apple
15
+ };
16
+
17
+ export enum EXIFType
18
+ {
19
+ Unknown,
20
+ Bytes,
21
+ STRING,
22
+ UINT16,
23
+ UINT32,
24
+ Rational,
25
+ Other,
26
+ INT16,
27
+ SubExif,
28
+ INT32,
29
+ SRational,
30
+ Double,
31
+ UINT64,
32
+ INT64
33
+ };
34
+
35
+ declare class GPSInfo
36
+ {
37
+ lat: number;
38
+ lon: number;
39
+ altitude: number;
40
+ gpsTime: data.Timestamp;
41
+ }
42
+
43
+ export function loadImageFromBlob(blob: Blob): Promise<Image>;
44
+
45
+ export class EXIFItem
46
+ {
47
+ id: number;
48
+ type: EXIFType;
49
+ data: any;
50
+
51
+ constructor(id: number, type: EXIFType, data: any);
52
+ clone(): EXIFItem;
53
+ };
54
+
55
+ export class EXIFData
56
+ {
57
+ exifMaker: EXIFMaker;
58
+ exifMap: object;
59
+
60
+ constructor(exifMaker: EXIFMaker);
61
+
62
+ getEXIFMaker(): EXIFMaker;
63
+ clone(): EXIFData;
64
+ addBytes(id: number, data: number[]): void;
65
+ addString(id: number, data: string): void;
66
+ addUInt16(id: number, data: number[]): void;
67
+ addUInt32(id: number, data: number[]): void;
68
+ addInt16(id: number, data: number[]): void;
69
+ addInt32(id: number, data: number[]): void;
70
+ addRational(id: number, data: number[]): void; //UInt32[]
71
+ addSRational(id: number, data: number[]): void; //Int32[]
72
+ addOther(id: number, data: ArrayBuffer): void;
73
+ addSubEXIF(id: number, data: EXIFData): void;
74
+ addDouble(id: number, data: number[]): void;
75
+ addUInt64(id: number, data: number[]): void;
76
+ addInt64(id: number, data: number[]): void;
77
+ remove(id: number): void;
78
+
79
+ getExifIds(): number[];
80
+ getExifType(id: number): EXIFType;
81
+ getExifItem(id: number): EXIFItem | null;
82
+ getExifUInt16(id: number): number[] | null;
83
+ getExifUInt32(id: number): number[] | null;
84
+ getExifSubexif(id: number): EXIFData | null;
85
+ getExifOther(id: number): ArrayBuffer | null;
86
+
87
+ getPhotoDate(): data.Timestamp;
88
+ getPhotoMake(): string;
89
+ getPhotoModel(): string;
90
+ getPhotoLens(): string;
91
+ getPhotoFNumber(): number;
92
+ getPhotoExpTime(): number;
93
+ getPhotoISO(): number;
94
+ getPhotoFocalLength(): number;
95
+ getPhotoLocation(): GPSInfo | null;
96
+
97
+ getProperties(): object;
98
+ parseMakerNote(buff: ArrayBuffer): EXIFData | null;
99
+
100
+ static getEXIFName(exifMaker: EXIFMaker, id: number, subId: number): string;
101
+ static parseIFD(reader: data.ByteReader, ofst: number, lsb: boolean, nextOfst: object, readBase: number, maker?: EXIFMaker);
102
+ };
103
+
104
+ export class StaticImage
105
+ {
106
+ img: HTMLImageElement;
107
+ exif: any;
108
+
109
+ constructor(img: HTMLImageElement);
110
+ setExif(exif: any): void;
111
+ getWidth(): number;
112
+ getHeight(): number;
113
+ getProperties(): object;
114
+
115
+ createCanvas(): HTMLCanvasElement;
116
+ exportJPG(quality?: number): Promise<Blob | null>;
117
+ exportWEBP(quality?: number): Promise<Blob | null>;
118
+ exportPNG(): Promise<Blob | null>;
119
+ }