Skip to content

Commit

Permalink
Fix adjacent edge index access
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Jun 22, 2024
1 parent 9c7dfa7 commit 9cfd804
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@
*/
package org.locationtech.jts.coverage;

import java.util.ArrayList;
import java.util.List;

import org.locationtech.jts.coverage.TPVWSimplifier.Edge;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.CoordinateArrays;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.LineSegment;
import org.locationtech.jts.geom.LineString;
import org.locationtech.jts.geom.MultiLineString;
import org.locationtech.jts.io.WKTWriter;

/**
Expand Down Expand Up @@ -223,4 +218,10 @@ public int getAdjacentIndex(int index) {
return adjacentIndex1;
}

public boolean hasAdjacentIndex(int index) {
if (index == 0)
return adjacentIndex0 >= 0;
return adjacentIndex1 >= 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ private double computeTolerance(CoverageEdge covEdge, double[] tolerances) {
// assert: index0 >= 0
double tolerance = tolerances[index0];

int index1 = covEdge.getAdjacentIndex(0);
if (index1 >= 0) {
if (covEdge.hasAdjacentIndex(1)) {
int index1 = covEdge.getAdjacentIndex(1);
double tol1 = tolerances[index1];
//-- minimum tolerance is used
//-- use lowest tolerance for edge
if (tol1 < tolerance)
tolerance = tol1;
}
Expand Down

0 comments on commit 9cfd804

Please sign in to comment.