Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop when calculating margin #14

Open
Wotuu opened this issue Apr 5, 2019 · 1 comment
Open

Infinite loop when calculating margin #14

Wotuu opened this issue Apr 5, 2019 · 1 comment

Comments

@Wotuu
Copy link

Wotuu commented Apr 5, 2019

Hi,

I've been using your library on my website for some time with great success, so thanks for it! However I've got a specific issue that only recently popped up on one of my pages. When passed a specific set of points and setting a specific amount of arcSegments the JS on the page freezes in an infinite loop when using Chrome.

The shortest reproduction I've found is the following:

var p = [
    [-99.695, 93.03], [-100.76, 93.25], [-98.63, 92.81]
];
       
let offset = new Offset();
let result = offset.data(p).arcSegments(9).margin(1);
console.log(result);

The console.log will never run because it's frozen. Creating 8 arcSegments will fix the issue and return a result as expected. This is however not something I can easily change, or well, I could but I don't expect the program to freeze in the first place since I'm sure there's more combinations that will trigger this issue.

Either way thanks again for the product and looking forward to hearing back!

@plarner30
Copy link

plarner30 commented Jan 20, 2021

Another workaround for this is to recreate the polygon as a GeoJSON feature using Turf JS before running Offset, downside is having to run it in all cases as not possible to detect when problem will occur?

const altGeometry = turf.cleanCoords(turf.simplify(turf.polygon([[ [-99.695, 93.03], [-100.76, 93.25], [-98.63, 92.81], [-99.695, 93.03] ]])), {tolerance: 0.000001, highQuality: true})).geometry.coordinates;
const result = offset.data(altGeometry.geometry.coordinates).margin(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants