Skip to content

Commit

Permalink
fix dce adding spurious closing vertex
Browse files Browse the repository at this point in the history
  • Loading branch information
micycle1 committed Feb 18, 2024
1 parent 939856f commit 3494e64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/micycle/pgs/PGS_Transformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public static PShape align(PShape alignShape, PShape baseShape, double alignment
}

// both shapes need same vertex quantity
final int vertices = Math.min(alignShape.getVertexCount(), baseShape.getVertexCount()) - 1;
final int vertices = Math.min(alignShape.getVertexCount(), baseShape.getVertexCount());
PShape sourceShapeT = alignShape;
PShape transformShapeT = baseShape;
if (alignShape.getVertexCount() > vertices) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ public interface DCETerminationCallback {
*/
public static Coordinate[] process(LineString lineString, DCETerminationCallback terminationCallback) {
final boolean closed = lineString.isClosed();
final Coordinate[] coords = lineString.getCoordinates();
Coordinate[] coords = lineString.getCoordinates();
if (closed && coords.length > 2) {
Coordinate[] newCoords = new Coordinate[coords.length - 1];
System.arraycopy(coords, 0, newCoords, 0, coords.length - 1);
coords = newCoords;
}

/*
* Initialise kinks (initially unlinked to each other), then link each one to
Expand Down

0 comments on commit 3494e64

Please sign in to comment.