@sswroom/sswr 1.6.3 → 1.6.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/geometry.js CHANGED
@@ -28,6 +28,9 @@ export const VectorType = {
28
28
  }
29
29
 
30
30
  export class Vector2D {
31
+ /**
32
+ * @param {number} srid
33
+ */
31
34
  constructor(srid)
32
35
  {
33
36
  this.srid = srid;
@@ -36,18 +39,37 @@ export class Vector2D {
36
39
 
37
40
  export class Point extends Vector2D
38
41
  {
42
+ /**
43
+ * @param {number} srid
44
+ * @param {math.Vector3 | math.Coord2D | number[]} coordinates
45
+ */
39
46
  constructor(srid, coordinates)
40
47
  {
41
48
  super(srid);
42
49
  this.type = VectorType.Point;
43
- if (coordinates instanceof math.Coord2D)
44
- this.coordinates = [coordinates.x, coordinates.y];
45
- else if (coordinates instanceof math.Vector3)
50
+ if (coordinates instanceof math.Vector3)
46
51
  this.coordinates = [coordinates.x, coordinates.y, coordinates.z];
52
+ else if (coordinates instanceof math.Coord2D)
53
+ this.coordinates = [coordinates.x, coordinates.y];
47
54
  else
48
55
  this.coordinates = coordinates;
49
56
  }
50
57
 
58
+
59
+ /**
60
+ * @param {math.Coord2D} coord
61
+ */
62
+ calBoundaryPoint(coord)
63
+ {
64
+ let xdiff = coord.x - this.coordinates[0];
65
+ let ydiff = coord.y - this.coordinates[1];
66
+ let dist = Math.sqrt(xdiff * xdiff + ydiff * ydiff);
67
+ return {x:this.coordinates[0], y:this.coordinates[1], dist:dist};
68
+ }
69
+
70
+ /**
71
+ * @param {math.Coord2D} coord
72
+ */
51
73
  insideOrTouch(coord)
52
74
  {
53
75
  return this.coordinates[0] == coord.x && this.coordinates[1] == coord.y;
@@ -61,6 +83,10 @@ export class Point extends Vector2D
61
83
 
62
84
  export class LineString extends Vector2D
63
85
  {
86
+ /**
87
+ * @param {number} srid
88
+ * @param {number[][]} coordinates
89
+ */
64
90
  constructor(srid, coordinates)
65
91
  {
66
92
  super(srid);
@@ -68,6 +94,9 @@ export class LineString extends Vector2D
68
94
  this.coordinates = coordinates;
69
95
  }
70
96
 
97
+ /**
98
+ * @param {math.Coord2D} coord
99
+ */
71
100
  calBoundaryPoint(coord)
72
101
  {
73
102
  let l;
@@ -176,13 +205,16 @@ export class LineString extends Vector2D
176
205
  calPtOutY = points[l][1];
177
206
  }
178
207
  }
179
- let ret = new Object();
180
- ret.x = calPtOutX;
181
- ret.y = calPtOutY;
182
- ret.dist = Math.sqrt(dist);
183
- return ret;
208
+ return {
209
+ x: calPtOutX,
210
+ y: calPtOutY,
211
+ dist: Math.sqrt(dist)
212
+ };
184
213
  }
185
214
 
215
+ /**
216
+ * @param {math.Coord2D} coord
217
+ */
186
218
  insideOrTouch(coord)
187
219
  {
188
220
  let thisX;
@@ -246,12 +278,19 @@ export class LineString extends Vector2D
246
278
 
247
279
  export class LinearRing extends LineString
248
280
  {
281
+ /**
282
+ * @param {number} srid
283
+ * @param {number[][]} coordinates
284
+ */
249
285
  constructor(srid, coordinates)
250
286
  {
251
287
  super(srid, coordinates);
252
288
  this.type = VectorType.LinearRing;
253
289
  }
254
290
 
291
+ /**
292
+ * @param {math.Coord2D} coord
293
+ */
255
294
  insideOrTouch(coord)
256
295
  {
257
296
  let thisX;
@@ -327,6 +366,13 @@ export class LinearRing extends LineString
327
366
  return new Polygon(this.srid, [this.coordinates]);
328
367
  }
329
368
 
369
+ /**
370
+ * @param {number} srid
371
+ * @param {math.Coord2D} center
372
+ * @param {number} radiusX
373
+ * @param {number} radiusY
374
+ * @param {number} nPoints
375
+ */
330
376
  static createFromCircle(srid, center, radiusX, radiusY, nPoints)
331
377
  {
332
378
  let pos = [];
@@ -346,20 +392,26 @@ export class LinearRing extends LineString
346
392
 
347
393
  export class MultiGeometry extends Vector2D
348
394
  {
395
+ /**
396
+ * @param {number} srid
397
+ */
349
398
  constructor(srid)
350
399
  {
351
400
  super(srid);
352
401
  this.geometries = new Array();
353
402
  }
354
403
 
404
+ /**
405
+ * @param {math.Coord2D} coord
406
+ */
355
407
  calBoundaryPoint(coord)
356
408
  {
357
409
  let minObj = null;
358
410
  let thisObj;
359
- let i = this.coordinates.length;
411
+ let i = this.geometries.length;
360
412
  while (i-- > 0)
361
413
  {
362
- thisObj = this.coordinates[i].calBoundaryPoint(coord);
414
+ thisObj = this.geometries[i].calBoundaryPoint(coord);
363
415
  if (minObj == null || minObj.dist > thisObj.dist)
364
416
  {
365
417
  minObj = thisObj;
@@ -368,12 +420,15 @@ export class MultiGeometry extends Vector2D
368
420
  return minObj;
369
421
  }
370
422
 
423
+ /**
424
+ * @param {math.Coord2D} coord
425
+ */
371
426
  insideOrTouch(coord)
372
427
  {
373
- let i = this.coordinates.length;
428
+ let i = this.geometries.length;
374
429
  while (i-- > 0)
375
430
  {
376
- if (this.coordinates[i].insideOrTouch(coord))
431
+ if (this.geometries[i].insideOrTouch(coord))
377
432
  {
378
433
  return true;
379
434
  }
@@ -407,24 +462,34 @@ export class MultiGeometry extends Vector2D
407
462
 
408
463
  export class Polygon extends MultiGeometry
409
464
  {
465
+ /**
466
+ * @param {number} srid
467
+ * @param {number[][][] | undefined} coordinates
468
+ */
410
469
  constructor(srid, coordinates)
411
470
  {
412
471
  super(srid);
413
472
  this.type = VectorType.Polygon;
414
- let i;
415
- for (i in coordinates)
473
+ if (coordinates)
416
474
  {
417
- this.geometries.push(new LinearRing(srid, coordinates[i]));
475
+ let i;
476
+ for (i in coordinates)
477
+ {
478
+ this.geometries.push(new LinearRing(srid, coordinates[i]));
479
+ }
418
480
  }
419
481
  }
420
482
 
483
+ /**
484
+ * @param {math.Coord2D} coord
485
+ */
421
486
  insideOrTouch(coord)
422
487
  {
423
- let i = this.coordinates.length;
488
+ let i = this.geometries.length;
424
489
  let inside = false;
425
490
  while (i-- > 0)
426
491
  {
427
- if (this.coordinates[i].insideOrTouch(coord))
492
+ if (this.geometries[i].insideOrTouch(coord))
428
493
  {
429
494
  inside = !inside;
430
495
  }
@@ -435,6 +500,10 @@ export class Polygon extends MultiGeometry
435
500
 
436
501
  export class MultiPolygon extends MultiGeometry
437
502
  {
503
+ /**
504
+ * @param {number} srid
505
+ * @param {number[][][][]} coordinates
506
+ */
438
507
  constructor(srid, coordinates)
439
508
  {
440
509
  super(srid);
@@ -450,8 +519,32 @@ export class MultiPolygon extends MultiGeometry
450
519
  }
451
520
  }
452
521
 
522
+ export class Polyline extends MultiGeometry
523
+ {
524
+ /**
525
+ * @param {number} srid
526
+ * @param {number[][][]} coordinates
527
+ */
528
+ constructor(srid, coordinates)
529
+ {
530
+ super(srid);
531
+ this.type = VectorType.Polyline;
532
+ let i;
533
+ if (coordinates)
534
+ {
535
+ for (i in coordinates)
536
+ {
537
+ this.geometries.push(new LineString(srid, coordinates[i]));
538
+ }
539
+ }
540
+ }
541
+ }
542
+
453
543
  export class GeometryCollection extends MultiGeometry
454
544
  {
545
+ /**
546
+ * @param {number} srid
547
+ */
455
548
  constructor(srid)
456
549
  {
457
550
  super(srid);
package/hash.js CHANGED
@@ -39,7 +39,10 @@ export class SHA1 extends Hash
39
39
  constructor()
40
40
  {
41
41
  super();
42
- this.clear();
42
+ this.messageLength = 0n;
43
+ this.messageBlockIndex = 0;
44
+ this.intermediateHash = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
45
+ this.messageBlock = new Array(64);
43
46
  }
44
47
 
45
48
  getName()
@@ -274,7 +277,9 @@ export class MD5 extends Hash
274
277
  {
275
278
  super();
276
279
  this.buff = new Array(64);
277
- this.clear();
280
+ this.msgLeng = 0n;
281
+ this.h = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476];
282
+ this.buffSize = 0;
278
283
  }
279
284
 
280
285
  getName()
package/kml.d.ts CHANGED
@@ -270,7 +270,7 @@ export class Container extends Feature
270
270
  addFeature(feature: Feature): void;
271
271
  addStyle(style: Style): void;
272
272
  addStyleMap(styleMap: StyleMap): void;
273
- getOrNewStyle(iconStyle: IconStyle, labelStyle: LabelStyle, lineStyle: LineStyle, polyStyle: PolyStyle, balloonStyle: BalloonStyle, listStyle: ListStyle): Style;
273
+ getOrNewStyle(iconStyle: IconStyle | null, labelStyle: LabelStyle | null, lineStyle: LineStyle | null, polyStyle: PolyStyle | null, balloonStyle: BalloonStyle | null, listStyle: ListStyle | null): Style;
274
274
  getStyleById(id: string): Style | StyleMap | null;
275
275
  getBounds(): math.RectArea | null;
276
276
  getUsedNS(ns: object): void;
package/kml.js CHANGED
@@ -107,6 +107,8 @@ export class ColorStyle extends Element
107
107
  constructor()
108
108
  {
109
109
  super();
110
+ this.color = null;
111
+ this.randomColor = null;
110
112
  }
111
113
 
112
114
  setRandomColor(randomColor)
@@ -352,7 +354,7 @@ export class PolyStyle extends ColorStyle
352
354
  strs.push("\t".repeat(level)+"<PolyStyle>");
353
355
  this.appendInnerXML(strs, level + 1);
354
356
  if (this.outline != null)
355
- strs.push("\t".repeat(level + 1)+"<outline>"+(this.labelVisibility?"1":"0")+"</outline>");
357
+ strs.push("\t".repeat(level + 1)+"<outline>"+(this.outline?"1":"0")+"</outline>");
356
358
  strs.push("\t".repeat(level)+"</PolyStyle>");
357
359
  }
358
360
 
@@ -373,6 +375,22 @@ export class BalloonStyle extends Element
373
375
  constructor()
374
376
  {
375
377
  super();
378
+ /**
379
+ * @type {string | null}
380
+ */
381
+ this.bgColor = null;
382
+ /**
383
+ * @type {string | null}
384
+ */
385
+ this.textColor = null;
386
+ /**
387
+ * @type {string | null}
388
+ */
389
+ this.text = null;
390
+ /**
391
+ * @type {string | null}
392
+ */
393
+ this.displayMode = null;
376
394
  }
377
395
 
378
396
  getUsedNS(ns)
@@ -382,7 +400,7 @@ export class BalloonStyle extends Element
382
400
  appendOuterXML(strs, level)
383
401
  {
384
402
  strs.push("\t".repeat(level)+"<BalloonStyle>");
385
- this.appendInnerXML(strs, level + 1);
403
+ //this.appendInnerXML(strs, level + 1);
386
404
  if (this.bgColor)
387
405
  strs.push("\t".repeat(level + 1)+"<bgColor>"+this.bgColor+"</bgColor>");
388
406
  if (this.textColor)
@@ -415,6 +433,14 @@ export class ListStyle extends Element
415
433
  constructor()
416
434
  {
417
435
  super();
436
+ /**
437
+ * @type {string | null}
438
+ */
439
+ this.listItemType = null;
440
+ /**
441
+ * @type {string | null}
442
+ */
443
+ this.bgColor = null;
418
444
  }
419
445
 
420
446
  getUsedNS(ns)
@@ -424,7 +450,7 @@ export class ListStyle extends Element
424
450
  appendOuterXML(strs, level)
425
451
  {
426
452
  strs.push("\t".repeat(level)+"<ListStyle>");
427
- this.appendInnerXML(strs, level + 1);
453
+ //this.appendInnerXML(strs, level + 1);
428
454
  if (this.listItemType)
429
455
  strs.push("\t".repeat(level + 1)+"<listItemType>"+text.toXMLText(this.listItemType)+"</listItemType>");
430
456
  if (this.bgColor)
@@ -446,6 +472,9 @@ export class ListStyle extends Element
446
472
 
447
473
  export class StyleSelector extends Element
448
474
  {
475
+ /**
476
+ * @param {string} id
477
+ */
449
478
  constructor(id)
450
479
  {
451
480
  super();
@@ -455,6 +484,9 @@ export class StyleSelector extends Element
455
484
 
456
485
  export class Style extends StyleSelector
457
486
  {
487
+ /**
488
+ * @param {string} id
489
+ */
458
490
  constructor(id)
459
491
  {
460
492
  super(id);
@@ -508,6 +540,14 @@ export class Style extends StyleSelector
508
540
  }
509
541
  }
510
542
 
543
+ /**
544
+ * @param {IconStyle | null} iconStyle
545
+ * @param {LabelStyle | null} labelStyle
546
+ * @param {LineStyle | null} lineStyle
547
+ * @param {PolyStyle | null} polyStyle
548
+ * @param {BalloonStyle | null} balloonStyle
549
+ * @param {ListStyle | null} listStyle
550
+ */
511
551
  isStyle(iconStyle, labelStyle, lineStyle, polyStyle, balloonStyle, listStyle)
512
552
  {
513
553
  if (iconStyle == null)
@@ -1058,7 +1098,8 @@ export class Placemark extends Feature
1058
1098
  if (subGeom != true)
1059
1099
  strs.push("\t".repeat(level + 1)+"<tessellate>1</tessellate>");
1060
1100
  }
1061
- for (i in vec.geometries)
1101
+ i = 0;
1102
+ while (i < vec.geometries.length)
1062
1103
  {
1063
1104
  if (i == 0)
1064
1105
  {
@@ -1072,6 +1113,7 @@ export class Placemark extends Feature
1072
1113
  this.appendGeometry(strs, level + 2, vec.geometries[i], true);
1073
1114
  strs.push("\t".repeat(level + 1)+"</innerBoundaryIs>");
1074
1115
  }
1116
+ i++;
1075
1117
  }
1076
1118
  strs.push("\t".repeat(level)+"</Polygon>");
1077
1119
  }
package/leaflet.d.ts CHANGED
@@ -20,8 +20,8 @@ export function fromLatLng(latLng: L.LatLng): math.Coord2D;
20
20
  export function fromLatLngBounds(b: L.LatLngBounds): math.RectArea;
21
21
  export function toLatLngBounds(rect: math.RectArea): L.LatLngBounds;
22
22
 
23
- export function createLayer(layer: map.LayerInfo, options: object): L.Layer;
24
- export function createFromKML(feature: kml.Feature | kml.KMLFile, options: KMLFeatureOptions): L.Layer;
23
+ export function createLayer(layer: map.LayerInfo, options?: object): L.Layer;
24
+ export function createFromKML(feature: kml.Feature | kml.KMLFile, options?: KMLFeatureOptions): L.Layer;
25
25
  export function createFromGeometry(geom: geometry.Vector2D, options: GeometryOptions): L.Layer;
26
26
  export function createKMLLookAt(map: L.Map): kml.LookAt;
27
27
  export function toKMLFeature(layer: L.Layer, doc?: kml.Document): kml.Feature | null;
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/map.js CHANGED
@@ -31,10 +31,18 @@ export const GeometryType = {
31
31
  GeometryCollection: "GeometryCollection"
32
32
  };
33
33
 
34
+ /**
35
+ * @param {number} srid
36
+ * @param {geometry.Vector2D} geom
37
+ * @param {number} x
38
+ * @param {number} y
39
+ */
34
40
  export function calcDistance(srid, geom, x, y)
35
41
  {
36
42
  let pt = geom.calBoundaryPoint(new math.Coord2D(x, y));
37
43
  let csys = math.CoordinateSystemManager.srCreateCsys(srid);
44
+ if (csys == null)
45
+ throw new Error("srid "+srid+" is not supported");
38
46
  return csys.calcSurfaceDistance(x, y, pt.x, pt.y, unit.Distance.Unit.METER);
39
47
  }
40
48
 
@@ -116,6 +124,8 @@ export class GeolocationFilter
116
124
  constructor(minSecs, minDistMeter)
117
125
  {
118
126
  this.csys = math.CoordinateSystemManager.srCreateCsys(4326);
127
+ if (this.csys == null)
128
+ throw new Error();
119
129
  this.minSecs = minSecs;
120
130
  this.minDistMeter = minDistMeter;
121
131
  }
@@ -166,6 +176,7 @@ export class WMS
166
176
  let resp = await fetch(this.url + "?SERVICE=WMS&REQUEST=GetCapabilities");
167
177
  let parser = new DOMParser();
168
178
  let contentType = resp.headers.get("Content-Type") || "text/xml";
179
+ // @ts-ignore
169
180
  let doc = parser.parseFromString(await resp.text(), contentType);
170
181
  let node = doc.childNodes[0];
171
182
  if (node.nodeName == "WMS_Capabilities" || node.nodeName == "WMT_MS_Capabilities")
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