-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathSECWebRenderer.js
834 lines (751 loc) · 35.8 KB
/
SECWebRenderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
var sec = sec || {};
/** namespace */
sec.web = sec.web || {};
sec.web.renderer = sec.web.renderer || {};
/** @class */
sec.web.renderer.SECWebRenderer = (function () {
//private vars
var CYLINDER = "CYLINDER-------",
ORBIT = "ORBIT----------",
ROUTE = "ROUTE----------",
POLYGON = "POLYGON--------",
RADARC = "RADARC---------",
POLYARC = "POLYARC--------",
CAKE = "CAKE-----------",
TRACK = "TRACK----------",
CURTAIN = "CURTAIN--------",
ATTRIBUTES = "attributes",
MIN_ALT = "minalt",
MAX_ALT = "maxalt",
RADIUS1 = "radius1",
RADIUS2 = "radius2",
LEFT_AZIMUTH = "leftAzimuth",
RIGHT_AZIMUTH = "rightAzimuth",
MIN_ALT_DEFAULT= 0.0,
MAX_ALT_DEFAULT= 100.0,
RADIUS1_DEFAULT= 50.0,
RADIUS2_DEFAULT= 100.0,
LEFT_AZIMUTH_DEFAULT= 0.0,
RIGHT_AZIMUTH_DEFAULT= 90.0,
ERR_ATTRIBUTES_NOT_FORMATTED = "{\"type\":\"error\",\"error\":\"The attribute paramaters are not formatted correctly",
DEFAULT_ATTRIBUTES = "[{radius1:50.0,radius2:100.0,minalt:0.0,maxalt:100.0,rightAzimuth:90.0,leftAzimuth:0.0}]",
spsPortNumber = -1,
ErrorLogger = armyc2.c2sd.renderer.utilities.ErrorLogger,
SymbolUtilities = armyc2.c2sd.renderer.utilities.SymbolUtilities,
JavaRendererUtilities = sec.web.renderer.utilities.JavaRendererUtilities,
Shape3DHandler = sec.web.renderer.Shape3DHandler,
MilStdIconRenderer = null;
//constructor code
if(armyc2.c2sd.renderer.MilStdIconRenderer)
{
MilStdIconRenderer = armyc2.c2sd.renderer.MilStdIconRenderer;
}
else
{
armyc2.c2sd.renderer.utilities.SymbolDefTable.init();
}
return{
//public vars
//publicVar : "I'm a public var",
setLoggingLevel: function(level)
{
ErrorLogger.setLevel(level);
},
/**
* Renders all multi-point symbols, creating KML that can be used to draw
* it on a Google map. Multipoint symbols cannot be draw the same
* at different scales. For instance, graphics with arrow heads will need to
* redraw arrowheads when you zoom in on it. Similarly, graphics like a
* Forward Line of Troops drawn with half circles can improve performance if
* clipped when the parts of the graphic that aren't on the screen. To help
* readjust graphics and increase performance, this function requires the
* scale and bounding box to help calculate the new locations.
* @param {string} id - A unique identifier used to identify the symbol by Google map.
* The id will be the folder name that contains the graphic.
* @param {string} name - a string used to display to the user as the name of the
* graphic being created.
* @param {string} description - a brief description about the graphic being made and
* what it represents.
* @param {string} symbolCode - A 15 character symbolID corresponding to one of the
* graphics in the MIL-STD-2525C
* @param {string} controlPoints - The vertices of the graphics that make up the
* graphic. Passed in the format of a string, using decimal degrees
* separating lat and lon by a comma, separating coordinates by a space.
* The following format shall be used "x1,y1[,z1] [xn,yn[,zn]]..."
* @param {string} altitudeMode - Indicates whether the symbol should interpret
* altitudes as above sea level or above ground level. Options are
* "clampToGround", "relativeToGround" (from surface of earth), "absolute"
* (sea level), "relativeToSeaFloor" (from the bottom of major bodies of
* water),"none" for non-three dimensions symbology.
* @param {number} scale - 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.
* @param {string} bbox - The viewable area of the map. Passed in the format of a
* string "lowerLeftX,lowerLeftY,upperRightX,upperRightY." Not required
* but can speed up rendering in some cases.
* example: "-50.4,23.6,-42.2,24.2"
* @param {object} modifiers - An Object representing all the possible symbol
* modifiers represented in the MIL-STD-2525C. Key values come from
* MilStdAttributes, ModifiersTG and ModifiersUnits
* example: {"C":"4","Z":"300","AN":[100,200]}}
* @param {number} format - An enumeration: 0 for KML, 1 for JSON.
* @param {number} symStd - An enumeration: 0 for 2525Bch2, 1 for 2525C.
* @param {object} converter - an optional canvas converter for the pixels based image
* @param {Object} fontInfo, required for SVG when used in Web Worker
* @return {string} A JSON string representation of the graphic.
*/
RenderSymbol: function(id, name, description, symbolCode, controlPoints, altitudeMode, scale, bbox, modifiers, format, symStd, converter, fontInfo)
{
var output = "";
try
{
sec.web.renderer.utilities.JavaRendererUtilities.addAltModeToModifiersString(modifiers, altitudeMode);
if (altitudeMode !== "clampToGround" && format === 0 && JavaRendererUtilities.is3dSymbol(symbolCode, modifiers))
{
if (!(altitudeMode))
altitudeMode = "absolute";
output = this.RenderMilStd3dSymbol(name, id, symbolCode, description, altitudeMode, controlPoints,
modifiers);
//get modifiers/////////////////////////////////////////////////
var modifierKML = sec.web.renderer.MultiPointHandler.getModifierKML(id, name, description, symbolCode, controlPoints,
scale, bbox, modifiers, format,symStd);
modifierKML += "</Folder>";
output = output.replace("</Folder>", modifierKML);
// Check the output of the 3D Symbol Drawing. If this returned an error
// it should either be "" or it should be a JSON string starting with "{".
// This really is not a good solution, but was up to 13.0.6 and had to make
// this bug fix in quick turnaround. More consistent error handling should
// be done through code.
if (output ==="") {
output = sec.web.renderer.MultiPointHandler.RenderSymbol(id, name, description, symbolCode, controlPoints,
scale, bbox, modifiers, format,symStd, converter, fontInfo);
}
}
else//*/
{
output = sec.web.renderer.MultiPointHandler.RenderSymbol (id, name, description, symbolCode, controlPoints, scale, bbox, modifiers, format, symStd, converter, fontInfo);
}
//console.dir(output);
return output;
}
catch (err)
{
output = "{\"type\":'error',error:'There was an error creating the MilStdSymbol - " + err.name + ":" + err.message + "'}";
ErrorLogger.LogException("SECWebRenderer", "RenderSymbol", err, ErrorLogger.WARNING);
}
return output;
},
/**
* Multipoint Rendering on flat 2D maps
* @param {string} id A unique ID for the symbol. only used in KML currently
* @param {string} name description
* @param {string} description description
* @param {string} symbolCode
* @param {string} controlPoints
* @param {number} pixelWidth pixel dimensions of the viewable map area
* @param {number} pixelHeight pixel dimensions of the viewable map area
* @param {string} bbox The viewable area of the map. Passed in the format of a
* string "lowerLeftX,lowerLeftY,upperRightX,upperRightY."
* example: "-50.4,23.6,-42.2,24.2"
* @param {object} An Object representing all the possible symbol
* modifiers represented in the MIL-STD-2525C. Key values come from
* MilStdAttributes, ModifiersTG and ModifiersUnits
* example: {"C":"4","Z":"300","AN":[100,200]}}
* @param {number} format An enumeration: 0 for KML, 1 for JSON.
* @param {number} symStd An enumeration: 0 for 2525Bch2, 1 for 2525C.
* @return {string} A JSON or KML string representation of the graphic.
*/
RenderSymbol2D: function(id, name, description, symbolCode, controlPoints, pixelWidth, pixelHeight, bbox, modifiers, format, symStd, fontInfo, converter)
{
var output = "";
try
{
output = sec.web.renderer.MultiPointHandler.RenderSymbol2D (id, name, description, symbolCode, controlPoints, pixelWidth, pixelHeight, bbox, modifiers, format, symStd, fontInfo, converter);
}
catch (exc)
{
output = "{\"type\":'error',error:'There was an error creating the MilStdSymbol: " + symbolCode + " - " + exc.toString () + "'}";
ErrorLogger.LogException("SECWebRenderer", "RenderSymbol2D", exc, ErrorLogger.WARNING);
}
return output;
},
/**
* Creates a 3D symbol to be displayed on some 3D globe surface. Generates
* Keyhole Markup Language (KML) to return that specifies the points and format of
* the rendering.
* <br/>
* Control points should be of the format of:
* <tr><code>"x,y,z [x,y,z]..."</code></tr>
* Attributes should be passed in as a JSON array. If more than one set of
* parameters are passed in as an array or more than one item, they will map
* to the vertex specified in the control points. The attributes are
* of the format:
* <tr><code>{"attributes":[{"<i>attribute1</i>":<i>value</i>,...},{<i>[optional]</i>]}</code></tr>
*
* @param {string} name - The user displayed name for the symbol. Users will use this
* to identify with the symbol.
* @param {string} id - An internally used unique id that developers can use to
* uniquely distinguish this symbol from others.
* @param {string} shapeType - A 15 character ID of the type of symbol to draw.
* @param {string} description - A brief description of what the symbol represents.
* Generic text that does not require any format.
* @param {string} lineColor - The line color of the graphic
* @param {string} fillColor - The fill color of the graphic
* @param {string} controlPoints - The vertices of the shape. The number of required
* vertices varies based on the shapeType of the symbol. The simplest shape
* requires at least one point. Shapes that require more points than
* required will ignore extra points. Format for numbers is as follows:
* <br/><br/>
* "x,y,z [x,y,z ]..."
* @param {string} AttributesArray - A JS array holding the parameters for the
* shape. Attributes should be of the following format: <br/><br/>
* <tr><code>[{"<i>attribute1</i>":<i>value</i>,...},{<i>[optional]</i>}]</code></tr>
* one attribute is "altitudeMode" which indicates whether the symbol should interpret
* altitudes as above sea level or above ground level. Options are
* "relativeToGround" (from surface of earth), "absolute" (sea level),
* "relativeToSeaFloor" (from the bottom of major bodies of water).
* @return {string} A KML string that represents a placemark for the 3D shape
*/
Render3dSymbol:function (name, id, shapeType, description, lineColor, fillColor, controlPoints, AttributesArray)
{
var returnValue = "";
try {
//alert('3d');
//var output = new sec.geo.utilities.StringBuilder ();
//var modifiers = new sec.web.renderer.SymbolModifiers ();
//var attributesJSON;
var attributes = {};//new java.util.HashMap();
attributes.AM_DISTANCE=new java.util.ArrayList();
attributes.X_ALTITUDE_DEPTH=new java.util.ArrayList();
attributes.AN_AZIMUTH=new java.util.ArrayList();
attributes.ALT_MODE=[];
if (AttributesArray === null || attributes === "") {
//attributesJSON = new sec.web.json.utilities.JSONObject ("[{radius1:50.0,radius2:100.0,minalt:0.0,maxalt:100.0,rightAzimuth:90.0,leftAzimuth:0.0}]");
AttributesArray=[{innerRadius:50.0,radius:100.0,minAlt:0.0,maxAlt:100.0,rightAzimuth:90.0,leftAzimuth:0.0}];
}
var attributesArrayLength = AttributesArray.length;
if (attributesArrayLength > 0) {
for (var i = 0; i < attributesArrayLength; i++)
{
if(AttributesArray[i].innerRadius !== undefined)
{
attributes.AM_DISTANCE.add(new Double(AttributesArray[i].innerRadius));
}
if(AttributesArray[i].radius !== undefined)
{
attributes.AM_DISTANCE.add(new Double(AttributesArray[i].radius));
}
else if(AttributesArray[i].width !== undefined)
{
attributes.AM_DISTANCE.add(new Double(AttributesArray[i].width));
}
else if(AttributesArray[i].leftWidth !== undefined)
{
attributes.AM_DISTANCE.add(new Double(AttributesArray[i].leftWidth));
}
if(AttributesArray[i].rightWidth !== undefined)
{
attributes.AM_DISTANCE.add(new Double(AttributesArray[i].rightWidth));
}
if(AttributesArray[i].minAlt !== undefined)
{
attributes.X_ALTITUDE_DEPTH.add(new Double(AttributesArray[i].minAlt));
}
if(AttributesArray[i].maxAlt !== undefined)
{
attributes.X_ALTITUDE_DEPTH.add(new Double(AttributesArray[i].maxAlt));
}
if(AttributesArray[i].leftAzimuth !== undefined)
{
attributes.AN_AZIMUTH.add(new Double(AttributesArray[i].leftAzimuth));
}
if(AttributesArray[i].rightAzimuth !== undefined)
{
attributes.AN_AZIMUTH.add(new Double(AttributesArray[i].rightAzimuth));
}
if(AttributesArray[i].altitudeMode !== undefined && AttributesArray[i].altitudeMode !== "clampToGround")
{
//attributes.ALT_MODE.add(AttributesArray[i].altitudeMode);
attributes.ALT_MODE.push(AttributesArray[i].altitudeMode);
}
else
{
attributes.ALT_MODE.push("absolute");
}
}
}
if(shapeType === CURTAIN)// || shapeType === TRACK)
{//CURTAIN is basically a TRACK without the width.
shapeType = TRACK;
var lenX = attributes.X_ALTITUDE_DEPTH.array.length;
var lenAM = attributes.AM_DISTANCE.array.length;
var pointCount = 0;
var coords = controlPoints.split(" ");
pointCount = coords.length;
var i = 0;
if(lenX===2)
{
var curtainMinAlt = new Double(attributes.X_ALTITUDE_DEPTH.get(0).value);
var curtainMaxAlt = new Double(attributes.X_ALTITUDE_DEPTH.get(1).value);
lenX = pointCount * 2;
attributes.X_ALTITUDE_DEPTH.clear();
for(i = 0; i < lenX; i++)
{
if(i%2===0)
attributes.X_ALTITUDE_DEPTH.add(curtainMinAlt);
else
attributes.X_ALTITUDE_DEPTH.add(curtainMaxAlt);
}
}
else
{
var curtainMinAlt = new Double(1);
var curtainMaxAlt = new Double(10000);
lenX = pointCount * 2;
attributes.X_ALTITUDE_DEPTH.clear();
for(i = 0; i < lenX; i++)
{
if(i%2===0)
attributes.X_ALTITUDE_DEPTH.add(curtainMinAlt);
else
attributes.X_ALTITUDE_DEPTH.add(curtainMaxAlt);
}
}
attributes.AM_DISTANCE.clear();
lenAM = pointCount * 2;
var curtainWidth = new Double(1);
for(i = 0; i < lenAM; i++)
{
attributes.AM_DISTANCE.add(curtainWidth);
}
for(i = 1; i < pointCount; i++)
{
if(AttributesArray[0].altitudeMode !== undefined)
{
attributes.ALT_MODE.push(AttributesArray[0].altitudeMode);
}
else
{
attributes.ALT_MODE.push("absolute");
}
}
}
//Make sure point order is good for POLYARC
if(shapeType === POLYARC)
{
var coords = controlPoints.split(" ");
var clockWise = false;
if(this.CalculateSignedAreaOfPolygon(coords)<0)
{
clockWise = true;
}
if(clockWise)//we want CCW
{
coords = coords.reverse();
controlPoints = "";
var len = coords.length;
for(var i = 0; i < (len); i++)
{
if(i < len - 1)
{
controlPoints += " " + coords[i];
}
else
{
controlPoints = coords[i] + controlPoints;
}
}
}
}
returnValue = sec.web.renderer.Shape3DHandler.render3dSymbol (name, id, shapeType, description, lineColor, fillColor, controlPoints, attributes);
}
catch (err)
{
armyc2.c2sd.renderer.utilities.ErrorLogger.LogException ("SECWebRenderer", "Render3dSymbol()", err);
return "";
}
return returnValue;
},
CalculateSignedAreaOfPolygon: function(coords)
{
//calculating the signed area will tell you which direction the points
//are going. Negative = Clock-wise, Positive = counter clock-wise
//A = 1/2 * (x1*y2 - x2*y1 + x2*y3 - x3*y2 + ... + xn*y1 - x1*yn)
var x1,y1,x2,y2, coord, signedArea=0, len=0;
len = coords.length;
for(var i = 0; i < len; i++)
{
if(i < len - 1)
{
coord = coords[i].split(",");
x1 = parseFloat(coord[0]);
y1 = parseFloat(coord[1]);
coord = coords[i+1].split(",");
x2 = parseFloat(coord[0]);
y2 = parseFloat(coord[1]);
}
else
{
coord = coords[i].split(",");
x1 = parseFloat(coord[0]);
y1 = parseFloat(coord[1]);
coord = coords[0].split(",");
x2 = parseFloat(coord[0]);
y2 = parseFloat(coord[1]);
}
signedArea += (x1*y2 - x2*y1);
}
return signedArea/2;
},
/**
* Creates a 3D symbol from the MilStd2525B USAS or MIL-STD-2525C to be
* displayed on a 3D globe surface. Only certain symbols from the MIL-STD
* can be displayed in 3D. Most of these are graphics that fall under Fire
* Support. Any graphic that has an X modifier (altitude/depth) should
* have a 3D representation. Generates
* Keyhole Markup Language (KML) to return that
* specifies the points and format of
* the rendering.
* <br/>
* Control points should be of the format of:
* <tr><code>"x,y,z [x,y,z]..."</code></tr>
*
*
* @param {string} name - The user displayed name for the symbol. Users will use this
* to identify with the symbol.
* @param {string} id - An internally used unique id that developers can use to
* uniquely distinguish this symbol from others.
* @param {string} symbolCode - A 15 character ID of the type of symbol to draw. Only
* symbols with an X modifier from the standard will draw.
* @param {string} description - A brief description of what the symbol represents.
* Generic text that does not require any format.
* @param {string} altitudeMode - Indicates whether the symbol should interpret
* altitudes as above sea level or above ground level. Options are
* "relativeToGround" (from surface of earth), "absolute" (sea level),
* "relativeToSeaFloor" (from the bottom of major bodies of water).
* @param {string} controlPoints - The vertices of the shape. The number of required
* vertices varies based on the shapeType of the symbol. The simplest shape
* requires at least one point. Shapes that require more points than
* required will ignore extra points. Format for numbers is as follows:
* <br/><br/>
* "x,y,z [x,y,z ]..."
* @param {string} modifiers - a JSON string containing the attributes of the object. These
* attributes can be in MIL-STD-2525BCh2 USAS 13-14 or MIL-STD-2525C. The
* format of the modifiers are:
* <br/>
* {"modifiers":{"<i>attribute1</i>":<i>value</i>}}
* @return {string} A KML string that represents a placemark for the 3D shape
*/
RenderMilStd3dSymbol: function(name, id, symbolCode,
description,
altitudeMode,
controlPoints,
modifiers) {
var symbolId = symbolCode.substring(4,10);
var attributes = {};//new java.util.HashMap();
attributes.AM_DISTANCE=new java.util.ArrayList();
attributes.X_ALTITUDE_DEPTH=new java.util.ArrayList();
attributes.AN_AZIMUTH=new java.util.ArrayList();
attributes.ALT_MODE=[];
var output = "";
var convertedAltitudeMode = null;//altitudeMode;//sec.geo.kml.KmlOptions.AltitudeMode.RELATIVE_TO_GROUND;
// Convert altitude mode to an enum that we understand. If it does not
// understand or is "", then convert to ALTITUDE_RELATIVE_TO_GROUND.
if (altitudeMode && altitudeMode.length)
{
convertedAltitudeMode = altitudeMode;////KmlOptions.AltitudeMode.fromString(altitudeMode);
}
else
{
convertedAltitudeMode = "relativeToGround";
}
try
{
var modifiersJSON;
var altitudeDepthJSON = null;
var distanceJSON = null;
var azimuthJSON = null;
var altitudeDepthLength = 0;
var distanceLength = 0;
var azimuthLength = 0;
var color = "";
var lineColor = null;
var fillColor = null;
//modifiers=JSON.parse(modifiers);
if (modifiers)
{
if(modifiers && modifiers.modifiers)
modifiersJSON = modifiers.modifiers;
else
modifiersJSON = modifiers;
if (modifiersJSON.X)
{
altitudeDepthJSON = modifiersJSON.X;
altitudeDepthLength = altitudeDepthJSON.length;
}
else if (modifiersJSON.altitudeDepth)
{
altitudeDepthJSON = modifiersJSON.altitudeDepth;
altitudeDepthLength = altitudeDepthJSON.length;
}
if (modifiersJSON.AN)
{
azimuthJSON = modifiersJSON.AN;
azimuthLength = azimuthJSON.length;
}
else if (modifiersJSON.azimuth)
{
azimuthJSON = modifiersJSON.azimuth;
azimuthLength = azimuthJSON.length;
}
if (modifiersJSON.AM)
{
distanceJSON = modifiersJSON.AM;
distanceLength = distanceJSON.length;
}
else if (modifiersJSON.distance)
{
distanceJSON = modifiersJSON.distance;
distanceLength = distanceJSON.length;
}
if (modifiersJSON.lineColor)
{
lineColor = modifiersJSON.lineColor;
}
else
{
lineColor = SymbolUtilities.getLineColorOfAffiliation(symbolCode);
if(lineColor !== null)
{
//lineColor.A = 170;
lineColor = lineColor.toHexString().substring(1);
}
else
{
// ensure that some color is selected. If no color can be
// found, use black.
lineColor = "FF000000";
}
}
if (modifiersJSON.fillColor)
{
fillColor = modifiersJSON.fillColor;
}
else
{
fillColor = SymbolUtilities.getFillColorOfAffiliation(symbolCode);
if(fillColor !== null)
{
fillColor.A = 170;
fillColor = fillColor.toHexString().substring(1);
}
else
{
// ensure that some color is selected. If no color can be
// found, use black.
fillColor = "AA000000";
}
}
var coords = controlPoints.split(" ");
var pointCount = coords.length;
for(var i = 0; i < pointCount; i++)
{
attributes.ALT_MODE.push(convertedAltitudeMode);
}
fillColor = JavaRendererUtilities.ARGBtoABGR(fillColor);
lineColor = JavaRendererUtilities.ARGBtoABGR(lineColor);
// if it's a killbox, need to set minimum alt to 0.
if (symbolId.substring(0,3)===("AKP") && altitudeDepthLength === 1)
{
attributes.X_ALTITUDE_DEPTH.add(new Double(0));
}
for (var i=0; i < altitudeDepthLength; i++)
{
attributes.X_ALTITUDE_DEPTH.add(new Double(altitudeDepthJSON[i]));
}
for (var i=0; i < distanceLength; i++)
{
// If this is a 'track' type graphic, then we need to take the distance
// and divide it by half, than add it twice. This is due
// to the TAIS requirement that Tracks must have a left width
// and a right width.
if (symbolId.equals("ACAR--") || // ACA - rectangular
symbolId.equals("AKPR--") || // Killbox - rectangular
symbolId.equals("ALC---") || // air corricor
symbolId.equals("ALM---") || // MRR
symbolId.equals("ALS---") || // SAAFR
symbolId.equals("ALU---") || // unmanned aircraft
symbolId.equals("ALL---")) { // LLTR) {
var width = distanceJSON[i] / 2;
attributes.AM_DISTANCE.add(new Double(width));
attributes.AM_DISTANCE.add(new Double(width));
} else {
attributes.AM_DISTANCE.add(new Double(distanceJSON[i]));
}
}
if (symbolId.equals("ACAI--") || // ACA - irregular
symbolId.equals("AKPI--") || // Killbox - irregular
symbolId.equals("AAR---") || // ROZ
symbolId.equals("AAF---") || // SHORADEZ
symbolId.equals("AAH---") || // HIDACZ
symbolId.equals("AAM---") || // MEZ
symbolId.equals("AAML--") || // LOMEZ
symbolId.equals("AAMH--")) // HIMEZ
{
output = Shape3DHandler.buildPolygon(controlPoints, id, name,
description, lineColor, fillColor, attributes);
}
else if (symbolId.equals("ACAR--") || // ACA - rectangular
symbolId.equals("AKPR--") || // Killbox - rectangular
symbolId.equals("ALC---") || // air corricor
symbolId.equals("ALM---") || // MRR
symbolId.equals("ALS---") || // SAAFR
symbolId.equals("ALU---") || // unmanned aircraft
symbolId.equals("ALL---")) // LLTR
{
output = Shape3DHandler.buildTrack(controlPoints, id, name,
description, lineColor, fillColor, attributes);
}
else if (symbolId.equals("ACAC--") || // ACA - circular
symbolId.equals("AKPC--")) // Killbox - circular
{
output = Shape3DHandler.buildCylinder(controlPoints, id, name,
description, lineColor, fillColor, attributes);
}
}
}
catch (je)
{
output = "";
ErrorLogger.LogException("SECWebRenderer","RenderMilStd3dSymbol",je);
}
return output;
},
/**
* ShouldClipMultipointSymbol
*
* @param {string} symbolID
* @returns {boolean} (description)
*/
ShouldClipMultipointSymbol: function(symbolID)
{
return sec.web.renderer.MultiPointHandler.ShouldClipSymbol (symbolID);
},
/**
* Given a symbol code meant for a single point symbol, returns the
* anchor point at which to display that image based off the image returned
* from the URL of the SinglePointServer.
*
* @param {string} symbolID - the 15 character symbolID of a single point MilStd2525
* symbol.
* @return {string} A pixel coordinate of the format "anchorX,anchorY,SymbolBoundsX,
* SymbolBoundsY,SymbolBoundsWidth,SymbolBoundsHeight,IconWidth,IconHeight".
* Anchor, represents the center point of the core symbol within the image.
* The image should be centered on this point.
* Symbol bounds represents the bounding rectangle of the core symbol within
* the image.
* IconWidth/Height represents the height and width of the image in its
* entirety.
* Returns an empty string if an error occurs.
*/
getSinglePointInfo: function(symbolID)
{
var info = "";
if(MilStdIconRenderer !== null)
{
var modifiers = JavaRendererUtilities.createParameterMapFromURL(symbolID);
var symbolID = modifiers["SYMBOLID"];
modifiers["RENDER"] = false;
var ii = MilStdIconRenderer.Render(symbolID, modifiers);
var anchor = ii.getCenterPoint();
var symbolBounds = ii.getSymbolBounds();
var iconSize = ii.getImageBounds();
info = anchor.getX() + "," + anchor.getY() + "," +
symbolBounds.getX() + "," + symbolBounds.getY() + "," +
symbolBounds.getWidth() + "," + symbolBounds.getHeight() + "," +
iconSize.getWidth() + "," + iconSize.getHeight();
}
return info;
},
/**
* Given a symbol code meant for a single point symbol, returns the
* anchor point at which to display that image based off the image returned
* from the URL of the SinglePointServer.
* @param {string} batch like "{"iconURLs":["SFGP------*****?size=35&T=Hello","SHGPE-----*****?size=50"]}"
* @return {string} like {"singlepoints":[{"x":0,"y":0,"boundsx":0,"boundsy":0,"boundswidth":35,"boundsheight":35,"iconwidth":35,"iconwidth":35}, ... ]}
*/
getSinglePointInfoBatch: function(batch)
{
var info = "",
sb = "";
try
{
if(MilStdIconRenderer !== null)
{
//must escape '=' so that JSONObject can parse string
//batch = batch.replace(/=/g, "%3D");
var data = null;
var jsonSPString = JSON.parse(batch);
var jsa = jsonSPString["iconURLs"];
var len = jsa.length;
sb += ("{\"singlepoints\":[");
var item = null;
for(var i = 0; i < len; i++)
{
if(i>0)
{
sb += (",");
}
info = jsa[i];
//System.out.println(info);
//info = java.net.URLDecoder.decode(info, "UTF-8");
//info = info.replace("%3D", "=");
//System.out.println(info);
var modifiers = JavaRendererUtilities.createParameterMapFromURL(info);
var symbolID = modifiers["SYMBOLID"];
modifiers["RENDER"]=false;
var ii = MilStdIconRenderer.Render(symbolID, modifiers);
var anchor = ii.getCenterPoint();
var symbolBounds = ii.getSymbolBounds();
var iconSize = ii.getImageBounds();
var item = "";
item += ("{\"x\":");
item += (anchor.getX());
item += (",\"y\":");
item += (anchor.getY());
item += (",\"boundsx\":");
item += (symbolBounds.getX());
item += (",\"boundsy\":");
item += (symbolBounds.getY());
item += (",\"boundswidth\":");
item += (symbolBounds.getWidth());
item += (",\"boundsheight\":");
item += (symbolBounds.getHeight());
item += (",\"iconwidth\":");
item += (iconSize.getWidth());
item += (",\"iconheight\":");
item += (iconSize.getHeight());
item += ("}");
sb += (item);
}
sb += ("]}");
}
}
catch(exc)
{
ErrorLogger.LogException("SECWebRenderer","getSinglePointInfoBatch",exc);
}
return sb;
},
/**
* Let's user choose between 2525Bch2 and 2525C.
* Ideally, set only once at startup.
* 2525Bch2 = 0, 2525C = 1.
* @param {number} symStd like armyc2.c2sd.renderer.utilities.RendererSettings.Symbology_2525C
*/
setDefaultSymbologyStandard: function(symStd)
{
armyc2.c2sd.renderer.utilities.RendererSettings.setSymbologyStandard (symStd);
}
};
}());