@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,971 @@
1
+ import { type double, type int } from "../../c5isr/graphics2d/BasicTypes";
2
+ import { Line2D } from "../graphics2d/Line2D"
3
+ import { Point2D } from "../graphics2d/Point2D"
4
+ import { Rectangle2D } from "../graphics2d/Rectangle2D"
5
+ import { POINT2 } from "../JavaLineArray/POINT2"
6
+ import { Shape2 } from "../JavaLineArray/Shape2"
7
+ import { TacticalLines } from "../JavaLineArray/TacticalLines"
8
+ import { clsUtility } from "../JavaTacticalRenderer/clsUtility"
9
+ import { TGLight } from "../JavaTacticalRenderer/TGLight"
10
+ import { RendererException } from "../renderer/utilities/RendererException"
11
+ import { ErrorLogger } from "../renderer/utilities/ErrorLogger";
12
+ import { clsUtilityCPOF } from "./clsUtilityCPOF";
13
+
14
+
15
+ /**
16
+ * A class to clip tactical lines and areas
17
+ *
18
+ */
19
+ export class clsClipPolygon2 {
20
+
21
+ private static readonly _className: string = "clsClipPolygon2";
22
+ /**
23
+ * Calculate the point the line intersects an edge of the clipbounds
24
+ * @param pt0 start point of the line
25
+ * @param pt1 end point of the line
26
+ * @param currentEdge
27
+ * @return
28
+ */
29
+ private static intersectPoint(pt0: Point2D,
30
+ pt1: Point2D,
31
+ currentEdge: Line2D): Point2D {
32
+ let ptIntersect: Point2D;
33
+ try {
34
+ let edgePt1: Point2D = currentEdge.getP1();
35
+ let edgePt2: Point2D = currentEdge.getP2();
36
+ let edge_x: double = 0;
37
+ let edge_y: double = 0;
38
+ let m: double = 0;
39
+ let deltaX: double = 0;
40
+ let deltaY: double = 0;
41
+ //vertical edge
42
+ if (Math.abs(edgePt1.getX() - edgePt2.getX()) < Math.abs(edgePt1.getY() - edgePt2.getY())) {
43
+ ptIntersect = new Point2D();
44
+ edge_x = edgePt1.getX();
45
+ //if (pt1.getX() == pt0.getX())
46
+ if (Math.abs(pt1.getX() - pt0.getX()) < 1) {
47
+
48
+ pt1.setLocation(pt1.getX() + 1, pt1.getY());
49
+ }
50
+
51
+
52
+ m = (pt1.getY() - pt0.getY()) / (pt1.getX() - pt0.getX());
53
+ deltaX = edge_x - pt0.getX();
54
+ ptIntersect.setLocation(edge_x, pt0.getY() + m * deltaX);
55
+ }
56
+ //horizontal edge
57
+ else {
58
+ ptIntersect = new Point2D();
59
+ edge_y = edgePt1.getY();
60
+ //if (pt1.getX() == pt0.getX())
61
+ if (Math.abs(pt1.getX() - pt0.getX()) < 1) {
62
+
63
+ pt1.setLocation(pt1.getX() + 1, pt1.getY());
64
+ }
65
+
66
+
67
+ m = (pt1.getY() - pt0.getY()) / (pt1.getX() - pt0.getX());
68
+ deltaY = edge_y - pt0.getY();
69
+ ptIntersect.setLocation(pt0.getX() + deltaY / m, edge_y);
70
+ }
71
+ } catch (exc) {
72
+ if (exc instanceof Error) {
73
+ ErrorLogger.LogException(clsClipPolygon2._className, "intersectPoint",
74
+ new RendererException("Failed inside intersectPoint", exc));
75
+ } else {
76
+ throw exc;
77
+ }
78
+ }
79
+ return ptIntersect;
80
+ }
81
+ /**
82
+ * clip the top
83
+ * on the line is considered inside
84
+ * @param pts
85
+ * @param clipBounds
86
+ * @return
87
+ */
88
+ private static clipTop(tg: TGLight, pts: Array<Point2D>,
89
+ clipBounds: Rectangle2D): Array<Point2D> {
90
+ let ptsResult: Array<Point2D> = new Array();
91
+ try {
92
+ let ulx: double = 0;
93
+ let uly: double = 0;
94
+ let lrx: double = 0;// lry = 0;
95
+ ulx = clipBounds.getMinX();
96
+ uly = clipBounds.getMinY();
97
+ let ul: Point2D = new Point2D(ulx, uly);
98
+ let ur: Point2D = new Point2D(lrx, uly);
99
+
100
+ let j: int = 0;
101
+ let current: Point2D;
102
+ let previous: Point2D;
103
+ let intersectPt: Point2D;
104
+ let edge: Line2D;
105
+ let n: int = pts.length;
106
+ //for (j = 0; j < pts.length; j++)
107
+ for (j = 0; j < n; j++) {
108
+ current = pts[j];
109
+ if (j === 0) {
110
+ previous = pts[pts.length - 1];
111
+ }
112
+ else {
113
+ previous = pts[j - 1];
114
+ }
115
+
116
+ //both inside
117
+ if (previous.getY() >= ul.getY() && current.getY() >= ul.getY()) {
118
+ ptsResult.push(current);
119
+ }
120
+ //previous inside, current outside
121
+ if (previous.getY() >= ul.getY() && current.getY() < ul.getY()) {
122
+ edge = new Line2D(ul, ur);
123
+ intersectPt = clsClipPolygon2.intersectPoint(previous, current, edge);
124
+ if (intersectPt != null) {
125
+ ptsResult.push(intersectPt);
126
+ }
127
+ tg.set_WasClipped(true);
128
+ }
129
+ //both outside
130
+ if (previous.getY() < ul.getY() && current.getY() < ul.getY()) {
131
+ continue;
132
+ }
133
+
134
+ //previous outside current inside
135
+ if (previous.getY() < ul.getY() && current.getY() >= ul.getY()) {
136
+ edge = new Line2D(ul, ur);
137
+ intersectPt = clsClipPolygon2.intersectPoint(previous, current, edge);
138
+ if (intersectPt != null) {
139
+ ptsResult.push(intersectPt);
140
+ }
141
+ ptsResult.push(current);
142
+ tg.set_WasClipped(true);
143
+ }
144
+ }
145
+ } catch (exc) {
146
+ if (exc instanceof Error) {
147
+ ErrorLogger.LogException(clsClipPolygon2._className, "clipTop",
148
+ new RendererException("Failed inside clipTop", exc));
149
+ } else {
150
+ throw exc;
151
+ }
152
+ }
153
+ return ptsResult;
154
+ }
155
+ /**
156
+ * on the boundary is considered inside
157
+ * clip the bottom
158
+ * @param pts
159
+ * @param clipBounds
160
+ * @return
161
+ */
162
+ private static clipBottom(tg: TGLight, pts: Array<Point2D>,
163
+ clipBounds: Rectangle2D): Array<Point2D> {
164
+ let ptsResult: Array<Point2D> = new Array();
165
+ try {
166
+ let ulx: double = 0;
167
+ let uly: double = 0;
168
+ let lrx: double = 0;
169
+ let lry: double = 0;
170
+ ulx = clipBounds.getMinX();
171
+ lrx = clipBounds.getMaxX();
172
+ lry = clipBounds.getMaxY();
173
+ let ll: Point2D = new Point2D(ulx, lry);
174
+ let lr: Point2D = new Point2D(lrx, lry);
175
+
176
+ let j: int = 0;
177
+ let current: Point2D;
178
+ let previous: Point2D;
179
+ let intersectPt: Point2D;
180
+ let edge: Line2D;
181
+ let n: int = pts.length;
182
+ //for (j = 0; j < pts.length; j++)
183
+ for (j = 0; j < n; j++) {
184
+ current = pts[j];
185
+ if (j === 0) {
186
+ previous = pts[pts.length - 1];
187
+ }
188
+ else {
189
+ previous = pts[j - 1];
190
+ }
191
+
192
+ //both inside
193
+ if (previous.getY() <= lr.getY() && current.getY() <= lr.getY()) {
194
+ ptsResult.push(current);
195
+ }
196
+ //previous inside, current outside
197
+ if (previous.getY() <= lr.getY() && current.getY() > lr.getY()) {
198
+ edge = new Line2D(ll, lr);
199
+ intersectPt = clsClipPolygon2.intersectPoint(previous, current, edge);
200
+ if (intersectPt != null) {
201
+ ptsResult.push(intersectPt);
202
+ }
203
+ tg.set_WasClipped(true);
204
+ }
205
+ //both outside
206
+ if (previous.getY() > lr.getY() && current.getY() > lr.getY()) {
207
+ continue;
208
+ }
209
+
210
+ //previous outside current inside
211
+ if (previous.getY() > lr.getY() && current.getY() <= lr.getY()) {
212
+ edge = new Line2D(ll, lr);
213
+ intersectPt = clsClipPolygon2.intersectPoint(previous, current, edge);
214
+ if (intersectPt != null) {
215
+ ptsResult.push(intersectPt);
216
+ }
217
+
218
+ ptsResult.push(current);
219
+ tg.set_WasClipped(true);
220
+ }
221
+ }
222
+ } catch (exc) {
223
+ if (exc instanceof Error) {
224
+ ErrorLogger.LogException(clsClipPolygon2._className, "clipBottom",
225
+ new RendererException("Failed inside clipBottom", exc));
226
+ } else {
227
+ throw exc;
228
+ }
229
+ }
230
+ return ptsResult;
231
+ }
232
+ /**
233
+ * on the bounds is considered inside
234
+ * clip the right side
235
+ * @param pts
236
+ * @param clipBounds
237
+ * @return
238
+ */
239
+ private static clipRight(tg: TGLight, pts: Array<Point2D>,
240
+ clipBounds: Rectangle2D): Array<Point2D> {
241
+ let ptsResult: Array<Point2D> = new Array();
242
+ try {
243
+ let uly: double = 0;
244
+ let lrx: double = 0;
245
+ let lry: double = 0;
246
+ uly = clipBounds.getMinY();
247
+ lrx = clipBounds.getMaxX();
248
+ lry = clipBounds.getMaxY();
249
+ let ur: Point2D = new Point2D(lrx, uly);
250
+ let lr: Point2D = new Point2D(lrx, lry);
251
+ let j: int = 0;
252
+ let current: Point2D;
253
+ let previous: Point2D;
254
+ let intersectPt: Point2D;
255
+ let edge: Line2D;
256
+ let n: int = pts.length;
257
+ //for (j = 0; j < pts.length; j++)
258
+ for (j = 0; j < n; j++) {
259
+ current = pts[j];
260
+ if (j === 0) {
261
+ previous = pts[pts.length - 1];
262
+ } else {
263
+ previous = pts[j - 1];
264
+ }
265
+
266
+ //both inside
267
+ if (previous.getX() <= lr.getX() && current.getX() <= lr.getX()) {
268
+ ptsResult.push(current);
269
+ }
270
+ //previous inside, current outside
271
+ if (previous.getX() <= lr.getX() && current.getX() > lr.getX()) {
272
+ edge = new Line2D(ur, lr);
273
+ intersectPt = clsClipPolygon2.intersectPoint(previous, current, edge);
274
+ if (intersectPt != null) {
275
+ ptsResult.push(intersectPt);
276
+ }
277
+ tg.set_WasClipped(true);
278
+ }
279
+ //both outside
280
+ if (previous.getX() > lr.getX() && current.getX() > lr.getX()) {
281
+ continue;
282
+ }
283
+
284
+ //previous outside current inside
285
+ if (previous.getX() > lr.getX() && current.getX() <= lr.getX()) {
286
+ edge = new Line2D(ur, lr);
287
+ intersectPt = clsClipPolygon2.intersectPoint(previous, current, edge);
288
+ if (intersectPt != null) {
289
+ ptsResult.push(intersectPt);
290
+ }
291
+
292
+ //if(j!=0 || clsUtility.isClosedPolygon(tg.get_LineType())==true)
293
+ ptsResult.push(current);
294
+ tg.set_WasClipped(true);
295
+ }
296
+ }
297
+ } catch (exc) {
298
+ if (exc instanceof Error) {
299
+ ErrorLogger.LogException(clsClipPolygon2._className, "clipRight",
300
+ new RendererException("Failed inside clipRight", exc));
301
+ } else {
302
+ throw exc;
303
+ }
304
+ }
305
+ return ptsResult;
306
+ }
307
+ /**
308
+ * on the line is considered inside
309
+ * clip the left side
310
+ * @param pts
311
+ * @param clipBounds
312
+ * @return
313
+ */
314
+ private static clipLeft(tg: TGLight, pts: Array<Point2D>,
315
+ clipBounds: Rectangle2D): Array<Point2D> {
316
+ let ptsResult: Array<Point2D> = new Array();
317
+ try {
318
+ let ulx: double = 0;
319
+ let uly: double = 0;
320
+ let lry: double = 0;
321
+ ulx = clipBounds.getMinX();
322
+ uly = clipBounds.getMinY();
323
+ lry = clipBounds.getMaxY();
324
+ let ul: Point2D = new Point2D(ulx, uly);
325
+ let ll: Point2D = new Point2D(ulx, lry);
326
+
327
+ let j: int = 0;
328
+ let current: Point2D;
329
+ let previous: Point2D;
330
+ let intersectPt: Point2D;
331
+ let edge: Line2D;
332
+ let n: int = pts.length;
333
+ //for (j = 0; j < pts.length; j++)
334
+ for (j = 0; j < n; j++) {
335
+ current = pts[j];
336
+ if (j === 0) {
337
+ previous = pts[pts.length - 1];
338
+ }
339
+ else {
340
+ previous = pts[j - 1];
341
+ }
342
+
343
+ //both inside
344
+ if (previous.getX() >= ll.getX() && current.getX() >= ll.getX()) {
345
+ ptsResult.push(current);
346
+ }
347
+ //previous inside, current outside
348
+ if (previous.getX() >= ll.getX() && current.getX() < ll.getX()) {
349
+ edge = new Line2D(ul, ll);
350
+ intersectPt = clsClipPolygon2.intersectPoint(previous, current, edge);
351
+ if (intersectPt != null) {
352
+ ptsResult.push(intersectPt);
353
+ }
354
+ tg.set_WasClipped(true);
355
+ }
356
+ //both outside
357
+ if (previous.getX() < ll.getX() && current.getX() < ll.getX()) {
358
+ continue;
359
+ }
360
+
361
+ //previous outside current inside
362
+ if (previous.getX() < ll.getX() && current.getX() >= ll.getX()) {
363
+ edge = new Line2D(ul, ll);
364
+ intersectPt = clsClipPolygon2.intersectPoint(previous, current, edge);
365
+ if (intersectPt != null) {
366
+ ptsResult.push(intersectPt);
367
+ }
368
+
369
+ //if(j!=0 || clsUtility.isClosedPolygon(tg.get_LineType())==true)
370
+ ptsResult.push(current);
371
+ tg.set_WasClipped(true);
372
+ }
373
+ }
374
+ } catch (exc) {
375
+ if (exc instanceof Error) {
376
+ ErrorLogger.LogException(clsClipPolygon2._className, "clipLeft",
377
+ new RendererException("Failed inside clipLeft", exc));
378
+ } else {
379
+ throw exc;
380
+ }
381
+ }
382
+ return ptsResult;
383
+ }
384
+
385
+ /**
386
+ * for non-areas add points to the ends as necessary to make the algorithm work
387
+ * @param polygon
388
+ * @param clipBounds
389
+ */
390
+ private static AddBoundaryPointsForLines(polygon: Array<Point2D>,
391
+ clipBounds: Rectangle2D): int {
392
+ let result: int = 0;
393
+ try {
394
+ let ulx: double = 0;
395
+ let uly: double = 0;
396
+ let lrx: double = 0;
397
+ let lry: double = 0;
398
+ ulx = clipBounds.getMinX();
399
+ uly = clipBounds.getMinY();
400
+ lrx = clipBounds.getMaxX();
401
+ lry = clipBounds.getMaxY();
402
+ //move these inside by 10 pixels so the algoithm will treat them as inside points
403
+ let ul: Point2D = new Point2D(ulx + 10, uly + 10);
404
+ let ur: Point2D = new Point2D(lrx - 10, uly + 10);
405
+ let ll: Point2D = new Point2D(ulx + 10, lry - 10);
406
+ let lr: Point2D = new Point2D(lrx - 10, lry - 10);
407
+
408
+ let pt0: Point2D = polygon[0];
409
+ let ptn: Point2D = polygon[polygon.length - 1];
410
+ //double dist0 = 0, dist1 = 0;
411
+ let addToFront: boolean = false;
412
+ let addToEnd: boolean = false;
413
+ //add a point to the begining of the array
414
+ if (pt0.getY() < uly) //above the top clip
415
+ {
416
+ polygon.splice(0, 0, ul);
417
+ addToFront = true;
418
+ } else if (pt0.getX() < ulx) //outside the left clip
419
+ {
420
+ polygon.splice(0, 0, ul);
421
+ addToFront = true;
422
+ } else if (pt0.getX() > lrx) //outside the right clip
423
+ {
424
+ polygon.splice(0, 0, lr);
425
+ addToFront = true;
426
+ } else if (pt0.getY() > lry) //below the bottom clip
427
+ {
428
+ polygon.splice(0, 0, lr);
429
+ addToFront = true;
430
+ }
431
+
432
+ //add a point to the end of the array
433
+ if (ptn.getY() < uly) //above the top clip
434
+ {
435
+ polygon.push(ul);
436
+ addToEnd = true;
437
+ } else if (ptn.getX() < ulx) //outside the left clip
438
+ {
439
+ polygon.push(ul);
440
+ addToEnd = true;
441
+ } else if (ptn.getX() > lrx) //outside the right clip
442
+ {
443
+ polygon.push(lr);
444
+ addToEnd = true;
445
+ } else if (ptn.getY() > lry) //below the bottom clip
446
+ {
447
+ polygon.push(lr);
448
+ addToEnd = true;
449
+ }
450
+
451
+ if (addToFront === false && addToEnd === false) {
452
+ result = 0;
453
+ }
454
+ if (addToFront === true && addToEnd === false) {
455
+ result = 1;
456
+ }
457
+ if (addToFront === false && addToEnd === true) {
458
+ result = 2;
459
+ }
460
+ if (addToFront === true && addToEnd === true) {
461
+ result = 3;
462
+ }
463
+
464
+ } catch (exc) {
465
+ if (exc instanceof Error) {
466
+ ErrorLogger.LogException(clsClipPolygon2._className, "AddBoundaryPointsForLines",
467
+ new RendererException("Failed inside AddBoundaryPointsForLines", exc));
468
+ } else {
469
+ throw exc;
470
+ }
471
+ }
472
+ return result;
473
+ }
474
+ /**
475
+ * closes an area
476
+ * @param tg
477
+ */
478
+ private static closeAreaTG(tg: TGLight): void {
479
+ try {
480
+ if (tg.Pixels == null || tg.Pixels.length === 0) {
481
+
482
+ return;
483
+ }
484
+
485
+
486
+ let pt0: POINT2 = tg.Pixels[0];
487
+ let ptn: POINT2 = tg.Pixels[tg.Pixels.length - 1];
488
+ if (pt0.x !== ptn.x || pt0.y !== ptn.y) {
489
+
490
+ tg.Pixels.push(pt0);
491
+ }
492
+
493
+
494
+ } catch (exc) {
495
+ if (exc instanceof Error) {
496
+ ErrorLogger.LogException(clsClipPolygon2._className, "closeAreaTG",
497
+ new RendererException("Failed inside closeAreaTG", exc));
498
+ } else {
499
+ throw exc;
500
+ }
501
+ }
502
+ }
503
+ /**
504
+ * DMA, DMAF fill must be handled separately because of the feint
505
+ * @param tg
506
+ * @param clipBounds
507
+ * @return
508
+ */
509
+ protected static fillDMA(tg: TGLight,
510
+ clipBounds: Rectangle2D): Array<Shape2> {
511
+ let shapes: Array<Shape2> = new Array();
512
+ try {
513
+ switch (tg.get_LineType()) {
514
+ case TacticalLines.OBSFAREA:
515
+ case TacticalLines.OBSAREA:
516
+ case TacticalLines.STRONG:
517
+ case TacticalLines.ZONE:
518
+ case TacticalLines.FORT_REVD:
519
+ case TacticalLines.FORT:
520
+ case TacticalLines.ENCIRCLE:
521
+ case TacticalLines.ATDITCHC:
522
+ case TacticalLines.ATDITCHM: {
523
+ break;
524
+ }
525
+
526
+ default: {
527
+ return shapes;
528
+ }
529
+
530
+ }
531
+ let shape: Shape2;
532
+
533
+ //create a generic area tg from the pixels and clip it
534
+ let j: int = 0;
535
+ let tg2: TGLight = new TGLight();
536
+ tg2.set_LineType(TacticalLines.GENERAL);
537
+ tg2.Pixels = new Array();
538
+ //to get the original pixels size
539
+ //int n=0;
540
+ let n: int = tg.Pixels.length;
541
+
542
+ for (j = 0; j < n; j++) {
543
+
544
+ tg2.Pixels.push(tg.Pixels[j]);
545
+ }
546
+
547
+
548
+ clsClipPolygon2.closeAreaTG(tg2);
549
+
550
+ if (clipBounds != null) {
551
+
552
+ clsClipPolygon2.ClipPolygon(tg2, clipBounds);
553
+ }
554
+
555
+
556
+ if (tg2.Pixels == null || tg2.Pixels.length === 0) {
557
+
558
+ return shapes;
559
+ }
560
+
561
+
562
+ //shape=new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
563
+ shape = new Shape2(Shape2.SHAPE_TYPE_FILL);
564
+ shape.setFillColor(tg.get_FillColor());
565
+
566
+ shape.moveTo(tg2.Pixels[0]);
567
+ //original pixels do not include feint
568
+ n = tg2.Pixels.length;
569
+ //for(j=1;j<tg2.Pixels.length;j++)
570
+ for (j = 1; j < n; j++) {
571
+
572
+ shape.lineTo(tg2.Pixels[j]);
573
+ }
574
+
575
+
576
+ shapes.push(shape);
577
+ } catch (exc) {
578
+ if (exc instanceof Error) {
579
+ ErrorLogger.LogException(clsClipPolygon2._className, "fillDMA",
580
+ new RendererException("Failed inside fillDMA", exc));
581
+ } else {
582
+ throw exc;
583
+ }
584
+ }
585
+ return shapes;
586
+ }
587
+ /**
588
+ * for pre-clipped lines which also require fill but need the processed points
589
+ * to create the fill. This functioni is called after the clip, so the fill
590
+ * does not get clipped.
591
+ * @param tg
592
+ * @param shapes
593
+ */
594
+ static addAbatisFill(tg: TGLight,
595
+ shapes: Array<Shape2>): void {
596
+ try {
597
+ if (tg.Pixels == null ||
598
+ tg.Pixels.length < 2 ||
599
+ tg.get_FillColor() == null ||
600
+ tg.get_FillColor().getAlpha() < 2 ||
601
+ shapes == null) {
602
+
603
+ return;
604
+ }
605
+
606
+
607
+ let j: int = 0;
608
+ let n: int = tg.Pixels.length;
609
+ let shape: Shape2;
610
+ let tg2: TGLight;
611
+ switch (tg.get_LineType()) {
612
+ case TacticalLines.MSDZ: {
613
+ let dist0: double = 0;
614
+ let dist1: double = 0;
615
+ let dist2: double = 0;
616
+ shape = new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
617
+ shape.setFillColor(tg.get_FillColor());
618
+ if (tg.Pixels != null && tg.Pixels.length >= 300) {
619
+ dist0 = Math.abs(tg.Pixels[0].x - tg.Pixels[50].x);
620
+ dist1 = Math.abs(tg.Pixels[100].x - tg.Pixels[150].x);
621
+ dist2 = Math.abs(tg.Pixels[200].x - tg.Pixels[250].x);
622
+ let start: int = -1;
623
+ let end: int = -1;
624
+ if (dist0 >= dist1 && dist0 >= dist2) {
625
+ start = 0;
626
+ end = 99;
627
+ }
628
+ else {
629
+ if (dist1 >= dist0 && dist1 >= dist2) {
630
+ start = 100;
631
+ end = 199;
632
+ }
633
+ else {
634
+ start = 200;
635
+ end = 299;
636
+ }
637
+ }
638
+
639
+ shape.moveTo(tg.Pixels[start]);
640
+ for (j = start; j <= end; j++) {
641
+
642
+ shape.lineTo(tg.Pixels[j]);
643
+ }
644
+
645
+
646
+ //shapes.add(0,shape);
647
+ }
648
+ break;
649
+ }
650
+
651
+ case TacticalLines.ABATIS: {
652
+ shape = new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
653
+ shape.setFillColor(tg.get_FillColor());
654
+ tg2 = new TGLight();
655
+ tg2.set_LineType(TacticalLines.GENERAL);
656
+ tg2.Pixels = new Array();
657
+ if (tg.Pixels != null && tg.Pixels.length > 2) {
658
+ tg2.Pixels.push(tg.Pixels[n - 3]);
659
+ tg2.Pixels.push(tg.Pixels[n - 2]);
660
+ tg2.Pixels.push(tg.Pixels[n - 1]);
661
+ tg2.Pixels.push(tg.Pixels[n - 3]);
662
+
663
+ shape.moveTo(tg2.Pixels[0]);
664
+ for (j = 1; j < tg2.Pixels.length; j++) {
665
+
666
+ shape.lineTo(tg2.Pixels[j]);
667
+ }
668
+
669
+
670
+ //shapes.push(shape);
671
+ }
672
+ break;
673
+ }
674
+
675
+ default: {
676
+ return;
677
+ }
678
+
679
+ }//end switch
680
+ if (shapes != null) {
681
+ shapes.splice(0, 0, shape);
682
+ }
683
+
684
+ } catch (exc) {
685
+ if (exc instanceof Error) {
686
+ ErrorLogger.LogException(clsClipPolygon2._className, "addAbatisFill",
687
+ new RendererException("Failed inside addAbatisFill", exc));
688
+ } else {
689
+ throw exc;
690
+ }
691
+ }
692
+ }
693
+ /**
694
+ * for lines with glyphs the fill must be handled (clipped) as a separate shape.
695
+ * this function needs to be called before the clipping is done to the line
696
+ * @param tg
697
+ * @param clipBounds
698
+ */
699
+ static LinesWithFill(tg: TGLight,
700
+ clipBounds: Rectangle2D | null): Array<Shape2> | null {
701
+ let shapes: Array<Shape2> = null;
702
+ try {
703
+ if (tg.get_FillColor() == null || tg.get_FillColor().getAlpha() <= 1 ||
704
+ tg.Pixels == null || tg.Pixels.length === 0) {
705
+
706
+ return shapes;
707
+ }
708
+
709
+
710
+ switch (tg.get_LineType()) {
711
+ case TacticalLines.ABATIS:
712
+ case TacticalLines.SPT:
713
+ case TacticalLines.MAIN:
714
+ case TacticalLines.AAAAA:
715
+ case TacticalLines.AIRAOA:
716
+ case TacticalLines.CATK:
717
+ case TacticalLines.CATKBYFIRE:
718
+ case TacticalLines.CORDONSEARCH:
719
+ case TacticalLines.CORDONKNOCK:
720
+ case TacticalLines.SECURE:
721
+ case TacticalLines.OCCUPY:
722
+ case TacticalLines.RETAIN:
723
+ case TacticalLines.ISOLATE:
724
+ case TacticalLines.CONVOY:
725
+ case TacticalLines.HCONVOY: {
726
+ return shapes;
727
+ }
728
+
729
+ case TacticalLines.PAA_RECTANGULAR:
730
+ case TacticalLines.RECTANGULAR_TARGET: {
731
+ return null;
732
+ }
733
+
734
+ case TacticalLines.OBSFAREA:
735
+ case TacticalLines.OBSAREA:
736
+ case TacticalLines.STRONG:
737
+ case TacticalLines.ZONE:
738
+ case TacticalLines.FORT_REVD:
739
+ case TacticalLines.FORT:
740
+ case TacticalLines.ENCIRCLE:
741
+ case TacticalLines.ATDITCHC:
742
+ case TacticalLines.ATDITCHM: {
743
+ return clsClipPolygon2.fillDMA(tg, clipBounds);
744
+ }
745
+
746
+ default: {
747
+ break;
748
+ }
749
+
750
+ }
751
+ if (clsUtility.LinesWithFill(tg.get_LineType()) === false) {
752
+ return shapes;
753
+ }
754
+
755
+
756
+ shapes = new Array();
757
+ //undo any fillcolor that might have been set for the existing shape
758
+ //because we are divorcing fill from the line
759
+ let shape: Shape2;
760
+
761
+ //create a generic area tg from the pixels and clip it
762
+ let tg2: TGLight = new TGLight();
763
+ tg2.set_LineType(TacticalLines.GENERAL);
764
+ tg2.Pixels = new Array();
765
+ tg2.Pixels.push(...tg.Pixels);
766
+ clsClipPolygon2.closeAreaTG(tg2);
767
+ //tg2.Pixels.push(tg.Pixels[0]);
768
+ if (clipBounds != null) {
769
+
770
+ clsClipPolygon2.ClipPolygon(tg2, clipBounds);
771
+ }
772
+
773
+
774
+
775
+ if (tg2.Pixels == null || tg2.Pixels.length === 0) {
776
+
777
+ return null;
778
+ }
779
+
780
+
781
+ let j: int = 0;
782
+ //shape=new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
783
+ shape = new Shape2(Shape2.SHAPE_TYPE_FILL);
784
+ shape.setFillColor(tg.get_FillColor());
785
+
786
+ shape.moveTo(tg2.Pixels[0]);
787
+ for (j = 1; j < tg2.Pixels.length; j++) {
788
+
789
+ shape.lineTo(tg2.Pixels[j]);
790
+ }
791
+
792
+
793
+ if (tg.get_FillColor() != null || tg.get_FillColor().getAlpha() > 1) {
794
+ shapes.push(shape);
795
+ }
796
+ else {
797
+
798
+ return null;
799
+ }
800
+
801
+ } catch (exc) {
802
+ if (exc instanceof Error) {
803
+ ErrorLogger.LogException(clsClipPolygon2._className, "LinesWithFill",
804
+ new RendererException("Failed inside LinesWithFill", exc));
805
+ } else {
806
+ throw exc;
807
+ }
808
+ }
809
+ return shapes;
810
+ }
811
+ /**
812
+ * @deprecated
813
+ * for polygon completely outside the clip area
814
+ * pass back a small box to be able to continue normal processing
815
+ * @param clipBounds
816
+ * @return
817
+ */
818
+ private static buildBox(clipBounds: Rectangle2D): Array<Point2D> {
819
+ let box: Array<Point2D> = new Array();
820
+ try {
821
+ {
822
+ let ulx: double = 0;
823
+ let uly: double = 0;
824
+ let lrx: double = 0;
825
+ let lry: double = 0;
826
+ ulx = clipBounds.getMinX() - 200;
827
+ uly = clipBounds.getMinY() - 200;
828
+ lrx = clipBounds.getMaxX() + 200;
829
+ lry = clipBounds.getMaxY() + 200;
830
+ let lr: Point2D = new Point2D(ulx, uly);
831
+ let ll: Point2D = new Point2D(ulx - 10, uly);
832
+ let ul: Point2D = new Point2D(ulx - 10, uly - 10);
833
+ let ur: Point2D = new Point2D(ulx, uly - 10);
834
+ box.push(lr);
835
+ box.push(ll);
836
+ box.push(ul);
837
+ box.push(ur);
838
+ box.push(lr);
839
+ }
840
+ } catch (exc) {
841
+ if (exc instanceof Error) {
842
+ ErrorLogger.LogException(clsClipPolygon2._className, "buildBox",
843
+ new RendererException("Failed inside buildBox", exc));
844
+ } else {
845
+ throw exc;
846
+ }
847
+ }
848
+ return box;
849
+ }
850
+ /**
851
+ * Works for tactical lines and areas
852
+ * @param tg
853
+ * @param clipBounds
854
+ * @return
855
+ */
856
+ public static ClipPolygon(tg: TGLight,
857
+ clipBounds: Rectangle2D): Array<Point2D> {
858
+ let poly: Array<Point2D> = new Array();
859
+ try {
860
+ let polygon: Array<Point2D> = clsUtilityCPOF.POINT2toPoint2D(tg.Pixels);
861
+ let isClosed: boolean = clsUtility.isClosedPolygon(tg.get_LineType());
862
+ //create a hashtable to hold the original points
863
+ let hashMap: Map<string, Point2D> = new Map<string, Point2D>();
864
+ let j: int = 0;
865
+ for (j = 0; j < polygon.length; j++) {
866
+ hashMap.set(j.toString(), polygon[j]);
867
+ }
868
+
869
+ let clipBounds2: Rectangle2D = new Rectangle2D(clipBounds.getX() - 50, clipBounds.getY() - 50, clipBounds.getWidth() + 100, clipBounds.getHeight() + 100);
870
+
871
+ let addedLinePoints: int = 0;
872
+ if (isClosed) {
873
+ polygon.splice(polygon.length - 1, 1);
874
+ isClosed = true;
875
+ } else {
876
+ //for tactical lines it always seems to work if the 0th and last points are inside the area
877
+ //add points on the edge as needed to make that happen
878
+ addedLinePoints = clsClipPolygon2.AddBoundaryPointsForLines(polygon, clipBounds2);
879
+ }
880
+ //expand the clip bounds by 10 pixels
881
+
882
+ poly = clsClipPolygon2.clipRight(tg, polygon, clipBounds2);
883
+ poly = clsClipPolygon2.clipTop(tg, poly, clipBounds2);
884
+ poly = clsClipPolygon2.clipLeft(tg, poly, clipBounds2);
885
+ poly = clsClipPolygon2.clipBottom(tg, poly, clipBounds2);
886
+
887
+ if (isClosed) {
888
+ if (poly.length > 0) {
889
+ poly.push(poly[0]);
890
+ }
891
+ }
892
+ else {
893
+ switch (addedLinePoints) {
894
+ case 0: { //no points were added, do nothing
895
+ break;
896
+ }
897
+
898
+ case 1: { //point was added to the front to make algorithm work, remove segment
899
+ if (poly.length > 0) {
900
+ poly.splice(0, 1);
901
+ }
902
+ if (poly.length > 0) {
903
+ poly.splice(0, 1);
904
+ }
905
+ break;
906
+ }
907
+
908
+ case 2: { //point was added to the end to make algorithm work, remove segment
909
+ if (poly.length > 0) {
910
+ poly.splice(poly.length - 1, 1);
911
+ }
912
+ if (poly.length > 0) {
913
+ poly.splice(poly.length - 1, 1);
914
+ }
915
+ break;
916
+ }
917
+
918
+ case 3: { //point was added to the front and end to make algorithm work, remove segments
919
+ if (poly.length > 0) {
920
+ poly.splice(0, 1);
921
+ }
922
+ if (poly.length > 0) {
923
+ poly.splice(0, 1);
924
+ }
925
+ if (poly.length > 0) {
926
+ poly.splice(poly.length - 1, 1);
927
+ }
928
+ if (poly.length > 0) {
929
+ poly.splice(poly.length - 1, 1);
930
+ }
931
+ break;
932
+ }
933
+
934
+
935
+ default:
936
+
937
+ }
938
+ }
939
+
940
+ if (isClosed === true) {
941
+ if (poly.length > 2) {
942
+ //tg.Pixels = clsUtilityCPOF.Point2DtoPOINT2(poly);
943
+ tg.Pixels = clsUtilityCPOF.Point2DtoPOINT2Mapped(poly, hashMap);
944
+ }
945
+ else {
946
+ //poly = buildBox(clipBounds);
947
+ //tg.Pixels = clsUtilityCPOF.Point2DtoPOINT2(poly);
948
+ tg.Pixels = new Array();
949
+ }
950
+
951
+ }
952
+ else {
953
+ if (poly.length > 1) {
954
+ tg.Pixels = clsUtilityCPOF.Point2DtoPOINT2Mapped(poly, hashMap);
955
+ }
956
+ else {
957
+ tg.Pixels = new Array();
958
+ }
959
+ }
960
+
961
+ } catch (exc) {
962
+ if (exc instanceof Error) {
963
+ ErrorLogger.LogException(clsClipPolygon2._className, "ClipPolygon",
964
+ new RendererException("Failed inside ClipPolygon", exc));
965
+ } else {
966
+ throw exc;
967
+ }
968
+ }
969
+ return poly;
970
+ }
971
+ }