Removing IntersectionOrder.SENTINEL and adding Edge.MAX_COORDINATE for code readability.

This commit is contained in:
Nicholas Knize 2014-11-20 14:48:57 -06:00
parent fc955551d4
commit 82f5252c14
2 changed files with 4 additions and 9 deletions

View File

@ -396,7 +396,7 @@ public abstract class BasePolygonBuilder<E extends BasePolygonBuilder<E>> extend
holes[numHoles] = null;
}
// only connect edges if intersections are pairwise (per comment above)
if (e1.intersect != Edge.maxCoordinate() && e2.intersect != Edge.maxCoordinate()) {
if (e1.intersect != Edge.MAX_COORDINATE && e2.intersect != Edge.MAX_COORDINATE) {
connect(e1, e2);
}
}

View File

@ -301,7 +301,7 @@ public abstract class ShapeBuilder implements ToXContent {
Coordinate p1 = edges[i].coordinate;
Coordinate p2 = edges[i].next.coordinate;
assert !Double.isNaN(p2.x) && !Double.isNaN(p1.x);
edges[i].intersect = IntersectionOrder.SENTINEL;
edges[i].intersect = Edge.MAX_COORDINATE;
double position = intersection(p1, p2, dateline);
if (!Double.isNaN(position)) {
@ -370,6 +370,7 @@ public abstract class ShapeBuilder implements ToXContent {
Edge next; // next segment
Coordinate intersect; // potential intersection with dateline
int component = -1; // id of the component this edge belongs to
public static final Coordinate MAX_COORDINATE = new Coordinate(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
protected Edge(Coordinate coordinate, Edge next, Coordinate intersection) {
this.coordinate = coordinate;
@ -381,7 +382,7 @@ public abstract class ShapeBuilder implements ToXContent {
}
protected Edge(Coordinate coordinate, Edge next) {
this(coordinate, next, IntersectionOrder.SENTINEL);
this(coordinate, next, Edge.MAX_COORDINATE);
}
private static final int top(Coordinate[] points, int offset, int length) {
@ -490,10 +491,6 @@ public abstract class ShapeBuilder implements ToXContent {
}
}
public static Coordinate maxCoordinate() {
return IntersectionOrder.SENTINEL;
}
@Override
public String toString() {
return "Edge[Component=" + component + "; start=" + coordinate + " " + "; intersection=" + intersect + "]";
@ -503,8 +500,6 @@ public abstract class ShapeBuilder implements ToXContent {
protected static final IntersectionOrder INTERSECTION_ORDER = new IntersectionOrder();
private static final class IntersectionOrder implements Comparator<Edge> {
private static final Coordinate SENTINEL = new Coordinate(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
@Override
public int compare(Edge o1, Edge o2) {
return Double.compare(o1.intersect.y, o2.intersect.y);