@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,2663 @@
1
+ import {type double, type int } from "../graphics2d/BasicTypes";
2
+
3
+ import { BasicStroke } from "../graphics2d/BasicStroke"
4
+ import { Graphics2D } from "../graphics2d/Graphics2D"
5
+ import { Line2D } from "../graphics2d/Line2D"
6
+ import { Point2D } from "../graphics2d/Point2D"
7
+ import { Polygon } from "../graphics2d/Polygon"
8
+ import { Rectangle2D } from "../graphics2d/Rectangle2D"
9
+ import { TexturePaint } from "../graphics2d/TexturePaint"
10
+ import { arraysupport } from "../JavaLineArray/arraysupport"
11
+ import { lineutility } from "../JavaLineArray/lineutility"
12
+ import { POINT2 } from "../JavaLineArray/POINT2"
13
+ import { ref } from "../JavaLineArray/ref"
14
+ import { Shape2 } from "../JavaLineArray/Shape2"
15
+ import { TacticalLines } from "../JavaLineArray/TacticalLines"
16
+ import { mdlGeodesic } from "../JavaTacticalRenderer/mdlGeodesic"
17
+ import { P1 } from "../JavaTacticalRenderer/P1"
18
+ import { TGLight } from "../JavaTacticalRenderer/TGLight"
19
+ import { Color } from "../renderer/utilities/Color"
20
+ import { DrawRules } from "../renderer/utilities/DrawRules"
21
+ import { ErrorLogger } from "../renderer/utilities/ErrorLogger"
22
+ import { IPointConversion } from "../renderer/utilities/IPointConversion"
23
+ import { MSInfo } from "../renderer/utilities/MSInfo"
24
+ import { MSLookup } from "../renderer/utilities/MSLookup"
25
+ import { RendererException } from "../renderer/utilities/RendererException"
26
+ import { RendererUtilities } from "../renderer/utilities/RendererUtilities"
27
+ import { SymbolID } from "../renderer/utilities/SymbolID"
28
+ import { clsRenderer } from "../RenderMultipoints/clsRenderer"
29
+ import { clsUtility as renderMPUtility } from "../RenderMultipoints/clsUtility";
30
+ import { clsMETOC } from "./clsMETOC";
31
+
32
+
33
+ /**
34
+ * A general utility class for the tactical renderer
35
+ *
36
+ */
37
+ export class clsUtility {
38
+ private static readonly _className: string = "clsUtility";
39
+ protected static POINT2ToPoint2D(pt2: POINT2): Point2D | null {
40
+ if (pt2 == null) {
41
+ return null;
42
+ }
43
+
44
+ let x: double = pt2.x;
45
+ let y: double = pt2.y;
46
+ let pt: Point2D = new Point2D(x, y);
47
+ return pt;
48
+ }
49
+ /**
50
+ * returns true if the line segments are all outside the bounds
51
+ * @param tg the tactical graphic
52
+ * @param clipBounds the pixels based clip bounds
53
+ * @return
54
+ */
55
+ public static linesOutsideClipBounds(tg: TGLight,
56
+ clipBounds: Rectangle2D): boolean {
57
+ try {
58
+ let isAutoshape: boolean = clsUtility.isAutoshape(tg);
59
+ if (isAutoshape) {
60
+ return false;
61
+ }
62
+
63
+
64
+ let xmin: double = clipBounds.getMinX();
65
+ let xmax: double = clipBounds.getMaxX();
66
+ let ymin: double = clipBounds.getMinY();
67
+ let ymax: double = clipBounds.getMaxY();
68
+ let j: int = 0;
69
+ let pt0: POINT2;
70
+ let pt1: POINT2;
71
+ let boundsEdge: Line2D;
72
+ let ptsLine: Line2D;
73
+ let n: int = tg.Pixels.length;
74
+ //for(j=0;j<tg.Pixels.length-1;j++)
75
+ for (j = 0; j < n - 1; j++) {
76
+ pt0 = tg.Pixels[j];
77
+ pt1 = tg.Pixels[j + 1];
78
+
79
+ //if either point is inside the bounds return false
80
+ if (clipBounds.contains(pt0.x, pt0.y)) {
81
+
82
+ return false;
83
+ }
84
+
85
+ if (clipBounds.contains(pt1.x, pt1.y)) {
86
+
87
+ return false;
88
+ }
89
+
90
+
91
+ ptsLine = new Line2D(pt0.x, pt0.y, pt1.x, pt1.y);
92
+
93
+ //if the pt0-pt1 line intersects any clip bounds edge then return false
94
+ boundsEdge = new Line2D(xmin, ymin, xmax, ymin);
95
+ if (ptsLine.intersectsLine(boundsEdge)) {
96
+
97
+ return false;
98
+ }
99
+
100
+
101
+ boundsEdge = new Line2D(xmax, ymin, xmax, ymax);
102
+ if (ptsLine.intersectsLine(boundsEdge)) {
103
+
104
+ return false;
105
+ }
106
+
107
+
108
+ boundsEdge = new Line2D(xmax, ymax, xmin, ymax);
109
+ if (ptsLine.intersectsLine(boundsEdge)) {
110
+
111
+ return false;
112
+ }
113
+
114
+
115
+ boundsEdge = new Line2D(xmin, ymax, xmin, ymin);
116
+ if (ptsLine.intersectsLine(boundsEdge)) {
117
+
118
+ return false;
119
+ }
120
+
121
+ }
122
+ } catch (exc) {
123
+ if (exc instanceof Error) {
124
+ ErrorLogger.LogException(clsUtility._className, "linesOutsideClipBounds",
125
+ new RendererException("Failed inside linesOutsideClipBounds", exc));
126
+ } else {
127
+ throw exc;
128
+ }
129
+ }
130
+ return true;
131
+ }
132
+ /**
133
+ * Returns the minimum client points needed for the symbol
134
+ * @param lineType line type
135
+ * @return minimum number of clients required to render the line
136
+ * @deprecated use MSInfo.getMinPointCount()
137
+ */
138
+ public static GetMinPoints(lineType: int): int {
139
+ let result: int = -1;
140
+ switch (lineType) {
141
+ case TacticalLines.RECTANGULAR:
142
+ case TacticalLines.CUED_ACQUISITION:
143
+ case TacticalLines.CIRCULAR:
144
+ case TacticalLines.PBS_CIRCLE:
145
+ case TacticalLines.BDZ:
146
+ case TacticalLines.FSA_CIRCULAR:
147
+ case TacticalLines.NOTACK:
148
+ case TacticalLines.FFA_CIRCULAR:
149
+ case TacticalLines.NFA_CIRCULAR:
150
+ case TacticalLines.RFA_CIRCULAR:
151
+ case TacticalLines.ACA_CIRCULAR:
152
+ case TacticalLines.PAA_CIRCULAR:
153
+ case TacticalLines.ATI_CIRCULAR:
154
+ case TacticalLines.CFFZ_CIRCULAR:
155
+ case TacticalLines.SENSOR_CIRCULAR:
156
+ case TacticalLines.CENSOR_CIRCULAR:
157
+ case TacticalLines.DA_CIRCULAR:
158
+ case TacticalLines.CFZ_CIRCULAR:
159
+ case TacticalLines.ZOR_CIRCULAR:
160
+ case TacticalLines.TBA_CIRCULAR:
161
+ case TacticalLines.TVAR_CIRCULAR:
162
+ case TacticalLines.KILLBOXBLUE_CIRCULAR:
163
+ case TacticalLines.KILLBOXPURPLE_CIRCULAR:
164
+ case TacticalLines.LAUNCH_AREA:
165
+ case TacticalLines.DEFENDED_AREA_CIRCULAR:
166
+ case TacticalLines.SHIP_AOI_CIRCULAR:
167
+ case TacticalLines.PBS_ELLIPSE:
168
+ case TacticalLines.RANGE_FAN:
169
+ case TacticalLines.RANGE_FAN_SECTOR:
170
+ case TacticalLines.RADAR_SEARCH: {
171
+ result = 1;
172
+ break;
173
+ }
174
+
175
+ case TacticalLines.PAA_RECTANGULAR:
176
+ case TacticalLines.FSA_RECTANGULAR:
177
+ case TacticalLines.SHIP_AOI_RECTANGULAR:
178
+ case TacticalLines.DEFENDED_AREA_RECTANGULAR:
179
+ case TacticalLines.FFA_RECTANGULAR:
180
+ case TacticalLines.RFA_RECTANGULAR:
181
+ case TacticalLines.NFA_RECTANGULAR:
182
+ case TacticalLines.ACA_RECTANGULAR:
183
+ case TacticalLines.ATI_RECTANGULAR:
184
+ case TacticalLines.CFFZ_RECTANGULAR:
185
+ case TacticalLines.SENSOR_RECTANGULAR:
186
+ case TacticalLines.CENSOR_RECTANGULAR:
187
+ case TacticalLines.DA_RECTANGULAR:
188
+ case TacticalLines.CFZ_RECTANGULAR:
189
+ case TacticalLines.ZOR_RECTANGULAR:
190
+ case TacticalLines.TBA_RECTANGULAR:
191
+ case TacticalLines.TVAR_RECTANGULAR:
192
+ case TacticalLines.KILLBOXBLUE_RECTANGULAR:
193
+ case TacticalLines.KILLBOXPURPLE_RECTANGULAR: {
194
+ result = 2; //was 3
195
+ break;
196
+ }
197
+
198
+ case TacticalLines.SPTBYFIRE:
199
+ case TacticalLines.RIP:
200
+ case TacticalLines.GAP:
201
+ case TacticalLines.ASLTXING:
202
+ case TacticalLines.MSDZ: {
203
+ result = 4;
204
+ break;
205
+ }
206
+
207
+ case TacticalLines.BYPASS:
208
+ case TacticalLines.BLOCK:
209
+ case TacticalLines.BREACH:
210
+ case TacticalLines.CANALIZE:
211
+ case TacticalLines.CLEAR:
212
+ case TacticalLines.CONTAIN:
213
+ case TacticalLines.DELAY:
214
+ case TacticalLines.DISRUPT:
215
+ case TacticalLines.PENETRATE:
216
+ case TacticalLines.RETIRE:
217
+ case TacticalLines.FPOL:
218
+ case TacticalLines.RPOL:
219
+ case TacticalLines.SCREEN:
220
+ case TacticalLines.COVER:
221
+ case TacticalLines.GUARD:
222
+ case TacticalLines.SEIZE:
223
+ case TacticalLines.WITHDRAW:
224
+ case TacticalLines.WDRAWUP:
225
+ //non task autoshapes
226
+ case TacticalLines.SARA:
227
+ case TacticalLines.PDF:
228
+ case TacticalLines.IL:
229
+ case TacticalLines.ATKBYFIRE:
230
+ case TacticalLines.AMBUSH:
231
+ case TacticalLines.RELEASE:
232
+ case TacticalLines.HOL:
233
+ case TacticalLines.BHL:
234
+ case TacticalLines.MNFLDBLK:
235
+ case TacticalLines.MNFLDDIS:
236
+ case TacticalLines.TURN:
237
+ case TacticalLines.PLANNED:
238
+ case TacticalLines.ESR1:
239
+ case TacticalLines.ESR2:
240
+ case TacticalLines.ROADBLK:
241
+ case TacticalLines.EASY:
242
+ case TacticalLines.BYDIF:
243
+ case TacticalLines.BYIMP:
244
+ case TacticalLines.FORDSITE:
245
+ case TacticalLines.FORDIF:
246
+ //METOCs
247
+ case TacticalLines.IFR:
248
+ case TacticalLines.MVFR:
249
+ case TacticalLines.TURBULENCE:
250
+ case TacticalLines.ICING:
251
+ case TacticalLines.NON_CONVECTIVE:
252
+ case TacticalLines.CONVECTIVE:
253
+ case TacticalLines.FROZEN:
254
+ case TacticalLines.THUNDERSTORMS:
255
+ case TacticalLines.FOG:
256
+ case TacticalLines.SAND:
257
+ case TacticalLines.FREEFORM:
258
+ case TacticalLines.DEPTH_AREA:
259
+ case TacticalLines.ISLAND:
260
+ case TacticalLines.BEACH:
261
+ case TacticalLines.WATER:
262
+ case TacticalLines.FISH_TRAPS:
263
+ case TacticalLines.SWEPT_AREA:
264
+ case TacticalLines.OIL_RIG_FIELD:
265
+ case TacticalLines.FOUL_GROUND:
266
+ case TacticalLines.KELP:
267
+ case TacticalLines.BEACH_SLOPE_MODERATE:
268
+ case TacticalLines.BEACH_SLOPE_STEEP:
269
+ case TacticalLines.ANCHORAGE_AREA:
270
+ case TacticalLines.TRAINING_AREA:
271
+ case TacticalLines.FORESHORE_AREA:
272
+ case TacticalLines.DRYDOCK:
273
+ case TacticalLines.LOADING_FACILITY_AREA:
274
+ case TacticalLines.PERCHES:
275
+ case TacticalLines.UNDERWATER_HAZARD:
276
+ case TacticalLines.DISCOLORED_WATER:
277
+ case TacticalLines.BEACH_SLOPE_FLAT:
278
+ case TacticalLines.BEACH_SLOPE_GENTLE:
279
+ case TacticalLines.MARITIME_AREA:
280
+ case TacticalLines.OPERATOR_DEFINED:
281
+ case TacticalLines.SUBMERGED_CRIB:
282
+ case TacticalLines.VDR_LEVEL_12:
283
+ case TacticalLines.VDR_LEVEL_23:
284
+ case TacticalLines.VDR_LEVEL_34:
285
+ case TacticalLines.VDR_LEVEL_45:
286
+ case TacticalLines.VDR_LEVEL_56:
287
+ case TacticalLines.VDR_LEVEL_67:
288
+ case TacticalLines.VDR_LEVEL_78:
289
+ case TacticalLines.VDR_LEVEL_89:
290
+ case TacticalLines.VDR_LEVEL_910:
291
+ case TacticalLines.SOLID_ROCK:
292
+ case TacticalLines.CLAY:
293
+ case TacticalLines.VERY_COARSE_SAND:
294
+ case TacticalLines.COARSE_SAND:
295
+ case TacticalLines.MEDIUM_SAND:
296
+ case TacticalLines.FINE_SAND:
297
+ case TacticalLines.VERY_FINE_SAND:
298
+ case TacticalLines.VERY_FINE_SILT:
299
+ case TacticalLines.FINE_SILT:
300
+ case TacticalLines.MEDIUM_SILT:
301
+ case TacticalLines.COARSE_SILT:
302
+ case TacticalLines.BOULDERS:
303
+ case TacticalLines.OYSTER_SHELLS:
304
+ case TacticalLines.PEBBLES:
305
+ case TacticalLines.SAND_AND_SHELLS:
306
+ case TacticalLines.BOTTOM_SEDIMENTS_LAND:
307
+ case TacticalLines.BOTTOM_SEDIMENTS_NO_DATA:
308
+ case TacticalLines.BOTTOM_ROUGHNESS_SMOOTH:
309
+ case TacticalLines.BOTTOM_ROUGHNESS_MODERATE:
310
+ case TacticalLines.BOTTOM_ROUGHNESS_ROUGH:
311
+ case TacticalLines.CLUTTER_LOW:
312
+ case TacticalLines.CLUTTER_MEDIUM:
313
+ case TacticalLines.CLUTTER_HIGH:
314
+ case TacticalLines.IMPACT_BURIAL_0:
315
+ case TacticalLines.IMPACT_BURIAL_10:
316
+ case TacticalLines.IMPACT_BURIAL_20:
317
+ case TacticalLines.IMPACT_BURIAL_75:
318
+ case TacticalLines.IMPACT_BURIAL_100:
319
+ case TacticalLines.BOTTOM_CATEGORY_A:
320
+ case TacticalLines.BOTTOM_CATEGORY_B:
321
+ case TacticalLines.BOTTOM_CATEGORY_C:
322
+ case TacticalLines.BOTTOM_TYPE_A1:
323
+ case TacticalLines.BOTTOM_TYPE_A2:
324
+ case TacticalLines.BOTTOM_TYPE_A3:
325
+ case TacticalLines.BOTTOM_TYPE_B1:
326
+ case TacticalLines.BOTTOM_TYPE_B2:
327
+ case TacticalLines.BOTTOM_TYPE_B3:
328
+ case TacticalLines.BOTTOM_TYPE_C1:
329
+ case TacticalLines.BOTTOM_TYPE_C2:
330
+ case TacticalLines.BOTTOM_TYPE_C3: {
331
+ result = 3;
332
+ break;
333
+ }
334
+
335
+ case TacticalLines.MRR:
336
+ case TacticalLines.SL:
337
+ case TacticalLines.TC:
338
+ case TacticalLines.SC:
339
+ case TacticalLines.LLTR:
340
+ case TacticalLines.DIRATKAIR:
341
+ case TacticalLines.ABATIS:
342
+ case TacticalLines.CLUSTER:
343
+ case TacticalLines.MNFLDFIX:
344
+ case TacticalLines.FERRY:
345
+ case TacticalLines.MFLANE:
346
+ case TacticalLines.RAFT:
347
+ case TacticalLines.FOXHOLE:
348
+ case TacticalLines.LINTGT:
349
+ case TacticalLines.LINTGTS:
350
+ case TacticalLines.FPF:
351
+ case TacticalLines.CONVOY:
352
+ case TacticalLines.HCONVOY: {
353
+ result = 2;
354
+ break;
355
+ }
356
+
357
+ default: {
358
+ result = 2;
359
+ break;
360
+ }
361
+
362
+ }
363
+ if (clsUtility.isClosedPolygon(lineType)) {
364
+ result = 3;
365
+ }
366
+ //add code for change 1 areas
367
+ return result;
368
+ }
369
+ /**
370
+ * @param linetype line type
371
+ * @return true if the line is a closed area
372
+ */
373
+ public static isClosedPolygon(linetype: int): boolean {
374
+ let result: boolean = false;
375
+ switch (linetype) {
376
+ case TacticalLines.BBS_AREA:
377
+ case TacticalLines.BS_BBOX:
378
+ case TacticalLines.AT:
379
+ case TacticalLines.DEPICT:
380
+ case TacticalLines.DZ:
381
+ case TacticalLines.MINED:
382
+ case TacticalLines.FENCED:
383
+ case TacticalLines.UXO:
384
+ case TacticalLines.ROZ:
385
+ case TacticalLines.AARROZ:
386
+ case TacticalLines.UAROZ:
387
+ case TacticalLines.WEZ:
388
+ case TacticalLines.FEZ:
389
+ case TacticalLines.JEZ:
390
+ case TacticalLines.FAADZ:
391
+ case TacticalLines.HIDACZ:
392
+ case TacticalLines.MEZ:
393
+ case TacticalLines.LOMEZ:
394
+ case TacticalLines.HIMEZ:
395
+ case TacticalLines.WFZ:
396
+ case TacticalLines.PNO:
397
+ case TacticalLines.BATTLE:
398
+ case TacticalLines.EA:
399
+ case TacticalLines.EZ:
400
+ case TacticalLines.LZ:
401
+ case TacticalLines.PZ:
402
+ case TacticalLines.GENERAL:
403
+ case TacticalLines.JTAA:
404
+ case TacticalLines.SAA:
405
+ case TacticalLines.SGAA:
406
+ case TacticalLines.BS_AREA:
407
+ case TacticalLines.ASSAULT:
408
+ case TacticalLines.ATKPOS:
409
+ case TacticalLines.OBJ:
410
+ case TacticalLines.AO:
411
+ case TacticalLines.AIRHEAD:
412
+ case TacticalLines.NAI:
413
+ case TacticalLines.TAI:
414
+ case TacticalLines.BASE_CAMP_REVD:
415
+ case TacticalLines.BASE_CAMP:
416
+ case TacticalLines.GUERILLA_BASE_REVD:
417
+ case TacticalLines.GUERILLA_BASE:
418
+ case TacticalLines.GENERIC_AREA:
419
+ case TacticalLines.OBSFAREA:
420
+ case TacticalLines.OBSAREA:
421
+ case TacticalLines.ZONE:
422
+ case TacticalLines.STRONG:
423
+ case TacticalLines.DRCL:
424
+ case TacticalLines.FSA:
425
+ case TacticalLines.ACA:
426
+ case TacticalLines.ASSY:
427
+ case TacticalLines.BSA:
428
+ case TacticalLines.NFA:
429
+ case TacticalLines.RFA:
430
+ case TacticalLines.FARP:
431
+ case TacticalLines.AIRFIELD:
432
+ case TacticalLines.LAA:
433
+ case TacticalLines.BOMB:
434
+ case TacticalLines.FFA:
435
+ case TacticalLines.SMOKE:
436
+ case TacticalLines.PAA:
437
+ case TacticalLines.ENCIRCLE:
438
+ case TacticalLines.DHA_REVD:
439
+ case TacticalLines.DHA:
440
+ case TacticalLines.EPW:
441
+ case TacticalLines.RHA:
442
+ case TacticalLines.DSA:
443
+ case TacticalLines.CSA:
444
+ case TacticalLines.RSA:
445
+ case TacticalLines.FORT_REVD:
446
+ case TacticalLines.FORT:
447
+ case TacticalLines.PEN:
448
+ case TacticalLines.BIO:
449
+ case TacticalLines.NUC:
450
+ case TacticalLines.RAD:
451
+ case TacticalLines.CHEM:
452
+ case TacticalLines.SERIES:
453
+ case TacticalLines.ATI:
454
+ case TacticalLines.TBA:
455
+ case TacticalLines.TVAR:
456
+ case TacticalLines.CFFZ:
457
+ case TacticalLines.CENSOR:
458
+ case TacticalLines.SENSOR:
459
+ case TacticalLines.ZOR:
460
+ case TacticalLines.DA:
461
+ case TacticalLines.CFZ:
462
+ case TacticalLines.KILLBOXBLUE:
463
+ case TacticalLines.KILLBOXPURPLE:
464
+ //METOCs
465
+ case TacticalLines.IFR:
466
+ case TacticalLines.MVFR:
467
+ case TacticalLines.TURBULENCE:
468
+ case TacticalLines.ICING:
469
+ case TacticalLines.NON_CONVECTIVE:
470
+ case TacticalLines.CONVECTIVE:
471
+ case TacticalLines.FROZEN:
472
+ case TacticalLines.THUNDERSTORMS:
473
+ case TacticalLines.FOG:
474
+ case TacticalLines.SAND:
475
+ case TacticalLines.FREEFORM:
476
+ case TacticalLines.DEPTH_AREA:
477
+ case TacticalLines.ISLAND:
478
+ case TacticalLines.BEACH:
479
+ case TacticalLines.WATER:
480
+ case TacticalLines.FISH_TRAPS:
481
+ case TacticalLines.SWEPT_AREA:
482
+ case TacticalLines.OIL_RIG_FIELD:
483
+ case TacticalLines.FOUL_GROUND:
484
+ case TacticalLines.KELP:
485
+ case TacticalLines.BEACH_SLOPE_MODERATE:
486
+ case TacticalLines.BEACH_SLOPE_STEEP:
487
+ case TacticalLines.ANCHORAGE_AREA:
488
+ case TacticalLines.TRAINING_AREA:
489
+ case TacticalLines.FORESHORE_AREA:
490
+ case TacticalLines.DRYDOCK:
491
+ case TacticalLines.LOADING_FACILITY_AREA:
492
+ case TacticalLines.PERCHES:
493
+ case TacticalLines.UNDERWATER_HAZARD:
494
+ case TacticalLines.DISCOLORED_WATER:
495
+ case TacticalLines.BEACH_SLOPE_FLAT:
496
+ case TacticalLines.BEACH_SLOPE_GENTLE:
497
+ case TacticalLines.MARITIME_AREA:
498
+ case TacticalLines.OPERATOR_DEFINED:
499
+ case TacticalLines.SUBMERGED_CRIB:
500
+ case TacticalLines.VDR_LEVEL_12:
501
+ case TacticalLines.VDR_LEVEL_23:
502
+ case TacticalLines.VDR_LEVEL_34:
503
+ case TacticalLines.VDR_LEVEL_45:
504
+ case TacticalLines.VDR_LEVEL_56:
505
+ case TacticalLines.VDR_LEVEL_67:
506
+ case TacticalLines.VDR_LEVEL_78:
507
+ case TacticalLines.VDR_LEVEL_89:
508
+ case TacticalLines.VDR_LEVEL_910:
509
+ case TacticalLines.SOLID_ROCK:
510
+ case TacticalLines.CLAY:
511
+ case TacticalLines.VERY_COARSE_SAND:
512
+ case TacticalLines.COARSE_SAND:
513
+ case TacticalLines.MEDIUM_SAND:
514
+ case TacticalLines.FINE_SAND:
515
+ case TacticalLines.VERY_FINE_SAND:
516
+ case TacticalLines.VERY_FINE_SILT:
517
+ case TacticalLines.FINE_SILT:
518
+ case TacticalLines.MEDIUM_SILT:
519
+ case TacticalLines.COARSE_SILT:
520
+ case TacticalLines.BOULDERS:
521
+ case TacticalLines.OYSTER_SHELLS:
522
+ case TacticalLines.PEBBLES:
523
+ case TacticalLines.SAND_AND_SHELLS:
524
+ case TacticalLines.BOTTOM_SEDIMENTS_LAND:
525
+ case TacticalLines.BOTTOM_SEDIMENTS_NO_DATA:
526
+ case TacticalLines.BOTTOM_ROUGHNESS_SMOOTH:
527
+ case TacticalLines.BOTTOM_ROUGHNESS_MODERATE:
528
+ case TacticalLines.BOTTOM_ROUGHNESS_ROUGH:
529
+ case TacticalLines.CLUTTER_LOW:
530
+ case TacticalLines.CLUTTER_MEDIUM:
531
+ case TacticalLines.CLUTTER_HIGH:
532
+ case TacticalLines.IMPACT_BURIAL_0:
533
+ case TacticalLines.IMPACT_BURIAL_10:
534
+ case TacticalLines.IMPACT_BURIAL_20:
535
+ case TacticalLines.IMPACT_BURIAL_75:
536
+ case TacticalLines.IMPACT_BURIAL_100:
537
+ case TacticalLines.BOTTOM_CATEGORY_A:
538
+ case TacticalLines.BOTTOM_CATEGORY_B:
539
+ case TacticalLines.BOTTOM_CATEGORY_C:
540
+ case TacticalLines.BOTTOM_TYPE_A1:
541
+ case TacticalLines.BOTTOM_TYPE_A2:
542
+ case TacticalLines.BOTTOM_TYPE_A3:
543
+ case TacticalLines.BOTTOM_TYPE_B1:
544
+ case TacticalLines.BOTTOM_TYPE_B2:
545
+ case TacticalLines.BOTTOM_TYPE_B3:
546
+ case TacticalLines.BOTTOM_TYPE_C1:
547
+ case TacticalLines.BOTTOM_TYPE_C2:
548
+ case TacticalLines.BOTTOM_TYPE_C3:
549
+ case TacticalLines.TGMF: {
550
+ result = true;
551
+ break;
552
+ }
553
+
554
+ default: {
555
+ break;
556
+ }
557
+
558
+ }
559
+ return result;
560
+ }
561
+
562
+ /**
563
+ * Closes the polygon for areas
564
+ * @param Pixels the client points
565
+ */
566
+ public static ClosePolygon(Pixels: Array<POINT2>): void {
567
+ try {
568
+ let pt0: POINT2 = Pixels[0];
569
+ let pt1: POINT2 = Pixels[Pixels.length - 1];
570
+ if (pt0.x !== pt1.x || pt0.y !== pt1.y) {
571
+ Pixels.push(new POINT2(pt0.x, pt0.y));
572
+ }
573
+ } catch (exc) {
574
+ if (exc instanceof Error) {
575
+ ErrorLogger.LogException(clsUtility._className, "ClosePolygon",
576
+ new RendererException("Failed inside ClosePolygon", exc));
577
+ } else {
578
+ throw exc;
579
+ }
580
+ }
581
+ }
582
+ /**
583
+ * for change 1 symbol the W/w1 modifiers run too close to the symbol outline
584
+ * so it shifts the line along the line away from the edge
585
+ * @param p1
586
+ * @param p2
587
+ * @param shift
588
+ */
589
+ public static shiftModifiersLeft(p1: POINT2, p2: POINT2, shift: double): void {
590
+ try {
591
+ let pt1: POINT2 = new POINT2(p1);
592
+ let pt2: POINT2 = new POINT2(p2);
593
+ let dist: double = lineutility.CalcDistanceDouble(pt1, pt2);
594
+ if (pt1.x < pt2.x || (pt1.x === pt2.x && pt1.y < pt2.y)) {
595
+ pt1 = lineutility.ExtendAlongLineDouble(pt2, pt1, dist + shift);
596
+ pt2 = lineutility.ExtendAlongLineDouble(pt1, pt2, dist - shift);
597
+ }
598
+ else {
599
+ pt1 = lineutility.ExtendAlongLineDouble(pt2, pt1, dist - shift);
600
+ pt2 = lineutility.ExtendAlongLineDouble(pt1, pt2, dist + shift);
601
+ }
602
+ p1.x = pt1.x;
603
+ p1.y = pt1.y;
604
+ p2.x = pt2.x;
605
+ p2.y = pt2.y;
606
+ } catch (exc) {
607
+ if (exc instanceof Error) {
608
+ ErrorLogger.LogException(clsUtility._className, "shiftModifiersLeft",
609
+ new RendererException("Failed inside shiftModifiersLeft", exc));
610
+ } else {
611
+ throw exc;
612
+ }
613
+ }
614
+ }
615
+ /**
616
+ * Overrides shape properties for symbols based on Mil-Std-2525
617
+ * @param tg
618
+ * @param shape
619
+ */
620
+ protected static ResolveModifierShape(tg: TGLight, shape: Shape2): void {
621
+ try {
622
+ //shape style was set by CELineArray and takes precedence
623
+ //whenever it is set
624
+ let shapeStyle: int = shape.get_Style();
625
+ let lineStyle: int = tg.get_LineStyle();
626
+ let lineType: int = tg.get_LineType();
627
+ let hasFill: boolean = clsUtility.LinesWithFill(lineType);
628
+ let bolMETOC: int = clsMETOC.IsWeather(tg.get_SymbolId());
629
+ if (bolMETOC > 0) {
630
+
631
+ return;
632
+ }
633
+
634
+ let fillStyle: int = 0;
635
+ //for some of these the style must be dashed
636
+ switch (tg.get_LineType()) {
637
+ case TacticalLines.NFA:
638
+ case TacticalLines.NFA_CIRCULAR:
639
+ case TacticalLines.NFA_RECTANGULAR:
640
+ case TacticalLines.BIO:
641
+ case TacticalLines.NUC:
642
+ case TacticalLines.CHEM:
643
+ case TacticalLines.RAD:
644
+ case TacticalLines.WFZ: {
645
+ //case TacticalLines.OBSAREA:
646
+ fillStyle = 3;
647
+ if (tg.get_UseHatchFill()) {
648
+
649
+ fillStyle = 0;
650
+ }
651
+
652
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_POLYLINE) {
653
+ shape.set_Style(tg.get_LineStyle());
654
+ shape.setLineColor(tg.get_LineColor());
655
+ shape.setFillStyle(fillStyle /*GraphicProperties.FILL_TYPE_RIGHT_SLANTS*/);//was 3
656
+ shape.setFillColor(tg.get_FillColor());
657
+ }
658
+ break;
659
+ }
660
+
661
+ case TacticalLines.OBSAREA: {
662
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_POLYLINE) {
663
+ shape.set_Style(tg.get_LineStyle());
664
+ shape.setLineColor(tg.get_LineColor());
665
+ shape.setFillStyle(0 /*GraphicProperties.FILL_TYPE_RIGHT_SLANTS*/);
666
+ shape.setFillColor(tg.get_FillColor());
667
+ }
668
+ break;
669
+ }
670
+
671
+ case TacticalLines.LAA: {
672
+ fillStyle = 2;
673
+ if (tg.get_UseHatchFill()) {
674
+
675
+ fillStyle = 0;
676
+ }
677
+
678
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_POLYLINE) {
679
+ shape.set_Style(tg.get_LineStyle());
680
+ shape.setLineColor(tg.get_LineColor());
681
+ shape.setFillStyle(fillStyle /*GraphicProperties.FILL_TYPE_LEFT_SLANTS*/);//was 2
682
+ shape.setFillColor(tg.get_FillColor());
683
+ }
684
+ break;
685
+ }
686
+
687
+ case TacticalLines.DIRATKAIR:
688
+ case TacticalLines.ATDITCHC:
689
+ case TacticalLines.ATDITCHM:
690
+ case TacticalLines.SARA:
691
+ case TacticalLines.FOLSP:
692
+ case TacticalLines.FERRY:
693
+ case TacticalLines.MNFLDFIX:
694
+ case TacticalLines.TURN:
695
+ case TacticalLines.MNFLDDIS:
696
+ case TacticalLines.EASY:
697
+ case TacticalLines.BYDIF:
698
+ case TacticalLines.BYIMP: {
699
+ tg.set_lineCap(BasicStroke.CAP_BUTT);
700
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_FILL) {
701
+ shape.setFillStyle(1 /*GraphicProperties.FILL_TYPE_SOLID*/);
702
+ shape.setFillColor(tg.get_LineColor());
703
+ }
704
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_POLYLINE) {
705
+ shape.set_Style(tg.get_LineStyle());
706
+ shape.setLineColor(tg.get_LineColor());
707
+ }
708
+ break;
709
+ }
710
+
711
+ case TacticalLines.CLUSTER:
712
+ case TacticalLines.CATK:
713
+ case TacticalLines.CATKBYFIRE:
714
+ case TacticalLines.PLD:
715
+ case TacticalLines.PLANNED:
716
+ case TacticalLines.CFL:
717
+ case TacticalLines.FORDSITE:
718
+ case TacticalLines.ACOUSTIC_AMB: {
719
+ //any shape for these symbols is dashed
720
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_POLYLINE) {
721
+ shape.set_Style(1 /*GraphicProperties.LINE_TYPE_DASHED*/);
722
+ shape.setLineColor(tg.get_LineColor());
723
+ }
724
+ break;
725
+ }
726
+
727
+ case TacticalLines.PNO: { //always dashed
728
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_POLYLINE) {
729
+ shape.set_Style(1 /*GraphicProperties.LINE_TYPE_DASHED*/);
730
+ shape.setLineColor(tg.get_LineColor());
731
+ shape.setFillColor(tg.get_FillColor());
732
+ shape.setFillStyle(tg.get_FillStyle());
733
+ }
734
+ break;
735
+ }
736
+
737
+ case TacticalLines.FOLLA:
738
+ case TacticalLines.ESR1:
739
+ case TacticalLines.FORDIF: {
740
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_POLYLINE) {
741
+ shape.setLineColor(tg.get_LineColor());
742
+ if (shapeStyle !== lineStyle) {
743
+ if (shapeStyle !== 1 /*GraphicProperties.LINE_TYPE_DASHED*/) {
744
+ shape.set_Style(lineStyle);
745
+ }
746
+ }
747
+ }
748
+ break;
749
+ }
750
+
751
+ default: {
752
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_FILL) {
753
+ shape.setFillStyle(tg.get_FillStyle());
754
+ shape.setFillColor(tg.get_FillColor());
755
+ }
756
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_POLYLINE) {
757
+ if (lineType !== TacticalLines.LC) {
758
+ shape.setLineColor(tg.get_LineColor());
759
+ } else {
760
+ clsUtility.SetLCColor(tg, shape);
761
+ }
762
+ shape.set_Style(lineStyle);
763
+ if (hasFill || clsUtility.isClosedPolygon(lineType) || clsUtility.IsChange1Area(lineType)) {
764
+ switch (lineType) {
765
+ case TacticalLines.RANGE_FAN:
766
+ case TacticalLines.RANGE_FAN_SECTOR:
767
+ case TacticalLines.RADAR_SEARCH:
768
+ case TacticalLines.BBS_AREA:
769
+ case TacticalLines.BBS_RECTANGLE: {
770
+ shape.setFillColor(null);
771
+ break;
772
+ }
773
+
774
+ default: {
775
+ shape.setFillStyle(tg.get_FillStyle());
776
+ shape.setFillColor(tg.get_FillColor());
777
+ break;
778
+ }
779
+
780
+ }
781
+ }
782
+ switch (lineType) {
783
+ case TacticalLines.BS_ELLIPSE:
784
+ case TacticalLines.BS_RECTANGLE: {
785
+ //case TacticalLines.BBS_RECTANGLE:
786
+ shape.setFillStyle(tg.get_FillStyle());
787
+ shape.setFillColor(tg.get_FillColor());
788
+ break;
789
+ }
790
+
791
+ case TacticalLines.BBS_RECTANGLE:
792
+ case TacticalLines.PBS_RECTANGLE:
793
+ case TacticalLines.PBS_SQUARE: {
794
+ shape.setFillColor(null);
795
+ break;
796
+ }
797
+
798
+ default: {
799
+ break;
800
+ }
801
+ }
802
+ }
803
+ break;
804
+ }
805
+
806
+ }
807
+
808
+ } catch (exc) {
809
+ if (exc instanceof Error) {
810
+ ErrorLogger.LogException(clsUtility._className, "ResolveModifierShape",
811
+ new RendererException("Failed inside ResolveModifierShape", exc));
812
+ } else {
813
+ throw exc;
814
+ }
815
+ }
816
+ }
817
+ public static GetOpaqueColor(color: Color): Color {
818
+ let r: int = color.getRed();
819
+ let g: int = color.getGreen();
820
+ let b: int = color.getBlue();
821
+ return new Color(r, g, b);
822
+ }
823
+ /**
824
+ * These lines allow fill
825
+ * @param linetype
826
+ * @return
827
+ */
828
+ public static LinesWithFill(linetype: int): boolean {
829
+ let result: boolean = false;
830
+ try {
831
+ switch (linetype) {
832
+ case TacticalLines.BS_LINE:
833
+ case TacticalLines.PAA_RECTANGULAR:
834
+ case TacticalLines.RECTANGULAR_TARGET:
835
+ case TacticalLines.CFL:
836
+ case TacticalLines.TRIP:
837
+ case TacticalLines.DIRATKAIR:
838
+ case TacticalLines.BOUNDARY:
839
+ case TacticalLines.ISOLATE:
840
+ case TacticalLines.CORDONKNOCK:
841
+ case TacticalLines.CORDONSEARCH:
842
+ case TacticalLines.OCCUPY:
843
+ case TacticalLines.RETAIN:
844
+ case TacticalLines.SECURE:
845
+ case TacticalLines.FLOT:
846
+ case TacticalLines.LC:
847
+ case TacticalLines.PL:
848
+ case TacticalLines.FEBA:
849
+ case TacticalLines.LL:
850
+ case TacticalLines.EWL:
851
+ // case TacticalLines.AC:
852
+ // case TacticalLines.SAAFR:
853
+ case TacticalLines.DIRATKGND:
854
+ case TacticalLines.DIRATKSPT:
855
+ case TacticalLines.FCL:
856
+ case TacticalLines.HOLD:
857
+ case TacticalLines.BRDGHD:
858
+ case TacticalLines.HOLD_GE:
859
+ case TacticalLines.BRDGHD_GE:
860
+ case TacticalLines.LOA:
861
+ case TacticalLines.LOD:
862
+ case TacticalLines.LDLC:
863
+ case TacticalLines.RELEASE:
864
+ case TacticalLines.HOL:
865
+ case TacticalLines.BHL:
866
+ case TacticalLines.LINE:
867
+ case TacticalLines.ABATIS:
868
+ case TacticalLines.ATDITCH:
869
+ case TacticalLines.ATWALL:
870
+ case TacticalLines.SFENCE:
871
+ case TacticalLines.DFENCE:
872
+ case TacticalLines.UNSP:
873
+ case TacticalLines.PLD:
874
+ case TacticalLines.DOUBLEA:
875
+ case TacticalLines.LWFENCE:
876
+ case TacticalLines.HWFENCE:
877
+ case TacticalLines.SINGLEC:
878
+ case TacticalLines.DOUBLEC:
879
+ case TacticalLines.TRIPLE:
880
+ case TacticalLines.FORTL:
881
+ case TacticalLines.LINTGT:
882
+ case TacticalLines.LINTGTS:
883
+ case TacticalLines.FSCL:
884
+ case TacticalLines.BCL_REVD:
885
+ case TacticalLines.BCL:
886
+ case TacticalLines.ICL:
887
+ case TacticalLines.IFF_OFF:
888
+ case TacticalLines.IFF_ON:
889
+ case TacticalLines.GENERIC_LINE:
890
+ case TacticalLines.NFL:
891
+ case TacticalLines.MFP:
892
+ case TacticalLines.RFL:
893
+ case TacticalLines.CONVOY:
894
+ case TacticalLines.HCONVOY:
895
+ case TacticalLines.MSR:
896
+ case TacticalLines.MSR_ONEWAY:
897
+ case TacticalLines.MSR_TWOWAY:
898
+ case TacticalLines.MSR_ALT:
899
+ case TacticalLines.ASR:
900
+ case TacticalLines.ASR_ONEWAY:
901
+ case TacticalLines.ASR_TWOWAY:
902
+ case TacticalLines.ASR_ALT:
903
+ case TacticalLines.ROUTE:
904
+ case TacticalLines.ROUTE_ONEWAY:
905
+ case TacticalLines.ROUTE_ALT: {
906
+ result = true;
907
+ break;
908
+ }
909
+
910
+ default: {
911
+ result = false;
912
+ break;
913
+ }
914
+
915
+ }
916
+ } catch (exc) {
917
+ if (exc instanceof Error) {
918
+ ErrorLogger.LogException(clsUtility._className, "LinesWithFill",
919
+ new RendererException("Failed inside LinesWithFill", exc));
920
+ } else {
921
+ throw exc;
922
+ }
923
+ }
924
+ return result;
925
+ }
926
+ /**
927
+ * @deprecated
928
+ * if the line color and fill color are the same or very close then we want to
929
+ * tweak the fill color a bit to make the line appear distinct from the fill.
930
+ * @param tg
931
+ */
932
+ public static tweakFillColor(tg: TGLight): void {
933
+ try {
934
+ if (clsUtility.isSameColor(tg.get_LineColor(), tg.get_FillColor()) === false) {
935
+
936
+ return;
937
+ }
938
+
939
+
940
+ let fillColor: Color = tg.get_FillColor();
941
+ let r: int = fillColor.getRed();
942
+ let g: int = fillColor.getGreen();
943
+ let b: int = fillColor.getBlue();
944
+ let alpha: int = fillColor.getAlpha();
945
+
946
+ r *= 0.9;
947
+ g *= 0.9;
948
+ b *= 0.9;
949
+ alpha *= 0.8;
950
+
951
+ fillColor = new Color(r, g, b, alpha);
952
+ tg.set_FillColor(fillColor);
953
+ } catch (exc) {
954
+ if (exc instanceof Error) {
955
+ ErrorLogger.LogException(clsUtility._className, "tweakFillColor",
956
+ new RendererException("Failed inside tweakFillColor", exc));
957
+ } else {
958
+ throw exc;
959
+ }
960
+ }
961
+ }
962
+ /**
963
+ * @deprecated
964
+ * Test to see if two colors are similar
965
+ * @param c1
966
+ * @param c2
967
+ * @return true is same (or similar) color
968
+ */
969
+ public static isSameColor(c1: Color, c2: Color): boolean {
970
+ try {
971
+ if (c1 == null || c2 == null) {
972
+
973
+ return true;
974
+ }
975
+
976
+
977
+ let r1: int = c1.getRed();
978
+ let r2: int = c2.getRed();
979
+ let g1: int = c1.getGreen();
980
+ let g2: int = c2.getGreen();
981
+ let
982
+ b1: int = c1.getBlue();
983
+ let b2: int = c2.getBlue();
984
+
985
+ if (Math.abs(r1 - r2) < 5) {
986
+
987
+ if (Math.abs(g1 - g2) < 5) {
988
+
989
+ if (Math.abs(b1 - b2) < 5) {
990
+
991
+ return true;
992
+ }
993
+
994
+ }
995
+
996
+ }
997
+
998
+ } catch (exc) {
999
+ if (exc instanceof Error) {
1000
+ ErrorLogger.LogException(clsUtility._className, "isSameColor",
1001
+ new RendererException("Failed inside isSameColor", exc));
1002
+ } else {
1003
+ throw exc;
1004
+ }
1005
+ }
1006
+ return false;
1007
+ }
1008
+ /**
1009
+ * Customer requested routine for setting the stroke dash pattern
1010
+ * Scales dash length with line width and DPI
1011
+ * @param width
1012
+ * @param style
1013
+ * @param cap
1014
+ * @param join
1015
+ * @return
1016
+ */
1017
+ public static getLineStroke(width: int, style: int, cap: int, join: int): BasicStroke {
1018
+ // Some segments are of length 0.1 because the Java2D renderer adds line caps of
1019
+ // width/2 size to both ends of the segment when "round" is one of BasicStroke.CAP_ROUND
1020
+ // or BasicStroke.CAP_SQUARE. This value is small enough not to affect the
1021
+ // stipple bit pattern calculation for the 3d map and still look good on the
1022
+ // 2d map.
1023
+
1024
+ // NOTE: The dash arrays below do not supportBasisStroke.CAP_BUTT line capping,
1025
+ // although it would be relatively simple to change them such that they would.
1026
+ let stroke: BasicStroke;
1027
+ try {
1028
+ let dashLength: double = 2 * width;
1029
+ let dotLength: double = 1;
1030
+ let dotSpace: double = 2 * width;
1031
+ switch (style) {
1032
+ case 0: {//GraphicProperties.LINE_TYPE_SOLID:
1033
+ stroke = new BasicStroke(width, cap, join);
1034
+ break;
1035
+ }
1036
+
1037
+ case 1: {//GraphicProperties.LINE_TYPE_DASHED:
1038
+ let dash: number[] = [dashLength, dashLength];
1039
+ stroke = new BasicStroke(width, cap, join, 4, dash, 0);
1040
+ break;
1041
+ }
1042
+
1043
+ case 2: {//GraphicProperties.LINE_TYPE_DOTTED:
1044
+ let dot: number[] = [dotLength, dotSpace];
1045
+ stroke = new BasicStroke(width, cap, join, 4, dot, 0);
1046
+ break;
1047
+ }
1048
+
1049
+ case 3: {//GraphicProperties.LINE_TYPE_DASHDOT:
1050
+ let dashdot: number[] = [2 * dashLength, dotSpace, dotLength, dotSpace];
1051
+ stroke = new BasicStroke(width, cap, join, 4, dashdot, 0);
1052
+ break;
1053
+ }
1054
+
1055
+ case 4: {//GraphicProperties.LINE_TYPE_DASHDOTDOT:
1056
+ let dashdotdot: number[] = [dashLength, dotSpace, dotLength, dotSpace, dotLength, dotSpace];
1057
+ stroke = new BasicStroke(width, cap, join, 4, dashdotdot, 0);
1058
+ break;
1059
+ }
1060
+
1061
+ default: {
1062
+ stroke = new BasicStroke(width, cap, join);
1063
+ break;
1064
+ }
1065
+
1066
+ }
1067
+ } catch (exc) {
1068
+ if (exc instanceof Error) {
1069
+ ErrorLogger.LogException(clsUtility._className, "getLineStroke",
1070
+ new RendererException("Failed inside getLineStroke", exc));
1071
+ } else {
1072
+ throw exc;
1073
+ }
1074
+ }
1075
+ return stroke;
1076
+ }
1077
+ /**
1078
+ * Sets shape properties based on other properties which were set by JavaLineArray
1079
+ * @param tg tactical graphic
1080
+ * @param shapes the ShapeInfo array
1081
+ */
1082
+ public static SetShapeProperties(tg: TGLight, shapes: Array<Shape2>): void {
1083
+ try {
1084
+ if (shapes == null) {
1085
+ return;
1086
+ }
1087
+
1088
+ let j: int = 0;
1089
+ let shape: Shape2;
1090
+ let stroke: BasicStroke;
1091
+ let dash: number[];
1092
+ let lineThickness: int = tg.get_LineThickness();
1093
+ let shapeType: int = -1;
1094
+ let lineType: int = tg.get_LineType();
1095
+ let hasFill: boolean = clsUtility.LinesWithFill(lineType);
1096
+ let isChange1Area: boolean = clsUtility.IsChange1Area(lineType);
1097
+ let isClosedPolygon: boolean = clsUtility.isClosedPolygon(lineType);
1098
+ //int n=shapes.length;
1099
+ //remove air corridors fill shapes if fill is null
1100
+ if (tg.get_FillColor() == null) {
1101
+ switch (tg.get_LineType()) {
1102
+ case TacticalLines.AC:
1103
+ case TacticalLines.SAAFR:
1104
+ case TacticalLines.MRR:
1105
+ case TacticalLines.SL:
1106
+ case TacticalLines.TC:
1107
+ case TacticalLines.SC:
1108
+ case TacticalLines.LLTR: {
1109
+ shape = shapes[shapes.length - 1];
1110
+ shapes.length = 0; // shapes.clear()
1111
+ shapes.push(shape);
1112
+ break;
1113
+ }
1114
+
1115
+ case TacticalLines.CATK:
1116
+ case TacticalLines.AIRAOA:
1117
+ case TacticalLines.AAAAA:
1118
+ case TacticalLines.SPT:
1119
+ case TacticalLines.MAIN:
1120
+ case TacticalLines.CATKBYFIRE: { //80
1121
+ let tempShapes: Array<Shape2> = new Array();
1122
+ for (j = 0; j < shapes.length; j++) {
1123
+ shape = shapes[j];
1124
+ if (shape.getShapeType() !== Shape2.SHAPE_TYPE_FILL) {
1125
+
1126
+ tempShapes.push(shape);
1127
+ }
1128
+
1129
+ }
1130
+ shapes = tempShapes;
1131
+ break;
1132
+ }
1133
+
1134
+ default: {
1135
+ break;
1136
+ }
1137
+
1138
+ }
1139
+ }
1140
+ for (j = 0; j < shapes.length; j++) {
1141
+ shape = shapes[j];
1142
+ if (shape == null || shape.getShape() == null) {
1143
+ continue;
1144
+ }
1145
+
1146
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_FILL) {
1147
+ switch (tg.get_LineType()) {
1148
+ case TacticalLines.DEPTH_AREA: {
1149
+ break;
1150
+ }
1151
+
1152
+ default: {
1153
+ shape.setFillColor(tg.get_FillColor());
1154
+ break;
1155
+ }
1156
+
1157
+ }
1158
+ }
1159
+
1160
+ //if(lineType != TacticalLines.LEADING_LINE)
1161
+ clsUtility.ResolveModifierShape(tg, shape);
1162
+ if (lineType === TacticalLines.AIRFIELD) {
1163
+
1164
+ if (j === 1) {
1165
+
1166
+ shape.setFillColor(null);
1167
+ }
1168
+
1169
+ }
1170
+
1171
+ //diagnostic
1172
+ if(lineType==TacticalLines.BBS_POINT)
1173
+ if(j==0)
1174
+ shape.setLineColor(null);
1175
+ //end section
1176
+
1177
+
1178
+ shapeType = shape.getShapeType();
1179
+
1180
+ let rect: Rectangle2D;
1181
+ let grid: Graphics2D;
1182
+ let tp: TexturePaint = tg.get_TexturePaint();
1183
+
1184
+ if (lineThickness === 0) {
1185
+
1186
+ lineThickness = 1;
1187
+ }
1188
+
1189
+ //set the shape with the default properties
1190
+ //the switch statement below will override specific properties as needed
1191
+ stroke = clsUtility.getLineStroke(lineThickness, shape.get_Style(), tg.get_lineCap(), BasicStroke.JOIN_ROUND);
1192
+ if (shape.getShapeType() === Shape2.SHAPE_TYPE_FILL) {
1193
+ stroke = new BasicStroke(lineThickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
1194
+ //shape.setStroke(new BasicStroke(0));
1195
+ }
1196
+ shape.setStroke(stroke);
1197
+ } // end loop over shapes
1198
+ if (tg.get_LineType() === TacticalLines.DIRATKAIR) {
1199
+ // Make arrowhead and bowtie shapes solid even if tg.get_LineStyle() isn't
1200
+ for (let i: int = 2; i < shapes.length; i++) {
1201
+ let arrowHeadShape: Shape2 = shapes[i];
1202
+ arrowHeadShape.set_Style(0);
1203
+ stroke = clsUtility.getLineStroke(lineThickness, 0, tg.get_lineCap(), BasicStroke.JOIN_ROUND);
1204
+ arrowHeadShape.setStroke(stroke);
1205
+ }
1206
+ } else {
1207
+ if (tg.get_LineType() === TacticalLines.DIRATKGND || tg.get_LineType() === TacticalLines.DIRATKSPT) {
1208
+ // Make arrowhead shape solid even if tg.get_LineStyle() isn't
1209
+ let arrowHeadShape: Shape2 = shapes[1];
1210
+ arrowHeadShape.set_Style(0);
1211
+ stroke = clsUtility.getLineStroke(lineThickness, 0, tg.get_lineCap(), BasicStroke.JOIN_ROUND);
1212
+ arrowHeadShape.setStroke(stroke);
1213
+ } else {
1214
+ if (tg.get_LineType() === TacticalLines.PDF) {
1215
+ let rectShape: Shape2 = shapes[1];
1216
+ rectShape.set_Style(0);
1217
+ stroke = clsUtility.getLineStroke(lineThickness, 0, tg.get_lineCap(), BasicStroke.JOIN_ROUND);
1218
+ rectShape.setStroke(stroke);
1219
+ rectShape.setFillColor(rectShape.getLineColor());
1220
+ }
1221
+ }
1222
+
1223
+ }
1224
+
1225
+ } catch (exc) {
1226
+ if (exc instanceof Error) {
1227
+ ErrorLogger.LogException(clsUtility._className, "SetShapeProperties",
1228
+ new RendererException("Failed inside SetShapeProperties", exc));
1229
+ } else {
1230
+ throw exc;
1231
+ }
1232
+ }
1233
+ }
1234
+ /**
1235
+ * Returns a boolean indicating whether the line type is a change 1 area
1236
+ * @param lineType the line type
1237
+ * @return true if change 1 area
1238
+ */
1239
+ public static IsChange1Area(lineType: int): boolean {
1240
+ try {
1241
+ switch (lineType) {
1242
+ case TacticalLines.LAUNCH_AREA:
1243
+ case TacticalLines.DEFENDED_AREA_CIRCULAR:
1244
+ case TacticalLines.SHIP_AOI_CIRCULAR:
1245
+ case TacticalLines.PBS_ELLIPSE:
1246
+ case TacticalLines.RECTANGULAR:
1247
+ case TacticalLines.CUED_ACQUISITION:
1248
+ case TacticalLines.PBS_RECTANGLE:
1249
+ case TacticalLines.PBS_SQUARE:
1250
+ case TacticalLines.CIRCULAR:
1251
+ case TacticalLines.PBS_CIRCLE:
1252
+ case TacticalLines.BDZ:
1253
+ case TacticalLines.BBS_POINT:
1254
+ case TacticalLines.FSA_CIRCULAR:
1255
+ case TacticalLines.NOTACK:
1256
+ case TacticalLines.FFA_CIRCULAR:
1257
+ case TacticalLines.NFA_CIRCULAR:
1258
+ case TacticalLines.RFA_CIRCULAR:
1259
+ case TacticalLines.ACA_CIRCULAR:
1260
+ case TacticalLines.PAA_CIRCULAR:
1261
+ case TacticalLines.ATI_CIRCULAR:
1262
+ case TacticalLines.CFFZ_CIRCULAR:
1263
+ case TacticalLines.SENSOR_CIRCULAR:
1264
+ case TacticalLines.CENSOR_CIRCULAR:
1265
+ case TacticalLines.DA_CIRCULAR:
1266
+ case TacticalLines.CFZ_CIRCULAR:
1267
+ case TacticalLines.ZOR_CIRCULAR:
1268
+ case TacticalLines.TBA_CIRCULAR:
1269
+ case TacticalLines.TVAR_CIRCULAR:
1270
+ case TacticalLines.KILLBOXBLUE_CIRCULAR:
1271
+ case TacticalLines.KILLBOXPURPLE_CIRCULAR:
1272
+ case TacticalLines.RANGE_FAN:
1273
+ case TacticalLines.RANGE_FAN_FILL:
1274
+ case TacticalLines.RANGE_FAN_SECTOR:
1275
+ case TacticalLines.RADAR_SEARCH:
1276
+ case TacticalLines.PAA_RECTANGULAR:
1277
+ case TacticalLines.RECTANGULAR_TARGET:
1278
+ case TacticalLines.FSA_RECTANGULAR:
1279
+ case TacticalLines.SHIP_AOI_RECTANGULAR:
1280
+ case TacticalLines.DEFENDED_AREA_RECTANGULAR:
1281
+ case TacticalLines.FFA_RECTANGULAR:
1282
+ case TacticalLines.RFA_RECTANGULAR:
1283
+ case TacticalLines.NFA_RECTANGULAR:
1284
+ case TacticalLines.ACA_RECTANGULAR:
1285
+ case TacticalLines.ATI_RECTANGULAR:
1286
+ case TacticalLines.CFFZ_RECTANGULAR:
1287
+ case TacticalLines.SENSOR_RECTANGULAR:
1288
+ case TacticalLines.CENSOR_RECTANGULAR:
1289
+ case TacticalLines.DA_RECTANGULAR:
1290
+ case TacticalLines.CFZ_RECTANGULAR:
1291
+ case TacticalLines.ZOR_RECTANGULAR:
1292
+ case TacticalLines.TBA_RECTANGULAR:
1293
+ case TacticalLines.TVAR_RECTANGULAR:
1294
+ case TacticalLines.KILLBOXBLUE_RECTANGULAR:
1295
+ case TacticalLines.KILLBOXPURPLE_RECTANGULAR: {
1296
+ return true;
1297
+ }
1298
+
1299
+ default: {
1300
+ return false;
1301
+ }
1302
+
1303
+ }
1304
+ } catch (exc) {
1305
+ if (exc instanceof Error) {
1306
+ //clsUtility.WriteFile("Error in clsUtility.IsChange1Area");
1307
+ ErrorLogger.LogException(clsUtility._className, "IsChange1Area",
1308
+ new RendererException("Failed inside IsChange1Area", exc));
1309
+ } else {
1310
+ throw exc;
1311
+ }
1312
+ }
1313
+ return false;
1314
+ }
1315
+
1316
+ /**
1317
+ * Calculates point where two lines intersect.
1318
+ * First line defined by pt1, m1.
1319
+ * Second line defined by pt2, m2.
1320
+ * result will be written to ptIntersect.
1321
+ * @param pt1 first line point
1322
+ * @param m1 slope of first line
1323
+ * @param pt2 second line point
1324
+ * @param m2 slope of second line
1325
+ * @param ptIntersect OUT - intersection point
1326
+ */
1327
+ protected static CalcIntersectPt(pt1: POINT2,
1328
+ m1: double,
1329
+ pt2: POINT2,
1330
+ m2: double,
1331
+ ptIntersect: POINT2): void {
1332
+ try {
1333
+ if (m1 === m2) {
1334
+ return;
1335
+ }
1336
+
1337
+ let x1: double = pt1.x;
1338
+ let y1: double = pt1.y;
1339
+ let x2: double = pt2.x;
1340
+ let y2: double = pt2.y;
1341
+ //formula for the intersection of two lines
1342
+ let dx2: double = ((y1 - y2 + m1 * x2 - m1 * x1) / (m2 - m1)) as double;
1343
+ let x3: double = x2 + dx2;
1344
+ let y3: double = (y2 + m2 * dx2) as double;
1345
+
1346
+ ptIntersect.x = x3;
1347
+ ptIntersect.y = y3;
1348
+ } catch (exc) {
1349
+ if (exc instanceof Error) {
1350
+ //clsUtility.WriteFile("Error in clsUtility.CalcIntersectPt");
1351
+ ErrorLogger.LogException(clsUtility._className, "CalcIntersectPt",
1352
+ new RendererException("Failed inside CalcIntersectPt", exc));
1353
+ } else {
1354
+ throw exc;
1355
+ }
1356
+ }
1357
+ }
1358
+
1359
+ /**
1360
+ * Calculates the channel width in pixels for channel types
1361
+ * @param pixels the client points as 2-tuples x,y in pixels
1362
+ * @param distanceToChannelPOINT2 OUT - the calculated distance in pixels from the tip of the
1363
+ * arrowhead to the back of the arrowhead.
1364
+ * @return the channel width in pixels
1365
+ */
1366
+ public static ChannelWidth(pixels: number[],
1367
+ distanceToChannelPOINT2: ref<number[]>): int {
1368
+ let width: int = 0;
1369
+ try {
1370
+ let numPOINT2s: int = pixels.length / 2;
1371
+ if (numPOINT2s < 3) {
1372
+ return 0;
1373
+ }
1374
+
1375
+ let channelWidthPOINT2: POINT2 = new POINT2(0, 0);
1376
+ let lastSegmentPt1: POINT2 = new POINT2(0, 0);
1377
+ let lastSegmentPt2: POINT2 = new POINT2(0, 0);
1378
+
1379
+ lastSegmentPt1.x = pixels[2 * numPOINT2s - 6] as double;
1380
+ lastSegmentPt1.y = pixels[2 * numPOINT2s - 5] as double;
1381
+ lastSegmentPt2.x = pixels[2 * numPOINT2s - 4] as double;
1382
+ lastSegmentPt2.y = pixels[2 * numPOINT2s - 3] as double;
1383
+ channelWidthPOINT2.x = pixels[2 * numPOINT2s - 2] as double;
1384
+ channelWidthPOINT2.y = pixels[2 * numPOINT2s - 1] as double;
1385
+
1386
+ let m: ref<number[]> = new ref();
1387
+ let m1: double = 0;
1388
+ //m1.value=new double[1];
1389
+ let distance: double = 0;
1390
+ let ptIntersect: POINT2 = new POINT2(0, 0);
1391
+ //boolean bolVertical = TrueSlope(lastSegmentPt1, lastSegmentPt2, ref m);
1392
+ let bolVertical: boolean = lineutility.CalcTrueSlopeDouble2(lastSegmentPt1, lastSegmentPt2, m);
1393
+ if (bolVertical === true && m.value[0] !== 0) {
1394
+ m1 = -1 / m.value[0];
1395
+ clsUtility.CalcIntersectPt(channelWidthPOINT2, m1, lastSegmentPt2, m.value[0], ptIntersect);
1396
+ distance = lineutility.CalcDistanceDouble(channelWidthPOINT2, ptIntersect);
1397
+ }
1398
+ if (bolVertical === true && m.value[0] === 0) //horizontal segment
1399
+ {
1400
+ distance = Math.abs(channelWidthPOINT2.y - lastSegmentPt1.y);
1401
+ }
1402
+ if (bolVertical === false) //vertical segment
1403
+ {
1404
+ distance = Math.abs(channelWidthPOINT2.x - lastSegmentPt1.x);
1405
+ distanceToChannelPOINT2.value = new Array<number>(1);
1406
+ distanceToChannelPOINT2.value[0] = distance;
1407
+ return distance as int * 4;
1408
+ }
1409
+
1410
+ width = distance as int * 8;
1411
+ if (width < 2) {
1412
+ width = 2;
1413
+ }
1414
+
1415
+ let hypotenuse: double = lineutility.CalcDistanceDouble(lastSegmentPt2, channelWidthPOINT2);
1416
+ distanceToChannelPOINT2.value = new Array<number>(1);
1417
+ distanceToChannelPOINT2.value[0] = Math.sqrt(hypotenuse * hypotenuse - distance * distance);
1418
+
1419
+ } catch (exc) {
1420
+ if (exc instanceof Error) {
1421
+ //clsUtility.WriteFile("Error in clsUtility.ChannelWidth");
1422
+ ErrorLogger.LogException(clsUtility._className, "ChannelWidth",
1423
+ new RendererException("Failed inside ChannelWidth", exc));
1424
+ } else {
1425
+ throw exc;
1426
+ }
1427
+ }
1428
+ return width;
1429
+ }
1430
+
1431
+ private static InYOrder(pt0: POINT2,
1432
+ pt1: POINT2,
1433
+ pt2: POINT2): boolean {
1434
+ try {
1435
+ if (pt0.y <= pt1.y && pt1.y <= pt2.y) {
1436
+ return true;
1437
+ }
1438
+
1439
+ if (pt2.y <= pt1.y && pt1.y <= pt0.y) {
1440
+ return true;
1441
+ }
1442
+
1443
+ } catch (exc) {
1444
+ if (exc instanceof Error) {
1445
+ //clsUtility.WriteFile("Error in clsUtility.InYOrder");
1446
+ ErrorLogger.LogException(clsUtility._className, "InYOrder",
1447
+ new RendererException("Failed inside InYOrder", exc));
1448
+ } else {
1449
+ throw exc;
1450
+ }
1451
+ }
1452
+ return false;
1453
+ }
1454
+ /// <summary>
1455
+ /// tests if POINT2s have successively increasing or decreasing x values.
1456
+ /// </summary>
1457
+ /// <param name="pt0"></param>
1458
+ /// <param name="pt1"></param>
1459
+ /// <param name="pt2"></param>
1460
+ /// <returns>true if POINT2s are in X order</returns>
1461
+
1462
+ private static InXOrder(pt0: POINT2,
1463
+ pt1: POINT2,
1464
+ pt2: POINT2): boolean {
1465
+ try {
1466
+ if (pt0.x <= pt1.x && pt1.x <= pt2.x) {
1467
+ return true;
1468
+ }
1469
+
1470
+ if (pt2.x <= pt1.x && pt1.x <= pt0.x) {
1471
+ return true;
1472
+ }
1473
+
1474
+ } catch (exc) {
1475
+ if (exc instanceof Error) {
1476
+ //clsUtility.WriteFile("Error in clsUtility.InXOrder");
1477
+ ErrorLogger.LogException(clsUtility._className, "InXOrder",
1478
+ new RendererException("Failed inside InXOrder", exc));
1479
+ } else {
1480
+ throw exc;
1481
+ }
1482
+ }
1483
+ return false;
1484
+ }
1485
+
1486
+ /**
1487
+ * For each sector calculates left azimuth, right azimuth, min radius, max radius
1488
+ * and stuff H2 with the string delimited result. The function is public, called by JavaRendererServer
1489
+ * @param tg tactical graphic
1490
+ */
1491
+ public static GetSectorRadiiFromPoints(tg: TGLight): void {
1492
+ try {
1493
+ if (tg.get_LineType() === TacticalLines.RANGE_FAN_FILL) {
1494
+
1495
+ return;
1496
+ }
1497
+
1498
+ let ptCenter: POINT2 = tg.LatLongs[0];
1499
+ let ptLeftMin: POINT2 = new POINT2();
1500
+ let ptRightMax: POINT2 = new POINT2();
1501
+ let k: int = 0;
1502
+ let strLeft: string = "";
1503
+ let strRight: string = "";
1504
+ let strMin: string = "";
1505
+ let strMax: string = "";
1506
+ let temp: string = "";
1507
+ let nLeft: double = 0;
1508
+ let nRight: double = 0;
1509
+ let nMin: double = 0;
1510
+ let nMax: double = 0;
1511
+ //if tg.PointCollection has more than one point
1512
+ //we use the points to calculate left,right,min,max
1513
+ //and then stuff tg.H2 with the comma delimited string
1514
+ let dist: double = 0;
1515
+ let a12: ref<number[]> = new ref();
1516
+ let a21: ref<number[]> = new ref();
1517
+ let numSectors: int = 0;
1518
+ if (tg.LatLongs.length > 2) {
1519
+ numSectors = (tg.LatLongs.length - 2) / 2;
1520
+ for (k = 0; k < numSectors; k++) {
1521
+ //get the sector points
1522
+ ptLeftMin = tg.LatLongs[2 * k + 2];
1523
+ ptRightMax = tg.LatLongs[2 * k + 3];
1524
+
1525
+ dist = mdlGeodesic.geodesic_distance(ptCenter, ptLeftMin, a12, a21);
1526
+ nLeft = a12.value[0];
1527
+ strLeft = nLeft.toString();
1528
+
1529
+ nMin = dist;
1530
+ strMin = nMin.toString();
1531
+
1532
+ dist = mdlGeodesic.geodesic_distance(ptCenter, ptRightMax, a12, a21);
1533
+ nRight = a12.value[0];
1534
+ strRight = nRight.toString();
1535
+
1536
+ nMax = dist;
1537
+ strMax = nMax.toString();
1538
+
1539
+ if (k === 0) {
1540
+ temp = strLeft + "," + strRight + "," + strMin + "," + strMax;
1541
+ } else {
1542
+ temp += "," + strLeft + "," + strRight + "," + strMin + "," + strMax;
1543
+ }
1544
+ }
1545
+ if (temp !== "") {
1546
+ tg.set_LRMM(temp);
1547
+ }
1548
+ }
1549
+ } catch (exc) {
1550
+ if (exc instanceof Error) {
1551
+ //clsUtility.WriteFile("Error in clsUtility.GetSectorRadiiFromPoints");
1552
+ ErrorLogger.LogException(clsUtility._className, "GetSectorRadiiFromPoints",
1553
+ new RendererException("Failed inside GetSectorRadiiFromPoints", exc));
1554
+ } else {
1555
+ throw exc;
1556
+ }
1557
+ }
1558
+ }
1559
+
1560
+ /**
1561
+ * Reverses the pixels except for the last point. This is used for
1562
+ * the axis of advance type routes. The pixels are 2-tuples x,y
1563
+ *
1564
+ * @param pixels OUT - Array of client points
1565
+ */
1566
+ public static ReorderPixels(pixels: number[]): void {
1567
+ try {
1568
+ let tempPixels: number[];
1569
+ //reverse the pixels
1570
+ let j: int = 0;
1571
+ let x: double = 0;
1572
+ let y: double = 0;
1573
+ let counter: int = 0;
1574
+ let numPoints: int = 0;
1575
+ counter = 0;
1576
+ numPoints = pixels.length / 2;
1577
+ tempPixels = new Array<number>(pixels.length);
1578
+ for (j = 0; j < numPoints - 1; j++) {
1579
+ x = pixels[pixels.length - 2 * j - 4];
1580
+ y = pixels[pixels.length - 2 * j - 3];
1581
+ tempPixels[counter] = x;
1582
+ tempPixels[counter + 1] = y;
1583
+ counter += 2;
1584
+ }
1585
+ //put the last pixel point into the last temppixels point
1586
+ let intPixelSize: int = pixels.length;
1587
+ tempPixels[counter] = pixels[intPixelSize - 2];
1588
+ tempPixels[counter + 1] = pixels[intPixelSize - 1];
1589
+ //stuff the pixels
1590
+ let n: int = pixels.length;
1591
+ //for (j = 0; j < pixels.length; j++)
1592
+ for (j = 0; j < n; j++) {
1593
+ pixels[j] = tempPixels[j];
1594
+ }
1595
+ //tempPixels = null;
1596
+ } catch (exc) {
1597
+ if (exc instanceof Error) {
1598
+ ErrorLogger.LogException(clsUtility._className, "ReorderPixels",
1599
+ new RendererException("Failed inside ReorderPixels", exc));
1600
+ } else {
1601
+ throw exc;
1602
+ }
1603
+ }
1604
+ }
1605
+ /**
1606
+ * do not allow vertical segments for these, move the point x value by 1 pixel
1607
+ * @param tg tactical graphic
1608
+ */
1609
+ public static FilterVerticalSegments(tg: TGLight): void {
1610
+ try {
1611
+ switch (tg.get_LineType()) {
1612
+ case TacticalLines.MAIN:
1613
+ case TacticalLines.CATK:
1614
+ case TacticalLines.CATKBYFIRE:
1615
+ case TacticalLines.AIRAOA:
1616
+ case TacticalLines.AAAAA:
1617
+ case TacticalLines.SPT:
1618
+ case TacticalLines.LC:
1619
+ case TacticalLines.UNSP:
1620
+ case TacticalLines.DFENCE:
1621
+ case TacticalLines.SFENCE:
1622
+ case TacticalLines.DOUBLEA:
1623
+ case TacticalLines.LWFENCE:
1624
+ case TacticalLines.HWFENCE:
1625
+ case TacticalLines.BBS_LINE:
1626
+ case TacticalLines.SINGLEC:
1627
+ case TacticalLines.DOUBLEC:
1628
+ case TacticalLines.TRIPLE:
1629
+ case TacticalLines.MSR_ONEWAY:
1630
+ case TacticalLines.MSR_TWOWAY:
1631
+ case TacticalLines.MSR_ALT:
1632
+ case TacticalLines.ASR_ONEWAY:
1633
+ case TacticalLines.ASR_TWOWAY:
1634
+ case TacticalLines.ASR_ALT:
1635
+ case TacticalLines.ROUTE_ONEWAY:
1636
+ case TacticalLines.ROUTE_ALT:
1637
+ case TacticalLines.ATWALL: {
1638
+ break;
1639
+ }
1640
+
1641
+ default: {
1642
+ return;
1643
+ }
1644
+
1645
+ }
1646
+ let ptCurrent: POINT2;
1647
+ let ptLast: POINT2;
1648
+ let n: int = tg.Pixels.length;
1649
+ //for(int j=1;j<tg.Pixels.length;j++)
1650
+ for (let j: int = 1; j < n; j++) {
1651
+ ptLast = new POINT2(tg.Pixels[j - 1]);
1652
+ ptCurrent = new POINT2(tg.Pixels[j]);
1653
+ //if(Math.round(ptCurrent.x)==Math.round(ptLast.x))
1654
+ if (Math.abs(ptCurrent.x - ptLast.x) < 1) {
1655
+ if (ptCurrent.x >= ptLast.x) {
1656
+
1657
+ ptCurrent.x += 1;
1658
+ }
1659
+
1660
+ else {
1661
+
1662
+ ptCurrent.x -= 1;
1663
+ }
1664
+
1665
+ tg.Pixels[j] = ptCurrent;
1666
+ }
1667
+ }
1668
+ } catch (exc) {
1669
+ if (exc instanceof Error) {
1670
+ ErrorLogger.LogException("clsUtility", "FilterVerticalSegments",
1671
+ new RendererException("Failed inside FilterVerticalSegments", exc));
1672
+
1673
+ } else {
1674
+ throw exc;
1675
+ }
1676
+ }
1677
+ }
1678
+ /**
1679
+ * Client utility to calculate the channel points for channel types.
1680
+ * This code was ported from CJMTK.
1681
+ * @param arrLocation the client points
1682
+ * @return the channel point
1683
+ */
1684
+ public static ComputeLastPoint(arrLocation: Array<POINT2>): POINT2 {
1685
+ let locD: POINT2 = new POINT2(0, 0);
1686
+ try {
1687
+ let locA: POINT2 = arrLocation[1];
1688
+ //Get the first point (b) in pixels.
1689
+ //var locB:Point=new Point(arrLocation[0].x,arrLocation[0].y);
1690
+ let locB: POINT2 = arrLocation[0];
1691
+
1692
+ //Compute the distance in pixels from (a) to (b).
1693
+ let dblDx: double = locB.x - locA.x;
1694
+ let dblDy: double = locB.y - locA.y;
1695
+
1696
+ //Compute the dblAngle in radians from (a) to (b).
1697
+ let dblTheta: double = Math.atan2(-dblDy, dblDx);
1698
+
1699
+ //Compute a reasonable intermediate point along the line from (a) to (b).
1700
+ let locC: POINT2 = new POINT2(0, 0);
1701
+ locC.x = Math.trunc(locA.x + 0.85 * dblDx);
1702
+ locC.y = Math.trunc(locA.y + 0.85 * dblDy);
1703
+ //Put the last point on the left side of the line from (a) to (b).
1704
+ let dblAngle: double = dblTheta + Math.PI / 2.0;
1705
+ if (dblAngle > Math.PI) {
1706
+ dblAngle = dblAngle - 2.0 * Math.PI;
1707
+ }
1708
+ if (dblAngle < -Math.PI) {
1709
+ dblAngle = dblAngle + 2.0 * Math.PI;
1710
+ }
1711
+
1712
+ //Set the magnitude of the dblWidth in pixels. Make sure it is at least 15 pixels.
1713
+ let dblWidth: double = 30;//was 15
1714
+
1715
+ //Compute the last point in pixels.
1716
+ locD.x = (locC.x + dblWidth * Math.cos(dblAngle));
1717
+ locD.y = (locC.y - dblWidth * Math.sin(dblAngle));
1718
+ } catch (exc) {
1719
+ if (exc instanceof Error) {
1720
+ //clsUtility.WriteFile("Error in clsUtility.ComputeLatPoint");
1721
+ ErrorLogger.LogException(clsUtility._className, "ComputeLastPoint",
1722
+ new RendererException("Failed inside ComputeLastPoint", exc));
1723
+ } else {
1724
+ throw exc;
1725
+ }
1726
+ }
1727
+ return locD;
1728
+ }
1729
+
1730
+ /**
1731
+ * Called by clsChannelUtility. The segments are used for managing double-backed segments
1732
+ * for channel types. If the new point is double-backed then the segment at that index will be false.
1733
+ *
1734
+ * @param pixels the client points as 2-tuples x,y in pixels
1735
+ * @param segments OUT - the segments
1736
+ * @param factor a steepness factor for calculating whether the segment is double-backed
1737
+ */
1738
+ public static GetSegments(pixels: number[],
1739
+ segments: boolean[],
1740
+ factor: double): void {
1741
+ try {
1742
+ let j: int = 0;
1743
+ let m1: ref<number[]> = new ref();
1744
+ let m2: ref<number[]> = new ref();
1745
+ let numPoints: int = 0;
1746
+ let bolVertical1: boolean = false;
1747
+ let bolVertical2: boolean = false;
1748
+
1749
+ let pt0F: POINT2 = new POINT2(0, 0);
1750
+ let pt1F: POINT2 = new POINT2(0, 0);
1751
+ let pt2F: POINT2 = new POINT2(0, 0);
1752
+
1753
+ segments[0] = true;
1754
+
1755
+ numPoints = pixels.length / 2;
1756
+ for (j = 0; j < numPoints - 2; j++) {
1757
+ pt0F.x = pixels[2 * j] as double;
1758
+ pt0F.y = pixels[2 * j + 1] as double;
1759
+
1760
+ pt1F.x = pixels[2 * j + 2] as double;
1761
+ pt1F.y = pixels[2 * j + 3] as double;
1762
+
1763
+ pt2F.x = pixels[2 * j + 4] as double;
1764
+ pt2F.y = pixels[2 * j + 5] as double;
1765
+
1766
+ bolVertical1 = lineutility.CalcTrueSlopeDoubleForRoutes(pt0F, pt1F, m1);
1767
+ bolVertical2 = lineutility.CalcTrueSlopeDoubleForRoutes(pt1F, pt2F, m2);
1768
+
1769
+ segments[j + 1] = true;
1770
+ if (bolVertical1 === true && bolVertical2 === true) {
1771
+ if (Math.abs(Math.atan(m1.value[0]) - Math.atan(m2.value[0])) < 1 / factor && clsUtility.InXOrder(pt0F, pt1F, pt2F) === false) //was 0.1
1772
+ {
1773
+ segments[j + 1] = false;
1774
+ }
1775
+ }
1776
+
1777
+ if ((bolVertical1 === false || Math.abs(m1.value[0]) > factor) && (bolVertical2 === false || Math.abs(m2.value[0]) > factor) && clsUtility.InYOrder(pt0F, pt1F, pt2F) === false) //was 10
1778
+ {
1779
+ segments[j + 1] = false;
1780
+ }
1781
+ } //end for
1782
+ //int n=segments.length;
1783
+ } catch (exc) {
1784
+ if (exc instanceof Error) {
1785
+ //console.log(e.message);
1786
+ //clsUtility.WriteFile("Error in clsUtility.GetSegments");
1787
+ ErrorLogger.LogException(clsUtility._className, "GetSegments",
1788
+ new RendererException("Failed inside GetSegments", exc));
1789
+ } else {
1790
+ throw exc;
1791
+ }
1792
+ }
1793
+ }
1794
+
1795
+ public static GetLCPartitions(pixels: number[],
1796
+ LCChannelWith: double,
1797
+ partitions: Array<P1>,
1798
+ singleLinePartitions: Array<P1>): void {
1799
+ try {
1800
+ let numPoints: int = pixels.length / 2;
1801
+ let pt0F: POINT2 = new POINT2(0, 0);
1802
+ let pt1F: POINT2 = new POINT2(0, 0);
1803
+ let pt2F: POINT2 = new POINT2(0, 0);
1804
+
1805
+ let nextP: P1 = new P1();
1806
+ nextP.start = 0;
1807
+
1808
+ //used for debugging
1809
+ let angles: number[] = new Array<number>(numPoints - 1);
1810
+
1811
+ for (let i: int = 0; i < numPoints - 2; i++) {
1812
+ pt0F.x = pixels[2 * i] as double;
1813
+ pt0F.y = pixels[2 * i + 1] as double;
1814
+
1815
+ pt1F.x = pixels[2 * i + 2] as double;
1816
+ pt1F.y = pixels[2 * i + 3] as double;
1817
+
1818
+ pt2F.x = pixels[2 * i + 4] as double;
1819
+ pt2F.y = pixels[2 * i + 5] as double;
1820
+
1821
+ let angle1: double = Math.atan2(pt1F.y - pt0F.y, pt1F.x - pt0F.x);
1822
+ let angle2: double = Math.atan2(pt1F.y - pt2F.y, pt1F.x - pt2F.x);
1823
+ let angle: double = angle1 - angle2;// * 180/Math.PI;
1824
+ let degrees: double = angle * 180 / Math.PI;
1825
+ if (angle < 0) {
1826
+ degrees = 360 + degrees;
1827
+ }
1828
+
1829
+ if (degrees > 270) {
1830
+ let angleTooSmall: boolean = false;
1831
+
1832
+ if (lineutility.CalcDistanceDouble(pt0F, pt1F) < lineutility.CalcDistanceDouble(pt1F, pt2F)) {
1833
+ let newPt: POINT2 = lineutility.ExtendAlongLineDouble2(pt1F, pt2F, lineutility.CalcDistanceDouble(pt1F, pt0F));
1834
+ if (lineutility.CalcDistanceDouble(pt0F, newPt) < LCChannelWith) {
1835
+
1836
+ angleTooSmall = true;
1837
+ }
1838
+
1839
+ } else {
1840
+ let newPt: POINT2 = lineutility.ExtendAlongLineDouble2(pt1F, pt0F, lineutility.CalcDistanceDouble(pt1F, pt2F));
1841
+ if (lineutility.CalcDistanceDouble(pt2F, newPt) < LCChannelWith) {
1842
+
1843
+ angleTooSmall = true;
1844
+ }
1845
+
1846
+ }
1847
+ if (angleTooSmall) {
1848
+ // Angle is too small to fit channel, make it a single line partition
1849
+ nextP.end_Renamed = i - 1;
1850
+ partitions.push(nextP);
1851
+ nextP = new P1();
1852
+ nextP.start = i;
1853
+ nextP.end_Renamed = i + 2;
1854
+ singleLinePartitions.push(nextP);
1855
+ i++;
1856
+ nextP = new P1();
1857
+ nextP.start = i + 1;
1858
+ }
1859
+ } else {
1860
+ if (degrees < 90) {
1861
+ // new Partition
1862
+ nextP.end_Renamed = i;
1863
+ partitions.push(nextP);
1864
+ nextP = new P1();
1865
+ nextP.start = i + 1;
1866
+ }
1867
+ }
1868
+
1869
+ angles[i] = degrees;
1870
+ } //end for
1871
+ nextP.end_Renamed = numPoints - 2;
1872
+ partitions.push(nextP);
1873
+ } catch (exc) {
1874
+ if (exc instanceof Error) {
1875
+ ErrorLogger.LogException(clsUtility._className, "GetLCPartitions",
1876
+ new RendererException("Failed inside GetLCPartitions", exc));
1877
+ } else {
1878
+ throw exc;
1879
+ }
1880
+ }
1881
+ }
1882
+
1883
+ /**
1884
+ * Sets the color for the current shape depending on the affiliation
1885
+ * @param tg
1886
+ * @param shape
1887
+ */
1888
+ protected static SetLCColor(tg: TGLight, shape: Shape2): void {
1889
+ try {
1890
+ if (tg.isHostile()) {
1891
+ if (shape.getLineColor() === Color.RED) {
1892
+ shape.setLineColor(tg.get_LineColor());
1893
+ } else {
1894
+ shape.setLineColor(Color.RED);
1895
+ }
1896
+ } else {
1897
+ if (shape.getLineColor() !== Color.RED) {
1898
+ shape.setLineColor(tg.get_LineColor());
1899
+ } else {
1900
+ shape.setLineColor(Color.RED);
1901
+ }
1902
+ }
1903
+
1904
+ } catch (exc) {
1905
+ if (exc instanceof Error) {
1906
+ //WriteFile("Error in clsUtility.SetLCColor");
1907
+ ErrorLogger.LogException(clsUtility._className, "SetLCColor",
1908
+ new RendererException("Failed inside SetLCColor", exc));
1909
+ } else {
1910
+ throw exc;
1911
+ }
1912
+ }
1913
+ }
1914
+ /**
1915
+ * USAS requires a left-right orientation for ENY, which negates the upper-lower
1916
+ * orientation we used for Mil-Std-2525 ENY compliance. Therefore we must reverse
1917
+ * the client points for two of the quadrants
1918
+ * @param tg tactical graphic
1919
+ */
1920
+ public static ReverseUSASLCPointsByQuadrant(tg: TGLight): void {
1921
+ try {
1922
+ if (tg.Pixels.length < 2) {
1923
+
1924
+ return;
1925
+ }
1926
+
1927
+ let quadrant: int = lineutility.GetQuadrantDouble(tg.Pixels[0], tg.Pixels[1]);
1928
+ switch (tg.get_LineType()) {
1929
+ case TacticalLines.LC: {
1930
+ if (tg.isHostile()) {
1931
+ switch (quadrant) {
1932
+ case 2:
1933
+ case 3: {
1934
+ break;
1935
+ }
1936
+
1937
+ case 1://reverse the points for these two quadrants
1938
+ case 4: {
1939
+ let n: int = tg.Pixels.length;
1940
+ let pts2: Array<POINT2> = [...tg.Pixels];
1941
+ //for(int j=0;j<tg.Pixels.length;j++)
1942
+ for (let j: int = 0; j < n; j++) {
1943
+
1944
+ tg.Pixels[j] = pts2[n - j - 1];
1945
+ }
1946
+
1947
+ break;
1948
+ }
1949
+
1950
+
1951
+ default:
1952
+
1953
+ }//end switch quadrant
1954
+ }//end if
1955
+ else {
1956
+ switch (quadrant) {
1957
+ case 1:
1958
+ case 4: {
1959
+ break;
1960
+ }
1961
+
1962
+ case 2://reverse the points for these two quadrants
1963
+ case 3: {
1964
+ let n: int = tg.Pixels.length;
1965
+ let pts2: Array<POINT2> = [...tg.Pixels];
1966
+ //for(int j=0;j<tg.Pixels.length;j++)
1967
+ for (let j: int = 0; j < n; j++) {
1968
+
1969
+ tg.Pixels[j] = pts2[n - j - 1];
1970
+ }
1971
+
1972
+ break;
1973
+ }
1974
+
1975
+
1976
+ default:
1977
+
1978
+ }//end switch quadrant
1979
+ }
1980
+ break;
1981
+ }
1982
+ //end else
1983
+ default: {
1984
+ break;
1985
+ }
1986
+
1987
+ }//end switch linetype
1988
+ } catch (exc) {
1989
+ if (exc instanceof Error) {
1990
+ //WriteFile("Error in clsUtility.SetLCColor");
1991
+ ErrorLogger.LogException(clsUtility._className, "ReverseUSASLCPointsByQuadrant",
1992
+ new RendererException("Failed inside ReverseUSASLCPointsByQuadrant", exc));
1993
+ } else {
1994
+ throw exc;
1995
+ }
1996
+ }
1997
+ }//end ReverseUSASLCPointsByQuadrant
1998
+ /**
1999
+ * use str if tg is null
2000
+ * @param symbolId Mil=Standard-2525 symbol id
2001
+ * @return line type
2002
+ */
2003
+ public static GetLinetypeFromString(symbolId: string): int {
2004
+ try {
2005
+ if (symbolId.length < 16) {
2006
+ return -1;
2007
+ }
2008
+ let symbolSet: int = SymbolID.getSymbolSet(symbolId);
2009
+ let entityCode: int = SymbolID.getEntityCode(symbolId);
2010
+ let version: int = SymbolID.getVersion(symbolId);
2011
+ if (symbolSet === 25) {
2012
+ return clsRenderer.getCMLineType(version, entityCode);
2013
+ } else {
2014
+ if (symbolSet === 45 || symbolSet === 46) {
2015
+ return clsMETOC.getWeatherLinetype(version, entityCode);
2016
+ }
2017
+ }
2018
+
2019
+ } catch (exc) {
2020
+ if (exc instanceof Error) {
2021
+ ErrorLogger.LogException(clsUtility._className, "GetLinetypeFromString",
2022
+ new RendererException("Failed inside GetLinetypeFromString", exc));
2023
+ } else {
2024
+ throw exc;
2025
+ }
2026
+ }
2027
+ return -1;
2028
+ }
2029
+
2030
+ /**
2031
+ * An auto-shape is a symbol with a fixed number of anchor points
2032
+ *
2033
+ * @param tg tactical graphic
2034
+ * @return true if auto-shape
2035
+ */
2036
+ public static isAutoshape(tg: TGLight): boolean {
2037
+ try {
2038
+ switch(tg.get_LineType())
2039
+ {
2040
+ case TacticalLines.BBS_RECTANGLE:
2041
+ case TacticalLines.BS_RECTANGLE:
2042
+ case TacticalLines.BS_ELLIPSE:
2043
+ case TacticalLines.PBS_CIRCLE:
2044
+ case TacticalLines.BS_CROSS:
2045
+ case TacticalLines.BS_BBOX:
2046
+ case TacticalLines.BBS_POINT:
2047
+ return true;
2048
+ }
2049
+ let msInfo: MSInfo = MSLookup.getInstance().getMSLInfo(tg.get_SymbolId());
2050
+ if (msInfo == null || clsUtility.IsChange1Area(tg.get_LineType())) {
2051
+ return false;
2052
+ }
2053
+ switch (tg.get_LineType()) {
2054
+ case TacticalLines.DIRATKAIR:
2055
+ case TacticalLines.DIRATKGND:
2056
+ case TacticalLines.DIRATKSPT: {
2057
+ // Direction of attack symbols only have two points but can handle more
2058
+ return false;
2059
+ }
2060
+
2061
+ default: {
2062
+ break;
2063
+ }
2064
+
2065
+ }
2066
+ switch (msInfo.getDrawRule()) {
2067
+ case DrawRules.LINE26: // Two ways to draw but fixed points
2068
+ case DrawRules.LINE27: // Two ways to draw but fixed points
2069
+ case DrawRules.AREA26: // Need same number of points in first half and second half to make two shapes
2070
+ case DrawRules.CORRIDOR1: { // Each point represents an Air Control Point or Communications Checkpoint
2071
+ return true;
2072
+ }
2073
+
2074
+ default: {
2075
+ return msInfo.getMaxPointCount() === msInfo.getMinPointCount();
2076
+ }
2077
+
2078
+ }
2079
+ } catch (exc) {
2080
+ if (exc instanceof Error) {
2081
+ ErrorLogger.LogException(clsUtility._className, "isAutoshape",
2082
+ new RendererException("Failed inside isAutoshape", exc));
2083
+ } else {
2084
+ throw exc;
2085
+ }
2086
+ }
2087
+ return false;
2088
+ }
2089
+ /**
2090
+ * Client will send the segment colors within a modifier.
2091
+ * Format is 0:FFBBBB,4:FFAAAA,...
2092
+ * For the time being will assume the modifier being used is the H modifier
2093
+ * @param tg
2094
+ * @return
2095
+ */
2096
+ public static getMSRSegmentColors(tg: TGLight): Map<number, Color> | null {
2097
+ let hMap: Map<number, Color>;
2098
+ try {
2099
+ let linetype: int = tg.get_LineType();
2100
+ switch (linetype) {
2101
+ case TacticalLines.MSR:
2102
+ case TacticalLines.ASR:
2103
+ case TacticalLines.ROUTE:
2104
+ case TacticalLines.BOUNDARY: {
2105
+ if (tg.get_H() == null || tg.get_H().length === 0) {
2106
+
2107
+ return null;
2108
+ }
2109
+
2110
+ hMap = new Map<number, Color>();
2111
+ break;
2112
+ }
2113
+
2114
+ default: {
2115
+ return null;
2116
+ }
2117
+
2118
+ }
2119
+ let colorStrs: string[] = tg.get_H().split(",");
2120
+ let j: int = 0;
2121
+ let numSegs: int = colorStrs.length;
2122
+ let segPlusColor: string = "";
2123
+ let seg: string[];
2124
+ let color: Color;
2125
+ let index: int = -1;
2126
+ for (j = 0; j < numSegs; j++) {
2127
+ segPlusColor = colorStrs[j];
2128
+ if (!segPlusColor.includes(":")) {
2129
+
2130
+ continue;
2131
+ }
2132
+
2133
+ seg = segPlusColor.split(":");
2134
+ color = RendererUtilities.getColorFromHexString(seg[1]);
2135
+ index = parseInt(seg[0]);
2136
+ hMap.set(index, color);
2137
+ }
2138
+ } catch (exc) {
2139
+ if (exc instanceof Error) {
2140
+ ErrorLogger.LogException(clsUtility._className, "getMSRSegmentColors",
2141
+ new RendererException("Failed inside getMSRSegmentColors", exc));
2142
+ } else {
2143
+ throw exc;
2144
+ }
2145
+ }
2146
+ return hMap;
2147
+ }
2148
+ public static getMSRSegmentColorStrings(tg: TGLight): Map<number, string> | null {
2149
+ let hMap: Map<number, string>;
2150
+ try {
2151
+ let linetype: int = tg.get_LineType();
2152
+ switch (linetype) {
2153
+ case TacticalLines.MSR:
2154
+ case TacticalLines.ASR:
2155
+ case TacticalLines.ROUTE:
2156
+ case TacticalLines.BOUNDARY: {
2157
+ if (tg.get_H() == null || tg.get_H().length === 0) {
2158
+
2159
+ return null;
2160
+ }
2161
+
2162
+ hMap = new Map();
2163
+ break;
2164
+ }
2165
+
2166
+ default: {
2167
+ return null;
2168
+ }
2169
+
2170
+ }
2171
+ let colorStrs: string[] = tg.get_H().split(",");
2172
+ let j: int = 0;
2173
+ let numSegs: int = colorStrs.length;
2174
+ let segPlusColor: string = "";
2175
+ let seg: string[];
2176
+ //Color color = null;
2177
+ let index: int = -1;
2178
+ for (j = 0; j < numSegs; j++) {
2179
+ segPlusColor = colorStrs[j];
2180
+ if (!segPlusColor.includes(":")) {
2181
+
2182
+ continue;
2183
+ }
2184
+
2185
+ seg = segPlusColor.split(":");
2186
+ //color = armyc2.c5isr.renderer.utilities.SymbolUtilitiesD.getColorFromHexString(seg[1]);
2187
+ index = parseInt(seg[0]);
2188
+ //hMap.set(new Integer(index), color);
2189
+ hMap.set(index, seg[1]);
2190
+ }
2191
+ } catch (exc) {
2192
+ if (exc instanceof Error) {
2193
+ ErrorLogger.LogException(clsUtility._className, "getMSRSegmentColorStrings",
2194
+ new RendererException("Failed inside getMSRSegmentColorStrings", exc));
2195
+ } else {
2196
+ throw exc;
2197
+ }
2198
+ }
2199
+ return hMap;
2200
+ }
2201
+ /**
2202
+ * tg.H must be revised for clipped MSR, ASR and Boundary
2203
+ * This function is called after the pixels were clipped
2204
+ * @param originalPixels the tactical graphic pixels before clipping
2205
+ * @param tg
2206
+ */
2207
+ public static reviseHModifier(originalPixels: Array<POINT2>,
2208
+ tg: TGLight): void {
2209
+ try {
2210
+ //only revise tg.H if it is not null or empty
2211
+ //and the linetype is bounday, MSR, or ASR
2212
+ if (tg.get_H() == null || tg.get_H().length === 0) {
2213
+
2214
+ return;
2215
+ }
2216
+
2217
+ let linetype: int = tg.get_LineType();
2218
+ switch (linetype) {
2219
+ case TacticalLines.ASR:
2220
+ case TacticalLines.MSR:
2221
+ case TacticalLines.ROUTE:
2222
+ case TacticalLines.BOUNDARY: {
2223
+ break;
2224
+ }
2225
+
2226
+ default: {
2227
+ return;
2228
+ }
2229
+
2230
+ }
2231
+ let j: int = 0;
2232
+ let k: int = 0;
2233
+ //Line2D line=new Line2D();
2234
+
2235
+ //get the first common point between the original points and tg.Pixels
2236
+ //if it is n then n segments will have been dropped at the front end of
2237
+ //the clipped array (from the original pixels) so then we would want to
2238
+ //set the start index to n for the loop through the original points
2239
+ let n: int = -1;
2240
+ let foundPt: boolean = false;
2241
+ let t: int = originalPixels.length;
2242
+ let u: int = tg.Pixels.length;
2243
+ //for(j=0;j<originalPixels.length;j++)
2244
+ for (j = 0; j < t; j++) {
2245
+ //for(k=0;k<tg.Pixels.length;k++)
2246
+ for (k = 0; k < u; k++) {
2247
+ if (originalPixels[j].x === tg.Pixels[k].x && originalPixels[j].y === tg.Pixels[k].y) {
2248
+ n = j;
2249
+ foundPt = true;
2250
+ break;
2251
+ }
2252
+ }
2253
+ if (foundPt) {
2254
+
2255
+ break;
2256
+ }
2257
+
2258
+ }
2259
+ let hmap: Map<number, Color> = clsUtility.getMSRSegmentColors(tg);
2260
+ //use a 2nd hashmap to store the revised segment numbers, and exisitng Colors
2261
+ let hmap2: Map<number, Color> = new Map<number, Color>();
2262
+ let segPt0: POINT2;
2263
+ let segPt1: POINT2; //the original segments
2264
+ let pt0: POINT2;
2265
+ let pt1: POINT2; //the clipped segments
2266
+ let color: Color;
2267
+ if (n < 1) {
2268
+
2269
+ n = 1;
2270
+ }
2271
+
2272
+ for (let key of hmap.keys()) //keys can begin at 0
2273
+ {
2274
+ if (key < n - 1) {
2275
+
2276
+ continue;
2277
+ }
2278
+
2279
+ if (key + 1 > originalPixels.length - 1) {
2280
+
2281
+ break;
2282
+ }
2283
+
2284
+ color = hmap.get(key);
2285
+ segPt0 = originalPixels[key];
2286
+ segPt1 = originalPixels[key + 1];
2287
+ u = tg.Pixels.length;
2288
+ //for(j=0;j<tg.Pixels.length-1;j++)
2289
+ for (j = 0; j < u - 1; j++) {
2290
+ pt0 = tg.Pixels[j];//clipped pixels
2291
+ pt1 = tg.Pixels[j + 1];
2292
+ if (segPt0.x === pt0.x && segPt0.y === pt0.y) {
2293
+ hmap2.set(j, color);
2294
+ break;
2295
+ }
2296
+ else {
2297
+ if (segPt1.x === pt1.x && segPt1.y === pt1.y) {
2298
+ hmap2.set(j, color);
2299
+ break;
2300
+ }
2301
+ else {
2302
+ if (pt0.x === segPt1.x && pt0.y === segPt1.y) {
2303
+
2304
+ continue;
2305
+ }
2306
+
2307
+ if (pt1.x === segPt0.x && pt1.y === segPt0.y) {
2308
+
2309
+ continue;
2310
+ }
2311
+
2312
+ else {
2313
+ //if the original segment straddles or clips the clipping area
2314
+ //then the original segment will contain the clipped segment
2315
+ let dist0: double = lineutility.CalcDistanceToLineDouble(segPt0, segPt1, pt0);
2316
+ let dist1: double = lineutility.CalcDistanceToLineDouble(segPt0, segPt1, pt1);
2317
+ let lineOrigPts: Line2D = new Line2D(segPt0.x, segPt0.y, segPt1.x, segPt1.y);
2318
+ let rectOrigPts: Rectangle2D = lineOrigPts.getBounds2D();
2319
+ let lineClipPts: Line2D = new Line2D(pt0.x, pt0.y, pt1.x, pt1.y);
2320
+ let rectClipPts: Rectangle2D = lineClipPts.getBounds2D();
2321
+ //test if the lines coincide and the clipped segment is within the original segment
2322
+ if (dist0 < 1 && dist1 < 1 && rectOrigPts.contains(rectClipPts)) {
2323
+ hmap2.set(j, color);
2324
+ }
2325
+ }
2326
+ }
2327
+ }
2328
+
2329
+ }
2330
+ }
2331
+ if (hmap2.size === 0) {
2332
+ tg.set_H("");
2333
+ return;
2334
+ }
2335
+
2336
+ let h: string = "";
2337
+ let temp: string = "";
2338
+ for (let key of hmap2.keys()) {
2339
+ color = hmap2.get(key);
2340
+ temp = RendererUtilities.colorToHexString(color, false);
2341
+ h += key.toString() + ":" + temp + ",";
2342
+ }
2343
+ h = h.substring(0, h.length - 1);
2344
+ tg.set_H(h);
2345
+ } catch (exc) {
2346
+ if (exc instanceof Error) {
2347
+ ErrorLogger.LogException(clsUtility._className, "reviseHModifer",
2348
+ new RendererException("Failed inside reviseHModifier", exc));
2349
+ } else {
2350
+ throw exc;
2351
+ }
2352
+ }
2353
+ }
2354
+
2355
+ /**
2356
+ * Adds extra points to LC if there are angles too small to fit the channel
2357
+ * @param tg
2358
+ * @param converter
2359
+ */
2360
+ public static SegmentLCPoints(tg: TGLight, converter: IPointConversion): void {
2361
+ try {
2362
+ if (tg.get_LineType() !== TacticalLines.LC) {
2363
+
2364
+ return;
2365
+ }
2366
+
2367
+
2368
+ let points: Array<POINT2> = tg.get_Pixels();
2369
+
2370
+ let LCChannelWith: double = arraysupport.getScaledSize(40, tg.get_LineThickness(), tg.get_patternScale());
2371
+
2372
+ for (let i: int = 0; i < points.length - 2; i++) {
2373
+ let ptA: POINT2 = new POINT2(points[i].x, points[i].y);
2374
+ let ptB: POINT2 = new POINT2(points[i + 1].x, points[i + 1].y);
2375
+ let ptC: POINT2 = new POINT2(points[i + 2].x, points[i + 2].y);
2376
+
2377
+ let angle1: double = Math.atan2(ptB.y - ptA.y, ptB.x - ptA.x);
2378
+ let angle2: double = Math.atan2(ptB.y - ptC.y, ptB.x - ptC.x);
2379
+ let angle: double = angle1 - angle2;
2380
+ let degrees: double = angle * 180 / Math.PI;
2381
+
2382
+ if (angle < 0) {
2383
+ degrees = 360 + degrees;
2384
+ }
2385
+
2386
+ if (degrees > 270) {
2387
+ // For acute angles where red is the outer line
2388
+ // Determine shorter segment (BA or BC)
2389
+ // On longer segment calculate potential new point (newPt) that is length of smaller segment from B
2390
+ // If distance between smaller segment end point (A or C) and newPt is smaller than the channel width add newPt to points
2391
+ // In GetLCPartitions() the black line won't be included between the smaller line and newPt since there isn't enough space to fit the channel
2392
+ if (lineutility.CalcDistanceDouble(ptB, ptA) < lineutility.CalcDistanceDouble(ptB, ptC)) {
2393
+ // BA is smaller segment
2394
+ let newPt: POINT2 = lineutility.ExtendAlongLineDouble2(ptB, ptC, lineutility.CalcDistanceDouble(ptB, ptA));
2395
+ if (lineutility.CalcDistanceDouble(ptA, newPt) < LCChannelWith) {
2396
+ points.splice(i + 2, 0, new POINT2(newPt.x, newPt.y));
2397
+ i++;
2398
+ }
2399
+ } else {
2400
+ // BC is smaller segment
2401
+ let newPt: POINT2 = lineutility.ExtendAlongLineDouble2(ptB, ptA, lineutility.CalcDistanceDouble(ptB, ptC));
2402
+ if (lineutility.CalcDistanceDouble(ptC, newPt) < LCChannelWith) {
2403
+ points.splice(i + 1, 0, new POINT2(newPt.x, newPt.y));
2404
+ i++;
2405
+ }
2406
+ }
2407
+ }
2408
+ }
2409
+ tg.Pixels = points;
2410
+ tg.LatLongs = renderMPUtility.PixelsToLatLong(points, converter);
2411
+ } catch (exc) {
2412
+ if (exc instanceof Error) {
2413
+ ErrorLogger.LogException(clsUtility._className, "segmentLCPoints",
2414
+ new RendererException("Failed inside segmentLCPoints", exc));
2415
+ } else {
2416
+ throw exc;
2417
+ }
2418
+ }
2419
+ }
2420
+
2421
+ /**
2422
+ * Interpolate pixels for lines with points too close together.
2423
+ * Drops successive points until the next point is at least 10 pixels from the preceding point
2424
+ * @param tg
2425
+ */
2426
+ public static InterpolatePixels(tg: TGLight): void {
2427
+ try {
2428
+ if (tg.get_UseLineInterpolation() === false) {
2429
+
2430
+ return;
2431
+ }
2432
+
2433
+
2434
+ let linetype: int = tg.get_LineType();
2435
+ let glyphSize: double = 10;
2436
+ switch (linetype) {
2437
+ case TacticalLines.ATDITCH:
2438
+ case TacticalLines.ATDITCHC: {
2439
+ glyphSize = 25;
2440
+ break;
2441
+ }
2442
+
2443
+ case TacticalLines.ATDITCHM: {
2444
+ glyphSize = 50;
2445
+ break;
2446
+ }
2447
+
2448
+ case TacticalLines.FLOT:
2449
+ case TacticalLines.LC:
2450
+ case TacticalLines.FORT_REVD:
2451
+ case TacticalLines.FORT:
2452
+ case TacticalLines.FORTL:
2453
+ case TacticalLines.ENCIRCLE:
2454
+ case TacticalLines.ZONE:
2455
+ case TacticalLines.OBSFAREA:
2456
+ case TacticalLines.OBSAREA:
2457
+ case TacticalLines.DOUBLEA:
2458
+ case TacticalLines.LWFENCE:
2459
+ case TacticalLines.HWFENCE:
2460
+ case TacticalLines.BBS_LINE:
2461
+ case TacticalLines.SINGLEC:
2462
+ case TacticalLines.DOUBLEC:
2463
+ case TacticalLines.TRIPLE:
2464
+ case TacticalLines.STRONG: {
2465
+ glyphSize = arraysupport.getScaledSize(30, tg.get_LineThickness(), tg.get_patternScale());
2466
+ break;
2467
+ }
2468
+
2469
+ case TacticalLines.UNSP:
2470
+ case TacticalLines.LINE:
2471
+ case TacticalLines.ATWALL:
2472
+ case TacticalLines.SFENCE: {
2473
+ glyphSize = arraysupport.getScaledSize(40, tg.get_LineThickness(), tg.get_patternScale());
2474
+ break;
2475
+ }
2476
+
2477
+ case TacticalLines.DFENCE: {
2478
+ glyphSize = arraysupport.getScaledSize(50, tg.get_LineThickness(), tg.get_patternScale());
2479
+ break;
2480
+ }
2481
+
2482
+ default: {
2483
+ return;
2484
+ }
2485
+
2486
+ }
2487
+ let hmapPixels: Map<number, POINT2> = new Map<number, POINT2>();
2488
+ let hmapGeo: Map<number, POINT2> = new Map<number, POINT2>();
2489
+ let j: int = 0;
2490
+ let currentIndex: int = 0;
2491
+ let dist: double = 0;
2492
+ let dist2: double = 0;
2493
+ let direction1: double = 0;
2494
+ let direction2: double = 0;
2495
+ let delta: double = 0;
2496
+ let pt0: POINT2;
2497
+ let pt1: POINT2;
2498
+ let pt2: POINT2;
2499
+ let n: int = tg.Pixels.length;
2500
+ //for(j=0;j<tg.Pixels.length;j++)
2501
+ for (j = 0; j < n; j++) {
2502
+ if (j === 0) {
2503
+ hmapPixels.set(j, tg.Pixels[j]);
2504
+ hmapGeo.set(j, tg.LatLongs[j]);
2505
+ currentIndex = 0;
2506
+ }
2507
+ else {
2508
+ if (j === tg.Pixels.length - 1) {
2509
+ hmapPixels.set(j, tg.Pixels[j]);
2510
+ hmapGeo.set(j, tg.LatLongs[j]);
2511
+ }
2512
+ else {
2513
+ dist = lineutility.CalcDistanceDouble(tg.Pixels[currentIndex], tg.Pixels[j]);
2514
+ dist2 = lineutility.CalcDistanceDouble(tg.Pixels[j], tg.Pixels[j + 1]);
2515
+
2516
+ //change of direction test 2-28-13
2517
+ pt0 = tg.Pixels[currentIndex];
2518
+ pt1 = tg.Pixels[j];
2519
+ pt2 = tg.Pixels[j + 1];
2520
+ direction1 = (180 / Math.PI) * Math.atan((pt0.y - pt1.y) / (pt0.x - pt1.x));
2521
+ direction2 = (180 / Math.PI) * Math.atan((pt1.y - pt2.y) / (pt1.x - pt2.x));
2522
+ delta = Math.abs(direction1 - direction2);
2523
+ if (dist > glyphSize || dist2 > glyphSize || delta > 20) {
2524
+ hmapPixels.set(j, tg.Pixels[j]);
2525
+ hmapGeo.set(j, tg.LatLongs[j]);
2526
+ currentIndex = j;
2527
+ }
2528
+ }
2529
+ }
2530
+
2531
+ }
2532
+ let pixels: Array<POINT2> = new Array();
2533
+ let geo: Array<POINT2> = new Array();
2534
+ n = tg.Pixels.length;
2535
+ //for(j=0;j<tg.Pixels.length;j++)
2536
+ for (j = 0; j < n; j++) {
2537
+ if (hmapPixels.has(j)) {
2538
+
2539
+ pixels.push(hmapPixels.get(j) as POINT2);
2540
+ }
2541
+
2542
+ if (hmapGeo.has(j)) {
2543
+
2544
+ geo.push(hmapGeo.get(j) as POINT2);
2545
+ }
2546
+
2547
+ }
2548
+ switch (linetype) {
2549
+ case TacticalLines.FORT_REVD:
2550
+ case TacticalLines.FORT:
2551
+ case TacticalLines.ENCIRCLE:
2552
+ case TacticalLines.ZONE:
2553
+ case TacticalLines.OBSFAREA:
2554
+ case TacticalLines.OBSAREA:
2555
+ case TacticalLines.STRONG: {
2556
+ if (pixels.length === 2) {
2557
+ n = tg.Pixels.length;
2558
+ //for(j=0;j<tg.Pixels.length;j++)
2559
+ for (j = 0; j < n; j++) {
2560
+ if (hmapPixels.has(j) === false && hmapGeo.has(j) === false) {
2561
+ pixels.splice(j, 0, tg.Pixels[j]);
2562
+ geo.splice(j, 0, tg.LatLongs[j]);
2563
+ break;
2564
+ }
2565
+ }
2566
+ }
2567
+ break;
2568
+ }
2569
+
2570
+ default: {
2571
+ break;
2572
+ }
2573
+
2574
+ }
2575
+ tg.Pixels = pixels;
2576
+ tg.LatLongs = geo;
2577
+ } catch (exc) {
2578
+ if (exc instanceof Error) {
2579
+ ErrorLogger.LogException(clsUtility._className, "InterpolatePixels",
2580
+ new RendererException("Failed inside InterpolatePixels", exc));
2581
+ } else {
2582
+ throw exc;
2583
+ }
2584
+ }
2585
+ }
2586
+ /**
2587
+ * construct a line segment outside the polygon corresponding to some index
2588
+ * @param tg
2589
+ * @param index
2590
+ * @param dist
2591
+ * @return
2592
+ */
2593
+ protected static getExtendedLine(tg: TGLight,
2594
+ index: int,
2595
+ dist: double): Line2D {
2596
+ let line: Line2D;
2597
+ try {
2598
+ let polygon: Polygon = new Polygon();
2599
+ let j: int = 0;
2600
+ let n: int = tg.Pixels.length;
2601
+ //for(j=0;j<tg.Pixels.length;j++)
2602
+ for (j = 0; j < n; j++) {
2603
+ polygon.addPoint(tg.Pixels[j].x as int, tg.Pixels[j].y as int);
2604
+ }
2605
+ let pt0: POINT2;
2606
+ let pt1: POINT2;
2607
+ if (tg.Pixels.length > 3) {
2608
+ pt0 = tg.Pixels[index];
2609
+ pt1 = tg.Pixels[index + 1];
2610
+ }
2611
+ else {
2612
+ pt0 = tg.Pixels[1];
2613
+ pt1 = tg.Pixels[2];
2614
+ }
2615
+
2616
+ let ptExtend: POINT2;
2617
+ let extend: int = -1;
2618
+ let midPt: POINT2 = lineutility.MidPointDouble(pt0, pt1, 0);
2619
+ let slope: double = Math.abs(pt1.y - pt0.y) / (pt1.x - pt0.x);
2620
+ if (slope <= 1) {
2621
+ ptExtend = lineutility.ExtendDirectedLine(pt0, pt1, midPt, lineutility.extend_above, 2);
2622
+ if (polygon.contains(ptExtend.x, ptExtend.y)) {
2623
+
2624
+ extend = lineutility.extend_below;
2625
+ }
2626
+
2627
+ else {
2628
+
2629
+ extend = lineutility.extend_above;
2630
+ }
2631
+
2632
+ }
2633
+ else {
2634
+ ptExtend = lineutility.ExtendDirectedLine(pt0, pt1, midPt, lineutility.extend_left, 2);
2635
+ if (polygon.contains(ptExtend.x, ptExtend.y)) {
2636
+
2637
+ extend = lineutility.extend_right;
2638
+ }
2639
+
2640
+ else {
2641
+
2642
+ extend = lineutility.extend_left;
2643
+ }
2644
+
2645
+
2646
+ }
2647
+ let pt3: POINT2;
2648
+ let pt4: POINT2;
2649
+ pt3 = lineutility.ExtendDirectedLine(pt0, pt1, pt0, extend, dist);
2650
+ pt4 = lineutility.ExtendDirectedLine(pt0, pt1, pt1, extend, dist);
2651
+ line = new Line2D(pt3.x, pt3.y, pt4.x, pt4.y);
2652
+ } catch (exc) {
2653
+ if (exc instanceof Error) {
2654
+ ErrorLogger.LogException(clsUtility._className, "getExtendedLine",
2655
+ new RendererException("Failed inside getExtendedLine", exc));
2656
+ } else {
2657
+ throw exc;
2658
+ }
2659
+ }
2660
+ return line;
2661
+ }
2662
+
2663
+ }//end clsUtility