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

VariableBuffer result polygon has incorrect hole #998

Closed
Alison-97 opened this issue Aug 14, 2023 · 3 comments · Fixed by #1041
Closed

VariableBuffer result polygon has incorrect hole #998

Alison-97 opened this issue Aug 14, 2023 · 3 comments · Fixed by #1041
Labels

Comments

@Alison-97
Copy link

Alison-97 commented Aug 14, 2023

Description

I am encountering an issue with the Variable Buffer class. Specifically, I am working with an open LineString. Given that the LineString is open and does not intersect itself, the buffer operation should yield a simple polygon without any interior rings (holes). However, in the current implementation, the resulting polygon contains an unnecessary interior ring. This is causing a disruption in the order of the resulting polygon coordinates.

Steps to Reproduce

Here's the .Net code to reproduce the issue:

public void Test()
        {
            var coordinates = new Coordinate[]
            {
                new Coordinate(200         ,   91.37371939),
                new Coordinate(199.9906516 ,   71.396149),
                new Coordinate(199.925198  ,   66.39682954),
                new Coordinate(135.4977781 ,   0.125906357),
                new Coordinate(56.41194182 ,   0.598175835),
                new Coordinate(0.024520295 ,   69.50077743),
                new Coordinate(0.000508719 ,   74.50086084),
                new Coordinate(6.22E-22    ,   76.39546845),
            };
            double[] widths = new double[]
            {
                5.4573551091373282,
                5.5548897583660466,
                5.5793006151088935,
                6.0919286067086738,
                6.4781230068945561,
                6.96634014175149,
                6.9907509984943372,
                7,
            };

            var innerLine = new LineString(coordinates);

            var variableBuffer = new VariableBuffer(innerLine, widths);
            var completeBuffer = variableBuffer.GetResult();

        }

This is a plot of the inner line coordinates.
image

@dr-jts
Copy link
Contributor

dr-jts commented Mar 14, 2024

This is due to a flaw in the generation of the buffers of the individual segments. In particular, the segment buffer for the last segment is being generated with a short spike in the buffer offset curve:
image

This overlaps the previous segment buffer polygon in a way that causes a small gap in the unioned buffers:
image

Hopefully this is a straightforward fix to improve the buffer offset curve generation to prevent spikes.

@dr-jts dr-jts changed the title Unnecessary Interior Ring Disrupting Inner Line Coordinates in Variable Buffer Operation Incorrect hole in Variable Buffer result Mar 14, 2024
@dr-jts dr-jts changed the title Incorrect hole in Variable Buffer result Variable Buffer result has incorrect hole Mar 15, 2024
@dr-jts dr-jts changed the title Variable Buffer result has incorrect hole VariableBuffer result has incorrect hole Mar 15, 2024
@dr-jts
Copy link
Contributor

dr-jts commented Mar 15, 2024

The example geometry as WKT:

LINESTRING (200 91.37371939, 199.9906516 71.396149, 199.925198 66.39682954, 135.4977781 0.125906357, 56.41194182 0.598175835, 0.024520295 69.50077743, 0.000508719 74.50086084, 0 76.39546845)

@dr-jts dr-jts changed the title VariableBuffer result has incorrect hole VariableBuffer polygon has incorrect hole Mar 15, 2024
@dr-jts dr-jts changed the title VariableBuffer polygon has incorrect hole VariableBuffer result polygon has incorrect hole Mar 15, 2024
@dr-jts
Copy link
Contributor

dr-jts commented Mar 15, 2024

@Alison-97 hopefully the fix in #1014 solves your issue.

Can I ask what you are using VariableBuffer for?

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

Successfully merging a pull request may close this issue.

2 participants