locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.95k stars 440 forks source link

VariableBuffer to handle zero distances #999

Closed Alison-97 closed 1 year ago

Alison-97 commented 1 year ago

Description

I've incorporated the patch Fix VariableBuffer to handle zero distances. However, there still exists an instance where the error is thrown, specifically when both the start and end widths are set to 0.

The error message is as follows: NetTopologySuite.Geometries.TopologyException: 'side location conflict: arg 0 [ (199.99999999999977, 99.999999999999972) ]'

Steps to Reproduce

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

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

namespace tryNetTopo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var polylineCoordinates = new Coordinate[]
              {
                    new Coordinate(0, 100),
                    new Coordinate(100.49, 93),
                    new Coordinate(200, 100),
              };

            double[] arr = new double[] {0, 3.6, 0};

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

The three points forms a simple line as follow: image

dr-jts commented 1 year ago

Unable to reproduce using latest VariableBuffer code.