@sswroom/sswr 1.6.15 → 1.6.17
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 +10 -0
- package/geometry.d.ts +14 -0
- package/geometry.js +238 -11
- package/leaflet.js +1 -1
- package/math.d.ts +2 -1
- package/olayer2.d.ts +5 -5
- package/olayer2.js +5 -1
- package/package.json +1 -1
package/Changelog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
1.6.17
|
|
2
|
+
-Fixed olayer2 types
|
|
3
|
+
-Added vector2D.hasArea
|
|
4
|
+
-Added Vector2D.calcHIntersacts
|
|
5
|
+
-Added Vector2D.getDisplayCenter
|
|
6
|
+
-Enhance math.GeoJSON.parseGeometry
|
|
7
|
+
|
|
8
|
+
1.6.16
|
|
9
|
+
-Fixed leaflet point icon
|
|
10
|
+
|
|
1
11
|
1.6.15
|
|
2
12
|
-shreadsheet Support Chart
|
|
3
13
|
-Added web.getCanvasElement, web.getImgElement
|
package/geometry.d.ts
CHANGED
|
@@ -42,6 +42,9 @@ export abstract class Vector2D {
|
|
|
42
42
|
abstract calBoundaryPoint(coord: math.Coord2D): BoundaryPointResult;
|
|
43
43
|
insideOrTouch(coord: math.Coord2D): boolean;
|
|
44
44
|
getBounds(): math.RectArea;
|
|
45
|
+
abstract hasArea(): boolean;
|
|
46
|
+
abstract calcHIntersacts(y: double): number[];
|
|
47
|
+
abstract getDisplayCenter(): math.Coord2D;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
export class Point extends Vector2D
|
|
@@ -51,6 +54,9 @@ export class Point extends Vector2D
|
|
|
51
54
|
calBoundaryPoint(coord: math.Coord2D): BoundaryPointResult;
|
|
52
55
|
insideOrTouch(coord: math.Coord2D): boolean;
|
|
53
56
|
getBounds(): math.RectArea;
|
|
57
|
+
hasArea(): boolean;
|
|
58
|
+
calcHIntersacts(y: double): number[];
|
|
59
|
+
getDisplayCenter(): math.Coord2D;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
|
|
@@ -61,6 +67,9 @@ export class LineString extends Vector2D
|
|
|
61
67
|
calBoundaryPoint(coord: math.Coord2D): BoundaryPointResult;
|
|
62
68
|
insideOrTouch(coord: math.Coord2D): boolean;
|
|
63
69
|
getBounds(): math.RectArea;
|
|
70
|
+
hasArea(): boolean;
|
|
71
|
+
calcHIntersacts(y: double): number[];
|
|
72
|
+
getDisplayCenter(): math.Coord2D;
|
|
64
73
|
}
|
|
65
74
|
|
|
66
75
|
export class LinearRing extends LineString
|
|
@@ -70,7 +79,10 @@ export class LinearRing extends LineString
|
|
|
70
79
|
isOpen(): boolean;
|
|
71
80
|
isClose(): boolean;
|
|
72
81
|
toPolygon(): Polygon;
|
|
82
|
+
hasArea(): boolean;
|
|
83
|
+
getDisplayCenter(): math.Coord2D;
|
|
73
84
|
|
|
85
|
+
static getHIntersactsCenter(xList: number[]): number;
|
|
74
86
|
static createFromCircle(srid: number, center: math.Coord2D, radiusX: number, radiusY: number, nPoints: number): LinearRing;
|
|
75
87
|
}
|
|
76
88
|
|
|
@@ -82,6 +94,8 @@ export class MultiGeometry<VecType> extends Vector2D
|
|
|
82
94
|
calBoundaryPoint(coord: math.Coord2D): BoundaryPointResult;
|
|
83
95
|
insideOrTouch(coord: math.Coord2D): boolean;
|
|
84
96
|
getBounds(): math.RectArea;
|
|
97
|
+
hasArea(): boolean;
|
|
98
|
+
getDisplayCenter(): math.Coord2D;
|
|
85
99
|
}
|
|
86
100
|
|
|
87
101
|
export class Polygon extends MultiGeometry<LinearRing>
|
package/geometry.js
CHANGED
|
@@ -35,6 +35,58 @@ export class Vector2D {
|
|
|
35
35
|
{
|
|
36
36
|
this.srid = srid;
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {math.Coord2D} coord
|
|
41
|
+
* @returns {{x: number;y: number;dist: number;}}
|
|
42
|
+
*/
|
|
43
|
+
calBoundaryPoint(coord)
|
|
44
|
+
{
|
|
45
|
+
throw new Error("Calling abstract function calBoundaryPoint is not allowed");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {math.Coord2D} coord
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
52
|
+
insideOrTouch(coord)
|
|
53
|
+
{
|
|
54
|
+
throw new Error("Calling abstract function insideOrTouch is not allowed");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @returns {math.RectArea}
|
|
59
|
+
*/
|
|
60
|
+
getBounds()
|
|
61
|
+
{
|
|
62
|
+
throw new Error("Calling abstract function getBounds is not allowed");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @returns {boolean}
|
|
67
|
+
*/
|
|
68
|
+
hasArea()
|
|
69
|
+
{
|
|
70
|
+
throw new Error("Calling abstract function hasArea is not allowed");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {number} y
|
|
75
|
+
* @returns {number[]}
|
|
76
|
+
*/
|
|
77
|
+
calcHIntersacts(y)
|
|
78
|
+
{
|
|
79
|
+
throw new Error("Calling abstract function calcHIntersacts is not allowed");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @returns {math.Coord2D}
|
|
84
|
+
*/
|
|
85
|
+
getDisplayCenter()
|
|
86
|
+
{
|
|
87
|
+
throw new Error("Calling abstract function getDisplayCenter is not allowed");
|
|
88
|
+
}
|
|
89
|
+
|
|
38
90
|
}
|
|
39
91
|
|
|
40
92
|
export class Point extends Vector2D
|
|
@@ -79,6 +131,24 @@ export class Point extends Vector2D
|
|
|
79
131
|
{
|
|
80
132
|
return new math.RectArea(this.coordinates[0], this.coordinates[1], this.coordinates[0], this.coordinates[1]);
|
|
81
133
|
}
|
|
134
|
+
|
|
135
|
+
hasArea()
|
|
136
|
+
{
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @param {number} y
|
|
142
|
+
*/
|
|
143
|
+
calcHIntersacts(y)
|
|
144
|
+
{
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getDisplayCenter()
|
|
149
|
+
{
|
|
150
|
+
return new math.Coord2D(this.coordinates[0], this.coordinates[1]);
|
|
151
|
+
}
|
|
82
152
|
}
|
|
83
153
|
|
|
84
154
|
export class LineString extends Vector2D
|
|
@@ -274,6 +344,59 @@ export class LineString extends Vector2D
|
|
|
274
344
|
}
|
|
275
345
|
return bounds;
|
|
276
346
|
}
|
|
347
|
+
|
|
348
|
+
hasArea()
|
|
349
|
+
{
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @param {number} y
|
|
355
|
+
*/
|
|
356
|
+
calcHIntersacts(y)
|
|
357
|
+
{
|
|
358
|
+
if (this.coordinates.length < 2)
|
|
359
|
+
throw new Error("coordinates length < 2");
|
|
360
|
+
/** @type {number[]} */
|
|
361
|
+
let ret = [];
|
|
362
|
+
let i = 1;
|
|
363
|
+
let lastPt = this.coordinates[0];
|
|
364
|
+
let thisPt;
|
|
365
|
+
let thisX;
|
|
366
|
+
while (i < this.coordinates.length)
|
|
367
|
+
{
|
|
368
|
+
thisPt = this.coordinates[i];
|
|
369
|
+
if ((lastPt[1] >= y && thisPt[1] < y) || (thisPt[1] >= y && lastPt[1] < y))
|
|
370
|
+
{
|
|
371
|
+
thisX = lastPt[0] + (y - lastPt[1]) / (thisPt[1] - lastPt[1]) * (thisPt[0] - lastPt[0]);
|
|
372
|
+
ret.push(thisX);
|
|
373
|
+
}
|
|
374
|
+
lastPt = thisPt;
|
|
375
|
+
i++;
|
|
376
|
+
}
|
|
377
|
+
if (this.hasArea())
|
|
378
|
+
{
|
|
379
|
+
thisPt = this.coordinates[0];
|
|
380
|
+
if ((lastPt[1] >= y && thisPt[1] < y) || (thisPt[1] >= y && lastPt[1] < y))
|
|
381
|
+
{
|
|
382
|
+
thisX = lastPt[0] + (y - lastPt[1]) / (thisPt[1] - lastPt[1]) * (thisPt[0] - lastPt[0]);
|
|
383
|
+
ret.push(thisX);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return ret;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
getDisplayCenter()
|
|
390
|
+
{
|
|
391
|
+
let bounds = this.getBounds();
|
|
392
|
+
let pt = bounds.getCenter();
|
|
393
|
+
let xList = this.calcHIntersacts(pt.y);
|
|
394
|
+
if (xList.length == 0)
|
|
395
|
+
{
|
|
396
|
+
throw new Error("No intersact point in middle y");
|
|
397
|
+
}
|
|
398
|
+
return new math.Coord2D(xList[xList.length >> 1], pt.y);
|
|
399
|
+
}
|
|
277
400
|
}
|
|
278
401
|
|
|
279
402
|
export class LinearRing extends LineString
|
|
@@ -366,6 +489,59 @@ export class LinearRing extends LineString
|
|
|
366
489
|
return new Polygon(this.srid, [this.coordinates]);
|
|
367
490
|
}
|
|
368
491
|
|
|
492
|
+
hasArea()
|
|
493
|
+
{
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
getDisplayCenter()
|
|
498
|
+
{
|
|
499
|
+
let bounds = this.getBounds();
|
|
500
|
+
let pt = bounds.getCenter();
|
|
501
|
+
let xList = this.calcHIntersacts(pt.y);
|
|
502
|
+
if (xList.length == 0)
|
|
503
|
+
{
|
|
504
|
+
throw new Error("No intersact point in middle y");
|
|
505
|
+
}
|
|
506
|
+
xList.sort();
|
|
507
|
+
let x = LinearRing.getHIntersactsCenter(xList);
|
|
508
|
+
return new math.Coord2D(xList[xList.length >> 1], pt.y);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* @param {number[]} xList
|
|
513
|
+
*/
|
|
514
|
+
static getHIntersactsCenter(xList)
|
|
515
|
+
{
|
|
516
|
+
if (xList.length == 0)
|
|
517
|
+
{
|
|
518
|
+
throw new Error("xList is empty");
|
|
519
|
+
}
|
|
520
|
+
if ((xList.length & 1) != 0)
|
|
521
|
+
{
|
|
522
|
+
throw new Error("xList length must be even number");
|
|
523
|
+
}
|
|
524
|
+
let totalLength = 0;
|
|
525
|
+
let leng;
|
|
526
|
+
let i = xList.length;
|
|
527
|
+
while (i > 0)
|
|
528
|
+
{
|
|
529
|
+
i -= 2;
|
|
530
|
+
totalLength += xList[i + 1] - xList[i];
|
|
531
|
+
}
|
|
532
|
+
totalLength = totalLength * 0.5;
|
|
533
|
+
i = xList.length;
|
|
534
|
+
while (i > 0)
|
|
535
|
+
{
|
|
536
|
+
i -= 2;
|
|
537
|
+
leng = xList[i + 1] - xList[i];
|
|
538
|
+
if (totalLength <= leng)
|
|
539
|
+
return xList[i + 1] - totalLength;
|
|
540
|
+
totalLength -= leng;
|
|
541
|
+
}
|
|
542
|
+
return xList[0];
|
|
543
|
+
}
|
|
544
|
+
|
|
369
545
|
/**
|
|
370
546
|
* @param {number} srid
|
|
371
547
|
* @param {math.Coord2D} center
|
|
@@ -398,7 +574,8 @@ export class MultiGeometry extends Vector2D
|
|
|
398
574
|
constructor(srid)
|
|
399
575
|
{
|
|
400
576
|
super(srid);
|
|
401
|
-
|
|
577
|
+
/** @type {Vector2D[]} */
|
|
578
|
+
this.geometries = [];
|
|
402
579
|
}
|
|
403
580
|
|
|
404
581
|
/**
|
|
@@ -417,6 +594,8 @@ export class MultiGeometry extends Vector2D
|
|
|
417
594
|
minObj = thisObj;
|
|
418
595
|
}
|
|
419
596
|
}
|
|
597
|
+
if (minObj == null)
|
|
598
|
+
return {x: coord.x, y: coord.y, dist:0};
|
|
420
599
|
return minObj;
|
|
421
600
|
}
|
|
422
601
|
|
|
@@ -440,23 +619,71 @@ export class MultiGeometry extends Vector2D
|
|
|
440
619
|
{
|
|
441
620
|
if (this.geometries.length == 0)
|
|
442
621
|
{
|
|
443
|
-
|
|
622
|
+
throw new Error("No geometries");
|
|
444
623
|
}
|
|
445
|
-
let bounds;
|
|
624
|
+
let bounds = this.geometries[0].getBounds();
|
|
446
625
|
let thisBounds;
|
|
447
|
-
let i;
|
|
448
|
-
|
|
626
|
+
let i = 1;
|
|
627
|
+
while (i < this.geometries.length)
|
|
449
628
|
{
|
|
450
629
|
thisBounds = this.geometries[i].getBounds();
|
|
451
|
-
if (
|
|
630
|
+
if (bounds)
|
|
631
|
+
bounds.unionInPlace(thisBounds);
|
|
632
|
+
else
|
|
633
|
+
bounds = thisBounds;
|
|
634
|
+
i++;
|
|
635
|
+
}
|
|
636
|
+
return bounds;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
hasArea()
|
|
640
|
+
{
|
|
641
|
+
if (this.geometries.length == 0)
|
|
642
|
+
return false;
|
|
643
|
+
return this.geometries[0].hasArea();
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* @param {number} y
|
|
648
|
+
*/
|
|
649
|
+
calcHIntersacts(y)
|
|
650
|
+
{
|
|
651
|
+
/** @type {number[]} */
|
|
652
|
+
let xList = [];
|
|
653
|
+
let i = 0;
|
|
654
|
+
while (i < this.geometries.length)
|
|
655
|
+
{
|
|
656
|
+
xList = xList.concat(this.geometries[i].calcHIntersacts(y));
|
|
657
|
+
i++;
|
|
658
|
+
}
|
|
659
|
+
return xList;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
getDisplayCenter()
|
|
663
|
+
{
|
|
664
|
+
let bounds = this.getBounds();
|
|
665
|
+
let pt = bounds.getCenter();
|
|
666
|
+
let xList = this.calcHIntersacts(pt.y);
|
|
667
|
+
if (xList.length == 0)
|
|
668
|
+
{
|
|
669
|
+
bounds = this.geometries[0].getBounds();
|
|
670
|
+
pt = bounds.getCenter();
|
|
671
|
+
xList = this.calcHIntersacts(pt.y);
|
|
672
|
+
if (xList.length == 0)
|
|
452
673
|
{
|
|
453
|
-
|
|
454
|
-
bounds.unionInPlace(thisBounds);
|
|
455
|
-
else
|
|
456
|
-
bounds = thisBounds;
|
|
674
|
+
throw new Error("Error in finding display center");
|
|
457
675
|
}
|
|
458
676
|
}
|
|
459
|
-
|
|
677
|
+
xList.sort();
|
|
678
|
+
if (this.hasArea())
|
|
679
|
+
{
|
|
680
|
+
let x = LinearRing.getHIntersactsCenter(xList);
|
|
681
|
+
return new math.Coord2D(x, pt.y);
|
|
682
|
+
}
|
|
683
|
+
else
|
|
684
|
+
{
|
|
685
|
+
return new math.Coord2D(xList[xList.length >> 1], pt.y);
|
|
686
|
+
}
|
|
460
687
|
}
|
|
461
688
|
}
|
|
462
689
|
|
package/leaflet.js
CHANGED
|
@@ -179,7 +179,7 @@ export function createFromGeometry(geom, options)
|
|
|
179
179
|
{
|
|
180
180
|
if (options.name)
|
|
181
181
|
opt.title = options.name;
|
|
182
|
-
if (options.icon && options.icon.iconUrl)
|
|
182
|
+
if (options.icon && options.icon.options.iconUrl)
|
|
183
183
|
opt.icon = options.icon;
|
|
184
184
|
}
|
|
185
185
|
return L.marker(L.latLng(geom.coordinates[1], geom.coordinates[0]), opt);
|
package/math.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as geometry from "./geometry";
|
|
2
|
+
import * as map from "./map";
|
|
2
3
|
import * as unit from "./unit";
|
|
3
4
|
|
|
4
5
|
export function roundToFloat(n: number, decimalPoints: number): number;
|
|
5
6
|
export function roundToStr(n: number, decimalPoints: number): string;
|
|
6
7
|
export class GeoJSON
|
|
7
8
|
{
|
|
8
|
-
static parseGeometry(srid: number, geom:
|
|
9
|
+
static parseGeometry(srid: number, geom: map.Geometry): geometry.Vector2D | null;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export class Coord2D
|
package/olayer2.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export class Olayer2Map extends map.MapControl
|
|
|
29
29
|
posFunc: (lat: number, lon: number)=>void;
|
|
30
30
|
|
|
31
31
|
constructor(mapId: string);
|
|
32
|
-
createLayer(layer: map.LayerInfo, options?: LayerOptions): any;
|
|
33
|
-
createMarkerLayer(name: string, options?: LayerOptions): any;
|
|
34
|
-
createGeometryLayer(name: string, options?: LayerOptions): any;
|
|
32
|
+
createLayer(layer: map.LayerInfo, options?: map.LayerOptions): any;
|
|
33
|
+
createMarkerLayer(name: string, options?: map.LayerOptions): any;
|
|
34
|
+
createGeometryLayer(name: string, options?: map.LayerOptions): any;
|
|
35
35
|
addLayer(layer: any): void;
|
|
36
36
|
addKML(feature: kml.Feature | kml.KMLFile): void;
|
|
37
37
|
uninit(): void;
|
|
@@ -47,13 +47,13 @@ export class Olayer2Map extends map.MapControl
|
|
|
47
47
|
map2ScnPos(mapPos: math.Coord2D): math.Coord2D;
|
|
48
48
|
scn2MapPos(scnPos: math.Coord2D): math.Coord2D;
|
|
49
49
|
|
|
50
|
-
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: MarkerOptions): any;
|
|
50
|
+
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: map.MarkerOptions): any;
|
|
51
51
|
layerAddMarker(markerLayer: any, marker: any): void;
|
|
52
52
|
layerRemoveMarker(markerLayer: any, marker: any): void;
|
|
53
53
|
layerClearMarkers(markerLayer: any): void;
|
|
54
54
|
markerIsOver(marker: any, scnPos: math.Coord2D): boolean;
|
|
55
55
|
|
|
56
|
-
createGeometry(geom: geometry.Vector2D,
|
|
56
|
+
createGeometry(geom: geometry.Vector2D, options: map.GeometryOptions): any;
|
|
57
57
|
layerAddGeometry(geometryLayer: any, geom: any): void;
|
|
58
58
|
layerRemoveGeometry(geometryLayer: any, geom: any): void;
|
|
59
59
|
layerClearGeometries(goemetryLayer: any): void;
|
package/olayer2.js
CHANGED
|
@@ -333,7 +333,7 @@ export class Olayer2Map extends map.MapControl
|
|
|
333
333
|
new OpenLayers.LonLat(this.initX, this.initY).transform(
|
|
334
334
|
this.mapProjection,
|
|
335
335
|
this.map.getProjectionObject()
|
|
336
|
-
), this.initLev);
|
|
336
|
+
), this.initLev, false, false);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
else if (data.isArray(layer))
|
|
@@ -507,6 +507,10 @@ export class Olayer2Map extends map.MapControl
|
|
|
507
507
|
return true;
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
+
/**
|
|
511
|
+
* @param {geometry.Vector2D} geom
|
|
512
|
+
* @param {map.GeometryOptions} options
|
|
513
|
+
*/
|
|
510
514
|
createGeometry(geom, options)
|
|
511
515
|
{
|
|
512
516
|
let opt = {};
|