Geo: Better error for invalid multipolygon

Closes #7126
This commit is contained in:
Colin Goodheart-Smithe 2014-08-07 16:11:48 +01:00
parent 7c5a954b93
commit 128b83e4a5
1 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,7 @@ package org.elasticsearch.common.geo.builders;
import com.spatial4j.core.shape.Shape;
import com.vividsolutions.jts.geom.*;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
@ -358,7 +359,9 @@ public abstract class BasePolygonBuilder<E extends BasePolygonBuilder<E>> extend
current.intersect = current.coordinate;
final int intersections = intersections(current.coordinate.x, edges);
final int pos = Arrays.binarySearch(edges, 0, intersections, current, INTERSECTION_ORDER);
assert pos < 0 : "illegal state: two edges cross the datum at the same position";
if (pos < 0) {
throw new ElasticsearchParseException("Invaild shape: Hole is not within polygon");
}
final int index = -(pos+2);
final int component = -edges[index].component - numHoles - 1;