@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,106 @@
1
+ import { ErrorLogger } from './ErrorLogger';
2
+ import { RendererUtilities } from './RendererUtilities';
3
+
4
+ import json from '../../data/genc.json';
5
+
6
+ /**
7
+ * Utility class that takes the 3 digit country code from the symbol ID and returns the 3 character string representation
8
+ * of that country. For example, 840 turns into "USA" for the United States.
9
+ */
10
+ export class GENCLookup {
11
+ private static gencJSON:string = "/genc.json";
12
+ private static _instance: GENCLookup;
13
+ private static _initCalled: boolean = false;
14
+ private static _isReady: boolean = false;
15
+
16
+ private static _GENCLookup: Map<string, string>;
17
+ //private TAG: string = "GENCLookup";
18
+ //private _IDList: Array<string> = new Array<string>();
19
+ private static genc:any;
20
+
21
+
22
+ /*public static async loadData(location?:string)
23
+ {
24
+ let path:string = GENCLookup.gencJSON;//String(genc);
25
+ if(location)
26
+ {
27
+ path = location + path.substring(path.lastIndexOf('/')+1,path.length);
28
+ }
29
+ RendererUtilities.getData(path).then(result => {this.genc = result;}).catch((err) => {ErrorLogger.LogException("GENCLookup","loadData",err)});
30
+ //RendererUtilities.getData(String(genc)).then(result => {this.genc = result;});
31
+ }//*/
32
+
33
+ /**
34
+ *
35
+ * @param url
36
+ * @deprecated
37
+ */
38
+ public static async setData(url:string)
39
+ {
40
+ //RendererUtilities.getData(url).then(result => {this.genc = result;}).catch((err) => {ErrorLogger.LogException("GENCLookup","loadData",err)});
41
+ }
42
+
43
+ /*public static setDataObject()
44
+ {
45
+ this.genc = json;
46
+ }//*/
47
+
48
+ private constructor()
49
+ {
50
+ this.init();
51
+ }
52
+
53
+ public static getInstance(): GENCLookup {
54
+ if (!GENCLookup._instance) {
55
+ GENCLookup._instance = new GENCLookup();
56
+ }
57
+ return GENCLookup._instance;
58
+ }
59
+
60
+ public isReady():boolean
61
+ {
62
+ return GENCLookup._isReady;
63
+ }
64
+
65
+ private init(): void {
66
+
67
+ if(typeof json === 'object')
68
+ {
69
+ GENCLookup.genc = json;
70
+ }
71
+
72
+ type gencIn =
73
+ {
74
+ "3char": string;
75
+ "numeric": string;
76
+ "name": string;
77
+ }
78
+
79
+ if (GENCLookup._initCalled === false) {
80
+ GENCLookup._initCalled = true;
81
+ GENCLookup._GENCLookup = new Map();
82
+ try {
83
+
84
+ let gencJSON: gencIn[] = GENCLookup.genc["genc"]["countries"]
85
+ for (let countryJSON of gencJSON) {
86
+ GENCLookup._GENCLookup.set(countryJSON["numeric"], countryJSON["3char"]);
87
+ }
88
+
89
+ } catch (e) {
90
+ if(console)
91
+ console.log(e.message);
92
+ else
93
+ throw e;
94
+ }
95
+ }
96
+ if(GENCLookup._GENCLookup &&GENCLookup._GENCLookup.size > 0)
97
+ GENCLookup._isReady = true;
98
+ }
99
+
100
+ public get3CharCode(id: number): string {
101
+ if (GENCLookup._GENCLookup && GENCLookup._GENCLookup.has(String(id))) {
102
+ return GENCLookup._GENCLookup.get(String(id));
103
+ }
104
+ return "";
105
+ }
106
+ }
@@ -0,0 +1,84 @@
1
+ import {type double } from "../../graphics2d/BasicTypes";
2
+
3
+ import { GeoPixelConversion } from "../../web/render/GeoPixelConversion"
4
+
5
+ /**
6
+ *
7
+ *
8
+ */
9
+ export class GeoPixelConversion3D {
10
+ public static metersPerPixel(scale: double): double {
11
+ return GeoPixelConversion.metersPerPixel(scale);
12
+ }
13
+
14
+ public static lat2y(latitude: double, scale: double, latOrigin: double, metPerPix: double): double {
15
+
16
+ let latRem: double = Math.abs(latitude - latOrigin);
17
+ let pixDis: double = 0;
18
+ if (latRem > 0) {
19
+ pixDis = (latRem * GeoPixelConversion.METERS_PER_DEG) / metPerPix;
20
+ if (latitude > latOrigin)//was < M. Deutch 6-20-11
21
+ {
22
+ pixDis = -pixDis;
23
+ }
24
+ }
25
+ return pixDis;
26
+ }
27
+
28
+ public static y2lat(yPosition: double, scale: double, latOrigin: double, metPerPix: double): double {
29
+
30
+ let latitude: double = latOrigin;
31
+ if (yPosition !== 0) {
32
+ latitude = latOrigin - ((yPosition * metPerPix) / GeoPixelConversion.METERS_PER_DEG);//was + M. Deutch 6-18-11
33
+ }
34
+ return latitude;
35
+ }
36
+
37
+ public static long2x(longitude: double, scale: double, longOrigin: double, latitude: double, metPerPix: double): double {
38
+
39
+ let longRem: double = Math.abs(longitude - longOrigin);
40
+ let metersPerDeg: double = GeoPixelConversion3D.GetMetersPerDegAtLat(latitude);
41
+ let pixDis: double = 0;
42
+ if (longRem > 0) {
43
+ pixDis = (longRem * metersPerDeg) / metPerPix;
44
+ if (longitude < longOrigin) {
45
+ pixDis = -pixDis;
46
+ }
47
+ }
48
+ return pixDis;
49
+ }
50
+
51
+ public static x2long(xPosition: double, scale: double, longOrigin: double, latitude: double, metPerPix: double): double {
52
+
53
+ let metersPerDeg: double = GeoPixelConversion3D.GetMetersPerDegAtLat(latitude);
54
+ let longitude: double = longOrigin;
55
+ if (xPosition !== 0) {
56
+ longitude = longOrigin + ((xPosition * metPerPix) / metersPerDeg);
57
+ }
58
+ return longitude;
59
+ }
60
+
61
+
62
+ public static Deg2Rad(deg: double): double {
63
+ let conv_factor: double = (2.0 * Math.PI) / 360.0;
64
+ return (deg * conv_factor);
65
+ }
66
+
67
+ public static GetMetersPerDegAtLat(lat: double): double {
68
+ // Convert latitude to radians
69
+ lat = GeoPixelConversion3D.Deg2Rad(lat);
70
+ // Set up "Constants"
71
+ let p1: double = 111412.84; // longitude calculation term 1
72
+
73
+ let p2: double = -93.5; // longitude calculation term 2
74
+
75
+ let p3: double = 0.118; // longitude calculation term 3
76
+
77
+ // Calculate the length of a degree of longitude in meters at given latitude
78
+ let longlen: double = (p1 * Math.cos(lat)) + (p2 * Math.cos(3 * lat)) + (p3 * Math.cos(5 * lat));
79
+
80
+ return longlen;
81
+ }
82
+
83
+
84
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @deprecated
3
+ */
4
+ interface IMultiPointRenderer {
5
+
6
+ /**
7
+ * Renders all multi-point symbols, creating KML that can be used to draw
8
+ * it on a Google map. Multipoint symbols cannot be draw the same
9
+ * at different scales. For instance, graphics with arrow heads will need to
10
+ * redraw arrowheads when you zoom in on it. Similarly, graphics like a
11
+ * Forward Line of Troops drawn with half circles can improve performance if
12
+ * clipped when the parts of the graphic that aren't on the screen. To help
13
+ * readjust graphics and increase performance, this function requires the
14
+ * scale and bounding box to help calculate the new locations.
15
+ * @param id A unique identifier used to identify the symbol by Google map.
16
+ * The id will be the folder name that contains the graphic.
17
+ * @param name a string used to display to the user as the name of the
18
+ * graphic being created.
19
+ * @param description a brief description about the graphic being made and
20
+ * what it represents.
21
+ * @param symbolCode A 15 character symbolID corresponding to one of the
22
+ * graphics in the MIL-STD-2525C
23
+ * @param controlPoints The vertices of the graphics that make up the
24
+ * graphic. Passed in the format of a string, using decimal degrees
25
+ * separating lat and lon by a comma, separating coordinates by a space.
26
+ * The following format shall be used "x1,y1[,z1] [xn,yn[,zn]]..."
27
+ * @param altitudeMode Indicates whether the symbol should interpret
28
+ * altitudes as above sea level or above ground level. Options are
29
+ * "clampToGround", "relativeToGround" (from surface of earth), "absolute"
30
+ * (sea level), "relativeToSeaFloor" (from the bottom of major bodies of
31
+ * water).
32
+ * @param scale A number corresponding to how many meters one meter of our
33
+ * map represents. A value "50000" would mean 1:50K which means for every
34
+ * meter of our map it represents 50000 meters of real world distance.
35
+ * @param bbox The viewable area of the map. Passed in the format of a
36
+ * string "lowerLeftX,lowerLeftY,upperRightX,upperRightY." Not required
37
+ * but can speed up rendering in some cases.
38
+ * example: "-50.4,23.6,-42.2,24.2"
39
+ * @param modifiers A JSON string representing all the possible symbol
40
+ * modifiers represented in the MIL-STD-2525C. Format of the string will be
41
+ * {"modifiers": {"attributeName":"value"[,"attributeNamen":"valuen"]...}}
42
+ * The quotes are literal in the above notation. Example:
43
+ * {"modifiers": {"quantity":"4","speed":"300","azimuth":[100,200]}}
44
+ * @param format An enumeration: 0 for KML, 1 for JSON.
45
+ * @param symStd An enumeration: 0 for 2525Bch2, 1 for 2525C.
46
+ * @return A JSON string representation of the graphic.
47
+ */
48
+ RenderSymbol(id: string, name: string, description: string,
49
+ symbolCode: string, controlPoints: string, altitudeMode: string,
50
+ scale: number, bbox: string, modifiers: string, format: number, symStd: number): string;
51
+
52
+
53
+ /**
54
+ * Renders all multi-point symbols, creating KML or JSON for the user to
55
+ * parse and render as they like.
56
+ * This function requires the bounding box to help calculate the new
57
+ * locations.
58
+ * @param id A unique identifier used to identify the symbol by Google map.
59
+ * The id will be the folder name that contains the graphic.
60
+ * @param name a string used to display to the user as the name of the
61
+ * graphic being created.
62
+ * @param description a brief description about the graphic being made and
63
+ * what it represents.
64
+ * @param symbolCode A 15 character symbolID corresponding to one of the
65
+ * graphics in the MIL-STD-2525C
66
+ * @param controlPoints The vertices of the graphics that make up the
67
+ * graphic. Passed in the format of a string, using decimal degrees
68
+ * separating lat and lon by a comma, separating coordinates by a space.
69
+ * The following format shall be used "x1,y1 [xn,yn]..."
70
+ * @param pixelWidth pixel dimensions of the viewable map area
71
+ * @param pixelHeight pixel dimensions of the viewable map area
72
+ * @param bbox The viewable area of the map. Passed in the format of a
73
+ * string "lowerLeftX,lowerLeftY,upperRightX,upperRightY."
74
+ * example: "-50.4,23.6,-42.2,24.2"
75
+ * @param modifiers A JSON string representing all the possible symbol
76
+ * modifiers represented in the MIL-STD-2525C. Format of the string will be
77
+ * {"modifiers": {"attributeName":"value"[,"attributeNamen":"valuen"]...}}
78
+ * The quotes are literal in the above notation. Example:
79
+ * {"modifiers": {"quantity":"4","speed":"300","azimuth":[100,200]}}
80
+ * @param format An enumeration: 0 for KML, 1 for JSON.
81
+ * @param symStd An enumeration: 0 for 2525Bch2, 1 for 2525C.
82
+ * @return A JSON (1) or KML (0) string representation of the graphic.
83
+ */
84
+ RenderSymbol2D(id: string, name: string, description: string, symbolCode: string, controlPoints: string,
85
+ pixelWidth: number, pixelHeight: number, bbox: string, modifiers: string, format: number, symStd: number): string;
86
+
87
+ }
@@ -0,0 +1,34 @@
1
+ import { Point2D } from "../../graphics2d/Point2D";
2
+
3
+ /**
4
+ * Interface for Point Conversion objects. Recommend using the functions
5
+ * that take and return Point2D objects.
6
+ *
7
+ */
8
+ export interface IPointConversion {
9
+
10
+ // public void UpdateExtents(int pixelWidth, int pixelHeight,
11
+ // double geoTop, double geoLeft,
12
+ // double geoBottom, double geoRight);
13
+
14
+ // public Point2D PixelsToGeo(Point pixel);
15
+
16
+ // public Point GeoToPixels(Point2D coord);
17
+
18
+ PixelsToGeo(pixel: Point2D): Point2D;
19
+
20
+ GeoToPixels(coord: Point2D): Point2D;
21
+
22
+ // public int getPixelWidth();
23
+ //
24
+ // public int getPixelHeight();
25
+ // public double getUpperLat();
26
+ //
27
+ // public double getLowerLat();
28
+ //
29
+ // public double getLeftLon();
30
+ //
31
+ // public double getRightLon();
32
+
33
+
34
+ }
@@ -0,0 +1,324 @@
1
+ import { type int, type double } from "../../graphics2d/BasicTypes";
2
+
3
+ import { BufferedImage } from "../../graphics2d/BufferedImage"
4
+ import { Point } from "../../graphics2d/Point"
5
+ import { Point2D } from "../../graphics2d/Point2D"
6
+ import { Rectangle2D } from "../../graphics2d/Rectangle2D"
7
+ import { ErrorLogger } from "../../renderer/utilities/ErrorLogger"
8
+ import { RectUtilities } from "../../renderer/utilities/RectUtilities"
9
+ import { SymbolDimensionInfo } from "../../renderer/utilities/SymbolDimensionInfo"
10
+
11
+
12
+ /**
13
+ * Object that holds an image of the symbol and all the information
14
+ * needed to place the symbol on the screen.
15
+ *
16
+ */
17
+ export class ImageInfo implements SymbolDimensionInfo {
18
+
19
+ public static readonly FormatPNG: string = "png";
20
+ public static readonly FormatJPG: string = "jpg";
21
+
22
+ private _Image: ImageBitmap;
23
+ private _X: int = 0;
24
+ private _Y: int = 0;
25
+ private _symbolCenterX: int = 0;
26
+ private _symbolCenterY: int = 0;
27
+ protected _symbolBounds: Rectangle2D;
28
+
29
+
30
+ /**
31
+ *
32
+ */
33
+ public constructor();
34
+
35
+ /**
36
+ * ImageInfo holds and image and holds the position at which the image
37
+ * should be drawn. Use for Multipoint and single point graphics.
38
+ * @param image {@link BufferedImage}
39
+ * @param x position of where the image should be drawn
40
+ * @param y position of where the image should be drawn
41
+ */
42
+ public constructor(image: ImageBitmap, x: int, y: int);
43
+
44
+ /**
45
+ * Creates a new ImageInfo object
46
+ * @param bi {@link BufferedImage}
47
+ * @param centerPoint can also be the anchor point of the symbol if it isn't the center of the image (action point)
48
+ * @param symbolBounds {@link Rectangle2D}
49
+ */
50
+ public constructor(bi: ImageBitmap, centerPoint: Point2D, symbolBounds: Rectangle2D);
51
+
52
+ /**
53
+ * ImageInfo holds and image and holds the position at which the image
54
+ * should be drawn. Use this if the image is a single point graphic.
55
+ * @param image {@link BufferedImage}
56
+ * @param x position of where the image should be drawn
57
+ * @param y position of where the image should be drawn
58
+ * @param symbolCenterX center point of image may be different from the center
59
+ * point of the symbol within the image. (single point graphics)
60
+ * @param symbolCenterY center point of image may be different from the center
61
+ * point of the symbol within the image. (single point graphics)
62
+ * @deprecated
63
+ */
64
+ public constructor(image: ImageBitmap, x: int, y: int, symbolCenterX: int, symbolCenterY: int);
65
+
66
+ /**
67
+ *
68
+ * ImageInfo holds and image and holds the position at which the image
69
+ * should be drawn. Use this if the image is a single point graphic.
70
+ * @param image {@link BufferedImage}
71
+ * @param x position of where the image should be drawn
72
+ * @param y position of where the image should be drawn
73
+ * @param symbolCenterX center point of image may be different center
74
+ * point of the symbol within the image. (single point graphics)
75
+ * @param symbolCenterY center point of image may be different center
76
+ * point of the symbol within the image. (single point graphics)
77
+ * @param symbolBounds minimum bounding rectangle for the core symbol. Does
78
+ * not include modifiers, display or otherwise.
79
+ */
80
+ public constructor(image: ImageBitmap, x: int, y: int, symbolCenterX: int, symbolCenterY: int, symbolBounds: Rectangle2D);
81
+ public constructor(...args: unknown[]) {
82
+ switch (args.length) {
83
+ case 0: {
84
+ break;
85
+ }
86
+
87
+ case 3:
88
+ {
89
+ if(typeof args[1] === 'number')
90
+ {
91
+ const [image, x, y] = args as [ImageBitmap, int, int];
92
+ this._Image = image;
93
+ this._X = x;
94
+ this._Y = y;
95
+ this._symbolCenterX = image.width / 2;
96
+ this._symbolCenterY = image.height / 2;
97
+ }
98
+ else if(args[1] instanceof Point2D)
99
+ {
100
+ const [bi, centerPoint, symbolBounds] = args as [ImageBitmap, Point2D, Rectangle2D];
101
+
102
+ this._Image = bi;
103
+ this._symbolCenterX = centerPoint.getX() as int;
104
+ this._symbolCenterY = centerPoint.getY() as int;
105
+ this._symbolBounds = symbolBounds;
106
+ }
107
+ break;
108
+ }
109
+
110
+ case 5: {
111
+ const [image, x, y, symbolCenterX, symbolCenterY] = args as [ImageBitmap, int, int, int, int];
112
+
113
+ this._Image = image;
114
+ this._X = x;
115
+ this._Y = y;
116
+ this._symbolCenterX = symbolCenterX;
117
+ this._symbolCenterY = symbolCenterY;
118
+
119
+ break;
120
+ }
121
+
122
+ case 6: {
123
+ const [image, x, y, symbolCenterX, symbolCenterY, symbolBounds] = args as [ImageBitmap, int, int, int, int, Rectangle2D];
124
+
125
+ this._Image = image;
126
+ this._X = x;
127
+ this._Y = y;
128
+ this._symbolCenterX = symbolCenterX;
129
+ this._symbolCenterY = symbolCenterY;
130
+ this._symbolBounds = symbolBounds;
131
+
132
+ break;
133
+ }
134
+
135
+ default: {
136
+ throw Error(`Invalid number of arguments`);
137
+ }
138
+ }
139
+ }
140
+
141
+
142
+ /**
143
+ * The BufferedImage
144
+ * @return the actual image
145
+ */
146
+ public getImage(): ImageBitmap {
147
+ return this._Image;
148
+ }
149
+
150
+ /**
151
+ * X position of where the image should be drawn
152
+ * @return {@link Integer}
153
+ */
154
+ public getX(): int {
155
+ return this._X;
156
+ }
157
+
158
+
159
+ /**
160
+ * Y position of where the image should be drawn
161
+ * @return {@link Integer}
162
+ */
163
+ public getY(): int {
164
+ return this._Y;
165
+ }
166
+
167
+ /**
168
+ * position of where the image should be drawn
169
+ * @return {@link Point}
170
+ */
171
+ public getPoint(): Point {
172
+ return new Point(this._X, this._Y);
173
+ }
174
+
175
+ /**
176
+ * The x value the image should be centered on or the "anchor point".
177
+ * @return {@link Integer}
178
+ */
179
+ public getSymbolCenterX(): int {
180
+ return this._symbolCenterX;
181
+ }
182
+
183
+ /**
184
+ * The y value the image should be centered on or the "anchor point".
185
+ * @return {@link Integer}
186
+ */
187
+ public getSymbolCenterY(): int {
188
+ return this._symbolCenterY;
189
+ }
190
+
191
+ /**
192
+ * The point the image should be centered on or the "anchor point".
193
+ * @return {@link Point}
194
+ */
195
+ public getSymbolCenterPoint(): Point2D {
196
+ return new Point2D(this._symbolCenterX, this._symbolCenterY);
197
+ }
198
+
199
+ /**
200
+ * minimum bounding rectangle for the core symbol. Does
201
+ * not include modifiers, display or otherwise.
202
+ * @return {@link Rectangle2D}
203
+ */
204
+ public getSymbolBounds(): Rectangle2D {
205
+ return this._symbolBounds;
206
+ }
207
+
208
+ /**
209
+ * Dimension of the entire image.
210
+ * @return {@link Rectangle2D}
211
+ */
212
+
213
+ public getImageBounds(): Rectangle2D {
214
+ return new Rectangle2D(0, 0, this._Image.width, this._Image.height);
215
+ }
216
+
217
+ /**
218
+ * Takes an image and a center point and generates a new, bigger image
219
+ * that has the symbol centered in it
220
+ * @param image {@link BufferedImage}
221
+ * @param point {@link Point2D}
222
+ * @return {@link BufferedImage}
223
+ */
224
+ public static CenterImageOnPoint(image: ImageBitmap, point: Point2D): ImageBitmap {
225
+ let bi:ImageBitmap;
226
+ let osc: OffscreenCanvas | any;
227
+ let x: int = 0;
228
+ let y: int = 0;
229
+ let height: int = 0;
230
+ let width: int = 0;
231
+ height = image.height;
232
+ width = image.width;
233
+
234
+ try {
235
+ if (point.getY() > height - point.getY()) {
236
+ height = (point.getY() * 2.0) as int;
237
+ y = 0;
238
+ }
239
+ else {
240
+ height = ((height - point.getY()) * 2) as int;
241
+ y = ((height / 2) - point.getY()) as int;
242
+ }
243
+
244
+ if (point.getX() > width - point.getX()) {
245
+ width = (point.getX() * 2.0) as int;
246
+ x = 0;
247
+ }
248
+ else {
249
+ width = ((width - point.getX()) * 2) as int;
250
+ x = ((width / 2) - point.getX()) as int;
251
+ }
252
+
253
+
254
+ osc = new OffscreenCanvas(width, height);
255
+ let ctx:OffscreenCanvasRenderingContext2D = osc.getContext("2d");
256
+ ctx.drawImage(image,x,y);
257
+ bi = osc.transferToImageBitmap();
258
+ } catch (exc) {
259
+ if (exc instanceof Error) {
260
+ ErrorLogger.LogException("ImageInfo", "CenterImageOnPoint", exc);
261
+ } else {
262
+ throw exc;
263
+ }
264
+ }
265
+ return bi;
266
+ }
267
+
268
+
269
+ /**
270
+ * Adds padding as needed to make the image a nice square.
271
+ * @return {@link ImageInfo}
272
+ */
273
+ public getSquareImageInfo(): ImageInfo {
274
+ let ii: ImageInfo;
275
+ let iwidth: int = 0;
276
+ let iheight: int = 0;
277
+ let x: int = 0;
278
+ let y: int = 0;
279
+ let width: int = this._Image.width;
280
+ let height: int = this._Image.height;
281
+
282
+ if (width > height) {
283
+ iwidth = width;
284
+ iheight = width;
285
+ x = 0;
286
+ y = (iheight - height) / 2;
287
+ }
288
+ else {
289
+ if (width < height) {
290
+ iwidth = height;
291
+ iheight = height;
292
+ x = (iwidth - width) / 2;
293
+ y = 0;
294
+ }
295
+ else {
296
+ iwidth = width;
297
+ iheight = height;
298
+ x = 0;
299
+ y = 0;
300
+ }
301
+ }
302
+
303
+
304
+ //Draw glyphs to bitmap
305
+ let bmp: OffscreenCanvas = new OffscreenCanvas(iwidth, iheight);
306
+
307
+ let g2d: OffscreenCanvasRenderingContext2D = bmp.getContext("2d");
308
+
309
+ g2d.drawImage(this._Image, x, y);
310
+
311
+
312
+ //create new ImageInfo
313
+ let center: Point2D = new Point2D(this._symbolCenterX, this._symbolCenterY);
314
+ center.setLocation(this._symbolCenterX + x, this._symbolCenterY + y);
315
+ let symbolBounds: Rectangle2D = RectUtilities.copyRect(this._symbolBounds);
316
+ RectUtilities.shift(this._symbolBounds, x, y);
317
+
318
+ ii = new ImageInfo(bmp.transferToImageBitmap(), center, symbolBounds);
319
+
320
+
321
+ return ii;
322
+ }
323
+
324
+ }