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

Issue with Error Handling and Width Calculation in VariableBuffer Class #698

Open
Alison-97 opened this issue Aug 7, 2023 · 0 comments
Open

Comments

@Alison-97
Copy link
Contributor

Description

We have identified an issue related to the VariableBuffer class from the NetTopologySuite library. When one of the widths in the array provided to the Buffer method is set to 0, it results in an unexpected error. The error message is as follows:
NetTopologySuite.Geometries.TopologyException: 'side location conflict: arg 1 [ (2216873.0320880944, 5312576.81797011) ]'

Steps to Reproduce

To reproduce the issue, we have prepared a code snippet that demonstrates the problem:
The following code is working fine:

using NetTopologySuite.Geometries;
using NetTopologySuite.Operation.Buffer;

namespace tryNetTopo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var polylineCoordinates = new Coordinate[]
              {
                    new Coordinate(2216883.9690149571, 5312555.8022460323),
                    new Coordinate(2216880.7776965303, 5312561.9943400519),
                    new Coordinate(2216874.5057125678, 5312574.1638290221),
                    new Coordinate(2216873.0320880935, 5312576.8179701111),
                    new Coordinate(2216872.0585015123, 5312578.3818236338),
                    new Coordinate(2216871.4142499096, 5312579.3486044565)
              };

            double[] arr = new double[polylineCoordinates.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = 1;
            }

            arr[3] = 0;

            var line = new LineString(polylineCoordinates);

            var result = VariableBuffer.Buffer(line, arr);
        }
    }
}

The following code contains one extra coordinate, and the error will be thrown:

using NetTopologySuite.Geometries;
using NetTopologySuite.Operation.Buffer;

namespace tryNetTopo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var polylineCoordinates = new Coordinate[]
              {
                    new Coordinate(2216883.9690149571, 5312555.8022460323),
                    new Coordinate(2216880.7776965303, 5312561.9943400519),
                    new Coordinate(2216874.5057125678, 5312574.1638290221),
                    new Coordinate(2216873.0320880935, 5312576.8179701111),
                    new Coordinate(2216872.0585015123, 5312578.3818236338),
                    new Coordinate(2216871.4142499096, 5312579.3486044565),
                    new Coordinate(2216863.677298767 , 5312590.6634067535),         // adding this coordinate will cause the error
              };

            double[] arr = new double[polylineCoordinates.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = 1;
            }

            arr[3] = 0;

            var line = new LineString(polylineCoordinates);

            var result = VariableBuffer.Buffer(line, arr);
        }
    }
}

System Configuration

  • NetTopologySuite version: v4.0.30319
  • Environment (Operating system, version and so on): Windows 11 version 21H2, 64 bits
  • .NET Framework version: .NET Framework 4.8
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