Tile inspector application
The Tile inspector is a browser application for loading MapLibre Tile bytes and understanding how the bytes form a tile. It connects the tile decoder to linked byte, region, geometry, statistics, and specification views so an engineer can move from raw input to the tile structure and its decoded meaning.
Application purpose
The application turns one tile into a shared inspection model. It keeps the original bytes, an annotated tree of structural regions, and decoded feature data together so each view can point to the same part of the tile.
The application supports three main goals:
- Load a known fixture, a local
.mltfile, or a web address. - Relate byte ranges to named tile regions and decoded values.
- Compare the encoded layout with geometry, byte-use statistics, and the tile specification.
The browser shell is mounted by inspector/…/main.ts, while inspector/…/App.vue owns the loaded tile and the active inspection state.
References: inspector/…/main.ts• L1-4 inspector/…/App.vue• L5-22 inspector/…/App.vue• L43-51
Tile inspection model
The decoder supplies two related results. The region tree describes where headers, metadata, columns, streams, and data blobs sit in the byte buffer. The feature collection gives the application a readable geometry and property view when the tile can be decoded.
The application uses the region tree as the common link between views. Selecting or hovering a region highlights its byte span, shows its address and meaning, and can decode the associated payload. A layer filter narrows the region tree without losing the mapping back to the full tile.
flowchart LR
A[Tile bytes] --> B[Tile decoder]
B --> C[Annotated region tree]
B --> D[Decoded features]
C --> E[Hex byte view]
C --> F[Region detail and values]
C --> G[Byte-use statistics]
D --> H[Geometry view]
D --> G
C -. links .-> I[Specification sections]
The decoder boundary is kept in inspector/…/annotate.ts. This lets the browser views work from a small, stable model instead of knowing how each wire field is decoded.
References: inspector/…/annotate.ts• L1-12 inspector/…/App.vue• L53-89 inspector/…/HexdumpView.vue• L23-31 inspector/…/hex.ts• L149-164
Inspection workspace
The loaded-tile workspace presents the byte buffer as a hex map beside a region tree. The two views share selection and hover state, so a region in the tree and its bytes in the map describe the same range.
The detail area adds context without changing the source bytes. It can show layer facts, bit fields, stream encoding labels, decoded values, and links into the specification. Large payloads are revealed in bounded steps so the first inspection stays quick and readable.
The workspace also provides optional geometry and statistics panels. Geometry shows the decoded tile in tile coordinates and exposes feature facts on hover. Statistics show how each layer spends bytes across geometry, properties, IDs, and metadata, together with feature and vertex counts when available.
For a focused explanation of these views, see Inspector views and annotations.
References: inspector/…/HexdumpView.vue• L145-180 inspector/…/HexdumpView.vue• L258-355 inspector/…/RegionDetail.vue• L146-258 inspector/…/GeometryView.vue• L155-227 inspector/…/StatsView.vue• L75-195
Input and fixture flow
The empty screen is an input point rather than a separate product mode. A reader can choose a fixture from the indexed corpus, open a local tile file, or enter an HTTP or HTTPS tile address. Each source produces the same tile inspection workspace.
Fixtures provide a useful starting set for common geometry and encoding shapes. The fixture index records each tile's size and facet values, such as wire tag, geometry, column type, string layout, and stream encoding. The picker uses this shared vocabulary to group and sort tiles, show coverage gaps, and narrow the corpus with compatible filter choices. It can also find a facet value that does not appear in any file name.
Remote loading is browser-based and sends no credentials. Relative and schemeless web addresses resolve against the current page, while non-web schemes and empty input are rejected. The remote server must allow the browser request. Local files do not receive a source address, while fixture and URL loads retain their source so the current tile can be named and shared.
For input, fixture, and deep-link behavior, see Inspector inputs and sharing.
References: inspector/…/SourcePicker.spec.ts• L64-111 inspector/…/SourcePicker.spec.ts• L113-216 inspector/…/fixtures.ts• L286-423 inspector/…/fixtures.ts• L447-475 inspector/…/fixture-index.spec.ts• L7-167
Sharing and documentation integration
The address bar represents the loaded source and the important inspection choices. A new tile creates a browser history entry. Changes inside that tile replace the current entry, so Back moves between tiles instead of recording every region selection.
The application can run on its own or inside the documentation site. In the embedded form it reports whether a tile is loaded and passes its current query string to the containing page. A pop-out link preserves that state, which lets a reader move between the documentation frame and a full-window inspection without losing the selected tile.
The detail view also receives specification text prepared at build time. Region labels and stream encoding names are mapped to the relevant specification sections. The mapping selects the specification version from the tile tag, removes duplicate sections, and ignores encoding variants that share one definition. The build checks that every section requested by the inspector still exists, which keeps a renamed or removed specification section from producing an empty reference panel.
References: inspector/…/App.vue• L215-267 inspector/…/App.vue• L271-357 inspector/…/encodingDocs.ts• L174-225 inspector/…/encodingDocs.ts• L271-295 inspector/…/encoding-docs.ts• L237-249 inspector/…/encoding-docs.ts• L278-315
Build and delivery boundary
The inspector is built as a static browser application for the documentation site. Its build creates the application bundle together with a fixture index, permitted fixture byte assets, and the specification sections used by the detail view.
The development server follows the same source boundary as the build: it serves indexed fixtures rather than exposing the fixture directories as a general file system. The application therefore depends on the fixture index and documentation-data steps as part of its delivered product, not only as local development helpers.
References: inspector/vite.config.ts• L6-15 inspector/…/fixture-index.ts• L135-185 inspector/…/encoding-docs.ts• L296-315 inspector/package.json• L7-14
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the decoder's region ordering and the application's layer-filter mapping aligned. A filtered tree must still resolve payload reads against the full tree.
- Keep fixture keys consistent across the fixture index, emitted
fixtures/<key>assets, source-picker selection, andfixturedeep links. - Keep fixture facet names and values aligned between
mlt ls, the filter vocabulary, coverage counts, and deep-link filter keys. A new or renamed facet can silently make a tile unfindable. - Keep source and view state changes compatible with browser history. Tile changes should remain distinct from region and layer changes.
- Keep inspector encoding-document keys aligned with specification headings and anchors. The build treats missing requested sections as an error.
- Keep the embedded-window message and pop-out URL contract aligned with the documentation page that hosts the application.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The decoder stops while walking a tile | The known prefix remains inspectable, but the remaining bytes are shown as unannotated | The workspace keeps the partial tree and reports the walk error instead of hiding the tile |
| Feature decoding fails while annotation succeeds | Byte and region inspection works, but geometry and feature-based statistics are unavailable | Feature decoding is isolated from annotation and the geometry input can be null |
| A remote tile server blocks cross-origin requests | The browser cannot load the tile | The URL flow reports the fetch failure and tells the reader that the server must allow requests from other sites |
| The fixture index cannot be loaded or a fixture is missing from the served set | Fixture browsing or a selected fixture can fail before inspection starts | The source loader checks response status and the build serves only keys present in the generated index |
| A fixture facet is read with a changed spelling or shape | Filters can show false gaps or fail to match tiles that carry the facet | The index checks cover all fixture directories and records the axes used by the picker |
| A specification heading or inspector anchor is renamed without updating its counterpart | A region's specification panel can be empty or the build can fail | The encoding-docs build check verifies every inspector document key resolves |
Key files
| File | Why to read it |
|---|---|
| inspector/…/App.vue | Shows the application lifecycle, loaded-tile state, source selection, view state, and browser-history coordination. |
| inspector/…/annotate.ts | Defines the boundary between the browser UI and the tile decoder. |
| inspector/…/HexdumpView.vue | Shows how the shared byte, region, detail, geometry, and statistics workspace is assembled. |
| inspector/…/RegionTree.vue and inspector/…/RegionDetail.vue | Explain the structural region view and the information attached to the selected region. |
| inspector/…/SourcePicker.vue and inspector/…/fixtures.ts | Explain the supported input sources and the fixture browsing and facet-filter model. |
| inspector/…/deeplink.ts | Defines the address-bar contract for sources, filters, layers, regions, and optional panels. |
| inspector/…/fixture-index.ts | Shows how fixture metadata and permitted tile assets reach the browser application. |
| inspector/…/encoding-docs.ts and inspector/…/encodingDocs.ts | Show how specification sections become data for the region detail view and how stream and region names resolve to those sections. |
| inspector/vite.config.ts | Defines the static output boundary and the development/build plugins. |