{"record":{"id":"ab2e5cc8f680a3f8","repo":"elastic/elasticsearch","slug":"coordinate-dimensions-do-not-match","errorCode":null,"errorMessage":"coordinate dimensions do not match: {}","messagePattern":"coordinate dimensions do not match: (.+?)","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"libs/geo/src/main/java/org/elasticsearch/geometry/utils/WellKnownText.java","lineNumber":524,"sourceCode":"    }\n\n    static void parseCoordinates(StreamTokenizer stream, ArrayList<Double> lats, ArrayList<Double> lons, ArrayList<Double> alts)\n        throws IOException, ParseException {\n        parseCoordinate(stream, lats, lons, alts);\n        while (nextCloserOrComma(stream).equals(COMMA)) {\n            parseCoordinate(stream, lats, lons, alts);\n        }\n    }\n\n    static void parseCoordinate(StreamTokenizer stream, ArrayList<Double> lats, ArrayList<Double> lons, ArrayList<Double> alts)\n        throws IOException, ParseException {\n        lons.add(nextNumber(stream));\n        lats.add(nextNumber(stream));\n        if (isNumberNext(stream)) {\n            alts.add(nextNumber(stream));\n        }\n        if (alts.isEmpty() == false && alts.size() != lons.size()) {\n            throw new ParseException(\"coordinate dimensions do not match: \" + tokenString(stream), stream.lineno());\n        }\n    }\n\n    private static MultiPoint parseMultiPoint(StreamTokenizer stream) throws IOException, ParseException {\n        String token = nextEmptyOrOpen(stream);\n        if (token.equals(EMPTY)) {\n            return MultiPoint.EMPTY;\n        }\n        ArrayList<Double> lats = new ArrayList<>();\n        ArrayList<Double> lons = new ArrayList<>();\n        ArrayList<Double> alts = new ArrayList<>();\n        ArrayList<Point> points = new ArrayList<>();\n        parseCoordinates(stream, lats, lons, alts);\n        for (int i = 0; i < lats.size(); i++) {\n            if (alts.isEmpty()) {\n                points.add(new Point(lons.get(i), lats.get(i)));\n            } else {\n                points.add(new Point(lons.get(i), lats.get(i), alts.get(i)));","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/geo/src/main/java/org/elasticsearch/geometry/utils/WellKnownText.java#L506-L542","documentation":"Thrown by WellKnownText.parseCoordinate when, within a single geometry, some coordinate tuples include an altitude (third number) and others do not. The method accumulates lons, lats, and alts; if alts is non-empty but its size differs from lons, the dimensions are inconsistent.","triggerScenarios":"A WKT geometry where coordinate tuples have mixed arity, e.g. \"LINESTRING (0 0 1, 1 1)\" — the first tuple has 3 values (altitude added to alts) but the second has only 2 (no altitude), so alts.size() (1) != lons.size() (2).","commonSituations":"CSV-to-WKT conversion where a row is missing its elevation column; data merged from sources with different dimensionality; a serialization bug that drops the Z value on some tuples; upstream truncation.","solutions":["Make all coordinate tuples in the geometry the same dimensionality: either all 2D (remove altitudes) or all 3D (add the missing altitude).","If the source data is heterogeneous, normalize it before WKT generation so every tuple has the same number of components.","Validate each tuple's component count during generation and log/skip inconsistent rows."],"exampleFix":"// before: mixed 2D/3D tuples\nGeometry g = WellKnownText.fromWKT(\"LINESTRING (0 0 1, 1 1)\");\n\n// after: consistent 3D\nGeometry g = WellKnownText.fromWKT(\"LINESTRING (0 0 1, 1 1 0)\");\n// or consistent 2D\nGeometry g = WellKnownText.fromWKT(\"LINESTRING (0 0, 1 1)\");","handlingStrategy":"validation","validationCode":"// Validate that all coordinate tuples in a WKT body have equal arity\nstatic void validateTupleArity(String wktBody) {\n    // extract tuples inside parentheses, split on commas, count numeric tokens per tuple\n    // ensure all tuples have the same component count (2 or 3)\n}","typeGuard":null,"tryCatchPattern":"try {\n    Geometry g = WellKnownText.fromWKT(wkt);\n} catch (java.text.ParseException e) {\n    if (e.getMessage().contains(\"coordinate dimensions do not match\")) {\n        // normalize source tuples to uniform dimensionality\n    }\n    throw e;\n}","preventionTips":["Normalize source data so every tuple has the same number of components.","When merging datasets, reconcile dimensionality before WKT generation.","Log tuples that deviate from the expected arity during ETL."],"tags":["geo","wkt","parsing","elasticsearch","geometry","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}