@sswroom/sswr 1.6.2 → 1.6.4

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,23 @@
1
+ 1.6.4
2
+ -Support geometry.Polyline
3
+ -Fixed geometry.Polygon.insideOrTouch
4
+ -Fixed geometry.MultiGeometry.insideOrTouch
5
+ -leaflet.createFromKML support group in group
6
+ -parser.parseKMLContainer hide Schema message
7
+ -Added data.Timestamp.toDate()
8
+ -Added data.Weekday enum
9
+ -Added data.DateTimeUtil.ticks2Weekday()
10
+ -Added data.LocalDate.getWeekday()
11
+ -Added data.StringMap and data.NumberMap interface type
12
+ -Fixed math.GeoJSON.parseGeometry
13
+
14
+ 1.6.3
15
+ -Added hash.MD5
16
+ -Support web.Dialog in frameset
17
+ -Added data.objectParseTS
18
+ -web.propertiesToHTML support nameMap and timeFormat
19
+ -text.isHKID fixed wrong validation
20
+
1
21
  1.6.2
2
22
  -Fixed data.DateTimeUtil.totalDays2DateValue bigint problem
3
23
 
package/data.d.ts CHANGED
@@ -1,3 +1,22 @@
1
+ export enum Weekday
2
+ {
3
+ Sunday,
4
+ Monday,
5
+ Tuesday,
6
+ Wednesday,
7
+ Thursday,
8
+ Friday,
9
+ Saturday
10
+ }
11
+
12
+ interface StringMap<Type> {
13
+ [key: string]: Type;
14
+ }
15
+
16
+ interface NumberMap<Type> {
17
+ [key: number]: Type;
18
+ }
19
+
1
20
  export function isArray(o: any): boolean;
2
21
  export function isObject(o: any): boolean;
3
22
  export function toObjectString(o: any, lev: number): string;
@@ -17,6 +36,7 @@ export function ror32(v: number, n: number): number;
17
36
  export function shl32(v: number, n: number): number;
18
37
  export function sar32(v: number, n: number): number;
19
38
  export function shr32(v: number, n: number): number;
39
+ export function objectParseTS(o: object, items: string[]): void;
20
40
 
21
41
  export class DateValue
22
42
  {
@@ -52,6 +72,7 @@ export class DateTimeUtil
52
72
  static secs2TimeValue(secs: bigint, tzQhr?: number): TimeValue;
53
73
  static totalDays2DateValue(totalDays: number, d: DateValue): void;
54
74
  static instant2TimeValue(secs: bigint, nanosec: number, tzQhr?: number): TimeValue;
75
+ static ticks2Weekday(ticks: number, tzQhr: number): Weekday;
55
76
  static toString(tval: TimeValue, pattern: string): string;
56
77
  static string2TimeValue(dateStr: string, tzQhr?: number): TimeValue;
57
78
  static isYearLeap(year: number): boolean;
@@ -97,6 +118,7 @@ export class LocalDate
97
118
  toString(pattern: string | null): string;
98
119
  compareTo(obj: Date): number;
99
120
  isNull(): boolean;
121
+ getWeekday(): Weekday;
100
122
  static today(): LocalDate;
101
123
  static fromStr(s: string): LocalDate | null;
102
124
  }
@@ -133,6 +155,9 @@ export class TimeInstant
133
155
  }
134
156
 
135
157
  export class Timestamp {
158
+ inst: TimeInstant;
159
+ tzQhr: number;
160
+
136
161
  constructor(inst: TimeInstant, tzQhr?: number);
137
162
  static fromTicks(ticks: number | number, tzQhr?: number): Timestamp;
138
163
  static fromStr(str: string, defTzQhr?: number): Timestamp | null;
@@ -166,6 +191,7 @@ export class Timestamp {
166
191
  diffMS(ts: Timestamp): number;
167
192
  diffSecDbl(ts: Timestamp): number;
168
193
  diff(ts: Timestamp): number;
194
+ toDate(): LocalDate;
169
195
  toTicks(): number;
170
196
  toDotNetTicks(): number;
171
197
  toUnixTimestamp(): number;
package/data.js CHANGED
@@ -1,5 +1,15 @@
1
1
  import * as text from "./text.js";
2
2
 
3
+ export const Weekday = {
4
+ Sunday: 0,
5
+ Monday: 1,
6
+ Tuesday: 2,
7
+ Wednesday: 3,
8
+ Thursday: 4,
9
+ Friday: 5,
10
+ Saturday: 6
11
+ }
12
+
3
13
  export function isArray(o)
4
14
  {
5
15
  return o != null && o.constructor === Array;
@@ -328,6 +338,18 @@ export function shr32(v, n)
328
338
  return ((v >> 1) & 0x7fffffff) >> (n - 1);
329
339
  }
330
340
 
341
+ export function objectParseTS(o, items)
342
+ {
343
+ let item;
344
+ for (item in items)
345
+ {
346
+ if (o[items[item]] && typeof o[items[item]] == "string")
347
+ {
348
+ o[items[item]] = Timestamp.fromStr(o[items[item]]);
349
+ }
350
+ }
351
+ }
352
+
331
353
  export class DateValue
332
354
  {
333
355
  constructor()
@@ -812,6 +834,19 @@ export class DateTimeUtil
812
834
  return t;
813
835
  }
814
836
 
837
+ static ticks2Weekday(ticks, tzQhr)
838
+ {
839
+ let days = ((ticks + tzQhr * 900000) / 86400000 + 4);
840
+ if (days >= 0)
841
+ {
842
+ return (days % 7);
843
+ }
844
+ else
845
+ {
846
+ return ((days % 7) + 7);
847
+ }
848
+ }
849
+
815
850
  static toString(tval, pattern)
816
851
  {
817
852
  let output = new Array();
@@ -1786,6 +1821,11 @@ export class LocalDate
1786
1821
  return this.dateVal == LocalDate.DATE_NULL;
1787
1822
  }
1788
1823
 
1824
+ getWeekday()
1825
+ {
1826
+ return DateTimeUtil.ticks2Weekday(this.dateVal * 86400000, 0);
1827
+ }
1828
+
1789
1829
  static today()
1790
1830
  {
1791
1831
  let d = new Date();
@@ -2208,6 +2248,11 @@ export class Timestamp
2208
2248
  return this.inst.diff(ts.inst);
2209
2249
  }
2210
2250
 
2251
+ toDate()
2252
+ {
2253
+ return new LocalDate(Math.floor(Number((this.inst.sec + BigInt(this.tzQhr * 900)) / 86400n)));
2254
+ }
2255
+
2211
2256
  toTicks()
2212
2257
  {
2213
2258
  return this.inst.toTicks();
package/geometry.d.ts CHANGED
@@ -85,11 +85,17 @@ export class MultiGeometry<VecType> extends Vector2D
85
85
  export class Polygon extends MultiGeometry<LinearRing>
86
86
  {
87
87
  constructor(srid: number, coordinates: number[][][]);
88
+ insideOrTouch(coord: math.Coord2D): boolean;
88
89
  }
89
90
 
90
91
  export class MultiPolygon extends MultiGeometry<Polygon>
91
92
  {
92
- constructor(srid: number, coordinates: number[][][][]);
93
+ constructor(srid: number, coordinates?: number[][][][]);
94
+ }
95
+
96
+ export class Polyline extends MultiGeometry<LineString>
97
+ {
98
+ constructor(srid: number, coordinates?: number[][][]);
93
99
  }
94
100
 
95
101
  export class GeometryCollection extends MultiGeometry<Vector2D>
package/geometry.js CHANGED
@@ -370,10 +370,10 @@ export class MultiGeometry extends Vector2D
370
370
 
371
371
  insideOrTouch(coord)
372
372
  {
373
- let i = this.coordinates.length;
373
+ let i = this.geometries.length;
374
374
  while (i-- > 0)
375
375
  {
376
- if (this.coordinates[i].insideOrTouch(coord))
376
+ if (this.geometries[i].insideOrTouch(coord))
377
377
  {
378
378
  return true;
379
379
  }
@@ -420,11 +420,11 @@ export class Polygon extends MultiGeometry
420
420
 
421
421
  insideOrTouch(coord)
422
422
  {
423
- let i = this.coordinates.length;
423
+ let i = this.geometries.length;
424
424
  let inside = false;
425
425
  while (i-- > 0)
426
426
  {
427
- if (this.coordinates[i].insideOrTouch(coord))
427
+ if (this.geometries[i].insideOrTouch(coord))
428
428
  {
429
429
  inside = !inside;
430
430
  }
@@ -450,6 +450,23 @@ export class MultiPolygon extends MultiGeometry
450
450
  }
451
451
  }
452
452
 
453
+ export class Polyline extends MultiGeometry
454
+ {
455
+ constructor(srid, coordinates)
456
+ {
457
+ super(srid);
458
+ this.type = VectorType.Polyline;
459
+ let i;
460
+ if (coordinates)
461
+ {
462
+ for (i in coordinates)
463
+ {
464
+ this.geometries.push(new LineString(srid, coordinates[i]));
465
+ }
466
+ }
467
+ }
468
+ }
469
+
453
470
  export class GeometryCollection extends MultiGeometry
454
471
  {
455
472
  constructor(srid)
package/hash.d.ts CHANGED
@@ -54,4 +54,22 @@ export class SHA1 extends Hash
54
54
  getBlockSize(): number;
55
55
 
56
56
  static calcBlock(intermediateHash: number[], messageBlock: ArrayBuffer): void;
57
+ }
58
+
59
+ export class MD5 extends Hash
60
+ {
61
+ messageLength: number;
62
+ h: number[];
63
+ buff: number[];
64
+ buffSize: number;
65
+
66
+ constructor();
67
+ getName(): string;
68
+ clone(): Hash;
69
+ clear(): void;
70
+ calc(buff: ArrayBuffer): void;
71
+ getValue(): ArrayBuffer;
72
+ getBlockSize(): number;
73
+
74
+ static calcBlock(hVals: number[], block: DataView): void;
57
75
  }
package/hash.js CHANGED
@@ -267,3 +267,281 @@ export class SHA1 extends Hash
267
267
  intermediateHash[4] = (intermediateHash[4] + e) & 0xffffffff;
268
268
  }
269
269
  }
270
+
271
+ export class MD5 extends Hash
272
+ {
273
+ constructor()
274
+ {
275
+ super();
276
+ this.buff = new Array(64);
277
+ this.clear();
278
+ }
279
+
280
+ getName()
281
+ {
282
+ return "MD5";
283
+ }
284
+
285
+ clone()
286
+ {
287
+ let md5 = new MD5();
288
+ md5.msgLeng = this.msgLeng;
289
+ md5.h[0] = this.h[0];
290
+ md5.h[1] = this.h[1];
291
+ md5.h[2] = this.h[2];
292
+ md5.h[3] = this.h[3];
293
+ md5.buffSize = this.buffSize;
294
+ return md5;
295
+ }
296
+
297
+ clear()
298
+ {
299
+ this.msgLeng = 0n;
300
+ this.h = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476];
301
+ this.buffSize = 0;
302
+ }
303
+
304
+ calc(buff)
305
+ {
306
+ if (!(buff instanceof ArrayBuffer))
307
+ return;
308
+ let i = 0;
309
+ let arr;
310
+ this.msgLeng += BigInt(buff.byteLength << 3);
311
+ if ((buff.byteLength + this.buffSize) < 64)
312
+ {
313
+ arr = new Uint8Array(buff);
314
+ while (i < buff.byteLength)
315
+ {
316
+ this.buff[this.buffSize + i] = arr[i];
317
+ i++;
318
+ }
319
+ this.buffSize += buff.byteLength;
320
+ return;
321
+ }
322
+
323
+ if (this.buffSize > 0)
324
+ {
325
+ arr = new Uint8Array(buff);
326
+ while (this.buffSize < 64)
327
+ {
328
+ this.buff[this.buffSize] = arr[i];
329
+ this.buffSize++;
330
+ i++;
331
+ }
332
+ MD5.calcBlock(this.h, new Uint8Array(this.buff).buffer);
333
+ this.buffSize = 0;
334
+ }
335
+ while (i + 64 <= buff.byteLength)
336
+ {
337
+ MD5.calcBlock(this.h, buff.slice(i, i + 64));
338
+ i += 64;
339
+ }
340
+ if (i < buff.byteLength)
341
+ {
342
+ arr = new Uint8Array(buff);
343
+ while (i < buff.byteLength)
344
+ {
345
+ this.buff[this.buffSize] = arr[i];
346
+ this.buffSize++;
347
+ i++;
348
+ }
349
+ }
350
+ }
351
+
352
+ getValue()
353
+ {
354
+ let calBuff = new Array(64);
355
+ let intHash = [
356
+ this.h[0],
357
+ this.h[1],
358
+ this.h[2],
359
+ this.h[3]];
360
+ let i;
361
+ i = 0;
362
+ while (i < this.buffSize)
363
+ {
364
+ calBuff[i] = this.buff[i];
365
+ i++;
366
+ }
367
+ if (this.buffSize < 56)
368
+ {
369
+ i = this.buffSize;
370
+ calBuff[i++] = 0x80;
371
+ while (i < 56)
372
+ {
373
+ calBuff[i] = 0;
374
+ i++;
375
+ }
376
+
377
+ }
378
+ else
379
+ {
380
+ i = this.buffSize;
381
+ calBuff[i++] = 0x80;
382
+ while (i < 64)
383
+ {
384
+ calBuff[i] = 0;
385
+ i++;
386
+ }
387
+ MD5.calcBlock(intHash, calBuff);
388
+ i = 0;
389
+ while (i < 56)
390
+ {
391
+ calBuff[i] = 0;
392
+ i++;
393
+ }
394
+ }
395
+ let view = new DataView(new Uint8Array(calBuff).buffer);
396
+ view.setBigUint64(56, this.msgLeng, true);
397
+ MD5.calcBlock(intHash, view.buffer);
398
+ view = new DataView(new ArrayBuffer(16));
399
+ i = 16;
400
+ while (i > 0)
401
+ {
402
+ i -= 4;
403
+ view.setUint32(i, intHash[i >> 2], true);
404
+ }
405
+ return view.buffer;
406
+ }
407
+
408
+ getBlockSize()
409
+ {
410
+ return 64;
411
+ }
412
+
413
+ static step1(vals, w, x, y, z, dataNum, s)
414
+ {
415
+ vals[w] += vals[z] ^ (vals[x] & (vals[y] ^ vals[z]));
416
+ vals[w] += dataNum;
417
+ vals[w] = data.rol32(vals[w], s);
418
+ vals[w] += vals[x];
419
+ }
420
+
421
+ static step2(vals, w, x, y, z, dataNum, s)
422
+ {
423
+ vals[w] += vals[y] ^ (vals[z] & (vals[x] ^ vals[y]));
424
+ vals[w] += dataNum;
425
+ vals[w] = data.rol32(vals[w], s);
426
+ vals[w] += vals[x];
427
+ }
428
+
429
+ static step3(vals, w, x, y, z, dataNum, s)
430
+ {
431
+ vals[w] += vals[z] ^ vals[y] ^ vals[x];
432
+ vals[w] += dataNum;
433
+ vals[w] = data.rol32(vals[w], s);
434
+ vals[w] += vals[x];
435
+ }
436
+
437
+ static step4(vals, w, x, y, z, dataNum, s)
438
+ {
439
+ vals[w] += vals[y] ^ (vals[x] | ~vals[z]);
440
+ vals[w] += dataNum;
441
+ vals[w] = data.rol32(vals[w], s);
442
+ vals[w] += vals[x];
443
+ }
444
+
445
+ static calcBlock(hVals, block)
446
+ {
447
+ let view = new DataView(block);
448
+ let blk = [view.getUint32(0, true),
449
+ view.getUint32(4, true),
450
+ view.getUint32(8, true),
451
+ view.getUint32(12, true),
452
+ view.getUint32(16, true),
453
+ view.getUint32(20, true),
454
+ view.getUint32(24, true),
455
+ view.getUint32(28, true),
456
+ view.getUint32(32, true),
457
+ view.getUint32(36, true),
458
+ view.getUint32(40, true),
459
+ view.getUint32(44, true),
460
+ view.getUint32(48, true),
461
+ view.getUint32(52, true),
462
+ view.getUint32(56, true),
463
+ view.getUint32(60, true)];
464
+ let vals = [hVals[0], hVals[1], hVals[2], hVals[3]];
465
+ let a = 0;
466
+ let b = 1;
467
+ let c = 2;
468
+ let d = 3;
469
+
470
+ MD5.step1(vals, a, b, c, d, blk[0] + 0xd76aa478, 7);
471
+ MD5.step1(vals, d, a, b, c, blk[1] + 0xe8c7b756, 12);
472
+ MD5.step1(vals, c, d, a, b, blk[2] + 0x242070db, 17);
473
+ MD5.step1(vals, b, c, d, a, blk[3] + 0xc1bdceee, 22);
474
+ MD5.step1(vals, a, b, c, d, blk[4] + 0xf57c0faf, 7);
475
+ MD5.step1(vals, d, a, b, c, blk[5] + 0x4787c62a, 12);
476
+ MD5.step1(vals, c, d, a, b, blk[6] + 0xa8304613, 17);
477
+ MD5.step1(vals, b, c, d, a, blk[7] + 0xfd469501, 22);
478
+ MD5.step1(vals, a, b, c, d, blk[8] + 0x698098d8, 7);
479
+ MD5.step1(vals, d, a, b, c, blk[9] + 0x8b44f7af, 12);
480
+ MD5.step1(vals, c, d, a, b, blk[10] + 0xffff5bb1, 17);
481
+ MD5.step1(vals, b, c, d, a, blk[11] + 0x895cd7be, 22);
482
+ MD5.step1(vals, a, b, c, d, blk[12] + 0x6b901122, 7);
483
+ MD5.step1(vals, d, a, b, c, blk[13] + 0xfd987193, 12);
484
+ MD5.step1(vals, c, d, a, b, blk[14] + 0xa679438e, 17);
485
+ MD5.step1(vals, b, c, d, a, blk[15] + 0x49b40821, 22);
486
+
487
+ MD5.step2(vals, a, b, c, d, blk[1] + 0xf61e2562, 5);
488
+ MD5.step2(vals, d, a, b, c, blk[6] + 0xc040b340, 9);
489
+ MD5.step2(vals, c, d, a, b, blk[11] + 0x265e5a51, 14);
490
+ MD5.step2(vals, b, c, d, a, blk[0] + 0xe9b6c7aa, 20);
491
+ MD5.step2(vals, a, b, c, d, blk[5] + 0xd62f105d, 5);
492
+ MD5.step2(vals, d, a, b, c, blk[10] + 0x02441453, 9);
493
+ MD5.step2(vals, c, d, a, b, blk[15] + 0xd8a1e681, 14);
494
+ MD5.step2(vals, b, c, d, a, blk[4] + 0xe7d3fbc8, 20);
495
+ MD5.step2(vals, a, b, c, d, blk[9] + 0x21e1cde6, 5);
496
+ MD5.step2(vals, d, a, b, c, blk[14] + 0xc33707d6, 9);
497
+ MD5.step2(vals, c, d, a, b, blk[3] + 0xf4d50d87, 14);
498
+ MD5.step2(vals, b, c, d, a, blk[8] + 0x455a14ed, 20);
499
+ MD5.step2(vals, a, b, c, d, blk[13] + 0xa9e3e905, 5);
500
+ MD5.step2(vals, d, a, b, c, blk[2] + 0xfcefa3f8, 9);
501
+ MD5.step2(vals, c, d, a, b, blk[7] + 0x676f02d9, 14);
502
+ MD5.step2(vals, b, c, d, a, blk[12] + 0x8d2a4c8a, 20);
503
+
504
+ MD5.step3(vals, a, b, c, d, blk[5] + 0xfffa3942, 4);
505
+ MD5.step3(vals, d, a, b, c, blk[8] + 0x8771f681, 11);
506
+ MD5.step3(vals, c, d, a, b, blk[11] + 0x6d9d6122, 16);
507
+ MD5.step3(vals, b, c, d, a, blk[14] + 0xfde5380c, 23);
508
+ MD5.step3(vals, a, b, c, d, blk[1] + 0xa4beea44, 4);
509
+ MD5.step3(vals, d, a, b, c, blk[4] + 0x4bdecfa9, 11);
510
+ MD5.step3(vals, c, d, a, b, blk[7] + 0xf6bb4b60, 16);
511
+ MD5.step3(vals, b, c, d, a, blk[10] + 0xbebfbc70, 23);
512
+ MD5.step3(vals, a, b, c, d, blk[13] + 0x289b7ec6, 4);
513
+ MD5.step3(vals, d, a, b, c, blk[0] + 0xeaa127fa, 11);
514
+ MD5.step3(vals, c, d, a, b, blk[3] + 0xd4ef3085, 16);
515
+ MD5.step3(vals, b, c, d, a, blk[6] + 0x04881d05, 23);
516
+ MD5.step3(vals, a, b, c, d, blk[9] + 0xd9d4d039, 4);
517
+ MD5.step3(vals, d, a, b, c, blk[12] + 0xe6db99e5, 11);
518
+ MD5.step3(vals, c, d, a, b, blk[15] + 0x1fa27cf8, 16);
519
+ MD5.step3(vals, b, c, d, a, blk[2] + 0xc4ac5665, 23);
520
+
521
+ MD5.step4(vals, a, b, c, d, blk[0] + 0xf4292244, 6);
522
+ MD5.step4(vals, d, a, b, c, blk[7] + 0x432aff97, 10);
523
+ MD5.step4(vals, c, d, a, b, blk[14] + 0xab9423a7, 15);
524
+ MD5.step4(vals, b, c, d, a, blk[5] + 0xfc93a039, 21);
525
+ MD5.step4(vals, a, b, c, d, blk[12] + 0x655b59c3, 6);
526
+ MD5.step4(vals, d, a, b, c, blk[3] + 0x8f0ccc92, 10);
527
+ MD5.step4(vals, c, d, a, b, blk[10] + 0xffeff47d, 15);
528
+ MD5.step4(vals, b, c, d, a, blk[1] + 0x85845dd1, 21);
529
+ MD5.step4(vals, a, b, c, d, blk[8] + 0x6fa87e4f, 6);
530
+ MD5.step4(vals, d, a, b, c, blk[15] + 0xfe2ce6e0, 10);
531
+ MD5.step4(vals, c, d, a, b, blk[6] + 0xa3014314, 15);
532
+ MD5.step4(vals, b, c, d, a, blk[13] + 0x4e0811a1, 21);
533
+ MD5.step4(vals, a, b, c, d, blk[4] + 0xf7537e82, 6);
534
+ MD5.step4(vals, d, a, b, c, blk[11] + 0xbd3af235, 10);
535
+ MD5.step4(vals, c, d, a, b, blk[2] + 0x2ad7d2bb, 15);
536
+ MD5.step4(vals, b, c, d, a, blk[9] + 0xeb86d391, 21);
537
+
538
+ vals[a] += hVals[0];
539
+ vals[b] += hVals[1];
540
+ vals[c] += hVals[2];
541
+ vals[d] += hVals[3];
542
+ hVals[0] = vals[a];
543
+ hVals[1] = vals[b];
544
+ hVals[2] = vals[c];
545
+ hVals[3] = vals[d];
546
+ }
547
+ }
package/leaflet.js CHANGED
@@ -69,12 +69,27 @@ export function createFromKML(feature, options)
69
69
  if (feature instanceof kml.Container)
70
70
  {
71
71
  let i;
72
- let layers = L.featureGroup();
72
+ let layers = [];
73
+ let lyr;
74
+ let hasGroup = false;
75
+ let hasFeature = false;
73
76
  for (i in feature.features)
74
77
  {
75
- createFromKML(feature.features[i], options).addTo(layers);
78
+ lyr = createFromKML(feature.features[i], options);
79
+ layers.push(lyr);
80
+ if ((lyr instanceof L.FeatureGroup) || (lyr instanceof L.LayerGroup))
81
+ hasGroup = true;
82
+ else
83
+ hasFeature = true;
84
+ }
85
+ if (hasGroup)
86
+ {
87
+ return L.layerGroup(layers);
88
+ }
89
+ else
90
+ {
91
+ return L.featureGroup(layers);
76
92
  }
77
- return layers;
78
93
  }
79
94
  else if (feature instanceof kml.Placemark)
80
95
  {
@@ -162,7 +177,7 @@ export function createFromGeometry(geom, options)
162
177
  {
163
178
  if (options.name)
164
179
  opt.title = options.name;
165
- if (options.icon)
180
+ if (options.icon && options.icon.iconUrl)
166
181
  opt.icon = options.icon;
167
182
  }
168
183
  return L.marker(L.latLng(geom.coordinates[1], geom.coordinates[0]), opt);
@@ -190,6 +205,35 @@ export function createFromGeometry(geom, options)
190
205
  }
191
206
  return L.polyline(pts, opt);
192
207
  }
208
+ else if (geom instanceof geometry.Polyline)
209
+ {
210
+ let opt = {};
211
+ let i;
212
+ let j;
213
+ let ptsArr = [];
214
+ if (options.lineColor)
215
+ opt.color = options.lineColor;
216
+ if (options.lineWidth)
217
+ opt.weight = options.lineWidth;
218
+ for (i in geom.geometries)
219
+ {
220
+ let pts = [];
221
+ for (j in geom.geometries[i].coordinates)
222
+ {
223
+ let latLng = L.latLng(geom.geometries[i].coordinates[j][1], geom.geometries[i].coordinates[j][0]);
224
+ if (latLng)
225
+ {
226
+ pts.push(latLng);
227
+ }
228
+ else
229
+ {
230
+ console.log("Error in Polyline", geom.geometries[i].coordinates[j]);
231
+ }
232
+ }
233
+ ptsArr.push(pts);
234
+ }
235
+ return L.polyline(ptsArr, opt);
236
+ }
193
237
  else if (geom instanceof geometry.LinearRing)
194
238
  {
195
239
  let opt = {};
package/math.d.ts CHANGED
@@ -5,7 +5,7 @@ export function roundToFloat(n: number, decimalPoints: number): number;
5
5
  export function roundToStr(n: number, decimalPoints: number): string;
6
6
  export class GeoJSON
7
7
  {
8
- static parseGeometry(srid: null, geom: object): geometry.Vector2D | null;
8
+ static parseGeometry(srid: number, geom: object): geometry.Vector2D | null;
9
9
  }
10
10
 
11
11
  export class Coord2D
package/math.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as geometry from "./geometry.js";
1
2
  import * as unit from "./unit.js";
2
3
 
3
4
  export function roundToFloat(n, decimalPoints)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sswroom/sswr",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "Libraries made by sswroom",
5
5
  "main": "sswr.js",
6
6
  "scripts": {
package/parser.js CHANGED
@@ -342,6 +342,8 @@ function parseKMLContainer(container, kmlNode, doc)
342
342
  break;
343
343
  case "#text":
344
344
  break;
345
+ case "Schema":
346
+ break;
345
347
  default:
346
348
  console.log("Unknown node in kml container: "+node.nodeName, node);
347
349
  break;
@@ -605,6 +607,15 @@ function parseKMLGeometry(kmlNode)
605
607
  }
606
608
  return geom;
607
609
  }
610
+ else if (geomList[0] instanceof geometry.LineString && (geomList.length == 1 || geomList[1] instanceof geometry.LineString))
611
+ {
612
+ geom = new geometry.Polyline(4326);
613
+ for (i in geomList)
614
+ {
615
+ geom.geometries.push(geomList[i]);
616
+ }
617
+ return geom;
618
+ }
608
619
  else
609
620
  {
610
621
  geom = new geometry.GeometryCollection(4326);
package/text.js CHANGED
@@ -464,7 +464,8 @@ export function isHKID(s)
464
464
  thisChk += (hkid.charCodeAt(5) - 0x30) * 4;
465
465
  thisChk += (hkid.charCodeAt(6) - 0x30) * 3;
466
466
  thisChk += (hkid.charCodeAt(7) - 0x30) * 2;
467
- if (ichk != (thisChk % 11))
467
+ thisChk += ichk;
468
+ if ((thisChk % 11) != 0)
468
469
  return false;
469
470
  return true;
470
471
  }
@@ -487,7 +488,8 @@ export function isHKID(s)
487
488
  thisChk += (hkid.charCodeAt(4) - 0x30) * 4;
488
489
  thisChk += (hkid.charCodeAt(5) - 0x30) * 3;
489
490
  thisChk += (hkid.charCodeAt(6) - 0x30) * 2;
490
- if (ichk != (thisChk % 11))
491
+ thisChk += ichk;
492
+ if ((thisChk % 11) != 0)
491
493
  return false;
492
494
  return true;
493
495
  }
package/web.d.ts CHANGED
@@ -23,7 +23,7 @@ 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
+ export function propertiesToHTML(prop: object, nameMap?: object, timeFormat?: string): string;
27
27
  export function getCacheSize(name: string): Promise<number>;
28
28
 
29
29
  declare class DialogButton
package/web.js CHANGED
@@ -721,22 +721,52 @@ export function getImageInfo(url)
721
721
  });
722
722
  }
723
723
 
724
- export function propertiesToHTML(prop)
724
+ export function propertiesToHTML(prop, nameMap, timeFormat)
725
725
  {
726
726
  let ret = ["<ul>"];
727
727
  let i;
728
- for (i in prop)
728
+ if (nameMap)
729
729
  {
730
- ret.push("<li><b>"+text.toHTMLText(i)+": </b>");
731
- if (typeof prop[i] == "object")
730
+ for (i in prop)
732
731
  {
733
- ret.push(propertiesToHTML(prop[i]));
732
+ if (nameMap[i])
733
+ {
734
+ ret.push("<li><b>"+nameMap[i]+": </b>");
735
+ if (prop[i] instanceof data.Timestamp)
736
+ {
737
+ ret.push(text.toHTMLText(prop[i].toString(timeFormat)));
738
+ }
739
+ else if (typeof prop[i] == "object")
740
+ {
741
+ ret.push(propertiesToHTML(prop[i], null, timeFormat));
742
+ }
743
+ else
744
+ {
745
+ ret.push(text.toHTMLText(""+prop[i]));
746
+ }
747
+ ret.push("</li>");
748
+ }
734
749
  }
735
- else
750
+ }
751
+ else
752
+ {
753
+ for (i in prop)
736
754
  {
737
- ret.push(text.toHTMLText(""+prop[i]));
755
+ ret.push("<li><b>"+text.toHTMLText(i)+": </b>");
756
+ if (prop[i] instanceof data.Timestamp)
757
+ {
758
+ ret.push(text.toHTMLText(prop[i].toString(timeFormat)));
759
+ }
760
+ else if (typeof prop[i] == "object")
761
+ {
762
+ ret.push(propertiesToHTML(prop[i], null, timeFormat));
763
+ }
764
+ else
765
+ {
766
+ ret.push(text.toHTMLText(""+prop[i]));
767
+ }
768
+ ret.push("</li>");
738
769
  }
739
- ret.push("</li>");
740
770
  }
741
771
  ret.push("</ul>");
742
772
  return ret.join("");
@@ -776,6 +806,23 @@ export class Dialog
776
806
  this.darkColor = null;
777
807
  }
778
808
 
809
+ getDocBody()
810
+ {
811
+ if (top.document.body.nodeName.toLowerCase() == "frameset")
812
+ {
813
+ let w = window;
814
+ while (w.parent && w.parent.document.body.nodeName.toLowerCase() != "frameset")
815
+ {
816
+ w = w.parent;
817
+ }
818
+ return w.document.body;
819
+ }
820
+ else
821
+ {
822
+ return top.document.body;
823
+ }
824
+ }
825
+
779
826
  show()
780
827
  {
781
828
  if (this.darkColor)
@@ -789,10 +836,11 @@ export class Dialog
789
836
  darkColor.style.display = "flex";
790
837
  darkColor.style.alignItems = "center";
791
838
  darkColor.style.justifyContent = "center";
792
- if (top.document.body.children.length > 0)
793
- top.document.body.insertBefore(darkColor, top.document.body.children[0]);
839
+ let docBody = this.getDocBody();
840
+ if (docBody.children.length > 0)
841
+ docBody.insertBefore(darkColor, docBody.children[0]);
794
842
  else
795
- top.document.body.appendChild(darkColor);
843
+ docBody.appendChild(darkColor);
796
844
  this.darkColor = darkColor;
797
845
  let dialog = document.createElement("div");
798
846
  dialog.style.backgroundColor = "#ffffff";
@@ -868,7 +916,7 @@ export class Dialog
868
916
  {
869
917
  if (this.darkColor)
870
918
  {
871
- top.document.body.removeChild(this.darkColor);
919
+ this.getDocBody().removeChild(this.darkColor);
872
920
  this.darkColor = null;
873
921
  }
874
922
  }