mikhailshilkov / leaflet-corridor

Leaflet plugin to draw a polyline with fixed width in meters
MIT License
34 stars 9 forks source link

[CRITICAL!] Incorrect corridor width #7

Open kurenai-11 opened 1 year ago

kurenai-11 commented 1 year ago

I don't know if I am stupid but I think this library did a critical error. In the function

_getWeight: function (map, corridor) {
    return corridor * 2 / this._getMetersPerPixel(map);
  },

Corridor in m gets doubled. Why? It makes no sense to me because upon a simple google, svg stroke width, and by extension leaflet polyline stroke weight are representing the STROKE WIDTH. I guess the error came because @mikhailshilkov thought that it is a circle radius (seeing how default settings have round lines) and we needed its diameter, but it is wrong. Stroke width represents exactly what it says, the actual line thickness. Circles in svg are different entities and they have the radius as a separate parameter.

Solution: remove the * 2.

I am myself too lazy to do a pull request, but wanted to warn someone who might see this someday.