@armyc2.c5isr.renderer/mil-sym-ts-web 2.2.0

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.
Files changed (170) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +57 -0
  3. package/buildNode.bat +2 -0
  4. package/buildWeb.bat +2 -0
  5. package/dist/C5Ren.d.ts +6970 -0
  6. package/dist/C5Ren.js +2 -0
  7. package/dist/C5Ren.js.map +1 -0
  8. package/dist/LICENSE +201 -0
  9. package/dist/README.md +57 -0
  10. package/dist/armyc2.c5isr.renderer-mil-sym-ts-web-2.2.0.tgz +0 -0
  11. package/dist/manifest.json +4 -0
  12. package/dist/package.json +16 -0
  13. package/index.ts +169 -0
  14. package/package.bak +50 -0
  15. package/package.json +40 -0
  16. package/package.node.json +43 -0
  17. package/package.pack.json +19 -0
  18. package/package.packWeb.json +16 -0
  19. package/package.web.json +40 -0
  20. package/src/main/ts/android/graphics/Bitmap.ts +7 -0
  21. package/src/main/ts/android/graphics/Paint.ts +26 -0
  22. package/src/main/ts/android/graphics/Path.ts +78 -0
  23. package/src/main/ts/android/graphics/PointF.ts +14 -0
  24. package/src/main/ts/android/graphics/Rect.ts +18 -0
  25. package/src/main/ts/android/graphics/RectF.ts +50 -0
  26. package/src/main/ts/android/graphics/Region.ts +36 -0
  27. package/src/main/ts/android/graphics/Typeface.ts +11 -0
  28. package/src/main/ts/armyc2/c5isr/JavaLineArray/BasicShapes.ts +99 -0
  29. package/src/main/ts/armyc2/c5isr/JavaLineArray/CChannelPoints2.ts +34 -0
  30. package/src/main/ts/armyc2/c5isr/JavaLineArray/CELineArray.ts +193 -0
  31. package/src/main/ts/armyc2/c5isr/JavaLineArray/Channels.ts +2971 -0
  32. package/src/main/ts/armyc2/c5isr/JavaLineArray/DISMSupport.ts +4008 -0
  33. package/src/main/ts/armyc2/c5isr/JavaLineArray/POINT2.ts +93 -0
  34. package/src/main/ts/armyc2/c5isr/JavaLineArray/Shape2.ts +89 -0
  35. package/src/main/ts/armyc2/c5isr/JavaLineArray/TacticalLines.ts +515 -0
  36. package/src/main/ts/armyc2/c5isr/JavaLineArray/arraysupport.ts +5403 -0
  37. package/src/main/ts/armyc2/c5isr/JavaLineArray/countsupport.ts +1084 -0
  38. package/src/main/ts/armyc2/c5isr/JavaLineArray/flot.ts +2173 -0
  39. package/src/main/ts/armyc2/c5isr/JavaLineArray/lineutility.ts +4934 -0
  40. package/src/main/ts/armyc2/c5isr/JavaLineArray/ref.ts +7 -0
  41. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/Modifier2.ts +5601 -0
  42. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/P1.ts +14 -0
  43. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/TGLight.ts +648 -0
  44. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsChannelUtility.ts +647 -0
  45. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsMETOC.ts +2994 -0
  46. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsUtility.ts +2663 -0
  47. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/mdlGeodesic.ts +669 -0
  48. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipPolygon2.ts +971 -0
  49. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipQuad.ts +871 -0
  50. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer.ts +3507 -0
  51. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer2.ts +500 -0
  52. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtility.ts +1089 -0
  53. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityCPOF.ts +2656 -0
  54. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityGE.ts +1419 -0
  55. package/src/main/ts/armyc2/c5isr/data/genc.json +1407 -0
  56. package/src/main/ts/armyc2/c5isr/data/msd.json +17311 -0
  57. package/src/main/ts/armyc2/c5isr/data/mse.json +18500 -0
  58. package/src/main/ts/armyc2/c5isr/data/svgd.json +31214 -0
  59. package/src/main/ts/armyc2/c5isr/data/svge.json +30558 -0
  60. package/src/main/ts/armyc2/c5isr/graphics2d/AffineTransform.ts +10 -0
  61. package/src/main/ts/armyc2/c5isr/graphics2d/Area.ts +437 -0
  62. package/src/main/ts/armyc2/c5isr/graphics2d/BasicStroke.ts +429 -0
  63. package/src/main/ts/armyc2/c5isr/graphics2d/BasicTypes.ts +7 -0
  64. package/src/main/ts/armyc2/c5isr/graphics2d/BufferedImage.ts +35 -0
  65. package/src/main/ts/armyc2/c5isr/graphics2d/Font.ts +111 -0
  66. package/src/main/ts/armyc2/c5isr/graphics2d/FontMetrics.ts +29 -0
  67. package/src/main/ts/armyc2/c5isr/graphics2d/FontRenderContext.ts +18 -0
  68. package/src/main/ts/armyc2/c5isr/graphics2d/GeneralPath.ts +211 -0
  69. package/src/main/ts/armyc2/c5isr/graphics2d/Graphics2D.ts +80 -0
  70. package/src/main/ts/armyc2/c5isr/graphics2d/IPathIterator.ts +33 -0
  71. package/src/main/ts/armyc2/c5isr/graphics2d/ImageIO.ts +16 -0
  72. package/src/main/ts/armyc2/c5isr/graphics2d/Line2D.ts +726 -0
  73. package/src/main/ts/armyc2/c5isr/graphics2d/PathIterator.ts +141 -0
  74. package/src/main/ts/armyc2/c5isr/graphics2d/Point.ts +112 -0
  75. package/src/main/ts/armyc2/c5isr/graphics2d/Point2D.ts +261 -0
  76. package/src/main/ts/armyc2/c5isr/graphics2d/Polygon.ts +391 -0
  77. package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle.ts +567 -0
  78. package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle2D.ts +445 -0
  79. package/src/main/ts/armyc2/c5isr/graphics2d/Shape.ts +31 -0
  80. package/src/main/ts/armyc2/c5isr/graphics2d/Stroke.ts +18 -0
  81. package/src/main/ts/armyc2/c5isr/graphics2d/TextLayout.ts +45 -0
  82. package/src/main/ts/armyc2/c5isr/graphics2d/TexturePaint.ts +25 -0
  83. package/src/main/ts/armyc2/c5isr/renderer/IIconRenderer.ts +15 -0
  84. package/src/main/ts/armyc2/c5isr/renderer/IconRenderer.ts +22 -0
  85. package/src/main/ts/armyc2/c5isr/renderer/MilStdIconRenderer.ts +269 -0
  86. package/src/main/ts/armyc2/c5isr/renderer/ModifierRenderer.ts +9882 -0
  87. package/src/main/ts/armyc2/c5isr/renderer/PatternFillRenderer.ts +146 -0
  88. package/src/main/ts/armyc2/c5isr/renderer/SinglePointSVGRenderer.ts +1265 -0
  89. package/src/main/ts/armyc2/c5isr/renderer/shapes/arc.ts +64 -0
  90. package/src/main/ts/armyc2/c5isr/renderer/shapes/bcurve.ts +95 -0
  91. package/src/main/ts/armyc2/c5isr/renderer/shapes/ellipse.ts +93 -0
  92. package/src/main/ts/armyc2/c5isr/renderer/shapes/line.ts +114 -0
  93. package/src/main/ts/armyc2/c5isr/renderer/shapes/path.ts +555 -0
  94. package/src/main/ts/armyc2/c5isr/renderer/shapes/pathiterator.ts +62 -0
  95. package/src/main/ts/armyc2/c5isr/renderer/shapes/point.ts +120 -0
  96. package/src/main/ts/armyc2/c5isr/renderer/shapes/rectangle.ts +431 -0
  97. package/src/main/ts/armyc2/c5isr/renderer/shapes/roundedrectangle.ts +99 -0
  98. package/src/main/ts/armyc2/c5isr/renderer/shapes/types.ts +25 -0
  99. package/src/main/ts/armyc2/c5isr/renderer/shapes/utilities.ts +203 -0
  100. package/src/main/ts/armyc2/c5isr/renderer/utilities/AffiliationColors.ts +104 -0
  101. package/src/main/ts/armyc2/c5isr/renderer/utilities/Color.ts +481 -0
  102. package/src/main/ts/armyc2/c5isr/renderer/utilities/DistanceUnit.ts +40 -0
  103. package/src/main/ts/armyc2/c5isr/renderer/utilities/DrawRules.ts +1323 -0
  104. package/src/main/ts/armyc2/c5isr/renderer/utilities/EntityCode.ts +51 -0
  105. package/src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger.ts +736 -0
  106. package/src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup.ts +106 -0
  107. package/src/main/ts/armyc2/c5isr/renderer/utilities/GeoPixelConversion3D.ts +84 -0
  108. package/src/main/ts/armyc2/c5isr/renderer/utilities/IMultiPointRenderer.ts +87 -0
  109. package/src/main/ts/armyc2/c5isr/renderer/utilities/IPointConversion.ts +34 -0
  110. package/src/main/ts/armyc2/c5isr/renderer/utilities/ImageInfo.ts +324 -0
  111. package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUCache.ts +127 -0
  112. package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUEntry.ts +18 -0
  113. package/src/main/ts/armyc2/c5isr/renderer/utilities/LogLevel.ts +111 -0
  114. package/src/main/ts/armyc2/c5isr/renderer/utilities/MODrawRules.ts +219 -0
  115. package/src/main/ts/armyc2/c5isr/renderer/utilities/MSInfo.ts +1008 -0
  116. package/src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup.ts +882 -0
  117. package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdAttributes.ts +380 -0
  118. package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdSymbol.ts +797 -0
  119. package/src/main/ts/armyc2/c5isr/renderer/utilities/Modifiers.ts +1699 -0
  120. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversion.ts +178 -0
  121. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversionDummy.ts +45 -0
  122. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConverter3D.ts +126 -0
  123. package/src/main/ts/armyc2/c5isr/renderer/utilities/RectUtilities.ts +118 -0
  124. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererException.ts +11 -0
  125. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererSettings.ts +1201 -0
  126. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererUtilities.ts +591 -0
  127. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGInfo.ts +29 -0
  128. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup.ts +753 -0
  129. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGSymbolInfo.ts +137 -0
  130. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGTextInfo.ts +438 -0
  131. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEvent.ts +19 -0
  132. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEventListener.ts +10 -0
  133. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsEventListener.ts +5 -0
  134. package/src/main/ts/armyc2/c5isr/renderer/utilities/Shape2SVG.ts +404 -0
  135. package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeInfo.ts +525 -0
  136. package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeUtilities.ts +55 -0
  137. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolDimensionInfo.ts +36 -0
  138. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolID.ts +1055 -0
  139. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolUtilities.ts +2085 -0
  140. package/src/main/ts/armyc2/c5isr/renderer/utilities/TextInfo.ts +157 -0
  141. package/src/main/ts/armyc2/c5isr/web/render/GeoPixelConversion.ts +86 -0
  142. package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandler.ts +3798 -0
  143. package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandlerSVG.ts +412 -0
  144. package/src/main/ts/armyc2/c5isr/web/render/PointConverter.ts +124 -0
  145. package/src/main/ts/armyc2/c5isr/web/render/SymbolModifiers.ts +26 -0
  146. package/src/main/ts/armyc2/c5isr/web/render/WebRenderer.ts +677 -0
  147. package/src/main/ts/armyc2/c5isr/web/render/utilities/JavaRendererUtilities.ts +484 -0
  148. package/src/main/ts/armyc2/c5isr/web/render/utilities/LineInfo.ts +62 -0
  149. package/src/main/ts/armyc2/c5isr/web/render/utilities/SymbolInfo.ts +46 -0
  150. package/src/main/ts/armyc2/c5isr/web/render/utilities/TextInfo.ts +51 -0
  151. package/src/main/ts/org/gavaghan/geodesy/Angle.ts +31 -0
  152. package/src/main/ts/org/gavaghan/geodesy/Ellipsoid.ts +71 -0
  153. package/src/main/ts/org/gavaghan/geodesy/GeodeticCalculator.ts +200 -0
  154. package/src/main/ts/org/gavaghan/geodesy/GeodeticCurve.ts +55 -0
  155. package/src/main/ts/org/gavaghan/geodesy/GeodeticMeasurement.ts +68 -0
  156. package/src/main/ts/org/gavaghan/geodesy/GlobalCoordinates.ts +103 -0
  157. package/src/main/ts/org/gavaghan/geodesy/GlobalPosition.ts +90 -0
  158. package/test/ExportSPImages.js +692 -0
  159. package/test/MPWW.html +556 -0
  160. package/test/MPWorker.js +318 -0
  161. package/test/SPWorker.js +233 -0
  162. package/test/SVGWW.html +363 -0
  163. package/test/singlePointTester3.html +751 -0
  164. package/tsconfig.json +54 -0
  165. package/typedoc.json +30 -0
  166. package/updateVersion.js +21 -0
  167. package/webpack.config.js +34 -0
  168. package/webpackn.config.js +28 -0
  169. package/webpackr.config.js +47 -0
  170. package/webpackw.config.js +23 -0
@@ -0,0 +1,178 @@
1
+ import { type int, type double } from "../../graphics2d/BasicTypes";
2
+
3
+ import { Point } from "../../graphics2d/Point"
4
+ import { Point2D } from "../../graphics2d/Point2D"
5
+ import { IPointConversion } from "../../renderer/utilities/IPointConversion"
6
+
7
+ /**
8
+ *
9
+ *
10
+ */
11
+ export class PointConversion implements IPointConversion {
12
+ protected _pixelWidth: int = 0;
13
+ protected _PixelHeight: int = 0;
14
+ protected _geoTop: double = 0;
15
+ protected _geoLeft: double = 0;
16
+ protected _geoBottom: double = 0;
17
+ protected _geoRight: double = 0;
18
+ protected _normalize: boolean = true;
19
+ //pixels to geo
20
+ //double _geoMultiplierX = 0;
21
+ //double _geoMultiplierY = 0;
22
+ //geo to pixels
23
+ protected _pixelMultiplierX: double = 0;
24
+ protected _pixelMultiplierY: double = 0;
25
+ public set_normalize(value: boolean): void {
26
+ this._normalize = value;
27
+ }
28
+
29
+ public constructor(pixelWidth: int, pixelHeight: int,
30
+ geoTop: double, geoLeft: double,
31
+ geoBottom: double, geoRight: double) {/*
32
+ _pixelWidth = pixelWidth;
33
+ _PixelHeight = pixelHeight;
34
+ _geoTop = geoTop;
35
+ _geoLeft = geoLeft;
36
+ _geoBottom = geoBottom;
37
+ _geoRight = geoRight;*/
38
+
39
+ this.UpdateExtents(pixelWidth, pixelHeight, geoTop, geoLeft, geoBottom, geoRight);
40
+ }
41
+
42
+ public UpdateExtents(pixelWidth: int, pixelHeight: int,
43
+ geoTop: double, geoLeft: double,
44
+ geoBottom: double, geoRight: double): void {
45
+ this._pixelWidth = pixelWidth;
46
+ this._PixelHeight = pixelHeight;
47
+ this._geoTop = geoTop;
48
+ this._geoLeft = geoLeft;
49
+ this._geoBottom = geoBottom;
50
+ this._geoRight = geoRight;
51
+
52
+ //_geoMultiplierX = ((double)_pixelWidth) / (_geoRight - _geoLeft) ;
53
+ //_geoMultiplierY = ((double)_PixelHeight) / (_geoTop - _geoBottom) ;
54
+
55
+ this._pixelMultiplierX = (this._geoRight - this._geoLeft) / (this._pixelWidth as double);
56
+ this._pixelMultiplierY = (this._geoTop - this._geoBottom) / (this._PixelHeight as double);
57
+
58
+ //diagnostic 12-18-12
59
+ if (this._geoRight - this._geoLeft < -180) {
60
+ this._pixelMultiplierX = (this._geoRight - this._geoLeft + 360) / (this._pixelWidth as double);
61
+ }
62
+ if (this._geoRight - this._geoLeft > 180) {
63
+ this._pixelMultiplierX = (360 - (this._geoRight - this._geoLeft)) / (this._pixelWidth as double);
64
+ }
65
+ //end section
66
+ if (this._geoTop < this._geoBottom) {
67
+
68
+ this._pixelMultiplierY = -Math.abs(this._pixelMultiplierY);
69
+ }
70
+
71
+ else {
72
+
73
+ this._pixelMultiplierY = Math.abs(this._pixelMultiplierY);
74
+ }
75
+
76
+
77
+ // if(_geoRight < _geoLeft)
78
+ // _pixelMultiplierX = -Math.abs(_pixelMultiplierX);
79
+ // else
80
+ // _pixelMultiplierX = Math.abs(_pixelMultiplierX);
81
+ //end section
82
+ }
83
+
84
+ public PixelsToGeo(pixel: Point): Point;
85
+
86
+ public PixelsToGeo(pixel: Point2D): Point2D;
87
+ public PixelsToGeo(...args: unknown[]): Point | Point2D {
88
+ const [pixel] = args as [Point | Point2D];
89
+
90
+ let coords: Point | Point2D
91
+ if (pixel instanceof Point)
92
+ coords = new Point()
93
+ else
94
+ coords = new Point2D();
95
+
96
+ coords.x = pixel.getX() * this._pixelMultiplierX + this._geoLeft; //xMultiplier;
97
+ coords.y = this._geoTop - (pixel.getY() * this._pixelMultiplierY);
98
+
99
+ //diagnostic 12-18-12
100
+ if (coords.x < -180) {
101
+
102
+ coords.x += 360;
103
+ }
104
+
105
+ if (coords.x > 180) {
106
+
107
+ coords.x -= 360;
108
+ }
109
+
110
+ //end section
111
+
112
+ return coords;
113
+ }
114
+
115
+
116
+ public GeoToPixels(coord: Point): Point;
117
+
118
+ public GeoToPixels(coord: Point2D): Point2D;
119
+ public GeoToPixels(...args: unknown[]): Point | Point2D {
120
+ const [coord] = args as [Point | Point2D];
121
+
122
+ let pixel: Point | Point2D;
123
+ if (coord instanceof Point)
124
+ pixel = new Point();
125
+ else
126
+ pixel = new Point2D();
127
+ //double xMultiplier = _pixelMultiplierX;//(_geoRight - _geoLeft) / ((double)_pixelWidth) ;
128
+ //double yMultiplier = _pixelMultiplierY;//(_geoTop - _geoBottom) / ((double)_PixelHeight) ;
129
+ let temp: double = 0;
130
+ //temp = ((coord.getX() - _geoLeft) / _pixelMultiplierX);//xMultiplier);
131
+ let calcValue: double = coord.getX() - this._geoLeft;
132
+ if (this._normalize) {
133
+ if (calcValue < -180) {
134
+
135
+ calcValue += 360;
136
+ }
137
+
138
+ else if (calcValue > 180) {
139
+
140
+ calcValue -= 360;
141
+ }
142
+ }
143
+ temp = (calcValue / this._pixelMultiplierX);
144
+
145
+ pixel.x = temp;
146
+
147
+ temp = ((this._geoTop - coord.getY()) / this._pixelMultiplierY);//yMultiplier);
148
+ pixel.y = temp;
149
+
150
+ return pixel;
151
+ }
152
+
153
+
154
+ public getPixelWidth(): int {
155
+ return this._pixelWidth;
156
+ }
157
+
158
+ public getPixelHeight(): int {
159
+ return this._PixelHeight;
160
+ }
161
+
162
+ public getUpperLat(): double {
163
+ return this._geoTop;
164
+ }
165
+
166
+ public getLowerLat(): double {
167
+ return this._geoBottom;
168
+ }
169
+
170
+ public getLeftLon(): double {
171
+ return this._geoLeft;
172
+ }
173
+
174
+ public getRightLon(): double {
175
+ return this._geoRight;
176
+ }
177
+
178
+ }
@@ -0,0 +1,45 @@
1
+ import { Point } from "../../graphics2d/Point"
2
+ import { Point2D } from "../../graphics2d/Point2D"
3
+ import { IPointConversion } from "../../renderer/utilities/IPointConversion"
4
+
5
+ /**
6
+ * Makes no change to the passed points. Useful for when the points
7
+ * are already in pixels.
8
+ *
9
+ */
10
+ export class PointConversionDummy implements IPointConversion {
11
+ public constructor() {
12
+ }
13
+
14
+ public PixelsToGeo(pixel: Point): Point;
15
+
16
+ public PixelsToGeo(pixel: Point2D): Point2D;
17
+ public PixelsToGeo(...args: unknown[]): Point | Point2D {
18
+ const [pixel] = args as [Point | Point2D];
19
+
20
+ let coords: Point | Point2D;
21
+ if (pixel instanceof Point)
22
+ coords = new Point()
23
+ else
24
+ coords = new Point2D();
25
+ coords.x = pixel.getX();
26
+ coords.y = pixel.getY();
27
+
28
+ return coords;
29
+ }
30
+
31
+
32
+ public GeoToPixels(coord: Point): Point;
33
+
34
+ public GeoToPixels(coord: Point2D): Point2D;
35
+ public GeoToPixels(...args: unknown[]): Point | Point2D {
36
+ const [coord] = args as [Point2D];
37
+ let pixel: Point | Point2D;
38
+ if (coord instanceof Point)
39
+ pixel = new Point(coord.getX(), coord.getY())
40
+ else
41
+ pixel = new Point2D(coord.getX(), coord.getY())
42
+
43
+ return pixel;
44
+ }
45
+ }
@@ -0,0 +1,126 @@
1
+ import { type double } from "../../graphics2d/BasicTypes";
2
+
3
+ import { Point } from "../../graphics2d/Point"
4
+ import { Point2D } from "../../graphics2d/Point2D"
5
+ import { GeoPixelConversion3D } from "../../renderer/utilities/GeoPixelConversion3D"
6
+ import { IPointConversion } from "../../renderer/utilities/IPointConversion"
7
+ import { POINT2 } from "../../JavaLineArray/POINT2";
8
+
9
+
10
+ /**
11
+ *
12
+ *
13
+ */
14
+ export class PointConverter3D implements IPointConversion {
15
+ private _controlLat: double = 0;
16
+ private _controlLong: double = 0;
17
+ private _scale: double = 0;
18
+ private _metersPerPixel: double = 0;
19
+ public constructor(controlLong: double, controlLat: double, scale: double) {
20
+ try {
21
+ this._controlLat = controlLat;
22
+ this._controlLong = controlLong;
23
+ this._scale = scale;
24
+ this._metersPerPixel = GeoPixelConversion3D.metersPerPixel(scale);
25
+ } catch (e) {
26
+ if (e instanceof Error) {
27
+ throw e;
28
+ } else {
29
+ throw e;
30
+ }
31
+ }
32
+ }
33
+ public PixelsToGeo(pixel: Point): Point2D;
34
+
35
+ public PixelsToGeo(pixel: Point2D): Point2D;
36
+ public PixelsToGeo(...args: unknown[]): Point2D | Point2D {
37
+ if (args[0] instanceof Point) {
38
+ const [pixel] = args as [Point];
39
+
40
+
41
+ let pt2dGeo: Point2D;
42
+ try {
43
+ let y: double = GeoPixelConversion3D.y2lat(pixel.getY(), this._scale, this._controlLat, this._metersPerPixel);
44
+ let x: double = GeoPixelConversion3D.x2long(pixel.getX(), this._scale, this._controlLong, y, this._metersPerPixel);
45
+ pt2dGeo = new Point2D(x, y);
46
+ } catch (e) {
47
+ if (e instanceof Error) {
48
+ throw e;
49
+ } else {
50
+ throw e;
51
+ }
52
+ }
53
+ return pt2dGeo;
54
+
55
+ } else {
56
+ const [pixel] = args as [Point2D];
57
+
58
+
59
+ let pt2dGeo: Point2D;
60
+ try {
61
+ let y: double = GeoPixelConversion3D.y2lat(pixel.getY(), this._scale, this._controlLat, this._metersPerPixel);
62
+ let x: double = GeoPixelConversion3D.x2long(pixel.getX(), this._scale, this._controlLong, y, this._metersPerPixel);
63
+ pt2dGeo = new Point2D(x, y);
64
+ } catch (e) {
65
+ if (e instanceof Error) {
66
+ throw e;
67
+ } else {
68
+ throw e;
69
+ }
70
+ }
71
+ return pt2dGeo;
72
+
73
+ }
74
+ }
75
+
76
+
77
+
78
+ public GeoToPixels(coord: Point2D): Point;
79
+
80
+ public GeoToPixels(coord: Point2D): Point2D;
81
+ public GeoToPixels(...args: unknown[]): Point | Point2D {
82
+
83
+ if (args[0] instanceof Point2D) {
84
+ const [coord] = args as [Point2D];
85
+
86
+
87
+ let ptPixels: Point;
88
+ try {
89
+ let y: double = GeoPixelConversion3D.lat2y(coord.getY(), this._scale, this._controlLat, this._metersPerPixel);
90
+ let x: double = GeoPixelConversion3D.long2x(coord.getX(), this._scale, this._controlLong, coord.getY(), this._metersPerPixel);
91
+ ptPixels = new Point();
92
+ ptPixels.setLocation(x, y);
93
+ } catch (e) {
94
+ if (e instanceof Error) {
95
+ throw e;
96
+ } else {
97
+ throw e;
98
+ }
99
+ }
100
+ return ptPixels;
101
+
102
+ } else {
103
+
104
+ const [coord] = args as [Point2D];
105
+
106
+
107
+ let pt2DPixels: Point2D;
108
+ try {
109
+ let y: double = GeoPixelConversion3D.lat2y(coord.getY(), this._scale, this._controlLat, this._metersPerPixel);
110
+ let x: double = GeoPixelConversion3D.long2x(coord.getX(), this._scale, this._controlLong, coord.getY(), this._metersPerPixel);
111
+ pt2DPixels = new Point2D(x, y);
112
+ } catch (e) {
113
+ if (e instanceof Error) {
114
+ throw e;
115
+ } else {
116
+ throw e;
117
+ }
118
+ }
119
+ return pt2DPixels;
120
+
121
+
122
+
123
+ }
124
+ }
125
+
126
+ }
@@ -0,0 +1,118 @@
1
+ import { type int, type double } from "../../graphics2d/BasicTypes";
2
+
3
+ import { Rectangle } from "../../graphics2d/Rectangle"
4
+ import { Rectangle2D } from "../../graphics2d/Rectangle2D"
5
+ import { Rectangle as Rect } from "../shapes/rectangle";
6
+
7
+ export class RectUtilities {
8
+
9
+ public static makeRectangleFromRect(x1: int, y1: int, x2: int, y2: int): Rectangle {
10
+ return new Rectangle(x1, y1, x2 - x1, y2 - y1);
11
+ }
12
+
13
+ public static makeRectangle2DFromRect(x1: double, y1: double, x2: double, y2: double): Rectangle2D {
14
+ return new Rectangle2D(x1, y1, x2 - x1, y2 - y1);
15
+ }
16
+
17
+
18
+
19
+ /**
20
+ * Copies a Rectangle
21
+ * @param rect {@link Rectangle2D}
22
+ * @return {@link Rectangle2D}
23
+ */
24
+ public static copyRect(rect: Rectangle2D): Rectangle2D {
25
+ return new Rectangle2D(rect.getX() as int, rect.getY() as int, (rect.getWidth() + 0.5) as int, (rect.getHeight() + 0.5) as int);
26
+ }
27
+
28
+ /**
29
+ * copies and rounds the points. x,y round down &amp; width,height round up
30
+ * @param rect {@link Rectangle2D}
31
+ * @return {@link Rectangle2D}
32
+ */
33
+ public static roundRect(rect: Rectangle2D): Rectangle2D {
34
+ let offsetX: double = rect.getX() - (rect.getX()) as int;
35
+ let offsetY: double = rect.getY() - (rect.getY()) as int;
36
+
37
+ return new Rectangle2D(rect.getX() as int, rect.getY() as int, (Math.round(rect.getWidth() + offsetX + 0.5)) as int, Math.round(rect.getHeight() + offsetY + 0.5) as int);
38
+ }
39
+
40
+ public static grow(rect: Rectangle2D, size: int): void {
41
+ rect.setRect(rect.getX() - size, rect.getY() - size, rect.getWidth() + (size * 2), rect.getHeight() + (size * 2));
42
+ //return new Rectangle2D(rect.left - size, rect.top - size, rect.right + size, rect.bottom + size);
43
+ }
44
+
45
+
46
+ public static shift(rect: Rectangle2D, x: int, y: int): void {
47
+ rect.setRect(rect.getX() + x, rect.getY() + y, rect.getWidth(), rect.getHeight());
48
+ }
49
+
50
+
51
+ public static shiftBR(rect: Rectangle2D, x: int, y: int): void {
52
+ rect.setRect(rect.getX(), rect.getY(), rect.getWidth() + x, rect.getHeight() + y);
53
+ }
54
+
55
+ public static toRectangle(b: Rectangle2D): Rectangle;
56
+
57
+ public static toRectangle(x: double, y: double, w: double, h: double): Rectangle;
58
+ public static toRectangle(...args: unknown[]): Rectangle | null {
59
+ switch (args.length) {
60
+ case 1: {
61
+ const [b] = args as [Rectangle2D];
62
+
63
+
64
+ if (b == null) {
65
+ return null;
66
+ }/*from w ww . j a va 2s . c o m*/
67
+ if (b instanceof Rectangle) {
68
+ return b as Rectangle;
69
+ } else {
70
+ return new Rectangle(b.getX() as int, b.getY() as int,
71
+ b.getWidth() as int, b.getHeight() as int);
72
+ }
73
+
74
+ }
75
+
76
+ case 4: {
77
+ const [x, y, w, h] = args as [double, double, double, double];
78
+
79
+ return new Rectangle(x as int, y as int,w as int, h as int);
80
+ }
81
+
82
+ default: {
83
+ throw Error(`Invalid number of arguments`);
84
+ }
85
+ }
86
+ }
87
+
88
+ public static toRectangle2D(b: Rectangle): Rectangle2D;
89
+ public static toRectangle2D(x: double, y: double, w: double, h: double): Rectangle2D;
90
+ public static toRectangle2D(...args: unknown[]): Rectangle2D | null {
91
+ switch (args.length) {
92
+ case 1: {
93
+ const [b] = args as [Rectangle];
94
+
95
+
96
+ if (b == null) {
97
+ return null;
98
+ }/*from w ww . j a va 2s . c o m*/
99
+ else
100
+ {
101
+ return new Rectangle2D(b.getX(), b.getY(),b.getWidth(), b.getHeight());
102
+ }
103
+
104
+ }
105
+
106
+ case 4: {
107
+ const [x, y, w, h] = args as [double, double, double, double];
108
+
109
+ return new Rectangle2D(x as int, y as int,w as int, h as int);
110
+ }
111
+
112
+ default: {
113
+ throw Error(`Invalid number of arguments`);
114
+ }
115
+ }
116
+ }
117
+
118
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ *
4
+ */
5
+ export class RendererException extends Error {
6
+
7
+ public constructor(message: string, cause: Error | null) {
8
+ super(message);
9
+ }
10
+
11
+ }