Cross-language validation
Cross-language validation keeps Java, Rust, TypeScript, C++, and Python tile code compatible with the same MapLibre Tile behavior. Shared binary fixtures and paired logical outputs let each language test what it can read and write without requiring every encoder to produce identical bytes. The suites also compare the two wire versions and the newer v2 data forms where a language supports them.
Validation model
A fixture is a small test tile with a known purpose. Each synthetic .mlt fixture has a matching .json file that describes the logical tile result. The shared test helper discovers these pairs and turns each pair into an active or explicitly unsupported test case.
The validation model separates two contracts:
- Logical compatibility: Every supported decoder produces the same feature, geometry, property, and metadata values.
- Byte compatibility: Encoders produce the same bytes only when the fixture is intended to share a physical encoding. Valid language-specific encodings can use separate reference files when their bytes differ but their logical output matches.
This separation allows implementations to use different compression choices while preserving the data contract consumed by applications.
The Java comparison rules make this contract useful for both full tile checks and focused checks. They distinguish layer, property, and geometry comparisons, ignore differences outside the selected mode, and use feature IDs to align features when order changes. Geometry checks also accept equivalent ring starts while still detecting invalid or different shapes. (See java/…/CompareHelperTest.java.)
Shared fixture contract
The shared fixture set lives under test/synthetic. The .mlt file is the input, and the same-name .json file is the expected logical output. The shared test helper discovers these pairs and turns each pair into an active or explicitly unsupported test case.
The expected output is the stable comparison point across languages. Numeric comparisons allow the small differences that can result from floating-point decoding. Special values such as NaN and infinity use string markers in JSON so that they remain representable in the expected output. The same contract now covers v2 nested values, vertex and triangle m-values, meshes, elevation, and property-column edge cases when a suite enables those features.
Unsupported fixtures are also part of the contract. A language may list a fixture as unsupported, but its test must fail if that fixture starts decoding to the expected result. This prevents an old exclusion from hiding newly added support.
Java also sweeps the repository's MVT fixture tree rather than relying on a fixed list. Each fixture is converted and decoded with both plain and advanced encoding choices, then compared with the source tile. The fixture root and selected layer rules are centralized in java/…/TestSettings.java and the sweep is exercised by java/…/MltDecoderTest.java.
See shared conformance assets for the wider description of shared test data and its ownership.
References: test/…/README.md• L1-16 test/…/index.ts• L8-37 test/…/index.ts• L48-104 java/…/TestSettings.java• L6-40 java/…/MltDecoderTest.java• L27-95
Synthetic dataset
Synthetic tiles are small, focused data sets that exercise one format feature or a useful combination of features. They cover geometry shapes, mixed geometry layers, extents, identifiers, properties, dictionaries, stream choices, nested values, m-values, elevation, and both wire versions. The current set also keeps focused coverage for string properties that use FSST compression, prefixes, offsets, nulls, and no-property variants.
Elevation and mesh coverage
The v2 synthetic set adds shared expected outputs for three-dimensional geometry and mesh data. It checks absolute heights, heights relative to ground, mixed geometry types, measured values, point ordering, polygon holes, polygon triangulation, mesh vertices, roof and wall faces, and the finest elevation step. The paired JSON keeps the coordinate values and tile metadata visible to every language suite instead of treating elevation or mesh data as an encoder-specific detail.
The mesh fixture corpus also contains real tile samples at test/fixtures/meshes/tiles/15/17294/10590.mlt and test/fixtures/meshes/tiles/16/34588/21180.mlt. These samples extend synthetic cases with tile-shaped mesh inputs while the focused Rust checks continue to compare the logical mesh rows.
References: test/…/z_height_absolute.json• L1-33 test/…/z_height_relative_to_ground.json• L1-34 test/…/z_mix.json• L1-294 test/…/z_mvalues.json• L1-38 test/…/z_points_hilbert.json• L1-85 test/…/z_poly_hole.json• L1-62 test/…/z_poly_hole_tes.json• L1-62 test/…/z_poly_hole_tri.json• L1-162 test/…/z_step_finest.json• L1-37 test/…/10590.mlt test/…/21180.mlt rust/…/tag02_meshes.rs• L236-309 rust/…/tag02_meshes.rs• L364-374
Java-generated fixtures form the common reference set. Rust also creates fixtures for cases where its encoding is valid but cannot share Java's exact bytes, such as a different FSST result. The paired JSON output remains the check for those files. The v2 set includes the same logical checks for string-property variants and m-value data, so changes to these fixtures can affect both property decoding and geometry metadata checks.
The dataset has a simple ownership split:
| Dataset area | Purpose |
|---|---|
0x01/ and 0x02/ | Common reference fixtures for the supported wire versions |
0x01-rust/ and 0x02-rust/ | Rust-specific or otherwise byte-different fixtures |
.json beside each .mlt | Expected logical tile output |
The v2 set also records nested columns and measured values as logical data. Rust-specific fixtures can therefore test a valid encoding choice without changing the output that other languages must read.
The generation and comparison path is shown below.
flowchart LR
D[Synthetic data definitions] --> R[Reference MLT and JSON fixtures]
R --> J[Language decoder suites]
R --> E[Language encoder round trips]
R --> V[Rust cross-encoder verification]
V -->|same bytes| R
V -->|different valid bytes| S[Rust-specific fixture]
S -->|same logical JSON| C[Compatibility signal]
J --> C
E --> C
A new synthetic must carry enough information for every enabled suite to decide whether it is supported. Its expected JSON must describe the logical result, not an accidental encoder layout.
References: java/…/SyntheticMltGenerator.java• L57-89 java/…/SyntheticMltUtil.java• L331-363 rust/…/main.rs• L1-25 rust/…/main.rs• L111-129 rust/…/writer.rs• L83-125 rust/…/hegel_property_columns.rs• L63-335 rust/…/tag02_nested.rs• L220-316 rust/…/tag02_meshes.rs• L236-309
v2 feature coverage
The v2 validation set checks data that does not fit the older wire contract. Nested values preserve maps, lists, null roots, and null list items. M-values preserve one value per vertex or one value per mesh triangle. Mesh tests preserve three-dimensional vertices and triangle links while allowing feature and vertex order to change.
The Rust checks also cover the boundaries around these features. Property columns are round-tripped across both wire versions with different presence patterns and string codecs. Writer tests compare direct feature writes with whole-layer writes for nested columns and m-values. Vertex-sort tests ensure that z values and m-values stay attached when geometry order changes.
These checks give the shared fixtures a clear role: they describe user-visible tile data, while the language suites decide which wire features they can support. A suite that does not support v2 keeps its exclusion and must fail the test when support appears so that the exclusion cannot become stale.
References: rust/…/tag02_nested.rs• L220-316 rust/…/tag02_mvalues.rs• L150-194 rust/…/tag02_meshes.rs• L236-274 rust/…/tag02_meshes.rs• L288-318 rust/…/tag02_vertex_sort.rs• L35-72 rust/…/layer_writer_nested.rs• L36-124 rust/…/layer_writer_m_values.rs• L323-390 rust/…/hegel_property_columns.rs• L63-190 rust/…/tag02_fixtures.rs• L63-84
Language test suites
Each language uses the shared fixtures through its own test runner and data model. The suites do not all cover the same wire versions or the same feature set, so an exclusion is a recorded support boundary rather than proof that the format is unsupported everywhere. Rust also uses focused v2 checks to compare decoded v1 and v2 data and to protect limits that a cross-language JSON check cannot show.
Java validation
The Java suite scans the common v1 and Rust-specific v1 directories. It decodes each tile, reads the paired JSON when present, and compares the logical objects. It also checks that polygon rings use the winding expected by MVT consumers.
The Java tools generate the common fixtures and verify their own encode/decode round trip before writing the .mlt and .json pair. This makes Java the source of the common reference fixtures for the synthetic workflow.
The Java converter checks also protect compatibility at the API boundary. They cover type mismatch policy, missing values, polygon winding, feature identity, feature order, and comparison scope so that a change in conversion does not silently change the logical tile that other languages compare.
References: java/…/SyntheticsTest.java• L24-65 java/…/SyntheticsTest.java• L82-104 java/…/SyntheticMltUtil.java• L331-363 java/…/build.gradle• L54-58 java/…/MltConverterTest.java• L151-234 java/…/CompareHelperTest.java• L20-375 java/…/MltDecoderTest.java• L40-95
Rust validation
Rust has both a fixture generator and broad fixture checks. Its generator compares generated bytes with the Java reference when the encoding should be shared. When bytes can differ, it compares decoded JSON and writes a Rust-specific fixture. Rust core tests also compare v1 and v2 logical layers, cover nested values and m-values, validate meshes, check vertex ordering, and check decoder memory limits for copied strings and nested dictionary data.
Rust also checks agreement between its public writing paths. A LayerWriter must produce the same MLT and MVT results as a complete TileLayer, including nested columns and m-values. Encoder profiles are tested as compatibility choices: they control whether the output favors speed, size, diffability, or client behavior while preserving the same data contract.
This gives Rust three useful signals: an exact match where the physical contract is shared, a logical match where the encoding is valid but language-specific, and focused safety checks for limits and malformed data that shared JSON cannot show.
The Rust conversion checks apply the same idea to typed fields and measured values. They verify that parsed lists and m-values survive the verify path while unrelated properties and existing columns stay in place.
References: rust/…/main.rs• L1-10 rust/…/writer.rs• L146-273 rust/…/tag02_fixtures.rs• L63-99 rust/…/tag02_nested.rs• L51-59 rust/…/tag02_mvalues.rs• L53-76 rust/…/tag02_meshes.rs• L236-274 rust/…/layer_writer.rs• L14-71 rust/…/layer_writer_m_values.rs• L323-390 rust/…/layer_writer_nested.rs• L36-172 rust/…/hegel_property_columns.rs• L63-335 rust/…/string_copy_budget.rs• L16-89 rust/…/encoder_preset.rs• L3-215 rust/…/convert_fields.rs• L776-816
TypeScript validation
The TypeScript decoder suite loads every discovered synthetic pair and compares the decoded feature collection with its expected JSON. Its encoder suite starts with a reference .mlt, decodes it, re-encodes the result, and checks the final logical output rather than the bytes. This allows the encoder to choose a different stream layout.
The comparison keeps 64-bit identifiers in their native value path and normalizes differences that are not part of the data contract, such as property order and typed null properties. The current suite marks v2 fixtures as unsupported and checks that they still fail until support is added.
References: ts/…/synthetic.spec.ts• L12-38 ts/…/mltEncoderSynthetic.spec.ts• L9-89 ts/…/featureTablesToGeoJson.ts• L1-12
C++ validation
The C++ synthetic suite uses the shared test helper and runs the C++ JSON command-line decoder against each active fixture. It compares parsed JSON with the paired expected output and records actual output when a comparison fails. Its current exclusion marks v2 fixtures as unsupported.
The C++ tool therefore participates in the same logical-output contract as TypeScript while keeping its process boundary separate from the test runner.
References: cpp/…/synthetic.test.ts• L1-41 cpp/package.json• L1-6 cpp/…/synthetic-geojson.hpp• L1-8
Python validation
The Python tests provide focused checks for v2 elevation and mesh fixtures. They compare decoded WKB geometry and the layer elevation step with the expected JSON. They also check the Python-facing encode and decode rules for three-dimensional geometry and height mode. These tests complement the broader synthetic sweeps by checking the public Python shape of the data.
References: rust/…/test_z.py• L1-18 rust/…/test_z.py• L68-85 rust/…/test_z.py• L88-121 rust/…/test_z.py• L120-138
Validation flow
When a fixture changes, the safest view is a path from bytes to logical data and then through each language suite. The following flow shows where a mismatch becomes useful: a byte mismatch can be expected, but a logical-output mismatch is a compatibility failure.
sequenceDiagram
participant F as Fixture pair
participant G as Language generator or encoder
participant D as Language decoder
participant X as Suite comparison
F->>G: Read synthetic input
G->>D: Produce or decode MLT bytes
D->>X: Return logical tile
F->>X: Provide expected JSON
X-->>G: Accept shared bytes or valid logical output
Use automation and releases for the repository-level commands that run these checks and for the way validation participates in delivery. Use shared conformance assets for the wider ownership and update rules for the fixture sets.
References: test/…/index.ts• L50-87 rust/…/writer.rs• L177-232 ts/…/mltEncoderSynthetic.spec.ts• L16-23 java/…/MltDecoderTest.java• L54-95
Change checklist
When these files or sections are changed, remember to consider these:
- A new or renamed
.mltfixture must keep its same-name .json output so all shared discovery code can pair it. - A new support boundary must update the language suite's exclusion list and preserve the guard that fails when support appears.
- A change to expected JSON must be checked against every language suite because JSON is the shared logical contract.
- A change to generator definitions must be checked against both the common reference directory and any language-specific output directory.
- A change to fixture names or version directories must be checked against Rust's generated-file report and the suites that scan fixed directory paths.
- A new v2 nested, m-value, mesh, or elevation case must be checked against the language suites that expose that data through their public API.
- A change to a v2 exclusion must be checked against both the shared helper's stale-exclusion guard and the suite's actual wire-version support.
- A change to a comparison mode or feature-order rule must be checked against Java's layer, feature, geometry, and property alignment contract.
- A change to
LayerWriterbehavior must be checked againstTileLayeroutput for MLT and MVT, including nested columns and m-values. - A change to vertex ordering must be checked with every per-vertex value, including z and m-values, because geometry order is allowed to change while attached data must not.
- A change to decoder string-copy or nested-value handling must be checked against the memory budget tests, not only against successful round trips.
- A change to an encoder profile must be checked for both wire versions and for the profile's intended byte-versus-logical compatibility boundary.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Missing same-name .json output | A decoder cannot compare its logical result with the shared contract | Fixture discovery reads the paired JSON and Java reports missing expected JSON |
| Expected JSON differs in geometry, properties, or metadata | One or more language implementations no longer agree on logical tile data | Every active suite compares decoded output with the expected result |
| A listed unsupported fixture starts passing | The exclusion can hide newly added support | TypeScript and C++ require the unsupported case to remain unequal; Java asserts a decode failure for explicit exclusions |
| Rust bytes differ from a shared reference without a valid language-specific case | Physical compatibility breaks without a recorded reason | Rust compares shared bytes and writes a separate output only for allowed differences |
| Comparison aligns features by position when IDs or order differ | A valid tile can be reported as different, or a real feature change can be missed | Java comparison tests define ID-aware alignment and mode-specific checks |
LayerWriter and TileLayer take different paths for the same data | One public writing path can emit different MLT or MVT results | Rust compares both paths across sorting, tessellation, nested, and m-value cases |
| Vertex sorting moves geometry without its z or m-values | Features keep valid geometry but expose wrong per-vertex data | Rust round trips compare the values after vertex reordering |
| A mesh or triangle-scoped m-value is paired with the wrong vertex or triangle | Three-dimensional features can decode with valid shapes but wrong user data | Rust v2 round trips compare canonicalized mesh rows and the related m-value scope |
| Sparse v2 columns or copied strings exceed the decoder memory budget | A small tile can cause unsafe memory growth during decode | Rust memory tests require a bounded error and check the charged copy size |
| A v2 elevation fixture lacks a matching expected geometry or step | A language can pass a format check while exposing the wrong public geometry | Python compares WKB geometry and elevation metadata with the paired JSON |
Key files
| File | Why to read it |
|---|---|
| test/…/README.md | Defines the purpose of synthetic fixtures and the common-versus-language-specific split |
| test/…/index.ts | Shows how fixture pairs, exclusions, numeric comparison, and failure output work |
| java/…/TestSettings.java | Defines the Java fixture roots and layer categories used by broad fixture checks |
| java/…/MltDecoderTest.java | Shows the Java MVT conversion and decode round trip under plain and advanced settings |
| java/…/CompareHelperTest.java | Shows the logical comparison contract for layers, features, properties, and geometry |
| java/…/SyntheticMltGenerator.java | Shows the main groups of common synthetic data |
| java/…/SyntheticsTest.java | Shows Java's shared logical-output and geometry checks |
| rust/…/writer.rs | Shows Rust's exact-byte and logical-output comparison rules |
| rust/…/tag02_fixtures.rs | Shows the v1-versus-v2 fixture comparison and byte coverage checks |
| rust/…/hegel_property_columns.rs | Shows property presence, string codec, dictionary, and integer boundary coverage |
| rust/…/tag02_mvalues.rs | Shows v2 vertex m-value round trips and shared logical checks |
| rust/…/tag02_nested.rs | Shows v2 nested map and list round trips, null handling, shape coverage, and memory guards |
| rust/…/tag02_meshes.rs | Shows v2 mesh, elevation, triangle m-value, ordering, and corruption checks |
| rust/…/tag02_vertex_sort.rs | Shows that z and m-values follow vertices when order changes |
| rust/…/layer_writer.rs | Shows parity between direct layer writing and complete tile-layer encoding |
| rust/…/layer_writer_m_values.rs | Shows writer parity and validation for per-vertex m-values |
| rust/…/layer_writer_nested.rs | Shows writer parity and validation for nested columns |
| rust/…/string_copy_budget.rs | Shows the decoder budget for copied strings and dictionary entries |
| rust/…/encoder_preset.rs | Shows the compatibility intent of encoder profiles across wire versions |
| ts/…/synthetic.spec.ts | Shows the TypeScript decoder sweep over shared fixtures |
| ts/…/mltEncoderSynthetic.spec.ts | Shows the TypeScript encode/decode round-trip contract |
| cpp/…/synthetic.test.ts | Shows the C++ decoder's use of the shared expected output |
| rust/…/test_z.py | Shows the Python-facing checks for elevation and three-dimensional geometry |