@sswroom/sswr 1.6.16 → 1.6.18
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 +14 -0
- package/geometry.d.ts +14 -0
- package/geometry.js +238 -11
- package/math.d.ts +4 -1
- package/math.js +24 -3
- package/media.d.ts +18 -0
- package/media.js +168 -0
- package/olayer2.d.ts +5 -5
- package/olayer2.js +5 -1
- package/package.json +1 -1
- package/web.js +9 -3
package/Changelog
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
1.6.18
|
|
2
|
+
-Change geometry.LinearRing.getHIntersactsCenter to getIntersactsCenter
|
|
3
|
+
-web.buildTable support StaticImage item
|
|
4
|
+
-Added media.genVector2DPreview
|
|
5
|
+
-Added media.DrawImage
|
|
6
|
+
-Added math.calcDir
|
|
7
|
+
|
|
8
|
+
1.6.17
|
|
9
|
+
-Fixed olayer2 types
|
|
10
|
+
-Added vector2D.hasArea
|
|
11
|
+
-Added Vector2D.calcHIntersacts
|
|
12
|
+
-Added Vector2D.getDisplayCenter
|
|
13
|
+
-Enhance math.GeoJSON.parseGeometry
|
|
14
|
+
|
|
1
15
|
1.6.16
|
|
2
16
|
-Fixed leaflet point icon
|
|
3
17
|
|
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 getIntersactsCenter(vals: 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.getIntersactsCenter(xList);
|
|
508
|
+
return new math.Coord2D(xList[xList.length >> 1], pt.y);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* @param {number[]} vals
|
|
513
|
+
*/
|
|
514
|
+
static getIntersactsCenter(vals)
|
|
515
|
+
{
|
|
516
|
+
if (vals.length == 0)
|
|
517
|
+
{
|
|
518
|
+
throw new Error("vals is empty");
|
|
519
|
+
}
|
|
520
|
+
if ((vals.length & 1) != 0)
|
|
521
|
+
{
|
|
522
|
+
throw new Error("vals length must be even number");
|
|
523
|
+
}
|
|
524
|
+
let totalLength = 0;
|
|
525
|
+
let leng;
|
|
526
|
+
let i = vals.length;
|
|
527
|
+
while (i > 0)
|
|
528
|
+
{
|
|
529
|
+
i -= 2;
|
|
530
|
+
totalLength += vals[i + 1] - vals[i];
|
|
531
|
+
}
|
|
532
|
+
totalLength = totalLength * 0.5;
|
|
533
|
+
i = vals.length;
|
|
534
|
+
while (i > 0)
|
|
535
|
+
{
|
|
536
|
+
i -= 2;
|
|
537
|
+
leng = vals[i + 1] - vals[i];
|
|
538
|
+
if (totalLength <= leng)
|
|
539
|
+
return vals[i + 1] - totalLength;
|
|
540
|
+
totalLength -= leng;
|
|
541
|
+
}
|
|
542
|
+
return vals[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.getIntersactsCenter(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/math.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
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;
|
|
7
|
+
export function calcDir(startPt: Coord2D, endPt: Coord2D, ang: unit.Angle.Unit): number;
|
|
8
|
+
|
|
6
9
|
export class GeoJSON
|
|
7
10
|
{
|
|
8
|
-
static parseGeometry(srid: number, geom:
|
|
11
|
+
static parseGeometry(srid: number, geom: map.Geometry): geometry.Vector2D | null;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
export class Coord2D
|
package/math.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as geometry from "./geometry.js";
|
|
2
|
+
import * as map from "./map.js";
|
|
2
3
|
import * as unit from "./unit.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -43,23 +44,43 @@ export function roundToStr(n, decimalPoints)
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @param {Coord2D} startPt
|
|
49
|
+
* @param {Coord2D} endPt
|
|
50
|
+
* @param {unit.Angle.Unit} ang
|
|
51
|
+
*/
|
|
52
|
+
export function calcDir(startPt, endPt, ang)
|
|
53
|
+
{
|
|
54
|
+
let a = Math.atan2(endPt.x - startPt.x, endPt.y - startPt.y);
|
|
55
|
+
if (a < 0)
|
|
56
|
+
{
|
|
57
|
+
a = a + Math.PI * 2;
|
|
58
|
+
}
|
|
59
|
+
return unit.Angle.convert(unit.Angle.Unit.RADIAN, ang, a);
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
export class GeoJSON {
|
|
47
63
|
/**
|
|
48
64
|
* @param {number} srid
|
|
49
|
-
* @param {
|
|
65
|
+
* @param {map.Geometry} geom
|
|
50
66
|
*/
|
|
51
67
|
static parseGeometry(srid, geom)
|
|
52
68
|
{
|
|
53
|
-
if (geom.type ==
|
|
69
|
+
if (geom.type == map.GeometryType.Polygon)
|
|
54
70
|
{
|
|
55
71
|
// @ts-ignore
|
|
56
72
|
return new geometry.Polygon(srid, geom.coordinates);
|
|
57
73
|
}
|
|
58
|
-
else if (geom.type ==
|
|
74
|
+
else if (geom.type == map.GeometryType.MultiPolygon)
|
|
59
75
|
{
|
|
60
76
|
// @ts-ignore
|
|
61
77
|
return new geometry.MultiPolygon(srid, geom.coordinates);
|
|
62
78
|
}
|
|
79
|
+
else if (geom.type == map.GeometryType.LineString)
|
|
80
|
+
{
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
return new geometry.LineString(srid, geom.coordinates);
|
|
83
|
+
}
|
|
63
84
|
else
|
|
64
85
|
{
|
|
65
86
|
console.log("GeoJSON.parseGeometry: unknown type "+geom.type);
|
package/media.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as data from "./data";
|
|
2
|
+
import * as geometry from "./geometry";
|
|
3
|
+
import * as math from "./math";
|
|
2
4
|
|
|
3
5
|
export enum EXIFMaker
|
|
4
6
|
{
|
|
@@ -41,6 +43,22 @@ declare class GPSInfo
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export function loadImageFromBlob(blob: Blob): Promise<HTMLImageElement>;
|
|
46
|
+
export function genVector2DPreview(vec: geometry.Vector2D, width: number, height: number): DrawImage;
|
|
47
|
+
|
|
48
|
+
export class DrawImage
|
|
49
|
+
{
|
|
50
|
+
canvas: HTMLCanvasElement;
|
|
51
|
+
ctx: CanvasRenderingContext2D | null;
|
|
52
|
+
|
|
53
|
+
constructor(width: number, height: number);
|
|
54
|
+
drawLine(startPt: math.Coord2D, endPt: math.Coord2D, lineWidth?: number, lineStyle?: string | CanvasGradient | CanvasPattern): void;
|
|
55
|
+
drawPolyline(pts: math.Coord2D[], lineWidth?: number, lineStyle?: string | CanvasGradient | CanvasPattern): void;
|
|
56
|
+
get width(): number;
|
|
57
|
+
get height(): number;
|
|
58
|
+
|
|
59
|
+
toPNGURL(): string;
|
|
60
|
+
createStaticImage(): StaticImage;
|
|
61
|
+
}
|
|
44
62
|
|
|
45
63
|
export class EXIFItem
|
|
46
64
|
{
|
package/media.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as data from "./data.js";
|
|
2
|
+
import * as geometry from "./geometry.js";
|
|
3
|
+
import * as math from "./math.js";
|
|
2
4
|
import * as text from "./text.js";
|
|
3
5
|
|
|
4
6
|
export const EXIFMaker = {
|
|
@@ -47,6 +49,167 @@ export function loadImageFromBlob(blob)
|
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {geometry.Vector2D} vec
|
|
55
|
+
* @param {number} width
|
|
56
|
+
* @param {number} height
|
|
57
|
+
*/
|
|
58
|
+
export function genVector2DPreview(vec, width, height)
|
|
59
|
+
{
|
|
60
|
+
let img = new DrawImage(width, height);
|
|
61
|
+
let bounds = vec.getBounds();
|
|
62
|
+
drawVector2DPreview(img, vec, bounds);
|
|
63
|
+
return img;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {DrawImage} img
|
|
68
|
+
* @param {geometry.Vector2D} vec
|
|
69
|
+
* @param {math.RectArea} bounds
|
|
70
|
+
*/
|
|
71
|
+
function drawVector2DPreview(img, vec, bounds)
|
|
72
|
+
{
|
|
73
|
+
let w = img.width;
|
|
74
|
+
let h = img.height;
|
|
75
|
+
let vecX = 0;
|
|
76
|
+
let vecY = 0;
|
|
77
|
+
let vecW = bounds.getWidth();
|
|
78
|
+
let vecH = bounds.getHeight();
|
|
79
|
+
if (vecW > vecH)
|
|
80
|
+
{
|
|
81
|
+
vecY = (vecW - vecH) * 0.5;
|
|
82
|
+
vecH = vecW;
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
{
|
|
86
|
+
vecX = (vecH - vecW) * 0.5;
|
|
87
|
+
vecW = vecH;
|
|
88
|
+
}
|
|
89
|
+
let pl = [];
|
|
90
|
+
let i;
|
|
91
|
+
if (vec instanceof geometry.LinearRing)
|
|
92
|
+
{
|
|
93
|
+
i = 0;
|
|
94
|
+
while (i < vec.coordinates.length)
|
|
95
|
+
{
|
|
96
|
+
pl.push(new math.Coord2D((vec.coordinates[i][0] - bounds.minX + vecX) * w / vecW, (bounds.maxY - vec.coordinates[i][1] + vecY) * h / vecH));
|
|
97
|
+
i++;
|
|
98
|
+
}
|
|
99
|
+
img.drawPolyline(pl, 1, "black");
|
|
100
|
+
}
|
|
101
|
+
else if (vec instanceof geometry.LineString)
|
|
102
|
+
{
|
|
103
|
+
i = 0;
|
|
104
|
+
while (i < vec.coordinates.length)
|
|
105
|
+
{
|
|
106
|
+
pl.push(new math.Coord2D((vec.coordinates[i][0] - bounds.minX + vecX) * w / vecW, (bounds.maxY - vec.coordinates[i][1] + vecY) * h / vecH));
|
|
107
|
+
i++;
|
|
108
|
+
}
|
|
109
|
+
img.drawPolyline(pl, 1, "black");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export class DrawImage
|
|
114
|
+
{
|
|
115
|
+
/**
|
|
116
|
+
* @param {number} width
|
|
117
|
+
* @param {number} height
|
|
118
|
+
*/
|
|
119
|
+
constructor(width, height)
|
|
120
|
+
{
|
|
121
|
+
this.canvas = document.createElement("canvas");
|
|
122
|
+
this.canvas.width = width;
|
|
123
|
+
this.canvas.height = height;
|
|
124
|
+
this.ctx = this.canvas.getContext("2d");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param {math.Coord2D} startPt
|
|
129
|
+
* @param {math.Coord2D} endPt
|
|
130
|
+
* @param {undefined | null | number} lineWidth
|
|
131
|
+
* @param {undefined | string | CanvasGradient | CanvasPattern} lineStyle
|
|
132
|
+
*/
|
|
133
|
+
drawLine(startPt, endPt, lineWidth, lineStyle)
|
|
134
|
+
{
|
|
135
|
+
let ctx = this.ctx;
|
|
136
|
+
if (ctx)
|
|
137
|
+
{
|
|
138
|
+
ctx.beginPath();
|
|
139
|
+
ctx.moveTo(startPt.x, startPt.y);
|
|
140
|
+
ctx.lineTo(endPt.x, endPt.y);
|
|
141
|
+
if (lineWidth)
|
|
142
|
+
{
|
|
143
|
+
ctx.lineWidth = lineWidth;
|
|
144
|
+
}
|
|
145
|
+
if (lineStyle)
|
|
146
|
+
{
|
|
147
|
+
ctx.strokeStyle = lineStyle;
|
|
148
|
+
}
|
|
149
|
+
ctx.stroke();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @param {math.Coord2D[]} pts
|
|
155
|
+
* @param {undefined | null | number} lineWidth
|
|
156
|
+
* @param {undefined | string | CanvasGradient | CanvasPattern} lineStyle
|
|
157
|
+
*/
|
|
158
|
+
drawPolyline(pts, lineWidth, lineStyle)
|
|
159
|
+
{
|
|
160
|
+
let ctx = this.ctx;
|
|
161
|
+
if (ctx && pts.length > 0)
|
|
162
|
+
{
|
|
163
|
+
let i;
|
|
164
|
+
ctx.beginPath();
|
|
165
|
+
ctx.moveTo(pts[0].x, pts[0].y);
|
|
166
|
+
i = 1;
|
|
167
|
+
while (i < pts.length)
|
|
168
|
+
{
|
|
169
|
+
ctx.lineTo(pts[i].x, pts[i].y);
|
|
170
|
+
i++;
|
|
171
|
+
}
|
|
172
|
+
if (lineWidth)
|
|
173
|
+
{
|
|
174
|
+
ctx.lineWidth = lineWidth;
|
|
175
|
+
}
|
|
176
|
+
if (lineStyle)
|
|
177
|
+
{
|
|
178
|
+
ctx.strokeStyle = lineStyle;
|
|
179
|
+
}
|
|
180
|
+
ctx.stroke();
|
|
181
|
+
}
|
|
182
|
+
else
|
|
183
|
+
{
|
|
184
|
+
console.log("ctx not found or pts is empty")
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
get width()
|
|
189
|
+
{
|
|
190
|
+
return this.canvas.width;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
get height()
|
|
194
|
+
{
|
|
195
|
+
return this.canvas.height;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
toPNGURL()
|
|
199
|
+
{
|
|
200
|
+
return this.canvas.toDataURL("image/png");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
createStaticImage()
|
|
204
|
+
{
|
|
205
|
+
let url = this.canvas.toDataURL("image/png");
|
|
206
|
+
let img = document.createElement("img");
|
|
207
|
+
img.src = url;
|
|
208
|
+
return new StaticImage(img, "DrawImage.png", "image/png");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
50
213
|
export class EXIFItem
|
|
51
214
|
{
|
|
52
215
|
constructor(id, type, data)
|
|
@@ -4039,6 +4202,11 @@ export class EXIFData
|
|
|
4039
4202
|
|
|
4040
4203
|
export class StaticImage extends data.ParsedObject
|
|
4041
4204
|
{
|
|
4205
|
+
/**
|
|
4206
|
+
* @param {HTMLImageElement} img
|
|
4207
|
+
* @param {string} sourceName
|
|
4208
|
+
* @param {string} objType MIME
|
|
4209
|
+
*/
|
|
4042
4210
|
constructor(img, sourceName, objType)
|
|
4043
4211
|
{
|
|
4044
4212
|
super(sourceName, objType);
|
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 = {};
|
package/package.json
CHANGED
package/web.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as data from "./data.js";
|
|
2
|
+
import * as media from "./media.js";
|
|
2
3
|
import * as text from "./text.js";
|
|
3
4
|
|
|
4
5
|
export const OSType = {
|
|
@@ -149,13 +150,18 @@ export function buildTable(o)
|
|
|
149
150
|
ret.push("<tr>");
|
|
150
151
|
for (name in o[0])
|
|
151
152
|
{
|
|
152
|
-
|
|
153
|
+
let thisObj = obj[name];
|
|
154
|
+
if (thisObj instanceof media.StaticImage)
|
|
153
155
|
{
|
|
154
|
-
ret.push("<td
|
|
156
|
+
ret.push("<td><img src="+text.toAttrText(thisObj.img.src)+"/></td>");
|
|
157
|
+
}
|
|
158
|
+
else if (typeof thisObj == "object")
|
|
159
|
+
{
|
|
160
|
+
ret.push("<td>"+text.toHTMLText(JSON.stringify(thisObj))+"</td>");
|
|
155
161
|
}
|
|
156
162
|
else
|
|
157
163
|
{
|
|
158
|
-
ret.push("<td>"+text.toHTMLText(""+
|
|
164
|
+
ret.push("<td>"+text.toHTMLText(""+thisObj)+"</td>");
|
|
159
165
|
}
|
|
160
166
|
}
|
|
161
167
|
ret.push("</tr>");
|