elastic/elasticsearch · error · IllegalArgumentException

Unknown simplification error calculator:

Error message

Unknown simplification error calculator: 

What it means

Thrown by SimplificationErrorCalculator.byName(String) when the supplied name (case-insensitively matched) is not one of the five registered calculators. The method uses a switch expression with a default branch that rejects any unrecognized name; this is a configuration-resolution error, not a geometry error.

Source

Thrown at libs/geo/src/main/java/org/elasticsearch/geometry/simplify/SimplificationErrorCalculator.java:41

        double x();

        double y();
    }

    SimplificationErrorCalculator CARTESIAN_TRIANGLE_AREA = new CartesianTriangleAreaCalculator();
    SimplificationErrorCalculator TRIANGLE_AREA = new TriangleAreaCalculator();
    SimplificationErrorCalculator TRIANGLE_HEIGHT = new TriangleHeightCalculator();
    SimplificationErrorCalculator HEIGHT_AND_BACKPATH_DISTANCE = new CartesianHeightAndBackpathDistanceCalculator();
    SimplificationErrorCalculator SPHERICAL_HEIGHT_AND_BACKPATH_DISTANCE = new SphericalHeightAndBackpathDistanceCalculator();

    static SimplificationErrorCalculator byName(String calculatorName) {
        return switch (calculatorName.toLowerCase(Locale.ROOT)) {
            case "cartesiantrianglearea" -> CARTESIAN_TRIANGLE_AREA;
            case "trianglearea" -> TRIANGLE_AREA;
            case "triangleheight" -> TRIANGLE_HEIGHT;
            case "heightandbackpathdistance" -> HEIGHT_AND_BACKPATH_DISTANCE;
            case "sphericalheightandbackpathdistance" -> SPHERICAL_HEIGHT_AND_BACKPATH_DISTANCE;
            default -> throw new IllegalArgumentException("Unknown simplification error calculator: " + calculatorName);
        };
    }

    /**
     * Calculate the triangle area using cartesian coordinates as described at
     * <a href="https://en.wikipedia.org/wiki/Area_of_a_triangle">Area of a triangle</a>
     */
    class CartesianTriangleAreaCalculator implements SimplificationErrorCalculator {

        @Override
        public double calculateError(PointLike left, PointLike middle, PointLike right) {
            double xb = middle.x() - left.x();
            double yb = middle.y() - left.y();
            double xc = right.x() - left.x();
            double yc = right.y() - left.y();
            return 0.5 * Math.abs(xb * yc - xc * yb);
        }
    }

View on GitHub (pinned to db6a809a66)

Solutions

  1. Use one of the exact keys: cartesiantrianglearea, trianglearea, triangleheight, heightandbackpathdistance, sphericalheightandbackpathdistance.
  2. Validate the user-supplied name against the known set before calling byName, and surface a clear configuration error to the operator.
  3. Reference the constants on SimplificationErrorCalculator (CARTESIAN_TRIANGLE_AREA, TRIANGLE_AREA, etc.) directly when wiring code, instead of round-tripping through string names.

Example fix

// before
var calc = SimplificationErrorCalculator.byName("triangle-area"); // hyphen not allowed

// after
var calc = SimplificationErrorCalculator.byName("trianglearea");
// or skip the string layer entirely
var calc = SimplificationErrorCalculator.TRIANGLE_AREA;
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = Set.of("cartesiantrianglearea", "trianglearea", "triangleheight",
    "heightandbackpathdistance", "sphericalheightandbackpathdistance");
String key = name.toLowerCase(Locale.ROOT);
if (!valid.contains(key)) throw new IllegalArgumentException("Unknown calculator: " + name);
return SimplificationErrorCalculator.byName(name);

Try / catch

try {
    return SimplificationErrorCalculator.byName(name);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Unknown simplification error calculator:")) {
        return SimplificationErrorCalculator.TRIANGLE_AREA; // safe default
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling `SimplificationErrorCalculator.byName(name)` with a string other than: "cartesiantrianglearea", "trianglearea", "triangleheight", "heightandbackpathdistance", or "sphericalheightandbackpathdistance". Matching is done after toLowerCase(Locale.ROOT) so case does not matter, but spelling and the 'cartesian'/'spherical' prefix do.

Common situations: Passing a user-supplied or config-file value into the calculator selector without validating it; typos like "triangleArea" vs the expected "trianglearea" (case-insensitive but exact spelling); version drift where a calculator name was renamed or removed between releases; copy-pasting a display label instead of the internal key.

Related errors


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