@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,318 @@
1
+ //https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
2
+ //THIS IS AN EXAMPLE. You can implement the web worker however you like.
3
+ //The ErrorLogger class will no longer log to the console as it doesn't' exist in a web worker. ErrorLogger.LogException() will just throw the exception passed into it.
4
+ //You can optionally replace the ErrorLogger class (like in the commented sample below to behave differently)
5
+
6
+ /* expected input format for batch
7
+ var e.data = {};
8
+ e.data.altMode = "absolute";//for 3D
9
+ e.data.scale = scale4;//for 3D like 50000.0; a number corresponding to how many meters one meter of our map represents. A value "50000" would mean 1:50K which means for every meter of our map it represents 50000 meters of real world distance.
10
+ e.data.bbox = bbox4;//like "66.25,30.60,66.28,30.65";"lowerLeftX,lowerLeftY,upperRightX,upperRightY."
11
+ e.data.format = format;//0 for KML, 2 for GeoJSON, 6 for GeoSVG
12
+ e.data.pHeight = pixelHeight;//for 2D
13
+ e.data.pWidth = pixelWidth;//for 2D
14
+ e.data.fontInfo = {name:"Arial",weight:"bold",size:15} OPTIONAL
15
+ e.data.batch = [{id:"ID",name:"name",description:"description",symbolID:"110325000014170000000000000000",points:controlPoints,symStd:symStd,modifiers:{ModifiersTG.T_UNIQUE_DESIGNATION_1:"T"},attributes:{MilStdAttributes.LineColor:"#00FF00"}}];
16
+
17
+ */
18
+
19
+ /* return objects for batch
20
+ {
21
+ //GeoJSON
22
+ [{id:batch.id,symbolID:symbolID,geojson:"geojson string"]
23
+ Error message in item.geojson looks like:
24
+ {"type":"error","error":"There was an error creating the MilStdSymbol 110325000014170000000000000000 - ID: ID - Basic ID: 25141700 requires a minimum of 3 points. 2 are present."}
25
+ }
26
+ */
27
+
28
+
29
+
30
+ //importScripts('dist/C5RenDebug.js');
31
+ importScripts('../dist/C5Ren.js');
32
+
33
+ let path = "/dist/";
34
+ //let path = self.location;
35
+
36
+ //C5Ren.initialize(path);//self.location
37
+
38
+ /*
39
+ //ErrorLogger can't output to console in a webworker so change behavior here if you like//////////////////////
40
+ C5Ren.ErrorLogger = {};
41
+ C5Ren.ErrorLogger.LogMessage = function(sourceClass, sourceMethod, message){throw {message:(sourceClass + "-" + sourceMethod + ": " + message)}};
42
+ C5Ren.ErrorLogger.LogWarning = function(sourceClass, sourceMethod, message, level){throw {message:(sourceClass + "-" + sourceMethod + ": " + message)}};
43
+ C5Ren.ErrorLogger.LogException = function(sourceClass, sourceMethod, err, level)
44
+ {
45
+ var strMessage = (sourceClass + "." + sourceMethod + "(): " + err.message);
46
+ var myStack = "";
47
+ if(err.stack !== undefined)
48
+ {
49
+ myStack = err.stack;
50
+ }
51
+
52
+ if(!(myStack))
53
+ {
54
+ if(err.filename && err.lineno)
55
+ {
56
+ myStack = err.filename + " @ line# " + err.lineno;
57
+ }
58
+ }
59
+ strMessage += "\n" + myStack;
60
+ err.message += "\n" + myStack;
61
+ throw strMessage;
62
+ //throw {message:strMessage,error:err, stack:myStack};
63
+ };
64
+
65
+
66
+ var window = {};
67
+ var console = {};
68
+ console.log = console.log || function(){};
69
+ console.info = console.info || function(){};
70
+ console.warn = console.warn || function(){};
71
+ console.error = console.error || function(){};
72
+ window.console = console;
73
+
74
+ var document = {};//*/
75
+
76
+ ///////////////////////////////////////////////////////////////////////////////
77
+
78
+ convertToMap = function(obj)
79
+ {
80
+ var map = new Map();
81
+ if(obj != null)
82
+ {
83
+ for (const [key, value] of Object.entries(obj))
84
+ {
85
+ //console.log(`${key}: ${value}`);
86
+ map.set(key, value);
87
+ }
88
+ }
89
+ return map;
90
+ }
91
+
92
+ parseMetaData = function(svg)
93
+ {
94
+ var width = 0;
95
+ var height = 0;
96
+ var symbolID = "";
97
+ var geoTL = 0;
98
+ var geoBR = 0;
99
+ var geoTR = 0;
100
+ var geoBL = 0;
101
+ var north = 0;
102
+ var south = 0;
103
+ var east = 0;
104
+ var west = 0;
105
+ var wasClipped = false;
106
+ var strPoint = "";
107
+ var arrPoint = null;
108
+ var b64;
109
+
110
+ var start = 0;
111
+ var end = 0;
112
+ if(svg != null && typeof svg == "string")
113
+ {
114
+ start = svg.indexOf("width=\"") + 7;
115
+ end = svg.indexOf("px",start);
116
+ width = parseInt(svg.substring(start,end));
117
+
118
+ start = svg.indexOf("height=\"",end) + 8;
119
+ end = svg.indexOf("px",start);
120
+ height = parseInt(svg.substring(start,end));
121
+
122
+ start = svg.indexOf("<symbolID>",end) + 10;
123
+ end = svg.indexOf("</symbolID>",start);
124
+ symbolID = svg.substring(start,end);
125
+
126
+ start = svg.indexOf("<geoTL>",end) + 7;
127
+ end = svg.indexOf("</geoTL>",start);
128
+ strPoint = (svg.substring(start,end));
129
+ arrPoint = strPoint.split(" ");
130
+ geoTL = new C5Ren.Point2D(arrPoint[0],arrPoint[1]);
131
+
132
+ start = svg.indexOf("<geoBR>",end) + 7;
133
+ end = svg.indexOf("</geoBR>",start);
134
+ strPoint = (svg.substring(start,end));
135
+ arrPoint = strPoint.split(" ");
136
+ geoBR = new C5Ren.Point2D(arrPoint[0],arrPoint[1]);
137
+
138
+ start = svg.indexOf("<geoTR>",end) + 7;
139
+ end = svg.indexOf("</geoTR>",start);
140
+ strPoint = (svg.substring(start,end));
141
+ arrPoint = strPoint.split(" ");
142
+ geoTR = new C5Ren.Point2D(arrPoint[0],arrPoint[1]);
143
+
144
+ start = svg.indexOf("<geoBL>",end) + 7;
145
+ end = svg.indexOf("</geoBL>",start);
146
+ strPoint = (svg.substring(start,end));
147
+ arrPoint = strPoint.split(" ");
148
+ geoBL = new C5Ren.Point2D(arrPoint[0],arrPoint[1]);
149
+
150
+ start = svg.indexOf("<north>",end) + 7;
151
+ end = svg.indexOf("</north>",start);
152
+ north = parseFloat(svg.substring(start,end));
153
+
154
+ start = svg.indexOf("<south>",end) + 7;
155
+ end = svg.indexOf("</south>",start);
156
+ south = parseFloat(svg.substring(start,end));
157
+
158
+ start = svg.indexOf("<east>",end) + 6;
159
+ end = svg.indexOf("</east>",start);
160
+ east = parseFloat(svg.substring(start,end));
161
+
162
+ start = svg.indexOf("<west>",end) + 6;
163
+ end = svg.indexOf("</west>",start);
164
+ west = parseFloat(svg.substring(start,end));
165
+
166
+ start = svg.indexOf("<wasClipped>",end) + 12;
167
+ end = svg.indexOf("</wasClipped>",start);
168
+ if(svg.substring(start,end).length==4)
169
+ wasClipped = true;
170
+ else
171
+ wasClipped = false;
172
+
173
+ b64 = "data:image/svg+xml;base64," + btoa(svg);
174
+ }
175
+ return {svg:svg, symbolID,symbolID, height:height, width:width, geoTL:geoTL,geoBR:geoBR,geoTR:geoTR,geoBL:geoBL,north:north,south:south,east:east,west:west,wasClipped,wasClipped,b64:b64};
176
+ }
177
+
178
+
179
+ onmessage = function(e)
180
+ {
181
+ var si = null;
182
+ var batch = null;
183
+ var msir = C5Ren.MilStdIconRenderer.getInstance();
184
+ var RS = C5Ren.RendererSettings.getInstance();
185
+ var output = null;
186
+ var converter = null;
187
+ var fontInfo = null;
188
+ var oldFont = null;
189
+ var format = ["kml","json","geojson"];
190
+
191
+ if(e.data.fontInfo)
192
+ {
193
+ fontInfo = e.data.fontInfo;
194
+ oldFont = RS.getMPLabelFont();
195
+ RS.setMPLabelFont(fontInfo.name, fontInfo.style, fontInfo.size);
196
+ }
197
+
198
+
199
+
200
+ if(e.data && e.data.batch && e.data.batch.length > 0)
201
+ {
202
+ var result = null;
203
+ var len = e.data.batch.length;
204
+ var items = e.data.batch;
205
+ var temp = null;
206
+ var mod;
207
+ var att;
208
+ //output = new Array(len);
209
+ output = [];
210
+ try
211
+ {
212
+ for(var i = 0; i < len; i++)
213
+ {
214
+ item = items[i];
215
+
216
+ if(item.modifiers instanceof Map)
217
+ mod = item.modifiers;
218
+ else
219
+ mod = convertToMap(item.modifiers);
220
+ if(item.attributes instanceof Map)
221
+ att = item.attributes;
222
+ else
223
+ att = convertToMap(item.attributes);
224
+
225
+
226
+ if(e.data.altMode)
227
+ {
228
+ if(e.data.converter)
229
+ converter = e.data.converter;
230
+ //data for symbol on 3d map so call RenderSymbol
231
+ result = C5Ren.WebRenderer.RenderSymbol(item.id,item.name,item.description, item.symbolID, item.points, e.data.altMode,e.data.scale, e.data.bbox, mod, att, e.data.format);
232
+ }
233
+ else
234
+ {
235
+ //data for symbol on 2D map so call RenderSymbol2D
236
+ result = C5Ren.WebRenderer.RenderSymbol2D(item.id,item.name,item.description, item.symbolID, item.points, e.data.pixelWidth,e.data.pixelHeight, e.data.bbox, mod, att, e.data.format);
237
+ }
238
+ if(result)
239
+ {
240
+ if(e.data.format === C5Ren.WebRenderer.OUTPUT_FORMAT_GEOSVG)
241
+ {
242
+ //result.id = item.id;
243
+ //result.symbolID = item.symbolID;
244
+ //output[i] = result;
245
+ result = parseMetaData(result);
246
+ result.id = item.id;
247
+ output.push(result);
248
+ }
249
+ else//KML or GeoJSON return string
250
+ {
251
+ temp = {id:item.id, symbolID:item.symbolID}
252
+ temp[format[e.data.format]] = result;
253
+ output.push(temp);
254
+ }
255
+ }
256
+ }
257
+ }
258
+ catch(err)
259
+ {
260
+ throw(err);
261
+ }
262
+ //[{id:batch.id,symbolID:symbolID,svg:dataURI,geoTL:geoCoordTL, geoBR:geoCoordBR, wasClipped:wasClipped}]
263
+ }
264
+ else if(e.data)
265
+ {
266
+ if(item.modifiers instanceof Map)
267
+ mod = item.modifiers;
268
+ else
269
+ mod = convertToMap(item.modifiers);
270
+ if(item.attributes instanceof Map)
271
+ att = item.attributes;
272
+ else
273
+ att = convertToMap(item.attributes);
274
+
275
+ if(e.data.altMode)
276
+ {
277
+ if(e.data.converter)
278
+ converter = e.data.converter;
279
+ //data for symbol on 3d map so call RenderSymbol
280
+ output = C5Ren.WebRenderer.RenderSymbol(e.data.id,e.data.name,e.data.description, e.data.symbolID, e.data.points, e.data.altMode,e.data.scale, e.data.bbox, mod, att, e.data.format);
281
+ }
282
+ else
283
+ {
284
+ //data for symbol on 2D map so call RenderSymbol2D
285
+ output = C5Ren.WebRenderer.RenderSymbol2D(e.data.id,e.data.name,e.data.description, e.data.symbolID, e.data.points, e.data.pixelWidth,e.data.pixelHeight, e.data.bbox, mod, att, e.data.format);
286
+ }
287
+ }
288
+
289
+ if(fontInfo)
290
+ {
291
+ RS.setMPLabelFont(oldFont.getName(), oldFont.getType(), oldFont.getSize());//name, size, style, scale
292
+ }
293
+
294
+ if(e.data.batch)
295
+ {
296
+ postMessage({result:output,format:e.data.format});
297
+ }
298
+ else
299
+ {
300
+ if(output && output.substring)//kml or geojson
301
+ {
302
+ //return results
303
+ var format = e.data.format;
304
+ if(output.substring(0,15) === '{"type":"error"')
305
+ {
306
+ format = "ERROR";
307
+ }
308
+ postMessage({id:e.data.id,result:output,format:format});
309
+
310
+ }
311
+ else if(output)//SVG
312
+ {
313
+ postMessage({id:e.data.id,result:output,format:format});
314
+ }
315
+ }
316
+
317
+ }
318
+
@@ -0,0 +1,233 @@
1
+ //https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
2
+ //THIS IS AN EXAMPLE. You can implement the web worker however you like.
3
+ //The ErrorLogger class will no longer log to the console as it doesn't' exist in a web worker. ErrorLogger.LogException() will just throw the exception passed into it.
4
+ //You can optionally replace the ErrorLogger class (like in the commented sample below to behave differently)
5
+
6
+ /* expected input format for non-batch
7
+ var batch = [];//batch objects look like {id:"ID",symbolID:"SFGPU----------",modifiers:{Modifiers.T_UNIQUE_DESIGNATION_1:"T",MilStdAttributes.PixelSize:"50"}};
8
+ var e.data = {base64:true, batch:batch};
9
+ e.data.batch[].id = "ID";
10
+ e.data.batch[].symbolID = "SFGPU----------";//A 15 character symbolID corresponding to one of the graphics in the MIL-STD-2525C
11
+ e.data.batch[].modifiers = Map<string,string> {ModifiersUnits.T_UNIQUE_DESIGNATION_1:"T"};
12
+ e.data.batch[].attributes = Map<string,string> {MilStdAttributes.PixelSize:50};
13
+ e.data.format = "svg", "base64", "both"
14
+ if(format === "svg"), return object will have a .svg property with the svg string
15
+ if(format === "base64"), return object will have a .base64 property with the svg string like:
16
+ "data:image/svg+xml;base64,[SVG string after run through btoa()]
17
+ if(format === "both"), return object will have both properties.
18
+ */
19
+
20
+ /* return object for non-batch
21
+ {
22
+ id:e.data.id,//same as what was passed in
23
+ symbolID:e.data.SymbolID,//resultant kml,json or error message
24
+ svg:svg string
25
+ anchorPoint:
26
+ symbolBounds:
27
+ imageBounds:
28
+ base64:svg string like: "data:image/svg+xml;base64,[SVG string after run through btoa()]".
29
+ }
30
+ */
31
+
32
+ /* expected input format for batch
33
+ var e.data = {};
34
+ e.data.batch = {fontInfo:fontInfo,batch:[{id:"ID",symbolID:"SFGPU----------",modifiers:{ModifiersUnits.T_UNIQUE_DESIGNATION_1:"T"},attributes:{MilStdAttributes.PixelSize:50}}]}
35
+ */
36
+
37
+ /* return object for batch
38
+ {
39
+ [{id:batch.id,symbolID:batch.symbolID,svg:si.getSVG(),anchorPoint:si.getSymbolCenterPoint(),symbolBounds:si.getSymbolBounds(),bounds:si.getImageBounds()}]
40
+ }
41
+ */
42
+
43
+
44
+
45
+ //importScripts('dist/C5RenDebug.js');
46
+ importScripts('../dist/C5Ren.js');
47
+
48
+ let path = "/dist/";
49
+ //let path = self.location;
50
+
51
+ //C5Ren.initialize(path);//self.location
52
+ /*
53
+ //ErrorLogger can't output to console in a webworker so change behavior here if you like//////////////////////
54
+ C5Ren.ErrorLogger = {};
55
+ C5Ren.ErrorLogger.LogMessage = function(sourceClass, sourceMethod, message){throw {message:(sourceClass + "-" + sourceMethod + ": " + message)}};
56
+ C5Ren.ErrorLogger.LogWarning = function(sourceClass, sourceMethod, message, level){throw {message:(sourceClass + "-" + sourceMethod + ": " + message)}};
57
+ C5Ren.ErrorLogger.LogException = function(sourceClass, sourceMethod, err, level)
58
+ {
59
+ var strMessage = (sourceClass + "." + sourceMethod + "(): " + err.message);
60
+ var myStack = "";
61
+ if(err.stack !== undefined)
62
+ {
63
+ myStack = err.stack;
64
+ }
65
+
66
+ if(!(myStack))
67
+ {
68
+ if(err.filename && err.lineno)
69
+ {
70
+ myStack = err.filename + " @ line# " + err.lineno;
71
+ }
72
+ }
73
+ strMessage += "\n" + myStack;
74
+ err.message += "\n" + myStack;
75
+ throw strMessage;
76
+ //throw {message:strMessage,error:err, stack:myStack};
77
+ };
78
+
79
+
80
+ var window = {};
81
+ var console = {};
82
+ console.log = console.log || function(){};
83
+ console.info = console.info || function(){};
84
+ console.warn = console.warn || function(){};
85
+ console.error = console.error || function(){};
86
+ window.console = console;
87
+
88
+ var document = {};
89
+ //*/
90
+ ///////////////////////////////////////////////////////////////////////////
91
+
92
+ convertToMap = function(obj)
93
+ {
94
+ var map = new Map();
95
+ if(obj != null)
96
+ {
97
+ for (const [key, value] of Object.entries(obj))
98
+ {
99
+ //console.log(`${key}: ${value}`);
100
+ map.set(key, value);
101
+ }
102
+ }
103
+ return map;
104
+ }
105
+
106
+ onmessage = function(e)
107
+ {
108
+ var si = null;
109
+ var batch = null;
110
+ var msir = C5Ren.MilStdIconRenderer.getInstance();
111
+
112
+ if(e.data !== null)
113
+ {
114
+ try
115
+ {
116
+ if(e.data.fontInfo)//set the font to be used with this batch of symbols, if not set will use last value
117
+ {
118
+ fontInfo = e.data.fontInfo;
119
+ RS.setLabelFont(fontInfo.name, fontInfo.style, fontInfo.size);
120
+ }
121
+
122
+ var returnVal = null;
123
+ if(e.data.batch && e.data.batch.length > 0)
124
+ {
125
+ var batch = e.data.batch;
126
+ var returnBatch = [];
127
+ var len = e.data.batch.length;
128
+ var item = null;
129
+
130
+ for(var i = 0; i < len; i++)
131
+ {
132
+ item = batch[i];
133
+ var mod;
134
+ var att;
135
+
136
+ if(item.modifiers instanceof Map)
137
+ mod = item.modifiers;
138
+ else
139
+ mod = convertToMap(item.modifiers);
140
+ if(item.attributes instanceof Map)
141
+ att = item.attributes;
142
+ else
143
+ att = convertToMap(item.attributes);
144
+
145
+ if(msir.CanRender(item.symbolID, item.attributes))
146
+ {
147
+ si = msir.RenderSVG(item.symbolID,mod,att);
148
+ if(si == null)
149
+ throw(new Error("Failed to Render: " + item.symbolID));
150
+ returnVal = {id:item.id,symbolID:item.symbolID,anchorPoint:si.getSymbolCenterPoint(),symbolBounds:si.getSymbolBounds(),bounds:si.getImageBounds()};
151
+ if(e.data.format === "base64")
152
+ returnVal.base64 = si.getSVGDataURI();
153
+ else if(e.data.format === "both")
154
+ {
155
+ returnVal.base64 = si.getSVGDataURI();
156
+ returnVal.svg = si.getSVG();
157
+ }
158
+ else
159
+ returnVal.svg = si.getSVG();
160
+
161
+ returnBatch.push(returnVal);
162
+ }
163
+ else
164
+ {
165
+ returnVal = {id:item.id,symbolID:item.symbolID,anchorPoint:null,symbolBounds:null,bounds:null,svg:null,base64:null};
166
+ returnVal.error = "Can't render code: " + item.symbolID + ", ID: " + item.id;
167
+
168
+ var msi = C5Ren.MSLookup.getInstance().getMSLInfo(item.symbolID);
169
+ if(msi == null)
170
+ returnVal.error += "/n code not found in the Lookup."
171
+ else
172
+ {
173
+ if(msi.getDrawRule()==0)
174
+ returnVal.error += "/n code is not a drawable symbol and likely just representative of a symbol category."
175
+ }
176
+ returnBatch.push(returnVal);
177
+ }
178
+ }
179
+ if(si !== null)
180
+ {
181
+ postMessage(returnBatch);
182
+ }
183
+ else
184
+ {
185
+ postMessage({error:"no results"});
186
+ }
187
+ }
188
+ else if(e.data.id && e.data.symbolID)
189
+ {
190
+ var mod = convertToMap(e.data.modifiers);
191
+ var att = convertToMap(e.data.attributes);
192
+ si = msir.RenderSVG(e.data.symbolID,mod,att);
193
+
194
+ if(si !== null)
195
+ {
196
+ //return results
197
+ returnVal = {id:e.data.id,symbolID:e.data.symbolID,svg:si.getSVG(),anchorPoint:si.getSymbolCenterPoint(),symbolBounds:si.getSymbolBounds(),bounds:si.getImageBounds()};
198
+
199
+ if(e.data.format === "base64")
200
+ returnVal.base64 = si.getSVGDataURI();
201
+ else if(e.data.format === "both")
202
+ {
203
+ returnVal.base64 = si.getSVGDataURI();
204
+ returnVal.svg = si.getSVG();
205
+ }
206
+ else
207
+ returnVal.svg = si.getSVG();
208
+
209
+ postMessage(returnVal);
210
+ }
211
+ else
212
+ {
213
+ postMessage({error:"no results"});
214
+ }
215
+ }
216
+ else
217
+ {
218
+ JSON.stringify(e.data);
219
+ postMessage({error:"no batch object or symbol information" + JSON.stringify(e.data)});
220
+ }
221
+
222
+
223
+ }
224
+ catch(err)
225
+ {
226
+ C5Ren.ErrorLogger.LogException("SPWorker","onmessage",err);
227
+ }
228
+ }
229
+
230
+
231
+
232
+ }
233
+