feat: multi-resolution networks (20km/50km) via subpath exports - #23
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
New subpath exports
searoute-ts/marnet-50kmsearoute-ts/marnet-20kmEach variant re-exports
DEFAULT_MARNET(aFeatureCollection<LineString>) plus theMarnetNetwork/MarnetPropertiestypes, and is backed by a single shareddata/marnet-<res>.cjsasset 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.cjsnow 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.ctstype declaration.scripts/copy-marnet.cjscopies everymarnet*.cjs/.d.ctsasset into the build outputs.eurostat/searoute, EUPL-1.2). I validated the pipeline by regenerating the 100 km network from source and confirming it reproduces the committeddata/marnet.cjsexactly (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.cjsand loadable vialoadNetwork/thenetworkoption; 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 lintandnpm testpassValidation (all steps CI runs, from a clean tree)
npm cinpm run lint✅npm run format:check✅npm run build✅ (emitssearoute-ts/marnet-20kmandmarnet-50kmin CJS/ESM/types; copies 6 shared network asset files intodist/data)npm test✅ (72 tests; 5 new insrc/marnet/index.spec.tscovering the 20 km/50 km feature counts and LineString geometry, ordering vs. the default, preserved native passage labels, routing via thenetworkoption, and the finer 20 km path having more coordinates than the default)Also verified end-to-end against the built
distin both CJS (require) and ESM (import):searoute-ts/marnet-20kmloads 29,581 features and Shanghai→Rotterdam routes to ~19,720 km with 244 coordinates versus the default's 112 (same corridor, higher fidelity);marnet-50kmloads 15,498 features.Closes #11
Generated by Claude Code