code: function (line, p) {
          var minDist = Infinity;
          var minX, minY, minI, minT;
  
          for (var i = 0; i < line.length - 1; i++) {
  
              var x = line[i][0];
              var y = line[i][1];
              var dx = (line[i + 1][0] - x) * this.kx;
              var dy = (line[i + 1][1] - y) * this.ky;
  
              if (dx !== 0 || dy !== 0) {
  
                  var t = ((p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
  
                  if (t > 1) {
                      x = line[i + 1][0];
                      y = line[i + 1][1];
  
                  } else if (t > 0) {
                      x += (dx / this.kx) * t;
                      y += (dy / this.ky) * t;
                  }
              }
  
              dx = (p[0] - x) * this.kx;
              dy = (p[1] - y) * this.ky;
  
              var sqDist = dx * dx + dy * dy;
              if (sqDist < minDist) {
                  minDist = sqDist;
                  minX = x;
                  minY = y;
                  minI = i;
                  minT = t;
              }
          }
  
          return {
              point: [minX, minY],
              index: minI,
              t: Math.max(0, Math.min(1, minT))
          };
      }
docs: Returns an object of the form {point, index, t}, where point is closest point on the line
  from the given point, index is the start index of the segment with the closest point,
  and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
  
  @pointOnLine
  @param {Array<Array<number>>} line
  @param {Array<number>} p point [longitude, latitude]
  @returns {Object} {point, index, t}
  @example
  var point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
  //=point