JamesRunnalls / leaflet-contour

A customisable Leaflet contour plugin. Uses d3-contour under the hood.
14 stars 3 forks source link

TypeError: t[(r + 1)] is undefined #2

Closed milesatstetson closed 1 year ago

milesatstetson commented 1 year ago

Hello, I'm trying to understand why I'm getting a "TypeError: t[(r + 1)] is undefined" error when using the following based on Example "Simple" (https://jamesrunnalls.github.io/leaflet-contour/example/simple/ ):

const data = {
        x: [
          [8.475, 8.5, 8.525, 8.55, 8.575, 8.6, 8.625],
          [8.475, 8.5, 8.525, 8.55, 8.575, 8.6, 8.625],
          [8.475, 8.5, 8.525, 8.55, 8.575, 8.6, 8.625],
          [8.475, 8.5, 8.525, 8.55, 8.575, 8.6, 8.625],
          [8.475, 8.5, 8.525, 8.55, 8.575, 8.6, 8.625],
          [8.475, 8.5, 8.525, 8.55, 8.575, 8.6, 8.625],
          [8.475, 8.5, 8.525, 8.55, 8.575, 8.6, 8.625],
        ],
        y: [
          [47.42, 47.42, 47.42, 47.42, 47.42, 47.42, 47.42],
          [47.4, 47.4, 47.4, 47.4, 47.4, 47.4, 47.4],
          [47.38, 47.38, 47.38, 47.38, 47.38, 47.38, 47.38],
          [47.36, 47.36, 47.36, 47.36, 47.36, 47.36, 47.36],
          [47.34, 47.34, 47.34, 47.34, 47.34, 47.34, 47.34],
          [47.32, 47.32, 47.32, 47.32, 47.32, 47.32, 47.32],
          [47.3, 47.3, 47.3, 47.3, 47.3, 47.3, 47.3],
        ],
        z:[
        [2, 2, 2, 1, 1, 1, 1],
        [2, 2, 2, 2, 2, 2, 2],
        [2, 2, 2, 5, 2, 2, 2],
        [2, 2, 5, 10, 5, 2, 2],
        [2, 2, 2, 5, 2, 2, 2],
        [2, 2, 2, 2, 2, 2, 2],
        [2, 2, 2, 2, 2, 2, 2],
        ], 
      };

Basically, just replacing the null values with numerical in the example seems to crash it sometimes? Not sure what is going on here.

JamesRunnalls commented 1 year ago

Hi Miles As it says in the readme "the gridded data must include geographic data beyond the real values (this means at least one layer of surrounding null values)" This means that the null values are required to define the boundary of the contour plot.

milesatstetson commented 1 year ago

Thank you! Set up my z array so everything is wrapped in a boundary of nulls and it now works for me.