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

If 2525B is not loaded, getBasicSymbolID errors out when called with no symStd parameter #29

Closed eric79 closed 6 years ago

eric79 commented 6 years ago

... even if RendererSettings symbology standard has been set to RendererSettings.Symbology_2525C.

This is for getBasicSymbolID, defined in SymbolUtilities.js, when the scheme is S, O, or E.

Here are some options for ways I think this could be fixed:

  1. Rather than checking both standards in a for loop, check only symStd. It appears that hasUnitDef will handle the case where symStd is undefined. (This has the added benefit of simplifying the logic quite a bit).
  2. Still check standards in a for loop, but if symStd is undefined, set it to RendererSettings.getSymbologyStandard() instead of 0
  3. Inside the for loop, you could check for UnitDefTable.hasSymbolMap(symStd) before doing anything else
  4. Update the developer's guide to say that symStd is a mandatory parameter

I think that I like (1) the most, but I leave the decision to your wise judgment. :smile:

michael-spinelli commented 6 years ago

I did a combination of 1-3. No for loop, setting symStd if undefined, also doing the symbolMap check in case someone sets symStd to an erroneous value.

eric79 commented 6 years ago

:+1: Thanks!