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

douglas peucker implementation glitch #38

Open
drunkhacker opened this issue Jun 25, 2018 · 0 comments
Open

douglas peucker implementation glitch #38

drunkhacker opened this issue Jun 25, 2018 · 0 comments

Comments

@drunkhacker
Copy link

drunkhacker commented Jun 25, 2018

        if ($distanceMax > $this->tolerance) {
            $lineSplitFirst  = array_slice($line, 0, $index);
            $lineSplitSecond = array_slice($line, $index, $lineSize);
            $resultsSplit1 = $this->douglasPeucker($lineSplitFirst);
            $resultsSplit2 = $this->douglasPeucker($lineSplitSecond);
            array_pop($resultsSplit1);
            return array_merge($resultsSplit1, $resultsSplit2);
        }

I think $resultsSplit1's last point shouldn't be dropped because $lineSplitFirst already only contains [$line[0],..., $line[$index-1]] because array_slice's second argument isn't inclusive. array_pop causes loose the point whose index is $index-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

1 participant