E4 ยท Publication Volume 26

Spatial Indexing

R-trees, grid indexes, bounding volumes and query trade-offs

Learning objectives

  • Explain the decision and evidence boundary for R-trees, grid indexes, bounding volumes and query trade-offs.
  • Select and implement the relevant representation or algorithm without hidden coordinate, support or topology assumptions.
  • Separate exact predicates, approximation error, source uncertainty and visual delivery.
  • Produce a broad-phase and exact-query benchmark with an index decision record from synthetic evidence.

The lesson is complete only when the learner can defend the representation, transform, predicates, tests and release decision. A visually clean map or 3D scene without executable invariants and provenance remains unverified.

This is a general, institution-neutral tutorial with no relationship to any company or individual. All coordinates, geometries, grids, points, surfaces, volumes, attributes and review events in the lesson are synthetic and must not be used for an operational decision.

Decision context

The decision is which index structure supports a declared query workload without changing the scientific predicate. Indexes accelerate candidate discovery; they do not prove exact intersection, containment or distance. The workload record states object type, dimensionality, coordinate range, static or update behaviour, typical and adversarial query extents, required exact predicate, latency objective, memory boundary and whether streaming or partial reads are needed. An index is rejected if it silently drops dimensions or cannot reproduce an unindexed result set.

Write the intended use, consequence of error, required evidence, spatial support and release authority before selecting a representation or transformation. Fitness is evaluated against a versioned contract and use, not attached permanently to a file extension.

Core concept

A spatial query normally has two phases. The broad phase compares conservative bounding volumes or occupied cells and returns a superset of possible matches. The narrow phase evaluates the exact predicate on those candidates. An axis-aligned bounding box is cheap and conservative but can be loose for diagonal or curved geometry. Hierarchical indexes group nearby bounds; regular grids give direct addressing but can perform poorly when density varies; octrees divide three-dimensional space; bounding-volume hierarchies can follow object geometry. The choice follows data and query distribution, not fashion.

Keep received evidence, accepted analytical views and derived representations as distinct objects. This allows corrected evidence, a changed transform or a new level of detail to generate a new result without rewriting history. Every coordinate and primitive therefore answers both a spatial question and a provenance question.

Algorithm and data model

Index immutable object versions and store index metadata separately from scientific attributes. Each leaf references stable object and primitive identities; each node records bounds in a declared coordinate frame. Broad-phase bounds must contain the represented geometry after quantisation. Updates either create a new index version or follow a documented incremental policy with consistency checks. Query output includes index version, query geometry, broad-phase candidates, exact matches and predicate version. For out-of-core delivery, hierarchy offsets, byte ranges and level-of-detail rules become part of the access contract.

Define parsing, semantic validation, canonicalisation, indexing, exact or approximate calculation, quality evaluation and encoding as separate stages. Each stage emits structured output and does not depend on interface state, file order, graphics-driver behaviour or undocumented defaults.

Constraints and invariants

| Invariant | Executable or review test | | --- | --- | | Broad-phase bounds conservatively contain every represented primitive. | Reject or quarantine the exact affected object and preserve the received representation. | | Exact predicates run after candidate retrieval for analytical decisions. | Evaluate this condition before creating a derived geometry, grid, surface or volume. | | Indexed results reproduce brute-force results on the validation corpus. | Record the predicate, tolerance policy, observed values and coordinate frame. | | Index dimension, coordinate frame and object version are explicit. | Make every repair a new version and rerun all dependent golden cases. |

An invariant must survive import, transformation, processing, export and rerun. A failed hard invariant produces no apparently valid substitute. Diagnostics remain visible with predicate, threshold, coordinate frame, scope and evidence, and require a reviewed rule before they can trigger repair.

Quantitative reasoning

For a corpus of N objects and query q, report broad-phase candidate count C_q, exact match count M_q, false-positive count C_q-M_q, pruning fraction 1-C_q/N, build time, index bytes and end-to-end query time. Recall against brute force must be one for a conservative index; a missing exact match is a correctness failure, not a performance trade-off. Stratify metrics by query size, orientation, density and empty-result cases. Test points on node boundaries, zero-volume bounds, objects spanning many cells, clustered and uniform distributions, large diagonal triangles and three-dimensional queries against a mistakenly two-dimensional index.

Every metric includes units, support, numerator and denominator where applicable, exclusions, comparison policy and evaluation version. Aggregate metrics are stratified when pooling can hide local geometry failure. A performance gain cannot overrule invalid topology, missing reference metadata or broken lineage.

Evidence and uncertainty

Keep acquisition uncertainty, interpretation uncertainty, discretisation error, numeric round-off and delivery error separate. Increasing coordinate digits or triangle count does not improve the original evidence. A sampled surface may be smooth and watertight while remaining poorly constrained between observations. Report uncertainty in the quantity and support to which it belongs.

Build an evidence packet containing immutable received objects, semantic declarations, validation findings, transform inputs and outputs, measured errors, test results, reviewer decisions and fingerprints. Contradictory evidence remains available. When a required reference, topology state or classification cannot be resolved, return unknown, conflict or blocked rather than inventing geometry.

Interfaces and storage

Interfaces transmit identity, coordinate reference, units, axis order, support, topology expectations, attribute association, null state, version and lineage beside coordinates. Structured errors identify the object, primitive, predicate, observed value, expected condition and rule. An interface that carries vertices but drops the transform or face orientation has not preserved the object.

Store authoritative received evidence separately from reproducible analytical derivatives and disposable delivery artefacts. Indexes, caches, pyramids and render meshes improve access but cannot become the only copy of source attributes or coordinate metadata. Round-trip tests verify identity, precision, topology, ordering, missingness and association after encoding changes.

Governance and review

Assign responsibilities to roles rather than named organisations or people: evidence custodian, representation author, algorithm maintainer, independent validator and release reviewer. A role may propose a repair but cannot erase the received geometry. Transform, predicate and tolerance changes are versioned and evaluated against fixed regression fixtures before release.

Exceptions are explicit decisions with scope, rationale, evidence, approving role, affected versions and review trigger. They never turn invalid topology into valid topology by label. The host website has no ownership or scientific-authority role in this workflow; it only delivers the tutorial.

Integration checkpoint

a broad-phase and exact-query benchmark with an index decision record
a broad-phase and exact-query benchmark with an index decision record

Read the figure as a reasoning map from preserved evidence through declared support and coordinates, controlled transformation, validation and scoped release. Each arrow represents a declared relationship. Integrate a broad-phase and exact-query benchmark with an index decision record into SYN-SPATIAL, rerun earlier fixtures and record every changed assumption.

Synthetic worked example

SYN-SPATIAL contains 10,000 synthetic triangles concentrated along a narrow diagonal zone. A coarse regular grid creates a few overloaded cells and returns 7,800 candidates for a small oblique query; a hierarchical bounding-box index returns 320. Both produce the same 27 exact intersections after the narrow phase. A benchmark records the distributions rather than claiming one universal winner. A deliberate test then indexes only horizontal bounds: it misses a vertically separated triangle intersected by a 3D query and is rejected despite faster timing.

  1. Preserve the received object and state the intended decision without repair.
  2. Resolve identity, reference, units, support, topology and evidence eligibility.
  3. Run the versioned transform or predicate while retaining intermediate diagnostics.
  4. Issue accept, reject or quarantine and show how an independent reviewer reproduces it.

Practice task

Implement the chapter artefact against a synthetic fixture containing one normal case, one boundary case, one invalid case and one unresolved-evidence case. Preserve the received fixture. Produce canonical input, validation findings, derivative output, processing manifest, measured error and a short release decision.

Acceptance criteria:

  • Every required identity, coordinate reference, unit, support and convention is explicit.
  • The implementation is deterministic under stable ordering and the declared numerical policy.
  • No repair overwrites received evidence or converts unknown into a guessed value.
  • All hard failures block the affected derivative and remain machine-readable.
  • A second implementation or reviewer can reproduce the result from the package alone.

Submit a broad-phase and exact-query benchmark with an index decision record, golden and adversarial fixtures, exact findings, measured error and a limitations note. A screenshot is not sufficient evidence because it does not identify input versions, transforms, algorithms or rule configuration.

Common failure modes

  • Treating bounding-box overlap as exact geometry intersection.
  • Benchmarking only one convenient query extent.
  • Building a two-dimensional index for a three-dimensional predicate.
  • Updating source geometry without rebuilding or invalidating the index.

These failures share a pattern: implicit convenience is substituted for evidence. Diagnose the earliest boundary where the assumption entered, restore the source statement, make the transform or predicate explicit, rerun all dependent derivatives and supersede rather than overwrite the affected release.

Review questions

  1. Why must a broad phase return a conservative superset?
  2. Which workload properties influence index choice?
  3. How is correctness checked independently of performance?
  4. Why can a fast index still be unacceptable?

For every answer, identify the governing invariant, evidence needed to evaluate it, numerical or semantic policy involved and correct behaviour when the condition fails.

Sources and further reading