elastic/elasticsearch · error · IllegalArgumentException

Unsupported geometry type:

Error message

Unsupported geometry type: 

What it means

Thrown by GeometrySimplifier.GeometryCollections.simplify() when an element of a GeometryCollection is not one of the supported types. The collection simplifier handles Point, Line, Polygon, MultiPolygon, and nested GeometryCollection explicitly; any other geometry type falls through to this exception.

Source

Thrown at libs/geo/src/main/java/org/elasticsearch/geometry/simplify/GeometrySimplifier.java:342

                    geometries.add(pointSimplifier.simplify(point));
                } else if (geometry instanceof Line line) {
                    var lineSimplifier = new LineSimplifier(maxPolyPoints, calculator, monitor);
                    lineSimplifier.description = "GeometryCollection.Line[" + i + "]";
                    geometries.add(lineSimplifier.simplify(line));
                } else if (geometry instanceof Polygon polygon) {
                    var polygonSimplifier = new PolygonSimplifier(maxPolyPoints, calculator, monitor);
                    polygonSimplifier.description = "GeometryCollection.Polygon[" + i + "]";
                    geometries.add(polygonSimplifier.simplify(polygon));
                } else if (geometry instanceof MultiPolygon multiPolygon) {
                    var multiPolygonSimplifier = new MultiPolygonSimplifier(maxPolyPoints, calculator, monitor);
                    multiPolygonSimplifier.description = "GeometryCollection.MultiPolygon[" + i + "]";
                    geometries.add(multiPolygonSimplifier.simplify(multiPolygon));
                } else if (geometry instanceof GeometryCollection<?> g) {
                    var collectionSimplifier = new GeometryCollections(maxPolyPoints, calculator, monitor);
                    collectionSimplifier.description = "GeometryCollection.GeometryCollection[" + i + "]";
                    geometries.add(collectionSimplifier.simplify(g));
                } else {
                    throw new IllegalArgumentException("Unsupported geometry type: " + geometry.type());
                }
            }
            notifyMonitorSimplificationEnd();
            return new GeometryCollection<>(geometries);
        }
    }

    public static <G extends Geometry> GeometrySimplifier<G> simplifierFor(
        G geometry,
        int maxPoints,
        SimplificationErrorCalculator calculator,
        StreamingGeometrySimplifier.Monitor monitor
    ) {
        // TODO: Find a way to get this method to return specialized simplifiers for non-identity cases (eg. Line and Polygon)
        if (geometry instanceof Point || geometry instanceof Circle || geometry instanceof Rectangle || geometry instanceof MultiPoint) {
            return new Identity<>(maxPoints, calculator, monitor);
        } else {
            throw new IllegalArgumentException("Unsupported geometry type: " + geometry.type());

View on GitHub (pinned to db6a809a66)

Solutions

  1. Filter or project the collection before simplifying: keep only Point, Line, Polygon, MultiPolygon, and GeometryCollection elements.
  2. Convert unsupported shapes first — e.g. use CircleUtils.createRegularGeoShapePolygon to turn a Circle into a Polygon, or extract a Rectangle's corners as a Polygon.
  3. Handle the exception and simplify only the supported subset, passing unsupported elements through unchanged.

Example fix

// before
collectionSimplifier.simplify(mixedCollection); // throws if a Circle is present

// after
List<Geometry> safe = collection.stream()
    .filter(g -> g instanceof Point || g instanceof Line || g instanceof Polygon
              || g instanceof MultiPolygon || g instanceof GeometryCollection)
    .toList();
collectionSimplifier.simplify(new GeometryCollection<>(safe));
Defensive patterns

Strategy: type-guard

Validate before calling

boolean supported = g instanceof Point || g instanceof Line || g instanceof Polygon
              || g instanceof MultiPolygon || g instanceof GeometryCollection;
if (!supported) throw new IllegalArgumentException("Unsupported element: " + g.type());

Type guard

static boolean isSimplifiableCollectionElement(Geometry g) {
    return g instanceof Point || g instanceof Line || g instanceof Polygon
        || g instanceof MultiPolygon || g instanceof GeometryCollection;
}

Try / catch

try {
    return collectionSimplifier.simplify(collection);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Unsupported geometry type:")) {
        // fall back: filter to supported types and retry
        List<Geometry> safe = collection.stream().filter(SupportedFilter::isSimplifiableCollectionElement).toList();
        return collectionSimplifier.simplify(new GeometryCollection<>(safe));
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling `.simplify(geometryCollection)` where the collection contains a Circle, Rectangle, MultiPoint, or any other geometry type not enumerated in the if/else chain at GeometrySimplifier.java:321-341.

Common situations: Ingesting heterogeneous geo data (e.g. from GeoJSON feeds mixing polygons with circles or bounding-box rectangles); simplifying a collection that was assembled from multiple sources without type normalization; migrating from a validator that silently ignored unsupported shapes to the simplifier that rejects them.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/7963813e88ccfe63. Report an issue: GitHub.