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

Multiple Simplifications #34

Open
tobias-r opened this issue Oct 18, 2017 · 4 comments
Open

Multiple Simplifications #34

tobias-r opened this issue Oct 18, 2017 · 4 comments
Labels

Comments

@tobias-r
Copy link

Hi there,

I haven't studied the Douglas-Peucker algorithm in details, but if I execute the simplification algorithm multiple times, the polyline reduces/smoothes more and more, although the algorithm tolerance is still unchanged.

// 1 meter tolerance
$processor = new SimplifyDouglasPeucker(1);

$polyline = $processor->simplify($polyline);
echo sizeof($polyline->getPoints());

echo "<br>";

$polyline = $processor->simplify($polyline);
echo sizeof($polyline->getPoints());

echo "<br>";

$polyline = $processor->simplify($polyline);
echo sizeof($polyline->getPoints());

Shouldn't it be constant?

@mjaschen
Copy link
Owner

Hi,

while iterating through all the polyline's points, only the situation around the current point is evaluated. The algorithm doesn't iterate through the polyline in reverse direction, so possible simplifications aren't found in a single run.

To be sure that all simplifications are found and applied, one has to restart the iteration after each changed point.

@tobias-r
Copy link
Author

Look, if I run about 20 simplification iterations with a tolerance of 1 meter on a polyline, that is about 43km long and has roughly 5k points, then I end up having 14 points with a distance of a couple of kilometers each.

Can this really be correct?

@mjaschen
Copy link
Owner

That sounds strange, indeed.

I'll take a closer look and create test cases if I find the time.

@mjaschen mjaschen added the bug label Oct 18, 2017
@tobias-r
Copy link
Author

@mjaschen, thanks for your awesome work btw!

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

No branches or pull requests

2 participants