coecms / frontdetection

Apache License 2.0
2 stars 2 forks source link

Weird duplication #8

Open ccarouge opened 3 years ago

ccarouge commented 3 years ago

The following code repeats itself: https://github.com/coecms/frontdetection/blob/250f598e10999b917af996751ec6bfb14fde1edd/fronts.py#L151-L190

We go twice through the list of points. Each time the code identifies all the points that are close enough to the point of interest and sort them from closest to farthest. I am not sure the second repetition will find anything since the first search seems to remove all the points that are close enough. The comment says "in the other direction" but the code doesn't seem to give a specific direction to the search.

There are probably ways to rewrite this more efficiently to get the same result as current. But we may need some more information on what the code is supposed to be doing afterwards to ensure the code is correct.

ScottWales commented 3 years ago

From what I understand, the problem is that you're not necessarily starting at the start of a line, just some random point on it. So going only one direction will not find the full line, you have to go back to the start location and try searching the other direction as well.