13
13
import org .elasticsearch .geometry .MultiPolygon ;
14
14
import org .elasticsearch .geometry .Point ;
15
15
import org .elasticsearch .geometry .Polygon ;
16
- import org .locationtech .spatial4j .exception .InvalidShapeException ;
17
16
18
17
import java .util .ArrayList ;
19
18
import java .util .Arrays ;
@@ -192,7 +191,7 @@ private static Edge[] ring(int component, boolean direction, boolean handedness,
192
191
}
193
192
if (signedArea == 0 ) {
194
193
// Points are collinear or self-intersection
195
- throw new InvalidShapeException ("Cannot determine orientation: signed area equal to 0." +
194
+ throw new IllegalArgumentException ("Cannot determine orientation: signed area equal to 0." +
196
195
" Points are collinear or polygon self-intersects." );
197
196
}
198
197
boolean orientation = signedArea < 0 ;
@@ -339,7 +338,7 @@ private static Edge[] concat(int component, boolean direction, Point[] points, f
339
338
edges [edgeOffset + i - 1 ].next = edges [edgeOffset + i ] = new Edge (nextPoint , null );
340
339
edges [edgeOffset + i - 1 ].component = component ;
341
340
} else {
342
- throw new InvalidShapeException ("Provided shape has duplicate consecutive coordinates at: (" + nextPoint + ")" );
341
+ throw new IllegalArgumentException ("Provided shape has duplicate consecutive coordinates at: (" + nextPoint + ")" );
343
342
}
344
343
}
345
344
@@ -464,7 +463,7 @@ private static void assign(Edge[] holes, Point[][] points, int numHoles, Edge[]
464
463
if (intersections == 0 ) {
465
464
// There were no edges that intersect the line of longitude through
466
465
// holes[i].coordinate, so there's no way this hole is within the polygon.
467
- throw new InvalidShapeException ("Invalid shape: Hole is not within polygon" );
466
+ throw new IllegalArgumentException ("Invalid shape: Hole is not within polygon" );
468
467
}
469
468
470
469
// Next we do a binary search to find the position of holes[i].coordinate in the array.
@@ -480,7 +479,7 @@ private static void assign(Edge[] holes, Point[][] points, int numHoles, Edge[]
480
479
// and it didn't match after all.
481
480
482
481
// TODO Can this actually happen? Needs a test to exercise it, or else needs to be removed.
483
- throw new InvalidShapeException ("Invalid shape: Hole is not within polygon" );
482
+ throw new IllegalArgumentException ("Invalid shape: Hole is not within polygon" );
484
483
}
485
484
486
485
final int index ;
@@ -546,7 +545,7 @@ private static int component(final Edge edge, final int id, final ArrayList<Edge
546
545
partitionPoint [1 ] = current .coordinate .getY ();
547
546
partitionPoint [2 ] = current .coordinate .getZ ();
548
547
if (connectedComponents > 0 && current .next != edge ) {
549
- throw new InvalidShapeException ("Shape contains more than one shared point" );
548
+ throw new IllegalArgumentException ("Shape contains more than one shared point" );
550
549
}
551
550
552
551
// a negative id flags the edge as visited for the edges(...) method.
@@ -594,10 +593,10 @@ private static Point[] coordinates(Edge component, Point[] coordinates, double[]
594
593
// First and last coordinates must be equal
595
594
if (coordinates [0 ].equals (coordinates [coordinates .length - 1 ]) == false ) {
596
595
if (Double .isNaN (partitionPoint [2 ])) {
597
- throw new InvalidShapeException ("Self-intersection at or near point ["
596
+ throw new IllegalArgumentException ("Self-intersection at or near point ["
598
597
+ partitionPoint [0 ] + "," + partitionPoint [1 ] + "]" );
599
598
} else {
600
- throw new InvalidShapeException ("Self-intersection at or near point ["
599
+ throw new IllegalArgumentException ("Self-intersection at or near point ["
601
600
+ partitionPoint [0 ] + "," + partitionPoint [1 ] + "," + partitionPoint [2 ] + "]" );
602
601
}
603
602
}
@@ -728,7 +727,7 @@ void setNext(Edge next) {
728
727
if (next != null ) {
729
728
// self-loop throws an invalid shape
730
729
if (this .coordinate .equals (next .coordinate )) {
731
- throw new InvalidShapeException ("Provided shape has duplicate consecutive coordinates at: " + this .coordinate );
730
+ throw new IllegalArgumentException ("Provided shape has duplicate consecutive coordinates at: " + this .coordinate );
732
731
}
733
732
this .next = next ;
734
733
}
0 commit comments