/**! * @license * The MIT License (MIT) * * Copyright (c) 2017 Måns Beckman - www.spatialillusions.com * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * More information can be found at www.spatialillusions.com */ !function(I,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("milsymbol",t):I.ms=t()}(this,function(){"use strict";var t={Black:{Civilian:"black",Friend:"black",Hostile:"black",Neutral:"black",Unknown:"black"},Dark:{Civilian:"rgb(80,0,80)",Friend:"rgb(0,107,140)",Hostile:"rgb(200,0,0)",Neutral:"rgb(0,160,0)",Unknown:"rgb(225,220,0)"},FrameColor:{Civilian:"rgb(255,0,255)",Friend:"rgb(0, 255, 255)",Hostile:"rgb(255, 0, 0)",Neutral:"rgb(0, 255, 0)",Unknown:"rgb(255, 255, 0)"},IconColor:{Civilian:"rgb(255,0,255)",Friend:"rgb(0, 255, 255)",Hostile:"rgb(255, 0, 0)",Neutral:"rgb(0, 255, 0)",Unknown:"rgb(255, 255, 0)"},Light:{Civilian:"rgb(255,161,255)",Friend:"rgb(128,224,255)",Hostile:"rgb(255,128,128)",Neutral:"rgb(170,255,170)",Unknown:"rgb(255,255,128)"},Medium:{Civilian:"rgb(128,0,128)",Friend:"rgb(0,168,220)",Hostile:"rgb(255,48,49)",Neutral:"rgb(0,226,110)",Unknown:"rgb(255,255,0)"},None:{Civilian:!1,Friend:!1,Hostile:!1,Neutral:!1,Unknown:!1},OffWhite:{Civilian:"rgb(239, 239, 239)",Friend:"rgb(239, 239, 239)",Hostile:"rgb(239, 239, 239)",Neutral:"rgb(239, 239, 239)",Unknown:"rgb(239, 239, 239)"},White:{Civilian:"white",Friend:"white",Hostile:"white",Neutral:"white",Unknown:"white"}};function E(I){var t,E=[],R=[],e=this.colors.frameColor[this.metadata.affiliation];if(!this.metadata.frame&&this.style.icon||void 0===this.metadata.baseGeometry.g.type)return{pre:E,post:R,bbox:this.metadata.baseGeometry.bbox};var A,C={type:this.metadata.baseGeometry.g.type};switch(C.type){case"path":C.d=this.metadata.baseGeometry.g.d;break;case"circle":C.cx=this.metadata.baseGeometry.g.cx,C.cy=this.metadata.baseGeometry.g.cy,C.r=this.metadata.baseGeometry.g.r}(C.fill=this.colors.fillColor[this.metadata.affiliation],C.fillopacity=this.style.fillOpacity,C.stroke=e,C.strokewidth=10<=this.style.size?this.style.strokeWidth:10,this.style.frame&&0":18,"?":19,"@":30,A:22,B:22,C:22,D:22,E:21,F:19,G:24,H:22,I:9,J:17,K:22,L:19,M:25,N:22,O:24,P:21,Q:24,R:22,S:21,T:19,U:22,V:21,W:29,X:21,Y:21,Z:19,"[":10,"]":10,"^":18,_:17,"`":10,a:17,b:19,c:17,d:19,e:17,f:10,g:19,h:19,i:9,j:9,k:17,l:9,m:27,n:19,o:19,p:19,q:19,r:12,s:17,t:10,u:19,v:17,w:24,x:17,y:17,z:15,"{":12,"|":9,"}":12,"~":18},E=0,R=0;R=this.x2?I.x2:this.x2,this.y2=I.y2>=this.y2?I.y2:this.y2,this}}}var O={AirHostile:{g:{type:"path",d:"M 45,150 L45,70 100,20 155,70 155,150"},bbox:new I({x1:45,y1:20,x2:155,y2:150})},AirFriend:{g:{type:"path",d:"M 155,150 C 155,50 115,30 100,30 85,30 45,50 45,150"},bbox:new I({x1:45,y1:30,x2:155,y2:150})},AirNeutral:{g:{type:"path",d:"M 45,150 L 45,30,155,30,155,150"},bbox:new I({x1:45,y1:30,x2:155,y2:150})},AirUnknown:{g:{type:"path",d:"M 65,150 c -55,0 -50,-90 0,-90 0,-50 70,-50 70,0 50,0 55,90 0,90"},bbox:new I({x1:25,y1:20,x2:175,y2:150})},GroundHostile:{g:{type:"path",d:"M 100,28 L172,100 100,172 28,100 100,28 Z"},bbox:new I({x1:28,y1:28,x2:172,y2:172})},GroundFriend:{g:{type:"path",d:"M25,50 l150,0 0,100 -150,0 z"},bbox:new I({x1:25,y1:50,x2:175,y2:150})},GroundNeutral:{g:{type:"path",d:"M45,45 l110,0 0,110 -110,0 z"},bbox:new I({x1:45,y1:45,x2:155,y2:155})},GroundUnknown:{g:{type:"path",d:"M63,63 C63,20 137,20 137,63 C180,63 180,137 137,137 C137,180 63,180 63,137 C20,137 20,63 63,63 Z"},bbox:new I({x1:30.75,y1:30.75,x2:169.25,y2:169.25})},LandDismountedIndividualHostile:{g:{type:"path",d:"M 100,28 L172,100 100,172 28,100 100,28 Z"},bbox:new I({x1:28,y1:28,x2:172,y2:172})},LandDismountedIndividualFriend:{g:{type:"path",d:"m 100,45 55,25 0,60 -55,25 -55,-25 0,-60 z"},bbox:new I({x1:45,y1:45,x2:155,y2:155})},LandDismountedIndividualNeutral:{g:{type:"path",d:"M45,45 l110,0 0,110 -110,0 z"},bbox:new I({x1:45,y1:45,x2:155,y2:155})},LandDismountedIndividualUnknown:{g:{type:"path",d:"M63,63 C63,20 137,20 137,63 C180,63 180,137 137,137 C137,180 63,180 63,137 C20,137 20,63 63,63 Z"},bbox:new I({x1:30.75,y1:30.75,x2:169.25,y2:169.25})},SeaHostile:{g:{type:"path",d:"M100,28 L172,100 100,172 28,100 100,28 Z"},bbox:new I({x1:28,y1:28,x2:172,y2:172})},SeaFriend:{g:{type:"circle",cx:100,cy:100,r:60},bbox:new I({x1:40,y1:40,x2:160,y2:160})},SeaNeutral:{g:{type:"path",d:"M45,45 l110,0 0,110 -110,0 z"},bbox:new I({x1:45,y1:45,x2:155,y2:155})},SeaUnknown:{g:{type:"path",d:"M63,63 C63,20 137,20 137,63 C180,63 180,137 137,137 C137,180 63,180 63,137 C20,137 20,63 63,63 Z"},bbox:new I({x1:30.75,y1:30.75,x2:169.25,y2:169.25})},SubsurfaceHostile:{g:{type:"path",d:"M45,50 L45,130 100,180 155,130 155,50"},bbox:new I({x1:45,y1:50,x2:155,y2:180})},SubsurfaceFriend:{g:{type:"path",d:"m 45,50 c 0,100 40,120 55,120 15,0 55,-20 55,-120"},bbox:new I({x1:45,y1:50,x2:155,y2:170})},SubsurfaceNeutral:{g:{type:"path",d:"M45,50 L45,170 155,170 155,50"},bbox:new I({x1:45,y1:50,x2:155,y2:170})},SubsurfaceUnknown:{g:{type:"path",d:"m 65,50 c -55,0 -50,90 0,90 0,50 70,50 70,0 50,0 55,-90 0,-90"},bbox:new I({x1:25,y1:50,x2:175,y2:180})},PositionMarker:{g:{type:"circle",cx:100,cy:100,r:15},bbox:new I({x1:85,y1:85,x2:115,y2:115})}},s=new function(){this._autoValidation=!1,this.version="2.0.0","object"==typeof console&&"object"!=typeof process&&console.info("milsymbol.js "+this.version+" - Copyright (c) 2018 M"+String.fromCharCode(229)+"ns Beckman http://www.spatialillusions.com")};function G(){this.bbox=new I,this.colors={},this.metadata={},this.octagonAnchor={x:50,y:50},this.options={},this.options.quantity="",this.options.reinforcedReduced="",this.options.staffComments="",this.options.additionalInformation="",this.options.evaluationRating="",this.options.combatEffectiveness="",this.options.signatureEquipment="",this.options.higherFormation="",this.options.hostile="",this.options.iffSif="",this.options.direction="",this.options.sigint="",this.options.uniqueDesignation="",this.options.type="",this.options.dtg="",this.options.altitudeDepth="",this.options.location="",this.options.speed="",this.options.speedLeader=0,this.options.specialHeadquarters="",this.options.country="",this.options.platformType="",this.options.equipmentTeardownTime="",this.options.commonIdentifier="",this.options.auxiliaryEquipmentIndicator="",this.options.headquartersElement="",this.options.installationComposition="",this.options.engagementBar="",this.options.engagementType="",this.options.guardedUnit="",this.options.specialDesignator="",this.style={},this.style.alternateMedal=!1,this.style.civilianColor=!0,this.style.colorMode="Light",this.style.fill=!0,this.style.fillOpacity=1,this.style.fontfamily="Arial",this.style.frame=!0,this.style.frameColor="",this.style.hqStaffLength=0,this.style.icon=!0,this.style.iconColor="",this.style.infoBackground="",this.style.infoBackgroundFrame="",this.style.infoColor="",this.style.infoFields=!0,this.style.infoSize=40,this.style.monoColor="",this.style.outlineColor="rgb(239, 239, 239)",this.style.outlineWidth=0,this.style.padding=0,this.style.simpleStatusModifier=!1,this.style.size=100,this.style.square=!1,this.style.standard="",this.style.strokeWidth=4,this.symbolAnchor={x:50,y:50},this.validIcon=!0,0';return I+=function I(t){for(var E="",R=0;R',e+='',e+=""),t[R].type){case"path":e+='/g,">")+"";break;case"translate":case"rotate":case"scale":e+=I.call(this,t[R].draw),e+=""}}E+=e}return E}.call(this,this.drawInstructions),I+="",this.XML=I},G.prototype.getAnchor=function(){return this.symbolAnchor},G.prototype.getColors=function(){var I="object"==typeof this.style.colorMode?this.style.colorMode:s.getColorMode(this.style.colorMode),t="object"==typeof this.style.frameColor?this.style.frameColor:s.getColorMode("FrameColor"),E="object"==typeof this.style.iconColor?this.style.iconColor:s.getColorMode("IconColor"),R=I,e=s.getColorMode("Black"),A=s.getColorMode("White"),C=s.getColorMode("OffWhite"),T=s.getColorMode("None");this.style.civilianColor&&this.metadata.civilian&&(I.Friend=I.Neutral=I.Unknown=I.Civilian,t.Friend=t.Neutral=t.Unknown=t.Civilian,E.Friend=E.Neutral=E.Unknown=E.Civilian),(this.metadata.joker||this.metadata.faker)&&(I.Friend=I.Hostile,t.Friend=t.Hostile,E.Friend=E.Hostile),""!=this.style.monoColor&&(t.Friend=t.Neutral=t.Hostile=t.Unknown=t.Civilian=this.style.monoColor,e=t,A=I=T);var S={fillColor:I,frameColor:t,iconColor:E,iconFillColor:R,none:T,black:e,white:A};return this.metadata.frame?S.frameColor="object"==typeof this.style.frameColor?this.style.frameColor:e:S.frameColor=T,this.metadata.fill?(S.fillColor=this.metadata.frame||!this.metadata.frame&&!this.style.icon?I:T,S.iconColor="object"==typeof this.style.iconColor?this.style.iconColor:e,S.iconFillColor=this.metadata.frame?C:I,S.white=C):(S.fillColor=T,S.frameColor=this.metadata.frame?t:T,S.iconColor=t,S.iconFillColor=T,this.metadata.frame||this.metadata.fill||this.style.icon||(S.frameColor=e,S.fillColor=e)),S},G.prototype.getOctagonAnchor=function(){return this.octagonAnchor},G.prototype.getMetadata=function(){var I={activity:!1,affiliation:"undefined",baseAffilation:"",baseDimension:"",baseGeometry:{g:"",bbox:{}},civilian:!1,condition:"",context:"",dimension:"undefined",dimensionUnknown:!1,echelon:"",faker:!1,fenintDummy:!1,fill:this.style.fill,frame:this.style.frame,functionid:"",headquarters:!1,installation:!1,joker:!1,mobility:"",notpresent:"",numberSIDC:!1,space:!1,STD2525:s._STD2525,taskForce:!1,unit:!1},t={context:["Reality","Exercise","Simulation"],status:["Present","Planned","FullyCapable","Damaged","Destroyed","FullToCapacity"],echelonMobility:{11:"Team/Crew",12:"Squad",13:"Section",14:"Platoon/detachment",15:"Company/battery/troop",16:"Battalion/squadron",17:"Regiment/group",18:"Brigade",21:"Division",22:"Corps/MEF",23:"Army",24:"Army Group/front",25:"Region/Theater",26:"Command",31:"Wheeled limited cross country",32:"Wheeled cross country",33:"Tracked",34:"Wheeled and tracked combination",35:"Towed",36:"Rail",37:"Pack animals",41:"Over snow (prime mover)",42:"Sled",51:"Barge",52:"Amphibious",61:"Short towed array",62:"Long towed Array",71:"Leader Individual",72:"Deputy Individual"},affiliation:["Hostile","Friend","Neutral","Unknown"],dimension:["Air","Ground","Sea","Subsurface"]};return I.context=t.context[0],this.style.standard&&(I.STD2525="APP6"!=this.style.standard),""!=this.style.monoColor&&(I.fill=!1),this.options.sidc=String(this.options.sidc).replace(/\*/g,"-").replace(/ /g,""),I.numberSIDC=!isNaN(this.options.sidc),I.numberSIDC?"function"==typeof s._getMetadata.number?I=s._getMetadata.number.call(this,s,I,t):console.warn("ms._getMetadata.number() is not present, you will need to load functionality for number based SIDCs"):"function"==typeof s._getMetadata.letter?I=s._getMetadata.letter.call(this,s,I,t):console.warn("ms._getMetadata.letter() is not present, you will need to load functionality for letter based SIDCs"),s._symbolGeometries.hasOwnProperty(I.dimension+I.affiliation)?I.baseGeometry=s._symbolGeometries[I.dimension+I.affiliation]:I.baseGeometry.bbox=new s.BBox,this.style.frame||this.style.icon||(I.baseGeometry=s._symbolGeometries.PositionMarker),I},G.prototype.getOptions=function(I){var t,E={};for(t in this.options)this.options.hasOwnProperty(t)&&(E[t]=this.options[t]);if(I||void 0===I)for(t in this.style)this.style.hasOwnProperty(t)&&(E[t]=this.style[t]);return E},G.prototype.getSize=function(){return void 0!==this.width&&void 0!==this.height||this.updateSymbol(),{width:this.width,height:this.height}},G.prototype.getStyle=function(){var I,t={};for(I in this.style)this.style.hasOwnProperty(I)&&(t[I]=this.style[I]);return t},G.prototype.isValid=function(I){var t=-1==JSON.stringify(this.drawInstructions).indexOf("null");return I?{affiliation:this.metadata.affiliation,dimension:this.metadata.dimension,dimensionUnknown:this.metadata.dimensionUnknown,drawInstructions:t,icon:this.validIcon,mobility:null!=this.metadata.mobility}:!("undefined"==this.metadata.affiliation||"undefined"==this.metadata.dimension&&!this.metadata.controlMeasure)&&t&&this.validIcon&&null!=this.metadata.mobility},G.prototype.setOptions=function(){var I;for(I=0;I