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

Single-side offset provides triangular spikes near sharp turns #1006

Open
nubblesite opened this issue Oct 13, 2023 · 1 comment
Open

Single-side offset provides triangular spikes near sharp turns #1006

nubblesite opened this issue Oct 13, 2023 · 1 comment

Comments

@nubblesite
Copy link

nubblesite commented Oct 13, 2023

I'm imagining that this issue is not uncommon. Wondering what sort of settings I need to be using to rid myself of these ugly triangles. Low mitre limit doesn't help, and I think I've tried all possible combos of endCapStyle and joinStyle. Any ideas?
image

private fun offsetPolyline(originalPolyline: ArrayList<Point3D>, offsetDistance: Double, closed: Boolean): ArrayList<Point3D> {
        val geometryFactory = GeometryFactory()

        // Step 1: Convert the ArrayList of Point3D into a Coordinate array for JTS
        val coordinates = originalPolyline.map { Coordinate(it.x, it.y) }.toTypedArray()

        // Step 2: Use JTS OffsetCurveBuilder to offset the Coordinate array
        val bufferParameters = BufferParameters(18)
        bufferParameters.joinStyle = JOIN_MITRE
        bufferParameters.endCapStyle = CAP_FLAT
        bufferParameters.mitreLimit = 1.0
        val curveBuilder = OffsetCurveBuilder(geometryFactory.precisionModel, bufferParameters)
        val offsetCoordinates = curveBuilder.getOffsetCurve(coordinates, offsetDistance)

        // Step 3: Convert the resulting Coordinate array back to ArrayList<Point3D>
        val offsetPolyline = ArrayList<Point3D>()
        for (coordinate in offsetCoordinates) {
            offsetPolyline.add(Point3D(coordinate.x, coordinate.y, 0.0, 0.0))
        }

        return offsetPolyline
    }
@Inamm7753a
Copy link

[ ]

@``__

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

2 participants