itacart.serialization.geometry_blob

GeometryBlob: binary encoding of an ordered ITACaRT vertex sequence.

Preserves what TreeBlob discards: vertex order, ring topology, edge model, densification parameters and OGC SFA type. That makes it the form to hash when a geometry must be identified rather than merely covered.

Header layout, 9 bytes:

Byte(s)

Bits

Field

Values

0x00

8

Magic

0xC8

0x01

8

Format version

0x01

0x02 hi

4

Canonical profile

0x0 MIN_LEX_CYCLIC_ROTATION

0x02 lo

4

Edge model

0x0 PLANAR_SINUSOIDAL_STRAIGHT, 0x1 WGS84_GEODESIC

0x03 hi

4

Densification model

0x0 NONE, 0x1 ORTHODROMIC_VINCENTY, 0x2 ASSUMED_BY_PRODUCER

0x03 lo

4

Resolution mode

0x0 UNIFORM, 0x1 MULTI

0x04-0x05

16

max_segment_m

0x03E8 = 1000 m

0x06 hi

4

Uniform resolution

0xD = res 13, 0x0 if MULTI

0x06 lo

4

Geometry type (OGC SFA)

0x0 reserved, 0x1 POINT .. 0x6 MULTIPOLYGON

0x07-0x08

16

component_count

1 for single, N for MULTI*

Components, parts and rings follow, then the vertex stream. Vertices are delta-encoded by shared_levels, the count of hierarchy levels a vertex shares with its predecessor; vertex 0 is always written in full.

Density is a curve in the depth of the shared prefix, not a constant. A vertex sharing nothing with its predecessor costs 65 bits at resolution 13 plus a 4-bit shared_levels field; one sharing all thirteen levels costs the 4-bit field alone. Measured on a synthetic resolution-13 polygon whose vertices share levels 1 to 7, the amortised cost is about 25 bits per vertex for a uniform blob and about 29 for a multi-resolution one, easing towards those figures as vertex count rises.

Module constants

GEOMETRY_TYPES

OGC Simple Feature Access type codes.

RING_ROLES

Ring roles, written in the high nibble of each part header.

Functions

decode_geometry

Decode a GeometryBlob into rings and profile metadata.

encode_geometry

Encode ordered vertex rings as a GeometryBlob.

geometry_hash

Content hash of a canonical GeometryBlob.

geometry_to_tree

Derive the TreeBlob of a GeometryBlob's vertex set.

read_geometry_type

Read the OGC SFA type from the header without full decoding.

validate_geometry

Validate blob structure, raising on the first problem found.