1313import org .elasticsearch .geometry .MultiPolygon ;
1414import org .elasticsearch .geometry .Point ;
1515import org .elasticsearch .geometry .Polygon ;
16- import org .locationtech .spatial4j .exception .InvalidShapeException ;
1716
1817import java .util .ArrayList ;
1918import java .util .Arrays ;
@@ -192,7 +191,7 @@ private static Edge[] ring(int component, boolean direction, boolean handedness,
192191 }
193192 if (signedArea == 0 ) {
194193 // 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." +
196195 " Points are collinear or polygon self-intersects." );
197196 }
198197 boolean orientation = signedArea < 0 ;
@@ -339,7 +338,7 @@ private static Edge[] concat(int component, boolean direction, Point[] points, f
339338 edges [edgeOffset + i - 1 ].next = edges [edgeOffset + i ] = new Edge (nextPoint , null );
340339 edges [edgeOffset + i - 1 ].component = component ;
341340 } 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 + ")" );
343342 }
344343 }
345344
@@ -464,7 +463,7 @@ private static void assign(Edge[] holes, Point[][] points, int numHoles, Edge[]
464463 if (intersections == 0 ) {
465464 // There were no edges that intersect the line of longitude through
466465 // 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" );
468467 }
469468
470469 // 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[]
480479 // and it didn't match after all.
481480
482481 // 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" );
484483 }
485484
486485 final int index ;
@@ -546,7 +545,7 @@ private static int component(final Edge edge, final int id, final ArrayList<Edge
546545 partitionPoint [1 ] = current .coordinate .getY ();
547546 partitionPoint [2 ] = current .coordinate .getZ ();
548547 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" );
550549 }
551550
552551 // 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[]
594593 // First and last coordinates must be equal
595594 if (coordinates [0 ].equals (coordinates [coordinates .length - 1 ]) == false ) {
596595 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 ["
598597 + partitionPoint [0 ] + "," + partitionPoint [1 ] + "]" );
599598 } else {
600- throw new InvalidShapeException ("Self-intersection at or near point ["
599+ throw new IllegalArgumentException ("Self-intersection at or near point ["
601600 + partitionPoint [0 ] + "," + partitionPoint [1 ] + "," + partitionPoint [2 ] + "]" );
602601 }
603602 }
@@ -728,7 +727,7 @@ void setNext(Edge next) {
728727 if (next != null ) {
729728 // self-loop throws an invalid shape
730729 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 );
732731 }
733732 this .next = next ;
734733 }
0 commit comments