{"record":{"id":"7963813e88ccfe63","repo":"elastic/elasticsearch","slug":"unsupported-geometry-type","errorCode":null,"errorMessage":"Unsupported geometry type: ","messagePattern":"Unsupported geometry type: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"libs/geo/src/main/java/org/elasticsearch/geometry/simplify/GeometrySimplifier.java","lineNumber":342,"sourceCode":"                    geometries.add(pointSimplifier.simplify(point));\n                } else if (geometry instanceof Line line) {\n                    var lineSimplifier = new LineSimplifier(maxPolyPoints, calculator, monitor);\n                    lineSimplifier.description = \"GeometryCollection.Line[\" + i + \"]\";\n                    geometries.add(lineSimplifier.simplify(line));\n                } else if (geometry instanceof Polygon polygon) {\n                    var polygonSimplifier = new PolygonSimplifier(maxPolyPoints, calculator, monitor);\n                    polygonSimplifier.description = \"GeometryCollection.Polygon[\" + i + \"]\";\n                    geometries.add(polygonSimplifier.simplify(polygon));\n                } else if (geometry instanceof MultiPolygon multiPolygon) {\n                    var multiPolygonSimplifier = new MultiPolygonSimplifier(maxPolyPoints, calculator, monitor);\n                    multiPolygonSimplifier.description = \"GeometryCollection.MultiPolygon[\" + i + \"]\";\n                    geometries.add(multiPolygonSimplifier.simplify(multiPolygon));\n                } else if (geometry instanceof GeometryCollection<?> g) {\n                    var collectionSimplifier = new GeometryCollections(maxPolyPoints, calculator, monitor);\n                    collectionSimplifier.description = \"GeometryCollection.GeometryCollection[\" + i + \"]\";\n                    geometries.add(collectionSimplifier.simplify(g));\n                } else {\n                    throw new IllegalArgumentException(\"Unsupported geometry type: \" + geometry.type());\n                }\n            }\n            notifyMonitorSimplificationEnd();\n            return new GeometryCollection<>(geometries);\n        }\n    }\n\n    public static <G extends Geometry> GeometrySimplifier<G> simplifierFor(\n        G geometry,\n        int maxPoints,\n        SimplificationErrorCalculator calculator,\n        StreamingGeometrySimplifier.Monitor monitor\n    ) {\n        // TODO: Find a way to get this method to return specialized simplifiers for non-identity cases (eg. Line and Polygon)\n        if (geometry instanceof Point || geometry instanceof Circle || geometry instanceof Rectangle || geometry instanceof MultiPoint) {\n            return new Identity<>(maxPoints, calculator, monitor);\n        } else {\n            throw new IllegalArgumentException(\"Unsupported geometry type: \" + geometry.type());","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/geo/src/main/java/org/elasticsearch/geometry/simplify/GeometrySimplifier.java#L324-L360","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Filter or project the collection before simplifying: keep only Point, Line, Polygon, MultiPolygon, and GeometryCollection elements.","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.","Handle the exception and simplify only the supported subset, passing unsupported elements through unchanged."],"exampleFix":"// before\ncollectionSimplifier.simplify(mixedCollection); // throws if a Circle is present\n\n// after\nList<Geometry> safe = collection.stream()\n    .filter(g -> g instanceof Point || g instanceof Line || g instanceof Polygon\n              || g instanceof MultiPolygon || g instanceof GeometryCollection)\n    .toList();\ncollectionSimplifier.simplify(new GeometryCollection<>(safe));","handlingStrategy":"type-guard","validationCode":"boolean supported = g instanceof Point || g instanceof Line || g instanceof Polygon\n              || g instanceof MultiPolygon || g instanceof GeometryCollection;\nif (!supported) throw new IllegalArgumentException(\"Unsupported element: \" + g.type());","typeGuard":"static boolean isSimplifiableCollectionElement(Geometry g) {\n    return g instanceof Point || g instanceof Line || g instanceof Polygon\n        || g instanceof MultiPolygon || g instanceof GeometryCollection;\n}","tryCatchPattern":"try {\n    return collectionSimplifier.simplify(collection);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unsupported geometry type:\")) {\n        // fall back: filter to supported types and retry\n        List<Geometry> safe = collection.stream().filter(SupportedFilter::isSimplifiableCollectionElement).toList();\n        return collectionSimplifier.simplify(new GeometryCollection<>(safe));\n    }\n    throw e;\n}","preventionTips":["Pre-validate every element of a GeometryCollection against the supported set before simplifying.","Convert Circle -> Polygon (CircleUtils) and Rectangle -> Polygon at ingestion so the simplifier never sees unsupported shapes.","Document the supported-element contract at the boundary where collections enter the simplification pipeline."],"tags":["geometry","simplification","geometry-collection","unsupported-type","libs-geo"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}