Skip to content

Commit

Permalink
Fixed small bug in in-memory polygon traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner committed Oct 10, 2020
1 parent a9cd18a commit f6db5c0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/src/main/java/org/neo4j/spatial/core/Polygon.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ default String toWKTPointString(boolean hole) {
StringJoiner joiner = new StringJoiner(",", "(", ")");
if (hole) {
if (calculator.isCCW(this)) {
for (int i = 0; i < points.length; i++) {
joiner.add(points[i].getCoordinate()[0] + " " + points[i].getCoordinate()[1]);
for (Point point : points) {
joiner.add(point.getCoordinate()[0] + " " + point.getCoordinate()[1]);
}
} else {
for (int i = points.length - 1; i >= 0; i--) {
Expand All @@ -178,8 +178,8 @@ default String toWKTPointString(boolean hole) {
joiner.add(points[i].getCoordinate()[0] + " " + points[i].getCoordinate()[1]);
}
} else {
for (int i = 0; i < points.length; i++) {
joiner.add(points[i].getCoordinate()[0] + " " + points[i].getCoordinate()[1]);
for (Point point : points) {
joiner.add(point.getCoordinate()[0] + " " + point.getCoordinate()[1]);
}
}
}
Expand All @@ -189,8 +189,8 @@ default String toWKTPointString(boolean hole) {
}

class InMemorySimplePolygon implements SimplePolygon {
private Point[] points;
private CRS crs;
private final Point[] points;
private final CRS crs;

private int pointer;
private int start;
Expand Down Expand Up @@ -237,7 +237,7 @@ public void startTraversal(Point startPoint, Point directionPoint) {

this.start = minIdx;

double forwardDistance = distance(directionPoint, points[(minIdx + 1) % (points.length - 1)]);
double forwardDistance = distance(directionPoint, points[(minIdx + 1) % (points.length)]);
int backwardsIdx = nextIndex(minIdx, -1);
double backwardDistance = distance(directionPoint, points[backwardsIdx]);
if (forwardDistance < backwardDistance) {
Expand Down

0 comments on commit f6db5c0

Please sign in to comment.