elastic/elasticsearch · error · IllegalArgumentException
Invalid cartesian rectangle: minX (%s) > maxX (%s)
Error message
Invalid cartesian rectangle: minX (%s) > maxX (%s)
What it means
Thrown by SpatialEnvelopeVisitor's visitRectangle override when a cartesian rectangle has minX > maxX. The visitor accumulates an envelope over a geometry; in cartesian space an inverted x-range is invalid (unlike geographic, where minX > maxX can denote an antimeridian-crossing envelope). The message uses String.format with Locale.ROOT and includes both ordinates.
Source
Thrown at libs/geo/src/main/java/org/elasticsearch/geometry/utils/SpatialEnvelopeVisitor.java:161
return maxY;
}
public double getMinY() {
return minY;
}
@Override
public void visitPoint(double x, double y) {
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
maxY = Math.max(maxY, y);
minY = Math.min(minY, y);
}
@Override
public void visitRectangle(double minX, double maxX, double maxY, double minY) {
if (minX > maxX) {
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Invalid cartesian rectangle: minX (%s) > maxX (%s)", minX, maxX)
);
}
this.minX = Math.min(this.minX, minX);
this.maxX = Math.max(this.maxX, maxX);
this.maxY = Math.max(this.maxY, maxY);
this.minY = Math.min(this.minY, minY);
}
@Override
public boolean isValid() {
return minY != Double.POSITIVE_INFINITY;
}
@Override
public Rectangle getResult() {
return new Rectangle(minX, maxX, maxY, minY);
}View on GitHub (pinned to db6a809a66)
Solutions
- If the data is geographic, use the geographic variant of the envelope visitor that tolerates minX > maxX.
- For cartesian data, ensure minX <= maxX before visiting — normalize or reject inverted rectangles upstream.
- Pass rectangle ordinates in the (minX, maxX, maxY, minY) order expected by visitRectangle.
Example fix
// before visitor.visitRectangle(170, -170, 20, -20); // cartesian, minX > maxX // after (geographic data) // use the geographic envelope visitor that handles antimeridian crossing // or, for true cartesian: visitor.visitRectangle(-170, 170, 20, -20);
Defensive patterns
Strategy: validation
Validate before calling
if (dataIsGeographic) {
// use a geographic envelope visitor that tolerates minX > maxX
} else {
if (minX > maxX) throw new IllegalArgumentException("cartesian rectangle minX > maxX");
visitor.visitRectangle(minX, maxX, maxY, minY);
} Prevention
- Choose the envelope visitor by CRS — geographic tolerates antimeridian crossing, cartesian does not.
- Pass rectangle ordinates in (minX, maxX, maxY, minY) order.
- Normalize or reject inverted cartesian rectangles upstream.
When it happens
Trigger: Visiting a Rectangle whose minX exceeds maxX through a SpatialEnvelopeVisitor configured for cartesian mode. The visitor's visitRectangle method explicitly checks before folding the rectangle into the running envelope.
Common situations: Geographic data (longitudes that cross the antimeridian) routed through a cartesian envelope visitor; argument-order bugs passing (maxX, minX); inverted rectangles coming from upstream bounding-box computations.
Related errors
- max x cannot be less than min x
- max y cannot be less than min y
- max y cannot be less than min y
- only one z value is specified
- Unsupported geometry type:
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/8c89c9e77ee49d94.
Report an issue: GitHub.