[GEO] Removing unnecessary orientation enumerators
PR #8978 included 4 unnecessary enumeration values ('cw', 'clockwise', 'ccw', 'counterclockwise'). Since the ShapeBuilder.parse method handles these as strings and maps them to LEFT and RIGHT enumerators, respectively, their enumeration counterpart is unnecessary. This minor change adds 4 static convenience variables (COUNTER_CLOCKWISE, CLOCKWISE, CCW, CW) for purposes of the API and removes the unnecessary values from the Orientation Enum. closes #9035
This commit is contained in:
parent
77a7ef28b3
commit
6d872843bd
|
@ -129,9 +129,9 @@ public abstract class BasePolygonBuilder<E extends BasePolygonBuilder<E>> extend
|
||||||
|
|
||||||
Edge[] edges = new Edge[numEdges];
|
Edge[] edges = new Edge[numEdges];
|
||||||
Edge[] holeComponents = new Edge[holes.size()];
|
Edge[] holeComponents = new Edge[holes.size()];
|
||||||
int offset = createEdges(0, orientation.getValue(), shell, null, edges, 0);
|
int offset = createEdges(0, orientation, shell, null, edges, 0);
|
||||||
for (int i = 0; i < holes.size(); i++) {
|
for (int i = 0; i < holes.size(); i++) {
|
||||||
int length = createEdges(i+1, orientation.getValue(), shell, this.holes.get(i), edges, offset);
|
int length = createEdges(i+1, orientation, shell, this.holes.get(i), edges, offset);
|
||||||
holeComponents[i] = edges[offset];
|
holeComponents[i] = edges[offset];
|
||||||
offset += length;
|
offset += length;
|
||||||
}
|
}
|
||||||
|
@ -457,14 +457,15 @@ public abstract class BasePolygonBuilder<E extends BasePolygonBuilder<E>> extend
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int createEdges(int component, boolean orientation, BaseLineStringBuilder<?> shell,
|
private static int createEdges(int component, Orientation orientation, BaseLineStringBuilder<?> shell,
|
||||||
BaseLineStringBuilder<?> hole,
|
BaseLineStringBuilder<?> hole,
|
||||||
Edge[] edges, int offset) {
|
Edge[] edges, int offset) {
|
||||||
// inner rings (holes) have an opposite direction than the outer rings
|
// inner rings (holes) have an opposite direction than the outer rings
|
||||||
boolean direction = (component != 0) ? !orientation : orientation;
|
// XOR will invert the orientation for outer ring cases (Truth Table:, T/T = F, T/F = T, F/T = T, F/F = F)
|
||||||
|
boolean direction = (component != 0 ^ orientation == Orientation.RIGHT);
|
||||||
// set the points array accordingly (shell or hole)
|
// set the points array accordingly (shell or hole)
|
||||||
Coordinate[] points = (hole != null) ? hole.coordinates(false) : shell.coordinates(false);
|
Coordinate[] points = (hole != null) ? hole.coordinates(false) : shell.coordinates(false);
|
||||||
Edge.ring(component, direction, orientation, shell, points, 0, edges, offset, points.length-1);
|
Edge.ring(component, direction, orientation == Orientation.LEFT, shell, points, 0, edges, offset, points.length-1);
|
||||||
return points.length-1;
|
return points.length-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -640,28 +640,13 @@ public abstract class ShapeBuilder implements ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Orientation {
|
public static enum Orientation {
|
||||||
LEFT("left", true),
|
LEFT,
|
||||||
CLOCKWISE("clockwise", true),
|
RIGHT;
|
||||||
CW("cw", true),
|
|
||||||
RIGHT("right", false),
|
|
||||||
COUNTERCLOCKWISE("counterclockwise", false),
|
|
||||||
CCW("ccw", false);
|
|
||||||
|
|
||||||
protected String name;
|
public static final Orientation CLOCKWISE = Orientation.LEFT;
|
||||||
protected boolean orientation;
|
public static final Orientation COUNTER_CLOCKWISE = Orientation.RIGHT;
|
||||||
|
public static final Orientation CW = Orientation.LEFT;
|
||||||
private Orientation(String name, boolean orientation) {
|
public static final Orientation CCW = Orientation.RIGHT;
|
||||||
this.orientation = orientation;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Orientation forName(String name) {
|
|
||||||
return Orientation.valueOf(name.toUpperCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getValue() {
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String FIELD_TYPE = "type";
|
public static final String FIELD_TYPE = "type";
|
||||||
|
|
Loading…
Reference in New Issue