Skip to content

feat(parser): add PocketTopo .top (v3) support#1

Merged
MattNotarangelo merged 1 commit into
mainfrom
feat/pockettopo-top-support
Jun 11, 2026
Merged

feat(parser): add PocketTopo .top (v3) support#1
MattNotarangelo merged 1 commit into
mainfrom
feat/pockettopo-top-support

Conversation

@MattNotarangelo

Copy link
Copy Markdown
Owner

Background

  • PocketTopo (DistoX paperless surveying) is how a large share of caves are surveyed today, but its native .top files couldn't be opened in the viewer — only processed formats (Survex .3d, Compass .plt, Therion .lox) were supported.
  • Unlike those formats, .top stores raw shot measurements (distance / azimuth / inclination), so support means the parser must also compute station coordinates, not just decode bytes.

What Has Changed

  • New parser src/parser/pocketTopoTop.ts for the binary .top v3 layout, cross-checked against TopoDroid's ptopo package (a port of Beat Heeb's reference implementation, incl. his 2026 station-id corrections). Decodes trips (date as .NET ticks, declination), shots (1/65536-circle angles, mm distances, major.minor / plain-number / undefined station ids), and reference points; the trailing sketch drawings carry no geometry and are skipped.
  • Coordinate computation: applies per-trip magnetic declination, averages consecutive repeats of the same shot (DistoX triple-shot practice), turns undefined-target shots into splays with anonymous endpoints, and propagates positions breadth-first from reference points (flagged fixed) or the origin. Loops are intentionally not adjusted — misclosure stays visible.
  • Wiring: parseCaveFile dispatches .top; file-input accept list, drop overlay, and HUD hint mention the new format; README updated (status, formats table, parser notes, testing section).
  • Tests: a from-spec encoder (test/helpers/encodeTop.ts) plus 17 round-trip tests covering trig-verified geometry, declination, averaging, splays, references, trip dates, station-id variants, comment/flag record alignment, disconnected components, truncation, and magic/version rejection.

Real-world validation

Two genuine PocketTopo files from a public survey-data repo were parsed and cross-checked against Therion's processed .3d of the same caves (independent oracle):

Cave This parser Therion .3d / published map
Area 51 (s1.top) 265.0 m length, 34.5 m depth 265.0 m, 34.5 m (map states "265 m / 35 m")
Bluewater Sink Canyon 53.7 m, 10.2 m depth 53.7 m, 10.2 m

The plan-view render also visually matches the cave's published map. (Fixtures not vendored — the source repo's data licence is ambiguous.)

Screenshots/Video

  • {Leave for author}

Checklist

  • Self-review completed
  • Tests added or updated
  • Tested locally

🤖 Generated with Claude Code

Parses PocketTopo's native binary format and converts its RAW shot
measurements into the normalized CaveModel: applies per-trip magnetic
declination, averages consecutive repeated shots (DistoX triple-shot
practice), turns undefined-target shots into splays with anonymous
endpoints, and propagates station coordinates breadth-first from
reference points (or the origin). Loops are not adjusted.

Byte layout cross-checked against TopoDroid's ptopo package, a port of
Beat Heeb's reference implementation (incl. his 2026 station-id
corrections). Round-trip tested via a from-spec encoder covering
declination, averaging, splays, references, trip dates, plain-number
vs major.minor ids, truncation, and version/magic rejection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying caveviewer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5623486
Status: ✅  Deploy successful!
Preview URL: https://60a6a379.caveviewer.pages.dev
Branch Preview URL: https://feat-pockettopo-top-support.caveviewer.pages.dev

View logs

@MattNotarangelo MattNotarangelo merged commit b812d71 into main Jun 11, 2026
2 checks passed
@MattNotarangelo MattNotarangelo deleted the feat/pockettopo-top-support branch June 11, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant