Skip to content

feat: multi-resolution networks (20km/50km) via subpath exports - #23

Merged
mayurrawte merged 1 commit into
mainfrom
feat/issue-11-multi-resolution-networks
Jul 9, 2026
Merged

feat: multi-resolution networks (20km/50km) via subpath exports#23
mayurrawte merged 1 commit into
mainfrom
feat/issue-11-multi-resolution-networks

Conversation

@mayurrawte

Copy link
Copy Markdown
Owner

What does this PR do?

Exposes finer Eurostat maritime networks as subpath exports so consumers can trade download size for coastal-routing accuracy — the design proposed in #11 (unblocked now that #10 ships the network as a shared loadable asset):

import { DEFAULT_MARNET } from 'searoute-ts/marnet-20km'; // or 'searoute-ts/marnet-50km'
import { seaRoute } from 'searoute-ts';

seaRoute(origin, destination, { network: DEFAULT_MARNET });

New subpath exports

Import Resolution Segments
searoute-ts/marnet-50km 50 km 15,498
searoute-ts/marnet-20km 20 km 29,581

Each variant re-exports DEFAULT_MARNET (a FeatureCollection<LineString>) plus the MarnetNetwork/MarnetProperties types, and is backed by a single shared data/marnet-<res>.cjs asset that both the CJS and ESM builds load at runtime — the same shared-asset approach #10 introduced for the default network, so a variant is never duplicated across builds and the core stays lean (you only pay for a finer network if you import it).

Generation & provenance

  • scripts/build-marnet.cjs now takes an optional resolution label and can generate any Eurostat resolution (5/10/20/50/100 km) from a GeoJSON source; it also (re)emits the matching .d.cts type declaration. scripts/copy-marnet.cjs copies every marnet*.cjs/.d.cts asset into the build outputs.
  • The bundled assets were regenerated from the upstream Eurostat GeoPackages (eurostat/searoute, EUPL-1.2). I validated the pipeline by regenerating the 100 km network from source and confirming it reproduces the committed data/marnet.cjs exactly (same 9,847 segments, identical geometry, identical 12 native passage labels), so the 20/50 km variants are produced the same, trusted way.

Not bundled: 10 km / 5 km

The 10 km (~5.9 MB) and 5 km (~9.0 MB) networks are large enough that bundling them would dominate the install, so they are not shipped in the package. They remain generatable with scripts/build-marnet.cjs and loadable via loadNetwork/the network option; the README table documents their sizes and how to use them.

Docs — README gains a size/accuracy tradeoff table (all five resolutions) and an updated bundle-size FAQ; DOCS "Other resolutions" and CHANGELOG updated. No breaking changes; no version bump.

Checklist

  • npm run lint and npm test pass
  • New behavior is covered by a test
  • CHANGELOG.md updated (user-visible changes only)

Validation (all steps CI runs, from a clean tree)

  • npm ci
  • npm run lint
  • npm run format:check
  • npm run build ✅ (emits searoute-ts/marnet-20km and marnet-50km in CJS/ESM/types; copies 6 shared network asset files into dist/data)
  • npm test ✅ (72 tests; 5 new in src/marnet/index.spec.ts covering the 20 km/50 km feature counts and LineString geometry, ordering vs. the default, preserved native passage labels, routing via the network option, and the finer 20 km path having more coordinates than the default)

Also verified end-to-end against the built dist in both CJS (require) and ESM (import): searoute-ts/marnet-20km loads 29,581 features and Shanghai→Rotterdam routes to ~19,720 km with 244 coordinates versus the default's 112 (same corridor, higher fidelity); marnet-50km loads 15,498 features.

Closes #11


Generated by Claude Code

Expose finer Eurostat networks so consumers can trade download size for
coastal-routing accuracy, per issue #11:

  import { DEFAULT_MARNET } from 'searoute-ts/marnet-20km';
  seaRoute(o, d, { network: DEFAULT_MARNET });

- New subpath exports searoute-ts/marnet-20km (~29,581 segments) and
  searoute-ts/marnet-50km (~15,498 segments), each backed by a single shared
  data/marnet-<res>.cjs asset both the CJS and ESM builds load at runtime
  (building on the shared-asset work from #10), so the core stays lean.
- scripts/build-marnet.cjs now accepts a resolution label and generates any
  Eurostat resolution from a GeoJSON source; scripts/copy-marnet.cjs copies all
  marnet assets into the build outputs.
- 10km/5km are too large to bundle and are documented for use via loadNetwork.
- README gains a size/accuracy tradeoff table; DOCS/CHANGELOG updated.

test: cover resolution variants (feature counts, LineString geometry, native
passage labels, routing via the network option, and finer path fidelity).

Closes #11
@mayurrawte
mayurrawte merged commit cbb670e into main Jul 9, 2026
4 checks passed
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.

Optional multi-resolution networks (5/10/20/50 km) via subpath exports

1 participant