Phrogz / svg2geojson

Converts an SVG file with added geo-referencing tags into one or more GeoJSON files.
MIT License
59 stars 30 forks source link

bug fix of maximum call stack size exceeded #18

Open SouthPWN opened 2 years ago

SouthPWN commented 2 years ago

When the points overlap or the accuracy of the process of finding the middle point is lost, the program will fall into an endless loop, resulting in the error "maximum call stack size exceeded". Found the problem in the file "\node_modules_svg-path-to-polygons@0.1.0@svg-path-to-polygons\svg-path-to-polygons.js:79:4". The code is sampleCubicBézier(x0, y0, x01, y01, x012, y012, x0123, y0123);sampleCubicBézier(x0123, y0123, x123, y123, x23, y23, x3, y3);.May cause dead circulation. So I suggest changing it to ' if(x1!=x01||y1!=y01||x2!=x012||y2!=y012||x3!=x0123||y3!=y0123){ sampleCubicBézier(x0, y0, x01, y01, x012, y012, x0123, y0123); } if(x0!=x0123||y0!=y0123||x1!=x123||y1!=y123||x2!=x23||y2!=y23){ sampleCubicBézier(x0123, y0123, x123, y123, x23, y23, x3, y3); } This can avoid the cycle of birth and death.