Skip to main content

Module shx

Module shx 

Source
Expand description

.shx random-access index for the companion .shp.

§Layout

Same 100-byte header as .shp (file code, version, shape type, bbox), then fixed 8-byte records:

BytesField
0..4Offset in 16-bit words from .shp start (big-endian i32)
4..8Content length in 16-bit words (big-endian i32)

Both fields are big-endian — they’re “file-management” data in Shapefile parlance. Byte offset = offset_words * 2. Without this file we’d have to scan .shp sequentially to find each record.

§Clever bit

We pre-convert words → bytes once on load so the iterator doesn’t have to multiply on every step. The index is parsed eagerly into a Vec (small even for huge shapefiles — 8 bytes × N records ≈ 80 MB at 10M features, well within RAM budget).

Structs§

Shx
ShxRecord

Functions§

parse