@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/Changelog +20 -0
- package/cert.d.ts +55 -53
- package/cert.js +733 -134
- package/certutil.d.ts +11 -11
- package/certutil.js +11 -6
- package/data.d.ts +29 -1
- package/data.js +152 -24
- package/geometry.d.ts +11 -3
- package/geometry.js +110 -17
- package/hash.js +7 -2
- package/kml.d.ts +1 -1
- package/kml.js +46 -4
- package/leaflet.d.ts +2 -2
- package/leaflet.js +48 -4
- package/map.js +11 -0
- package/math.d.ts +1 -1
- package/math.js +361 -29
- package/media.d.ts +1 -1
- package/media.js +20 -9
- package/package.json +1 -1
- package/parser.js +30 -9
- package/text.d.ts +1 -1
- package/text.js +2 -2
- package/unit.js +746 -663
- package/web.d.ts +3 -0
- package/web.js +138 -15
package/math.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import * as geometry from "./geometry.js";
|
|
1
2
|
import * as unit from "./unit.js";
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @param {number} n
|
|
6
|
+
* @param {number | undefined} decimalPoints
|
|
7
|
+
*/
|
|
3
8
|
export function roundToFloat(n, decimalPoints)
|
|
4
9
|
{
|
|
5
10
|
if (decimalPoints === undefined) {
|
|
@@ -11,6 +16,10 @@ export function roundToFloat(n, decimalPoints)
|
|
|
11
16
|
return Math.round(n) / multiplicator;
|
|
12
17
|
}
|
|
13
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @param {number} n
|
|
21
|
+
* @param {number | undefined} decimalPoints
|
|
22
|
+
*/
|
|
14
23
|
export function roundToStr(n, decimalPoints)
|
|
15
24
|
{
|
|
16
25
|
if (decimalPoints === undefined) {
|
|
@@ -35,14 +44,20 @@ export function roundToStr(n, decimalPoints)
|
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
export class GeoJSON {
|
|
47
|
+
/**
|
|
48
|
+
* @param {number} srid
|
|
49
|
+
* @param {{ type: string; coordinates: number[][][] | number[][][][] | undefined; }} geom
|
|
50
|
+
*/
|
|
38
51
|
static parseGeometry(srid, geom)
|
|
39
52
|
{
|
|
40
53
|
if (geom.type == "Polygon")
|
|
41
54
|
{
|
|
55
|
+
// @ts-ignore
|
|
42
56
|
return new geometry.Polygon(srid, geom.coordinates);
|
|
43
57
|
}
|
|
44
58
|
else if (geom.type == "MultiPolygon")
|
|
45
59
|
{
|
|
60
|
+
// @ts-ignore
|
|
46
61
|
return new geometry.MultiPolygon(srid, geom.coordinates);
|
|
47
62
|
}
|
|
48
63
|
else
|
|
@@ -55,6 +70,10 @@ export class GeoJSON {
|
|
|
55
70
|
|
|
56
71
|
export class Coord2D
|
|
57
72
|
{
|
|
73
|
+
/**
|
|
74
|
+
* @param {number} x
|
|
75
|
+
* @param {number} y
|
|
76
|
+
*/
|
|
58
77
|
constructor(x, y)
|
|
59
78
|
{
|
|
60
79
|
this.x = x;
|
|
@@ -71,6 +90,9 @@ export class Coord2D
|
|
|
71
90
|
return this.x;
|
|
72
91
|
}
|
|
73
92
|
|
|
93
|
+
/**
|
|
94
|
+
* @param {number} val
|
|
95
|
+
*/
|
|
74
96
|
mul(val)
|
|
75
97
|
{
|
|
76
98
|
return new Coord2D(this.x * val, this.y * val);
|
|
@@ -79,6 +101,12 @@ export class Coord2D
|
|
|
79
101
|
|
|
80
102
|
export class RectArea
|
|
81
103
|
{
|
|
104
|
+
/**
|
|
105
|
+
* @param {number} x1
|
|
106
|
+
* @param {number} y1
|
|
107
|
+
* @param {number} x2
|
|
108
|
+
* @param {number} y2
|
|
109
|
+
*/
|
|
82
110
|
constructor(x1, y1, x2, y2)
|
|
83
111
|
{
|
|
84
112
|
let minX;
|
|
@@ -125,6 +153,10 @@ export class RectArea
|
|
|
125
153
|
return this.max.y;
|
|
126
154
|
}
|
|
127
155
|
|
|
156
|
+
/**
|
|
157
|
+
* @param {number} x
|
|
158
|
+
* @param {number} y
|
|
159
|
+
*/
|
|
128
160
|
containPt(x, y)
|
|
129
161
|
{
|
|
130
162
|
return (x >= this.min.x && x <= this.max.x && y >= this.min.y && y <= this.max.y);
|
|
@@ -150,6 +182,9 @@ export class RectArea
|
|
|
150
182
|
return this.getWidth() * this.getHeight();
|
|
151
183
|
}
|
|
152
184
|
|
|
185
|
+
/**
|
|
186
|
+
* @param {RectArea} rect
|
|
187
|
+
*/
|
|
153
188
|
unionInPlace(rect)
|
|
154
189
|
{
|
|
155
190
|
if (this.min.x > rect.min.x)
|
|
@@ -163,6 +198,10 @@ export class RectArea
|
|
|
163
198
|
return this;
|
|
164
199
|
}
|
|
165
200
|
|
|
201
|
+
/**
|
|
202
|
+
* @param {number} x
|
|
203
|
+
* @param {number} y
|
|
204
|
+
*/
|
|
166
205
|
unionPointInPlace(x, y)
|
|
167
206
|
{
|
|
168
207
|
if (this.min.x > x)
|
|
@@ -179,6 +218,11 @@ export class RectArea
|
|
|
179
218
|
|
|
180
219
|
export class Vector3 extends Coord2D
|
|
181
220
|
{
|
|
221
|
+
/**
|
|
222
|
+
* @param {number} x
|
|
223
|
+
* @param {number} y
|
|
224
|
+
* @param {number} z
|
|
225
|
+
*/
|
|
182
226
|
constructor(x, y, z)
|
|
183
227
|
{
|
|
184
228
|
super(x, y);
|
|
@@ -190,16 +234,26 @@ export class Vector3 extends Coord2D
|
|
|
190
234
|
return this.z;
|
|
191
235
|
}
|
|
192
236
|
|
|
237
|
+
/**
|
|
238
|
+
* @param {number} val
|
|
239
|
+
*/
|
|
193
240
|
mulXY(val)
|
|
194
241
|
{
|
|
195
242
|
return new Vector3(this.x * val, this.y * val, this.z);
|
|
196
243
|
}
|
|
197
244
|
|
|
245
|
+
/**
|
|
246
|
+
* @param {number} val
|
|
247
|
+
*/
|
|
198
248
|
mul(val)
|
|
199
249
|
{
|
|
200
250
|
return new Vector3(this.x * val, this.y * val, this.z * val);
|
|
201
251
|
}
|
|
202
252
|
|
|
253
|
+
/**
|
|
254
|
+
* @param {{ x: any; y: any; }} coord
|
|
255
|
+
* @param {number} z
|
|
256
|
+
*/
|
|
203
257
|
static fromCoord2D(coord, z)
|
|
204
258
|
{
|
|
205
259
|
return new Vector3(coord.x, coord.y, z);
|
|
@@ -237,11 +291,18 @@ export const EarthEllipsoidType = {
|
|
|
237
291
|
|
|
238
292
|
export class EarthEllipsoid
|
|
239
293
|
{
|
|
294
|
+
/**
|
|
295
|
+
* @param {number | null} semiMajorAxis
|
|
296
|
+
* @param {number | null} inverseFlattening
|
|
297
|
+
* @param {number} eet
|
|
298
|
+
*/
|
|
240
299
|
constructor(semiMajorAxis, inverseFlattening, eet)
|
|
241
300
|
{
|
|
242
301
|
this.eet = eet;
|
|
243
302
|
if (semiMajorAxis == null || inverseFlattening == null)
|
|
244
303
|
{
|
|
304
|
+
this.semiMajorAxis = 0;
|
|
305
|
+
this.inverseFlattening = 99999999.0;
|
|
245
306
|
this.initEarthInfo(eet);
|
|
246
307
|
}
|
|
247
308
|
else
|
|
@@ -254,6 +315,13 @@ export class EarthEllipsoid
|
|
|
254
315
|
this.eccentricity = Math.sqrt(2 * f - f * f);
|
|
255
316
|
};
|
|
256
317
|
|
|
318
|
+
/**
|
|
319
|
+
* @param {number} dLat1
|
|
320
|
+
* @param {number} dLon1
|
|
321
|
+
* @param {number} dLat2
|
|
322
|
+
* @param {number} dLon2
|
|
323
|
+
* @param {unit.Distance.Unit | null} distUnit
|
|
324
|
+
*/
|
|
257
325
|
calSurfaceDistance(dLat1, dLon1, dLat2, dLon2, distUnit)
|
|
258
326
|
{
|
|
259
327
|
let r;
|
|
@@ -307,11 +375,17 @@ export class EarthEllipsoid
|
|
|
307
375
|
return this.eccentricity;
|
|
308
376
|
}
|
|
309
377
|
|
|
378
|
+
/**
|
|
379
|
+
* @param {{ semiMajorAxis: any; inverseFlattening: any; }} ellipsoid
|
|
380
|
+
*/
|
|
310
381
|
equals(ellipsoid)
|
|
311
382
|
{
|
|
312
383
|
return ellipsoid.semiMajorAxis == this.semiMajorAxis && ellipsoid.inverseFlattening == this.inverseFlattening;
|
|
313
384
|
}
|
|
314
385
|
|
|
386
|
+
/**
|
|
387
|
+
* @param {number} eet
|
|
388
|
+
*/
|
|
315
389
|
initEarthInfo(eet)
|
|
316
390
|
{
|
|
317
391
|
switch (eet)
|
|
@@ -423,6 +497,9 @@ export class EarthEllipsoid
|
|
|
423
497
|
return;
|
|
424
498
|
}
|
|
425
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* @param {{ lat: number; lon: number; z: number; }} lonLatH
|
|
502
|
+
*/
|
|
426
503
|
toCartesianCoordRad(lonLatH)
|
|
427
504
|
{
|
|
428
505
|
let cLat = Math.cos(lonLatH.lat);
|
|
@@ -437,6 +514,9 @@ export class EarthEllipsoid
|
|
|
437
514
|
((1 - e2) * v + lonLatH.z) * sLat);
|
|
438
515
|
}
|
|
439
516
|
|
|
517
|
+
/**
|
|
518
|
+
* @param {{ y: number; x: number; z: number; }} coord
|
|
519
|
+
*/
|
|
440
520
|
fromCartesianCoordRad(coord)
|
|
441
521
|
{
|
|
442
522
|
let e2 = this.eccentricity * this.eccentricity;
|
|
@@ -459,11 +539,17 @@ export class EarthEllipsoid
|
|
|
459
539
|
return new Vector3(rLon, rLat, p / Math.cos(rLat) - v);
|
|
460
540
|
}
|
|
461
541
|
|
|
542
|
+
/**
|
|
543
|
+
* @param {{ mulXY: (arg0: number) => any; }} lonLatH
|
|
544
|
+
*/
|
|
462
545
|
toCartesianCoordDeg(lonLatH)
|
|
463
546
|
{
|
|
464
547
|
return this.toCartesianCoordRad(lonLatH.mulXY(Math.PI / 180.0));
|
|
465
548
|
}
|
|
466
549
|
|
|
550
|
+
/**
|
|
551
|
+
* @param {any} coord
|
|
552
|
+
*/
|
|
467
553
|
fromCartesianCoordDeg(coord)
|
|
468
554
|
{
|
|
469
555
|
return this.fromCartesianCoordRad(coord).mulXY(180.0 / Math.PI);
|
|
@@ -472,6 +558,11 @@ export class EarthEllipsoid
|
|
|
472
558
|
|
|
473
559
|
export class Spheroid
|
|
474
560
|
{
|
|
561
|
+
/**
|
|
562
|
+
* @param {number} srid
|
|
563
|
+
* @param {EarthEllipsoid} ellipsoid
|
|
564
|
+
* @param {string} name
|
|
565
|
+
*/
|
|
475
566
|
constructor(srid, ellipsoid, name)
|
|
476
567
|
{
|
|
477
568
|
this.srid = srid;
|
|
@@ -482,6 +573,22 @@ export class Spheroid
|
|
|
482
573
|
|
|
483
574
|
export class DatumData
|
|
484
575
|
{
|
|
576
|
+
/**
|
|
577
|
+
* @param {number} srid
|
|
578
|
+
* @param {Spheroid} spheroid
|
|
579
|
+
* @param {string} name
|
|
580
|
+
* @param {number} x0
|
|
581
|
+
* @param {number} y0
|
|
582
|
+
* @param {number} z0
|
|
583
|
+
* @param {number} cX
|
|
584
|
+
* @param {number} cY
|
|
585
|
+
* @param {number} cZ
|
|
586
|
+
* @param {number} xAngle
|
|
587
|
+
* @param {number} yAngle
|
|
588
|
+
* @param {number} zAngle
|
|
589
|
+
* @param {number} scale
|
|
590
|
+
* @param {unit.Angle.Unit} aunit
|
|
591
|
+
*/
|
|
485
592
|
constructor(srid, spheroid, name, x0, y0, z0, cX, cY, cZ, xAngle, yAngle, zAngle, scale, aunit)
|
|
486
593
|
{
|
|
487
594
|
this.srid = srid;
|
|
@@ -512,12 +619,55 @@ export const CoordinateSystemType = {
|
|
|
512
619
|
|
|
513
620
|
export class CoordinateSystem
|
|
514
621
|
{
|
|
622
|
+
/**
|
|
623
|
+
* @param {number} srid
|
|
624
|
+
* @param {string} csysName
|
|
625
|
+
*/
|
|
515
626
|
constructor(srid, csysName)
|
|
516
627
|
{
|
|
628
|
+
if(this.constructor == CoordinateSystem) {
|
|
629
|
+
throw new Error("Class is of abstract type and can't be instantiated");
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
if(this.getCoordSysType == undefined) {
|
|
633
|
+
throw new Error("getCoordSysType method must be implemented");
|
|
634
|
+
};
|
|
517
635
|
this.srid = srid;
|
|
518
636
|
this.csysName = csysName;
|
|
519
637
|
}
|
|
520
638
|
|
|
639
|
+
/**
|
|
640
|
+
* @param {number} x1
|
|
641
|
+
* @param {number} y1
|
|
642
|
+
* @param {number} x2
|
|
643
|
+
* @param {number} y2
|
|
644
|
+
* @param {unit.Distance.Unit} distUnit
|
|
645
|
+
* @returns {number}
|
|
646
|
+
*/
|
|
647
|
+
calcSurfaceDistance(x1, y1, x2, y2, distUnit)
|
|
648
|
+
{
|
|
649
|
+
throw new Error("Calling abstract method CoordinateSystem.calcSurfaceDistance");
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* @returns {number}
|
|
654
|
+
*/
|
|
655
|
+
getCoordSysType()
|
|
656
|
+
{
|
|
657
|
+
throw new Error("Calling abstract method CoordinateSystem.getCoordSysType");
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* @returns {boolean}
|
|
662
|
+
*/
|
|
663
|
+
isProjected()
|
|
664
|
+
{
|
|
665
|
+
throw new Error("Calling abstract method CoordinateSystem.isProjected");
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* @param {CoordinateSystem} csys
|
|
670
|
+
*/
|
|
521
671
|
equals(csys)
|
|
522
672
|
{
|
|
523
673
|
if (this == csys)
|
|
@@ -526,66 +676,107 @@ export class CoordinateSystem
|
|
|
526
676
|
let csysType = csys.getCoordSysType();
|
|
527
677
|
if (thisType != csysType)
|
|
528
678
|
return false;
|
|
529
|
-
if (csysType == CoordinateSystemType.Geographic)
|
|
679
|
+
if (csysType == CoordinateSystemType.Geographic && (this instanceof GeographicCoordinateSystem) && (csys instanceof GeographicCoordinateSystem))
|
|
530
680
|
{
|
|
531
681
|
return this.getEllipsoid().equals(csys.getEllipsoid());
|
|
532
682
|
}
|
|
533
|
-
else if (
|
|
683
|
+
else if (csysType == CoordinateSystemType.PointMapping)
|
|
534
684
|
{
|
|
535
685
|
return false;
|
|
536
686
|
}
|
|
537
|
-
else
|
|
687
|
+
else if ((this instanceof ProjectedCoordinateSystem) && (csys instanceof ProjectedCoordinateSystem))
|
|
538
688
|
{
|
|
539
689
|
return this.sameProjection(csys);
|
|
540
690
|
}
|
|
691
|
+
else
|
|
692
|
+
{
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
541
695
|
}
|
|
542
696
|
|
|
697
|
+
/**
|
|
698
|
+
* @param {CoordinateSystem} srcCoord
|
|
699
|
+
* @param {CoordinateSystem} destCoord
|
|
700
|
+
* @param {Coord2D} coord
|
|
701
|
+
*/
|
|
543
702
|
static convert(srcCoord, destCoord, coord)
|
|
544
703
|
{
|
|
545
704
|
return CoordinateSystem.convert3D(srcCoord, destCoord, Vector3.fromCoord2D(coord, 0));
|
|
546
705
|
}
|
|
547
706
|
|
|
707
|
+
/**
|
|
708
|
+
* @param {CoordinateSystem} srcCoord
|
|
709
|
+
* @param {CoordinateSystem} destCoord
|
|
710
|
+
* @param {Vector3} srcPos
|
|
711
|
+
*/
|
|
548
712
|
static convert3D(srcCoord, destCoord, srcPos)
|
|
549
713
|
{
|
|
550
|
-
|
|
714
|
+
let srcGCsys;
|
|
715
|
+
if (srcCoord instanceof ProjectedCoordinateSystem)
|
|
551
716
|
{
|
|
552
717
|
srcPos = Vector3.fromCoord2D(srcCoord.toGeographicCoordinateDeg(srcPos), srcPos.z);
|
|
553
|
-
|
|
718
|
+
srcGCsys = srcCoord.getGeographicCoordinateSystem();
|
|
719
|
+
}
|
|
720
|
+
else if (srcCoord instanceof GeographicCoordinateSystem)
|
|
721
|
+
{
|
|
722
|
+
srcGCsys = srcCoord;
|
|
723
|
+
}
|
|
724
|
+
else
|
|
725
|
+
{
|
|
726
|
+
throw new Error("Unsupported coordinate system in srcCoord");
|
|
554
727
|
}
|
|
555
|
-
if (
|
|
728
|
+
if (srcGCsys.equals(destCoord))
|
|
556
729
|
{
|
|
557
730
|
return srcPos;
|
|
558
731
|
}
|
|
559
|
-
srcPos =
|
|
732
|
+
srcPos = srcGCsys.toCartesianCoordDeg(srcPos);
|
|
560
733
|
|
|
561
|
-
if (destCoord
|
|
734
|
+
if (destCoord instanceof ProjectedCoordinateSystem)
|
|
562
735
|
{
|
|
563
736
|
let gcs = destCoord.getGeographicCoordinateSystem();
|
|
564
737
|
srcPos = gcs.fromCartesianCoordRad(srcPos);
|
|
565
738
|
return Vector3.fromCoord2D(destCoord.fromGeographicCoordinateRad(srcPos), srcPos.z);
|
|
566
739
|
}
|
|
567
|
-
else
|
|
740
|
+
else if (destCoord instanceof GeographicCoordinateSystem)
|
|
568
741
|
{
|
|
569
742
|
return destCoord.fromCartesianCoordDeg(srcPos);
|
|
570
743
|
}
|
|
744
|
+
else
|
|
745
|
+
{
|
|
746
|
+
throw new Error("Unsupported coordinate system in destCoord");
|
|
747
|
+
}
|
|
571
748
|
}
|
|
572
749
|
|
|
750
|
+
/**
|
|
751
|
+
* @param {CoordinateSystem} srcCoord
|
|
752
|
+
* @param {CoordinateSystem} destCoord
|
|
753
|
+
* @param {Coord2D[]} srcArr
|
|
754
|
+
*/
|
|
573
755
|
static convertArray(srcCoord, destCoord, srcArr)
|
|
574
756
|
{
|
|
575
757
|
let i;
|
|
576
758
|
let srcRad = false;
|
|
577
759
|
let destArr = [];
|
|
578
|
-
|
|
760
|
+
let srcGCsys;
|
|
761
|
+
if (srcCoord instanceof ProjectedCoordinateSystem)
|
|
579
762
|
{
|
|
580
763
|
for (i in srcArr)
|
|
581
764
|
{
|
|
582
765
|
destArr[i] = srcCoord.toGeographicCoordinateRad(srcArr[i]);
|
|
583
766
|
}
|
|
584
|
-
|
|
767
|
+
srcGCsys = srcCoord.getGeographicCoordinateSystem();
|
|
585
768
|
srcArr = destArr;
|
|
586
769
|
srcRad = true;
|
|
587
770
|
}
|
|
588
|
-
if (srcCoord
|
|
771
|
+
else if (srcCoord instanceof GeographicCoordinateSystem)
|
|
772
|
+
{
|
|
773
|
+
srcGCsys = srcCoord;
|
|
774
|
+
}
|
|
775
|
+
else
|
|
776
|
+
{
|
|
777
|
+
throw new Error("Unsupported coordinate system in srcCoord");
|
|
778
|
+
}
|
|
779
|
+
if (srcGCsys.equals(destCoord))
|
|
589
780
|
{
|
|
590
781
|
if (srcRad)
|
|
591
782
|
{
|
|
@@ -604,14 +795,14 @@ export class CoordinateSystem
|
|
|
604
795
|
return destArr;
|
|
605
796
|
}
|
|
606
797
|
let tmpPos;
|
|
607
|
-
if (destCoord
|
|
798
|
+
if (destCoord instanceof ProjectedCoordinateSystem)
|
|
608
799
|
{
|
|
609
800
|
let gcs = destCoord.getGeographicCoordinateSystem();
|
|
610
801
|
if (srcRad)
|
|
611
802
|
{
|
|
612
803
|
for (i in srcArr)
|
|
613
804
|
{
|
|
614
|
-
tmpPos =
|
|
805
|
+
tmpPos = srcGCsys.toCartesianCoordRad(Vector3.fromCoord2D(srcArr[i], 0));
|
|
615
806
|
tmpPos = gcs.fromCartesianCoordRad(tmpPos);
|
|
616
807
|
destArr[i] = destCoord.fromGeographicCoordinateRad(tmpPos);
|
|
617
808
|
}
|
|
@@ -620,35 +811,42 @@ export class CoordinateSystem
|
|
|
620
811
|
{
|
|
621
812
|
for (i in srcArr)
|
|
622
813
|
{
|
|
623
|
-
tmpPos =
|
|
814
|
+
tmpPos = srcGCsys.toCartesianCoordDeg(Vector3.fromCoord2D(srcArr[i], 0));
|
|
624
815
|
tmpPos = gcs.fromCartesianCoordRad(tmpPos);
|
|
625
|
-
destArr[i] = destCoord.
|
|
816
|
+
destArr[i] = destCoord.fromGeographicCoordinateRad(tmpPos);
|
|
626
817
|
}
|
|
627
818
|
}
|
|
628
819
|
}
|
|
629
|
-
else
|
|
820
|
+
else if (destCoord instanceof GeographicCoordinateSystem)
|
|
630
821
|
{
|
|
631
822
|
if (srcRad)
|
|
632
823
|
{
|
|
633
824
|
for (i in srcArr)
|
|
634
825
|
{
|
|
635
|
-
tmpPos =
|
|
826
|
+
tmpPos = srcGCsys.toCartesianCoordRad(Vector3.fromCoord2D(srcArr[i], 0));
|
|
636
827
|
destArr[i] = destCoord.fromCartesianCoordDeg(tmpPos);
|
|
637
828
|
}
|
|
638
829
|
}
|
|
639
830
|
else
|
|
640
831
|
{
|
|
641
|
-
i
|
|
642
|
-
while (i-- > 0)
|
|
832
|
+
for (i in srcArr)
|
|
643
833
|
{
|
|
644
|
-
tmpPos =
|
|
834
|
+
tmpPos = srcGCsys.toCartesianCoordDeg(Vector3.fromCoord2D(srcArr[i], 0));
|
|
645
835
|
destArr[i] = destCoord.fromCartesianCoordDeg(tmpPos);
|
|
646
836
|
}
|
|
647
837
|
}
|
|
648
838
|
}
|
|
839
|
+
else
|
|
840
|
+
{
|
|
841
|
+
throw new Error("Unsupported coordinate system in destCoord");
|
|
842
|
+
}
|
|
649
843
|
return destArr;
|
|
650
844
|
}
|
|
651
845
|
|
|
846
|
+
/**
|
|
847
|
+
* @param {{ isProjected: () => any; toGeographicCoordinateDeg: (arg0: any) => any; getGeographicCoordinateSystem: () => any; toCartesianCoordDeg: (arg0: any) => any; }} srcCoord
|
|
848
|
+
* @param {Vector3} srcPos
|
|
849
|
+
*/
|
|
652
850
|
static convertToCartesianCoord(srcCoord, srcPos)
|
|
653
851
|
{
|
|
654
852
|
if (srcCoord.isProjected())
|
|
@@ -662,12 +860,24 @@ export class CoordinateSystem
|
|
|
662
860
|
|
|
663
861
|
export class GeographicCoordinateSystem extends CoordinateSystem
|
|
664
862
|
{
|
|
863
|
+
/**
|
|
864
|
+
* @param {number} srid
|
|
865
|
+
* @param {string} csysName
|
|
866
|
+
* @param {DatumData} datumData
|
|
867
|
+
*/
|
|
665
868
|
constructor(srid, csysName, datumData)
|
|
666
869
|
{
|
|
667
870
|
super(srid, csysName);
|
|
668
871
|
this.datum = datumData;
|
|
669
872
|
}
|
|
670
873
|
|
|
874
|
+
/**
|
|
875
|
+
* @param {number} x1
|
|
876
|
+
* @param {number} y1
|
|
877
|
+
* @param {number} x2
|
|
878
|
+
* @param {number} y2
|
|
879
|
+
* @param {unit.Distance.Unit} unit
|
|
880
|
+
*/
|
|
671
881
|
calcSurfaceDistance(x1, y1, x2, y2, unit)
|
|
672
882
|
{
|
|
673
883
|
return this.datum.spheroid.ellipsoid.calSurfaceDistance(y1, x1, y2, x2, unit);
|
|
@@ -688,6 +898,9 @@ export class GeographicCoordinateSystem extends CoordinateSystem
|
|
|
688
898
|
return this.datum.spheroid.ellipsoid;
|
|
689
899
|
}
|
|
690
900
|
|
|
901
|
+
/**
|
|
902
|
+
* @param {Vector3} lonLatH
|
|
903
|
+
*/
|
|
691
904
|
toCartesianCoordRad(lonLatH)
|
|
692
905
|
{
|
|
693
906
|
let tmpPos = this.datum.spheroid.ellipsoid.toCartesianCoordRad(lonLatH);
|
|
@@ -711,6 +924,9 @@ export class GeographicCoordinateSystem extends CoordinateSystem
|
|
|
711
924
|
}
|
|
712
925
|
}
|
|
713
926
|
|
|
927
|
+
/**
|
|
928
|
+
* @param {{ x: number; y: number; z: number; }} coord
|
|
929
|
+
*/
|
|
714
930
|
fromCartesianCoordRad(coord)
|
|
715
931
|
{
|
|
716
932
|
let tmpPos;
|
|
@@ -735,11 +951,17 @@ export class GeographicCoordinateSystem extends CoordinateSystem
|
|
|
735
951
|
return this.datum.spheroid.ellipsoid.fromCartesianCoordRad(tmpPos);
|
|
736
952
|
}
|
|
737
953
|
|
|
954
|
+
/**
|
|
955
|
+
* @param {{ mulXY: (arg0: number) => any; }} lonLatH
|
|
956
|
+
*/
|
|
738
957
|
toCartesianCoordDeg(lonLatH)
|
|
739
958
|
{
|
|
740
959
|
return this.toCartesianCoordRad(lonLatH.mulXY(Math.PI / 180.0));
|
|
741
960
|
}
|
|
742
961
|
|
|
962
|
+
/**
|
|
963
|
+
* @param {any} coord
|
|
964
|
+
*/
|
|
743
965
|
fromCartesianCoordDeg(coord)
|
|
744
966
|
{
|
|
745
967
|
return this.fromCartesianCoordRad(coord).mulXY(180.0 / Math.PI);
|
|
@@ -748,6 +970,16 @@ export class GeographicCoordinateSystem extends CoordinateSystem
|
|
|
748
970
|
|
|
749
971
|
export class ProjectedCoordinateSystem extends CoordinateSystem
|
|
750
972
|
{
|
|
973
|
+
/**
|
|
974
|
+
* @param {number} srid
|
|
975
|
+
* @param {string} csysName
|
|
976
|
+
* @param {number} falseEasting
|
|
977
|
+
* @param {number} falseNorthing
|
|
978
|
+
* @param {number} dcentralMeridian
|
|
979
|
+
* @param {number} dlatitudeOfOrigin
|
|
980
|
+
* @param {number} scaleFactor
|
|
981
|
+
* @param {GeographicCoordinateSystem} gcs
|
|
982
|
+
*/
|
|
751
983
|
constructor(srid, csysName, falseEasting, falseNorthing, dcentralMeridian, dlatitudeOfOrigin, scaleFactor, gcs)
|
|
752
984
|
{
|
|
753
985
|
super(srid, csysName);
|
|
@@ -759,6 +991,31 @@ export class ProjectedCoordinateSystem extends CoordinateSystem
|
|
|
759
991
|
this.gcs = gcs;
|
|
760
992
|
}
|
|
761
993
|
|
|
994
|
+
/**
|
|
995
|
+
* @param {Coord2D} projPos
|
|
996
|
+
* @returns {Coord2D}
|
|
997
|
+
*/
|
|
998
|
+
toGeographicCoordinateRad(projPos)
|
|
999
|
+
{
|
|
1000
|
+
throw new Error("abstract function ProjectedCoordinateSystem.toGeographicCoordinateRad is called");
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* @param {Coord2D} geogPos
|
|
1005
|
+
* @returns {Coord2D}
|
|
1006
|
+
*/
|
|
1007
|
+
fromGeographicCoordinateRad(geogPos)
|
|
1008
|
+
{
|
|
1009
|
+
throw new Error("abstract function ProjectedCoordinateSystem.fromGeographicCoordinateRad is called");
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* @param {number} x1
|
|
1014
|
+
* @param {number} y1
|
|
1015
|
+
* @param {number} x2
|
|
1016
|
+
* @param {number} y2
|
|
1017
|
+
* @param {unit.Distance.Unit} distUnit
|
|
1018
|
+
*/
|
|
762
1019
|
calcSurfaceDistance(x1, y1, x2, y2, distUnit)
|
|
763
1020
|
{
|
|
764
1021
|
let diffX = x2 - x1;
|
|
@@ -783,16 +1040,25 @@ export class ProjectedCoordinateSystem extends CoordinateSystem
|
|
|
783
1040
|
return this.gcs;
|
|
784
1041
|
}
|
|
785
1042
|
|
|
1043
|
+
/**
|
|
1044
|
+
* @param {Coord2D} projPos
|
|
1045
|
+
*/
|
|
786
1046
|
toGeographicCoordinateDeg(projPos)
|
|
787
1047
|
{
|
|
788
1048
|
return this.toGeographicCoordinateRad(projPos).mul(180 / Math.PI);
|
|
789
1049
|
}
|
|
790
1050
|
|
|
1051
|
+
/**
|
|
1052
|
+
* @param {Coord2D} geoPos
|
|
1053
|
+
*/
|
|
791
1054
|
fromGeographicCoordinateDeg(geoPos)
|
|
792
1055
|
{
|
|
793
1056
|
return this.fromGeographicCoordinateRad(geoPos.mul(Math.PI / 180.0));
|
|
794
1057
|
}
|
|
795
1058
|
|
|
1059
|
+
/**
|
|
1060
|
+
* @param {ProjectedCoordinateSystem} csys
|
|
1061
|
+
*/
|
|
796
1062
|
sameProjection(csys)
|
|
797
1063
|
{
|
|
798
1064
|
if (this.falseEasting != csys.falseEasting)
|
|
@@ -811,6 +1077,16 @@ export class ProjectedCoordinateSystem extends CoordinateSystem
|
|
|
811
1077
|
|
|
812
1078
|
export class MercatorProjectedCoordinateSystem extends ProjectedCoordinateSystem
|
|
813
1079
|
{
|
|
1080
|
+
/**
|
|
1081
|
+
* @param {number} srid
|
|
1082
|
+
* @param {string} csysName
|
|
1083
|
+
* @param {number} falseEasting
|
|
1084
|
+
* @param {number} falseNorthing
|
|
1085
|
+
* @param {number} dcentralMeridian
|
|
1086
|
+
* @param {number} dlatitudeOfOrigin
|
|
1087
|
+
* @param {number} scaleFactor
|
|
1088
|
+
* @param {GeographicCoordinateSystem} gcs
|
|
1089
|
+
*/
|
|
814
1090
|
constructor(srid, csysName, falseEasting, falseNorthing, dcentralMeridian, dlatitudeOfOrigin, scaleFactor, gcs)
|
|
815
1091
|
{
|
|
816
1092
|
super(srid, csysName, falseEasting, falseNorthing, dcentralMeridian, dlatitudeOfOrigin, scaleFactor, gcs);
|
|
@@ -821,6 +1097,9 @@ export class MercatorProjectedCoordinateSystem extends ProjectedCoordinateSystem
|
|
|
821
1097
|
return CoordinateSystemType.MercatorProjected;
|
|
822
1098
|
}
|
|
823
1099
|
|
|
1100
|
+
/**
|
|
1101
|
+
* @param {Coord2D} projPos
|
|
1102
|
+
*/
|
|
824
1103
|
toGeographicCoordinateRad(projPos)
|
|
825
1104
|
{
|
|
826
1105
|
let ellipsoid = this.gcs.getEllipsoid();
|
|
@@ -870,6 +1149,9 @@ export class MercatorProjectedCoordinateSystem extends ProjectedCoordinateSystem
|
|
|
870
1149
|
rLatL - ser7 * eDiff2 + ser8 * eDiff4 - ser9 * eDiff6);
|
|
871
1150
|
}
|
|
872
1151
|
|
|
1152
|
+
/**
|
|
1153
|
+
* @param {Coord2D} geoPos
|
|
1154
|
+
*/
|
|
873
1155
|
fromGeographicCoordinateRad(geoPos)
|
|
874
1156
|
{
|
|
875
1157
|
let ellipsoid = this.gcs.getEllipsoid();
|
|
@@ -907,6 +1189,9 @@ export class MercatorProjectedCoordinateSystem extends ProjectedCoordinateSystem
|
|
|
907
1189
|
ser1 + ser2 * dlon2 + ser3 * dlon4 + ser3a * dlon4 * dlon2);
|
|
908
1190
|
}
|
|
909
1191
|
|
|
1192
|
+
/**
|
|
1193
|
+
* @param {number} rLat
|
|
1194
|
+
*/
|
|
910
1195
|
calcM(rLat)
|
|
911
1196
|
{
|
|
912
1197
|
let ellipsoid = this.gcs.getEllipsoid();
|
|
@@ -928,6 +1213,16 @@ export class MercatorProjectedCoordinateSystem extends ProjectedCoordinateSystem
|
|
|
928
1213
|
|
|
929
1214
|
export class Mercator1SPProjectedCoordinateSystem extends ProjectedCoordinateSystem
|
|
930
1215
|
{
|
|
1216
|
+
/**
|
|
1217
|
+
* @param {number} srid
|
|
1218
|
+
* @param {string} csysName
|
|
1219
|
+
* @param {number} falseEasting
|
|
1220
|
+
* @param {number} falseNorthing
|
|
1221
|
+
* @param {number} dcentralMeridian
|
|
1222
|
+
* @param {number} dlatitudeOfOrigin
|
|
1223
|
+
* @param {number} scaleFactor
|
|
1224
|
+
* @param {GeographicCoordinateSystem} gcs
|
|
1225
|
+
*/
|
|
931
1226
|
constructor(srid, csysName, falseEasting, falseNorthing, dcentralMeridian, dlatitudeOfOrigin, scaleFactor, gcs)
|
|
932
1227
|
{
|
|
933
1228
|
super(srid, csysName, falseEasting, falseNorthing, dcentralMeridian, dlatitudeOfOrigin, scaleFactor, gcs);
|
|
@@ -938,6 +1233,9 @@ export class Mercator1SPProjectedCoordinateSystem extends ProjectedCoordinateSys
|
|
|
938
1233
|
return CoordinateSystemType.Mercator1SPProjected;
|
|
939
1234
|
}
|
|
940
1235
|
|
|
1236
|
+
/**
|
|
1237
|
+
* @param {Coord2D} projPos
|
|
1238
|
+
*/
|
|
941
1239
|
toGeographicCoordinateRad(projPos)
|
|
942
1240
|
{
|
|
943
1241
|
let ellipsoid = this.gcs.getEllipsoid();
|
|
@@ -947,6 +1245,9 @@ export class Mercator1SPProjectedCoordinateSystem extends ProjectedCoordinateSys
|
|
|
947
1245
|
(Math.atan(Math.exp((projPos.y - this.falseNorthing) / a)) - Math.PI * 0.25) * 2);
|
|
948
1246
|
}
|
|
949
1247
|
|
|
1248
|
+
/**
|
|
1249
|
+
* @param {Coord2D} geoPos
|
|
1250
|
+
*/
|
|
950
1251
|
fromGeographicCoordinateRad(geoPos)
|
|
951
1252
|
{
|
|
952
1253
|
let ellipsoid = this.gcs.getEllipsoid();
|
|
@@ -962,6 +1263,11 @@ export class Mercator1SPProjectedCoordinateSystem extends ProjectedCoordinateSys
|
|
|
962
1263
|
|
|
963
1264
|
export class CoordinateSystemManager
|
|
964
1265
|
{
|
|
1266
|
+
/**
|
|
1267
|
+
* @param {number} srid
|
|
1268
|
+
* @param {number} datumSrid
|
|
1269
|
+
* @param {string} name
|
|
1270
|
+
*/
|
|
965
1271
|
static srCreateGeogCSysData(srid, datumSrid, name)
|
|
966
1272
|
{
|
|
967
1273
|
let data = this.srGetDatumData(datumSrid);
|
|
@@ -972,9 +1278,20 @@ export class CoordinateSystemManager
|
|
|
972
1278
|
return new GeographicCoordinateSystem(srid, name, data);
|
|
973
1279
|
}
|
|
974
1280
|
|
|
1281
|
+
/**
|
|
1282
|
+
* @param {number} srid
|
|
1283
|
+
* @param {number} geogcsSrid
|
|
1284
|
+
* @param {number} csysType
|
|
1285
|
+
* @param {string} projName
|
|
1286
|
+
* @param {number} falseEasting
|
|
1287
|
+
* @param {number} falseNorthing
|
|
1288
|
+
* @param {number} centralMeridian
|
|
1289
|
+
* @param {number} latitudeOfOrigin
|
|
1290
|
+
* @param {number} scaleFactor
|
|
1291
|
+
*/
|
|
975
1292
|
static srCreateProjCSysData(srid, geogcsSrid, csysType, projName, falseEasting, falseNorthing, centralMeridian, latitudeOfOrigin, scaleFactor)
|
|
976
1293
|
{
|
|
977
|
-
let gcsys =
|
|
1294
|
+
let gcsys = CoordinateSystemManager.srCreateGeogCSys(geogcsSrid);
|
|
978
1295
|
if (gcsys == null)
|
|
979
1296
|
return null;
|
|
980
1297
|
if (csysType == CoordinateSystemType.MercatorProjected || csysType == CoordinateSystemType.GausskrugerProjected)
|
|
@@ -988,6 +1305,9 @@ export class CoordinateSystemManager
|
|
|
988
1305
|
return null;
|
|
989
1306
|
}
|
|
990
1307
|
|
|
1308
|
+
/**
|
|
1309
|
+
* @param {number} srid
|
|
1310
|
+
*/
|
|
991
1311
|
static srCreateGeogCSys(srid)
|
|
992
1312
|
{
|
|
993
1313
|
switch (srid)
|
|
@@ -1002,6 +1322,9 @@ export class CoordinateSystemManager
|
|
|
1002
1322
|
}
|
|
1003
1323
|
}
|
|
1004
1324
|
|
|
1325
|
+
/**
|
|
1326
|
+
* @param {number} srid
|
|
1327
|
+
*/
|
|
1005
1328
|
static srCreateProjCSys(srid)
|
|
1006
1329
|
{
|
|
1007
1330
|
switch (srid)
|
|
@@ -1017,6 +1340,9 @@ export class CoordinateSystemManager
|
|
|
1017
1340
|
return null;
|
|
1018
1341
|
}
|
|
1019
1342
|
}
|
|
1343
|
+
/**
|
|
1344
|
+
* @param {number} srid
|
|
1345
|
+
*/
|
|
1020
1346
|
static srCreateCsys(srid)
|
|
1021
1347
|
{
|
|
1022
1348
|
switch (srid)
|
|
@@ -1035,26 +1361,32 @@ export class CoordinateSystemManager
|
|
|
1035
1361
|
}
|
|
1036
1362
|
}
|
|
1037
1363
|
|
|
1364
|
+
/**
|
|
1365
|
+
* @param {number} srid
|
|
1366
|
+
*/
|
|
1038
1367
|
static srGetDatumData(srid)
|
|
1039
1368
|
{
|
|
1040
1369
|
switch (srid)
|
|
1041
1370
|
{
|
|
1042
1371
|
case 6326:
|
|
1043
|
-
return new DatumData(6326,
|
|
1372
|
+
return new DatumData(6326, CoordinateSystemManager.srGetSpheroid(7030), "WGS_1984", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, unit.Angle.Unit.RADIAN);
|
|
1044
1373
|
case 6600:
|
|
1045
|
-
return new DatumData(6600,
|
|
1374
|
+
return new DatumData(6600, CoordinateSystemManager.srGetSpheroid(7012), "Anguilla_1957", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, unit.Angle.Unit.RADIAN);
|
|
1046
1375
|
case 6601:
|
|
1047
|
-
return new DatumData(6601,
|
|
1376
|
+
return new DatumData(6601, CoordinateSystemManager.srGetSpheroid(7012), "Antigua_1943", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, unit.Angle.Unit.RADIAN);
|
|
1048
1377
|
case 6602:
|
|
1049
|
-
return new DatumData(6602,
|
|
1378
|
+
return new DatumData(6602, CoordinateSystemManager.srGetSpheroid(7012), "Dominica_1945", 0, 0, 0, 725, 685, 536, 0, 0, 0, 0, unit.Angle.Unit.ARCSECOND);
|
|
1050
1379
|
case 6603:
|
|
1051
|
-
return new DatumData(6603,
|
|
1380
|
+
return new DatumData(6603, CoordinateSystemManager.srGetSpheroid(7012), "Grenada_1953", 0, 0, 0, 72, 213.7, 93, 0, 0, 0, 0, unit.Angle.Unit.ARCSECOND);
|
|
1052
1381
|
case 6611:
|
|
1053
|
-
return new DatumData(6611,
|
|
1382
|
+
return new DatumData(6611, CoordinateSystemManager.srGetSpheroid(7022), "Hong_Kong_1980", 0, 0, 0, -162.619, -276.959, -161.764, 0.067753, -2.24365, -1.15883, -1.09425, unit.Angle.Unit.ARCSECOND);
|
|
1054
1383
|
}
|
|
1055
1384
|
return null;
|
|
1056
1385
|
}
|
|
1057
1386
|
|
|
1387
|
+
/**
|
|
1388
|
+
* @param {number} srid
|
|
1389
|
+
*/
|
|
1058
1390
|
static srGetSpheroid(srid)
|
|
1059
1391
|
{
|
|
1060
1392
|
switch (srid)
|
|
@@ -1066,6 +1398,6 @@ export class CoordinateSystemManager
|
|
|
1066
1398
|
case 7030:
|
|
1067
1399
|
return new Spheroid(7030, new EarthEllipsoid(null, null, EarthEllipsoidType.WGS84), "WGS 84");
|
|
1068
1400
|
}
|
|
1069
|
-
|
|
1401
|
+
throw new Error("Unsupported srid: "+srid);
|
|
1070
1402
|
}
|
|
1071
1403
|
};
|