@sswroom/sswr 1.6.17 → 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 +7 -0
- package/geometry.d.ts +1 -1
- package/geometry.js +14 -14
- package/math.d.ts +2 -0
- package/math.js +24 -3
- package/media.d.ts +18 -0
- package/media.js +168 -0
- package/package.json +1 -1
- package/web.js +9 -3
package/Changelog
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
1.6.17
|
|
2
9
|
-Fixed olayer2 types
|
|
3
10
|
-Added vector2D.hasArea
|
package/geometry.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export class LinearRing extends LineString
|
|
|
82
82
|
hasArea(): boolean;
|
|
83
83
|
getDisplayCenter(): math.Coord2D;
|
|
84
84
|
|
|
85
|
-
static
|
|
85
|
+
static getIntersactsCenter(vals: number[]): number;
|
|
86
86
|
static createFromCircle(srid: number, center: math.Coord2D, radiusX: number, radiusY: number, nPoints: number): LinearRing;
|
|
87
87
|
}
|
|
88
88
|
|
package/geometry.js
CHANGED
|
@@ -504,42 +504,42 @@ export class LinearRing extends LineString
|
|
|
504
504
|
throw new Error("No intersact point in middle y");
|
|
505
505
|
}
|
|
506
506
|
xList.sort();
|
|
507
|
-
let x = LinearRing.
|
|
507
|
+
let x = LinearRing.getIntersactsCenter(xList);
|
|
508
508
|
return new math.Coord2D(xList[xList.length >> 1], pt.y);
|
|
509
509
|
}
|
|
510
510
|
|
|
511
511
|
/**
|
|
512
|
-
* @param {number[]}
|
|
512
|
+
* @param {number[]} vals
|
|
513
513
|
*/
|
|
514
|
-
static
|
|
514
|
+
static getIntersactsCenter(vals)
|
|
515
515
|
{
|
|
516
|
-
if (
|
|
516
|
+
if (vals.length == 0)
|
|
517
517
|
{
|
|
518
|
-
throw new Error("
|
|
518
|
+
throw new Error("vals is empty");
|
|
519
519
|
}
|
|
520
|
-
if ((
|
|
520
|
+
if ((vals.length & 1) != 0)
|
|
521
521
|
{
|
|
522
|
-
throw new Error("
|
|
522
|
+
throw new Error("vals length must be even number");
|
|
523
523
|
}
|
|
524
524
|
let totalLength = 0;
|
|
525
525
|
let leng;
|
|
526
|
-
let i =
|
|
526
|
+
let i = vals.length;
|
|
527
527
|
while (i > 0)
|
|
528
528
|
{
|
|
529
529
|
i -= 2;
|
|
530
|
-
totalLength +=
|
|
530
|
+
totalLength += vals[i + 1] - vals[i];
|
|
531
531
|
}
|
|
532
532
|
totalLength = totalLength * 0.5;
|
|
533
|
-
i =
|
|
533
|
+
i = vals.length;
|
|
534
534
|
while (i > 0)
|
|
535
535
|
{
|
|
536
536
|
i -= 2;
|
|
537
|
-
leng =
|
|
537
|
+
leng = vals[i + 1] - vals[i];
|
|
538
538
|
if (totalLength <= leng)
|
|
539
|
-
return
|
|
539
|
+
return vals[i + 1] - totalLength;
|
|
540
540
|
totalLength -= leng;
|
|
541
541
|
}
|
|
542
|
-
return
|
|
542
|
+
return vals[0];
|
|
543
543
|
}
|
|
544
544
|
|
|
545
545
|
/**
|
|
@@ -677,7 +677,7 @@ export class MultiGeometry extends Vector2D
|
|
|
677
677
|
xList.sort();
|
|
678
678
|
if (this.hasArea())
|
|
679
679
|
{
|
|
680
|
-
let x = LinearRing.
|
|
680
|
+
let x = LinearRing.getIntersactsCenter(xList);
|
|
681
681
|
return new math.Coord2D(x, pt.y);
|
|
682
682
|
}
|
|
683
683
|
else
|
package/math.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import * as unit from "./unit";
|
|
|
4
4
|
|
|
5
5
|
export function roundToFloat(n: number, decimalPoints: number): number;
|
|
6
6
|
export function roundToStr(n: number, decimalPoints: number): string;
|
|
7
|
+
export function calcDir(startPt: Coord2D, endPt: Coord2D, ang: unit.Angle.Unit): number;
|
|
8
|
+
|
|
7
9
|
export class GeoJSON
|
|
8
10
|
{
|
|
9
11
|
static parseGeometry(srid: number, geom: map.Geometry): geometry.Vector2D | null;
|
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/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>");
|