spatialillusions / milsymbol

Military Symbols in JavaScript
www.spatialillusions.com/milsymbol
MIT License
531 stars 132 forks source link

Unsupported symbols sometimes render nothing (instead of the expected question mark) #256

Closed newmansam79 closed 3 years ago

newmansam79 commented 3 years ago

Most of the time milsymbol returns an upside-down question mark for symbols it does not support. However, I found at least two separate cases where nothing is rendered.

First case: For e.g. W*A*PH----***** (presumably valid symbol for weather / pressure systems / high pressure centre, but milsymbol does not support this, and I don't really expect it to), the question mark is neither filled nor stroked (and thus nothing is visible). Relevant code is in https://github.com/spatialillusions/milsymbol/blob/master/src/symbolfunctions/icon.js#L237:

    iconColor = this.colors.iconColor[this.metadata.affiliation];
    var undefinedIcon = [
      {
        type: "path",
        stroke: false,
        fill: iconColor,

In case this.metadata.affiliation is "undefined", iconColor will be undefined. Proposed fix: default to black or perhaps this.colors.iconColor["Unknown"]so at least something gets drawn.

The second case occurs with e.g. totally invalid SIDC -------------- (and many other similar strings). The relevant code is at https://github.com/spatialillusions/milsymbol/blob/master/src/symbolfunctions/icon.js#L348

      if (icons.hasOwnProperty(genericSIDC)) {
        drawArray2.push(icons[genericSIDC]);
      } else {
        if (
          !(
            this.options.sidc.substr(4, 6) == "------" ||
            this.options.sidc.substr(4, 6) == ""
          )
        ) {
          drawArray2.push(undefinedIcon);
          this.validIcon = false;
          //console.info("Invalid icon code in SIDC: " + this.options.sidc);
        }
      }

If the latter condition is false, nothing gets pushed to drawArray2 (and thus nothing is drawn), and validIcon remains true. Proposed fix: Check later if both drawArray1 and drawArray2 are empty, and if they are, draw the question mark and set validIcon to false.

yevhenii-username commented 3 years ago

Faced with the same problem while using APP6 sidc symbol for weather sidc - 10034500001101000000

spatialillusions commented 3 years ago

None of the weather symbols are supported in milsymbol, you can see in the documentation what appendixes that are supported.

On 3 Feb 2021, at 14:58, Yevhenii notifications@github.com wrote:

 Faced with the same problem while using APP6 sidc symbol for weather sidc - 10034500001101000000

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.