@sswroom/sswr 1.5.3 → 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 +20 -0
- package/cesium.js +15 -2
- package/data.d.ts +27 -0
- package/data.js +160 -0
- package/geometry.d.ts +4 -0
- package/geometry.js +39 -0
- package/kml.d.ts +36 -2
- package/kml.js +123 -1
- package/leaflet.d.ts +16 -4
- package/leaflet.js +56 -1
- package/map.js +1 -1
- package/math.d.ts +2 -0
- package/math.js +26 -0
- package/media.d.ts +119 -0
- package/media.js +2271 -0
- package/package.json +1 -1
- package/parser.d.ts +2 -1
- package/parser.js +296 -0
- package/text.d.ts +1 -0
- package/text.js +27 -0
- package/web.d.ts +2 -1
- package/web.js +37 -4
package/package.json
CHANGED
package/parser.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as kml from "./kml";
|
|
2
|
+
import * as media from "./media";
|
|
2
3
|
|
|
3
4
|
export function parseXML(txt: string): kml.Feature | kml.NetworkLinkControl | null;
|
|
4
|
-
export function parseFile(file: File): Promise<kml.Feature | kml.NetworkLinkControl | null>;
|
|
5
|
+
export function parseFile(file: File | Response): Promise<kml.Feature | kml.NetworkLinkControl | media.StaticImage | null>;
|
package/parser.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import * as data from "./data.js";
|
|
1
2
|
import * as geometry from "./geometry.js";
|
|
2
3
|
import * as kml from "./kml.js";
|
|
4
|
+
import * as media from "./media.js";
|
|
3
5
|
import * as text from "./text.js";
|
|
4
6
|
import * as web from "./web.js";
|
|
5
7
|
|
|
@@ -275,6 +277,46 @@ function parseKMLContainer(container, kmlNode, doc)
|
|
|
275
277
|
case "visibility":
|
|
276
278
|
container.setVisibility(node.textContent == "1");
|
|
277
279
|
break;
|
|
280
|
+
case "atom:author":
|
|
281
|
+
for (subNode of node.childNodes)
|
|
282
|
+
{
|
|
283
|
+
switch (subNode.nodeName)
|
|
284
|
+
{
|
|
285
|
+
case "#text":
|
|
286
|
+
{
|
|
287
|
+
let txt = subNode.textContent.trim();
|
|
288
|
+
if (txt.length > 0)
|
|
289
|
+
{
|
|
290
|
+
if (container.author)
|
|
291
|
+
container.setAuthor(container.author + " " + txt);
|
|
292
|
+
else
|
|
293
|
+
container.setAuthor(txt);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
case "atom:name":
|
|
298
|
+
container.setAuthorName(subNode.textContent);
|
|
299
|
+
break;
|
|
300
|
+
default:
|
|
301
|
+
console.log("Unknown node in kml atom:author: "+subNode.nodeName, subNode);
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
break;
|
|
306
|
+
case "atom:link":
|
|
307
|
+
for (subNode of node.attributes)
|
|
308
|
+
{
|
|
309
|
+
switch (subNode.name)
|
|
310
|
+
{
|
|
311
|
+
case "href":
|
|
312
|
+
container.setLink(subNode.value);
|
|
313
|
+
break;
|
|
314
|
+
default:
|
|
315
|
+
console.log("Unknown attribute in kml atom:link: "+subNode.nodeName, subNode);
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
break;
|
|
278
320
|
case "Style":
|
|
279
321
|
break;
|
|
280
322
|
case "StyleMap":
|
|
@@ -285,6 +327,11 @@ function parseKMLContainer(container, kmlNode, doc)
|
|
|
285
327
|
if (feature)
|
|
286
328
|
container.addFeature(feature);
|
|
287
329
|
break;
|
|
330
|
+
case "NetworkLink":
|
|
331
|
+
feature = parseKMLNetworkLink(node, doc || container);
|
|
332
|
+
if (feature)
|
|
333
|
+
container.addFeature(feature);
|
|
334
|
+
break;
|
|
288
335
|
case "LookAt":
|
|
289
336
|
container.setLookAt(parseKMLLookAt(node));
|
|
290
337
|
break;
|
|
@@ -574,6 +621,98 @@ function parseKMLGeometry(kmlNode)
|
|
|
574
621
|
return null;
|
|
575
622
|
}
|
|
576
623
|
|
|
624
|
+
function parseKMLNetworkLink(kmlNode, doc)
|
|
625
|
+
{
|
|
626
|
+
let name;
|
|
627
|
+
let description;
|
|
628
|
+
let open;
|
|
629
|
+
let refreshVisibility;
|
|
630
|
+
let flyToView;
|
|
631
|
+
let linkHref;
|
|
632
|
+
let refreshMode;
|
|
633
|
+
let refreshInterval;
|
|
634
|
+
let viewRefreshMode;
|
|
635
|
+
|
|
636
|
+
let feature;
|
|
637
|
+
let node;
|
|
638
|
+
let subNode;
|
|
639
|
+
for (node of kmlNode.childNodes)
|
|
640
|
+
{
|
|
641
|
+
switch (node.nodeName)
|
|
642
|
+
{
|
|
643
|
+
case "#text":
|
|
644
|
+
break;
|
|
645
|
+
case "name":
|
|
646
|
+
name = node.textContent;
|
|
647
|
+
break;
|
|
648
|
+
case "description":
|
|
649
|
+
description = node.textContent.trim();
|
|
650
|
+
break;
|
|
651
|
+
case "open":
|
|
652
|
+
open = (node.textContent == "1");
|
|
653
|
+
break;
|
|
654
|
+
case "refreshVisibility":
|
|
655
|
+
refreshVisibility = (node.textContent == "1");
|
|
656
|
+
break;
|
|
657
|
+
case "flyToView":
|
|
658
|
+
flyToView = (node.textContent == "1");
|
|
659
|
+
break;
|
|
660
|
+
case "Link":
|
|
661
|
+
for (subNode of node.childNodes)
|
|
662
|
+
{
|
|
663
|
+
switch (subNode.nodeName)
|
|
664
|
+
{
|
|
665
|
+
case "#comment":
|
|
666
|
+
break;
|
|
667
|
+
case "#text":
|
|
668
|
+
break;
|
|
669
|
+
case "href":
|
|
670
|
+
linkHref = subNode.textContent;
|
|
671
|
+
break;
|
|
672
|
+
case "refreshMode":
|
|
673
|
+
refreshMode = subNode.textContent;
|
|
674
|
+
break;
|
|
675
|
+
case "refreshInterval":
|
|
676
|
+
refreshInterval = subNode.textContent;
|
|
677
|
+
break;
|
|
678
|
+
case "viewRefreshMode":
|
|
679
|
+
viewRefreshMode = subNode.textContent;
|
|
680
|
+
break;
|
|
681
|
+
default:
|
|
682
|
+
console.log("Unknown node in kml NetworkLink.Link", subNode);
|
|
683
|
+
break;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
break;
|
|
687
|
+
default:
|
|
688
|
+
console.log("Unknown node in kml NetworkLink", node);
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (linkHref)
|
|
693
|
+
{
|
|
694
|
+
feature = new kml.NetworkLink(linkHref);
|
|
695
|
+
if (name)
|
|
696
|
+
feature.setName(name);
|
|
697
|
+
if (description)
|
|
698
|
+
feature.setDescription(description);
|
|
699
|
+
if (open != null)
|
|
700
|
+
feature.setOpen(open);
|
|
701
|
+
if (refreshVisibility != null)
|
|
702
|
+
feature.setRefreshVisibility(refreshVisibility);
|
|
703
|
+
if (flyToView != null)
|
|
704
|
+
feature.setFlyToView(flyToView);
|
|
705
|
+
if (refreshMode)
|
|
706
|
+
feature.setRefreshMode(refreshMode);
|
|
707
|
+
if (refreshInterval)
|
|
708
|
+
feature.setRefreshInterval(Number.parseFloat(refreshInterval));
|
|
709
|
+
if (viewRefreshMode)
|
|
710
|
+
feature.setViewRefreshMode(viewRefreshMode);
|
|
711
|
+
return feature;
|
|
712
|
+
}
|
|
713
|
+
return null;
|
|
714
|
+
}
|
|
715
|
+
|
|
577
716
|
function parseKMLLookAt(kmlNode)
|
|
578
717
|
{
|
|
579
718
|
let longitude;
|
|
@@ -654,6 +793,159 @@ function parseKMLNode(kmlNode, doc)
|
|
|
654
793
|
}
|
|
655
794
|
}
|
|
656
795
|
|
|
796
|
+
async function parseJpg(reader)
|
|
797
|
+
{
|
|
798
|
+
if (!(reader instanceof data.ByteReader))
|
|
799
|
+
return null;
|
|
800
|
+
if (reader.getLength() < 2)
|
|
801
|
+
return null;
|
|
802
|
+
if (reader.readUInt8(0) != 0xff || reader.readUInt8(1) != 0xd8)
|
|
803
|
+
return null;
|
|
804
|
+
let ofst = 2;
|
|
805
|
+
let ret = false;
|
|
806
|
+
let j;
|
|
807
|
+
let exif;
|
|
808
|
+
while (true)
|
|
809
|
+
{
|
|
810
|
+
if (ofst + 4 > reader.getLength())
|
|
811
|
+
{
|
|
812
|
+
ret = false;
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
if (reader.readUInt8(ofst + 0) != 0xff)
|
|
816
|
+
{
|
|
817
|
+
ret = false;
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
if (reader.readUInt8(ofst + 1) == 0xdb)
|
|
821
|
+
{
|
|
822
|
+
ret = true;
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
j = ((reader.readUInt8(ofst + 2) << 8) | reader.readUInt8(ofst + 3)) - 2;
|
|
827
|
+
if (reader.readUInt8(ofst + 1) == 0xe1)
|
|
828
|
+
{
|
|
829
|
+
let t = reader.readUTF8Z(ofst + 4, 14);
|
|
830
|
+
if (t == "Exif")
|
|
831
|
+
{
|
|
832
|
+
let lsb;
|
|
833
|
+
if (reader.readUTF8(ofst + 10, 2) == "II")
|
|
834
|
+
{
|
|
835
|
+
lsb = true;
|
|
836
|
+
}
|
|
837
|
+
else if (reader.readUTF8(ofst + 10, 2) == "MM")
|
|
838
|
+
{
|
|
839
|
+
lsb = false;
|
|
840
|
+
}
|
|
841
|
+
else
|
|
842
|
+
{
|
|
843
|
+
console.log("JPG Exif unknown byte order", reader.readUTF8(ofst + 10, 2));
|
|
844
|
+
ret = false;
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
if (reader.readUInt16(ofst + 12, lsb) != 42)
|
|
848
|
+
{
|
|
849
|
+
console.log("JPG Exif not 42", reader.readUInt16(ofst + 12, lsb));
|
|
850
|
+
ret = false;
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
if (reader.readUInt32(ofst + 14, lsb) != 8)
|
|
854
|
+
{
|
|
855
|
+
console.log("JPG Exif not 8", reader.readUInt32(ofst + 14, lsb));
|
|
856
|
+
ret = false;
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
exif = media.EXIFData.parseIFD(reader, ofst + 18, lsb, null, ofst + 10);
|
|
860
|
+
if (exif == null)
|
|
861
|
+
{
|
|
862
|
+
console.log("Error in parsing EXIF");
|
|
863
|
+
}
|
|
864
|
+
ofst += j + 4;
|
|
865
|
+
}
|
|
866
|
+
else if (t == "FLIR")
|
|
867
|
+
{
|
|
868
|
+
/* if (buff[4] == 0 && buff[5] == 1)
|
|
869
|
+
{
|
|
870
|
+
if (flirMstm == 0 && buff[6] == 0)
|
|
871
|
+
{
|
|
872
|
+
flirMaxSegm = buff[7];
|
|
873
|
+
NEW_CLASS(flirMstm, IO::MemoryStream());
|
|
874
|
+
flirCurrSegm = buff[6];
|
|
875
|
+
Data::ByteBuffer tagBuff(j);
|
|
876
|
+
fd->GetRealData(ofst + 4, j, tagBuff);
|
|
877
|
+
flirMstm->Write(&tagBuff[8], j - 8);
|
|
878
|
+
}
|
|
879
|
+
else if (flirMstm && buff[6] == (flirCurrSegm + 1))
|
|
880
|
+
{
|
|
881
|
+
flirCurrSegm = (UInt8)(flirCurrSegm + 1);
|
|
882
|
+
Data::ByteBuffer tagBuff(j);
|
|
883
|
+
fd->GetRealData(ofst + 4, j, tagBuff);
|
|
884
|
+
flirMstm->Write(&tagBuff[8], j - 8);
|
|
885
|
+
}
|
|
886
|
+
}*/
|
|
887
|
+
ofst += j + 4;
|
|
888
|
+
}
|
|
889
|
+
else
|
|
890
|
+
{
|
|
891
|
+
console.log("Unknown type for e1", t);
|
|
892
|
+
ofst += j + 4;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
else if (reader.readUInt8(ofst + 1) == 0xe2)
|
|
896
|
+
{
|
|
897
|
+
let t = reader.readUTF8Z(ofst + 4);
|
|
898
|
+
if (t == "ICC_PROFILE")
|
|
899
|
+
{
|
|
900
|
+
let iccBuff = reader.getArrayBuffer(ofst + 4 + 14, j - 14);
|
|
901
|
+
/*
|
|
902
|
+
NotNullPtr<Media::ICCProfile> icc;
|
|
903
|
+
if (Media::ICCProfile::Parse(tagBuff.SubArray(14, j - 14)).SetTo(icc))
|
|
904
|
+
{
|
|
905
|
+
icc->SetToColorProfile(img->info.color);
|
|
906
|
+
icc.Delete();
|
|
907
|
+
}*/
|
|
908
|
+
console.log("ICC Profile found");
|
|
909
|
+
}
|
|
910
|
+
else
|
|
911
|
+
{
|
|
912
|
+
console.log("Unknown type for e2", t);
|
|
913
|
+
}
|
|
914
|
+
ofst += j + 4;
|
|
915
|
+
}
|
|
916
|
+
else
|
|
917
|
+
{
|
|
918
|
+
ofst += j + 4;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
if (ret)
|
|
922
|
+
{
|
|
923
|
+
let buff = reader.getArrayBuffer();
|
|
924
|
+
let b = new Blob([buff], {type: "image/jpeg"});
|
|
925
|
+
let img = await media.loadImageFromBlob(b);
|
|
926
|
+
let simg = new media.StaticImage(img);
|
|
927
|
+
if (exif)
|
|
928
|
+
simg.setExif(exif);
|
|
929
|
+
return simg;
|
|
930
|
+
}
|
|
931
|
+
return null;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
async function parseWebp(reader)
|
|
935
|
+
{
|
|
936
|
+
if (!(reader instanceof data.ByteReader))
|
|
937
|
+
return null;
|
|
938
|
+
if (reader.getLength() < 20)
|
|
939
|
+
return null;
|
|
940
|
+
if (reader.readUInt32(0, true) != 0x46464952 || reader.readUInt32(8, true) != 0x50424557 || reader.readUInt32(4, true) + 8 != reader.getLength())
|
|
941
|
+
return null;
|
|
942
|
+
let buff = reader.getArrayBuffer();
|
|
943
|
+
let b = new Blob([buff], {type: "image/webp"});
|
|
944
|
+
let img = await media.loadImageFromBlob(b);
|
|
945
|
+
let simg = new media.StaticImage(img);
|
|
946
|
+
return simg;
|
|
947
|
+
}
|
|
948
|
+
|
|
657
949
|
export function parseXML(txt)
|
|
658
950
|
{
|
|
659
951
|
let parser = new DOMParser();
|
|
@@ -700,6 +992,10 @@ export async function parseFile(file)
|
|
|
700
992
|
}
|
|
701
993
|
else
|
|
702
994
|
{
|
|
995
|
+
let view = new data.ByteReader(await file.arrayBuffer());
|
|
996
|
+
let obj;
|
|
997
|
+
if (obj = await parseJpg(view)) return obj;
|
|
998
|
+
if (obj = await parseWebp(view)) return obj;
|
|
703
999
|
console.log("Unsupported file type", t);
|
|
704
1000
|
return null;
|
|
705
1001
|
}
|
package/text.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export function arrayToNumbers(arr: string[]): number[];
|
|
|
23
23
|
export function toHex8(v: number): string;
|
|
24
24
|
export function toHex16(v: number): string;
|
|
25
25
|
export function toHex32(v: number): string;
|
|
26
|
+
export function u8Arr2Hex(buff: Uint8Array, byteSep: string, rowSep: string): string;
|
|
26
27
|
export function getEncList(): TextBinEnc[];
|
|
27
28
|
|
|
28
29
|
export class TextBinEnc
|
package/text.js
CHANGED
|
@@ -220,6 +220,33 @@ export function toHex32(v)
|
|
|
220
220
|
return "0".repeat(8 - s.length)+s;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
export function u8Arr2Hex(buff, byteSep, rowSep)
|
|
224
|
+
{
|
|
225
|
+
let rows = [];
|
|
226
|
+
let thisRow = [];
|
|
227
|
+
let i = 1;
|
|
228
|
+
let j = buff.length;
|
|
229
|
+
if (j == 0)
|
|
230
|
+
return "";
|
|
231
|
+
if (byteSep == null)
|
|
232
|
+
byteSep = "";
|
|
233
|
+
thisRow.push(toHex8(buff[0]));
|
|
234
|
+
while (i < j)
|
|
235
|
+
{
|
|
236
|
+
if ((i & 15) == 0)
|
|
237
|
+
{
|
|
238
|
+
rows.push(thisRow.join(byteSep));
|
|
239
|
+
thisRow = [];
|
|
240
|
+
}
|
|
241
|
+
thisRow.push(toHex8(buff[i]));
|
|
242
|
+
i++;
|
|
243
|
+
}
|
|
244
|
+
rows.push(thisRow.join(byteSep));
|
|
245
|
+
if (rowSep == null)
|
|
246
|
+
rowSep = byteSep;
|
|
247
|
+
return rows.join(rowSep);
|
|
248
|
+
}
|
|
249
|
+
|
|
223
250
|
export function getEncList()
|
|
224
251
|
{
|
|
225
252
|
let ret = [];
|
package/web.d.ts
CHANGED
|
@@ -16,13 +16,14 @@ export function getRequestURLBase(): string;
|
|
|
16
16
|
export function getParameterByName(name: string): string | null;
|
|
17
17
|
export function loadJSON(url: string, onResultFunc: Function): void;
|
|
18
18
|
export function buildTable(o: object | object[]): string;
|
|
19
|
-
export function openData(data: string, contentType: string, fileName?: string): void;
|
|
19
|
+
export function openData(data: string | Blob, contentType: string, fileName?: string): void;
|
|
20
20
|
export function parseCSSColor(c: string): Color;
|
|
21
21
|
export function handleFileDrop(ele: HTMLElement, hdlr: (file: File)=>void): void;
|
|
22
22
|
export function appendUrl(targetUrl: string, docUrl: string): string;
|
|
23
23
|
export function mimeFromFileName(fileName: string): string;
|
|
24
24
|
export function mimeFromExt(ext: string): string;
|
|
25
25
|
export function getImageInfo(url: string): Promise<ImageInfo|null>;
|
|
26
|
+
export function propertiesToHTML(prop: object): string;
|
|
26
27
|
|
|
27
28
|
declare class DialogButton
|
|
28
29
|
{
|
package/web.js
CHANGED
|
@@ -95,6 +95,18 @@ export function openData(data, contentType, fileName)
|
|
|
95
95
|
ele.setAttribute('download', fileName);
|
|
96
96
|
ele.style.display = 'none';
|
|
97
97
|
|
|
98
|
+
document.body.appendChild(ele);
|
|
99
|
+
ele.click();
|
|
100
|
+
document.body.removeChild(ele);
|
|
101
|
+
}
|
|
102
|
+
else if (data instanceof Blob)
|
|
103
|
+
{
|
|
104
|
+
let ele = document.createElement("a");
|
|
105
|
+
ele.setAttribute('href', URL.createObjectURL(data));
|
|
106
|
+
if (fileName)
|
|
107
|
+
ele.setAttribute('download', fileName);
|
|
108
|
+
ele.style.display = 'none';
|
|
109
|
+
|
|
98
110
|
document.body.appendChild(ele);
|
|
99
111
|
ele.click();
|
|
100
112
|
document.body.removeChild(ele);
|
|
@@ -709,6 +721,27 @@ export function getImageInfo(url)
|
|
|
709
721
|
});
|
|
710
722
|
}
|
|
711
723
|
|
|
724
|
+
export function propertiesToHTML(prop)
|
|
725
|
+
{
|
|
726
|
+
let ret = ["<ul>"];
|
|
727
|
+
let i;
|
|
728
|
+
for (i in prop)
|
|
729
|
+
{
|
|
730
|
+
ret.push("<li><b>"+text.toHTMLText(i)+": </b>");
|
|
731
|
+
if (typeof prop[i] == "object")
|
|
732
|
+
{
|
|
733
|
+
ret.push(propertiesToHTML(prop[i]));
|
|
734
|
+
}
|
|
735
|
+
else
|
|
736
|
+
{
|
|
737
|
+
ret.push(text.toHTMLText(""+prop[i]));
|
|
738
|
+
}
|
|
739
|
+
ret.push("</li>");
|
|
740
|
+
}
|
|
741
|
+
ret.push("</ul>");
|
|
742
|
+
return ret.join("");
|
|
743
|
+
}
|
|
744
|
+
|
|
712
745
|
export class Dialog
|
|
713
746
|
{
|
|
714
747
|
constructor(content, options)
|
|
@@ -739,10 +772,10 @@ export class Dialog
|
|
|
739
772
|
darkColor.style.display = "flex";
|
|
740
773
|
darkColor.style.alignItems = "center";
|
|
741
774
|
darkColor.style.justifyContent = "center";
|
|
742
|
-
if (document.body.children.length > 0)
|
|
743
|
-
document.body.insertBefore(darkColor, document.body.children[0]);
|
|
775
|
+
if (top.document.body.children.length > 0)
|
|
776
|
+
top.document.body.insertBefore(darkColor, top.document.body.children[0]);
|
|
744
777
|
else
|
|
745
|
-
document.body.appendChild(darkColor);
|
|
778
|
+
top.document.body.appendChild(darkColor);
|
|
746
779
|
this.darkColor = darkColor;
|
|
747
780
|
let dialog = document.createElement("div");
|
|
748
781
|
dialog.style.backgroundColor = "#ffffff";
|
|
@@ -818,7 +851,7 @@ export class Dialog
|
|
|
818
851
|
{
|
|
819
852
|
if (this.darkColor)
|
|
820
853
|
{
|
|
821
|
-
document.body.removeChild(this.darkColor);
|
|
854
|
+
top.document.body.removeChild(this.darkColor);
|
|
822
855
|
this.darkColor = null;
|
|
823
856
|
}
|
|
824
857
|
}
|