missioncommand / mil-sym-js

(RETIRED) MIL-STD-2525 symbol rendering JavaScript library for modern web applications
Apache License 2.0
76 stars 25 forks source link

getBasicSymbolID fails when using m-ba.js #31

Open sjpinizzotto opened 6 years ago

sjpinizzotto commented 6 years ago

When trying to use utility method armyc2.c2sd.renderer.utilities.SymbolUtilities.getBasicSymbolID, I get the following error:

image

This does not occur in the savm-bc.js

sjpinizzotto commented 6 years ago

I was converting "SFGPUCI----K---"

michael-spinelli commented 6 years ago

So there's a few things.

1) when the renderer just has 'm' in from of the dash, we're assuming the need is only for multipoints. UnitDefTable is not loaded in m-b.js so getBasicSymbolID() failed because it can't do a check against the UnitDefTable 2) we do a check against the UnitDefTable because there are a handful of symbols where an Installation or mobility modifier is a part of the basic symbol code and removing it changes the symbol. If you're not concerned with that check, call getBasicSymbolIDStrict() and it will replace affiliation, status and any modifiers with '*'.

To resolve this 1) use getBasicSymbolIDStrict() as mentioned above or 2) use a different output version of the renderer. "sm-b.js" perhaps. or 3) load UnitConstantsB.js and/or UnitConstantsC.js along with UnitDefTable manually so that they're available. Then call UnitDefTable.init(); I've not tested that but I think it would work. UnitDefTable will automatically feed off of whichever UnitContants files you've loaded when you call init.