feat: ECA/SECA distance + optional CO₂e emissions reporting - #22
Open
mayurrawte wants to merge 2 commits into
Open
feat: ECA/SECA distance + optional CO₂e emissions reporting#22mayurrawte wants to merge 2 commits into
mayurrawte wants to merge 2 commits into
Conversation
Opt-in emissions reporting on route properties (rough estimates, not certified): - properties.ecaKm / ecaFraction: kilometres of the in-water route inside ECA/SECA emission-control zones. The zones ship behind a new searoute-ts/eca subpath export (bounding-box approximations of the IMO MARPOL Annex VI areas: Baltic, North Sea, Mediterranean, North American, US Caribbean); importing it registers them, keeping the core lean. Computed by subdividing each segment and testing midpoints against zone bboxes, mirroring passage detection. - properties.co2eTonnes: rough distance x vessel-class factor estimate, when a vesselClass or co2eFactorKgPerKm is given. Factors derive transparently from representative fuel burn and the IMO HFO CO2 conversion (VESSEL_CLASSES); glecInflation applies the GLEC ~15% distance uplift. New exports: registerEcaZones, getEcaZones, hasEcaZones, ecaDistanceKm, EcaZone, EcaBbox, VESSEL_CLASSES, co2eFactorKgPerKm, CO2_PER_TONNE_FUEL, VesselClass, VesselClassSpec, and searoute-ts/eca (ECA_ZONES). Tests, README, DOCS, CHANGELOG updated.
ecaDistanceKm interpolated segment midpoints linearly in wrapped lon/lat, so the 37 network edges that jump the ±180° dateline swept their midpoints the long way round the globe — straight through the Mediterranean, North Atlantic and North Sea bboxes. A Yokohama → Honolulu route reported ~249 km of ECA distance in the open Pacific. Unwrap the path first (reusing unwrapCoords) so dateline-crossing segments interpolate the short way, and wrap each midpoint back into ±180° for the zone test. Adds a unit regression for a mid-Pacific dateline segment and an end-to-end trans-Pacific route test; corrects the DOCS.md claim. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mayurrawte
force-pushed
the
feat/issue-12-eca-emissions
branch
from
July 9, 2026 09:26
05627b3 to
0fa50bd
Compare
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?
Adds opt-in emissions reporting to
seaRoute/seaRouteMulti— the two things the commercial Searoutes API leads with, offered in open source. Turn it on withemissions: true:Phase 1 — ECA/SECA distance (
ecaKm)properties.ecaKm/ecaFractionreport how much of the in-water route lies inside ECA/SECA emission-control areas. Computed by subdividing each route segment into ~5 km steps and testing midpoints against zone bboxes — the same bbox idea already used for passage detection, as the issue suggested.searoute-ts/ecasubpath export (per the issue's "keep zone polygons behind a subpath to avoid bloating the core (Halve package size: load the network from a single shared asset instead of inlining it in both builds #10)"), mirroring thesearoute-ts/portspattern — importing it registers the defaults viaregisterEcaZones; without the import,ecaKmstaysundefinedand the core stays lean.registerEcaZones.Phase 2 — CO₂e estimate (
co2eTonnes, opt-in)vesselClass(VESSEL_CLASSES) or explicitco2eFactorKgPerKmis given,properties.co2eTonnes = distanceKm × factor.fuelTonnesPerDay × 3.114 (IMO HFO CO₂ conversion) × 1000 / (24 × serviceSpeedKnots × 1.852)→ kg CO₂e/km. Cited to the IMO Fourth GHG Study 2020.glecInflation(e.g.0.15) applies the GLEC ~15 % shortest-path distance uplift to the CO₂e estimate only.New exports — core:
registerEcaZones,getEcaZones,hasEcaZones,ecaDistanceKm,EcaZone,EcaBbox,VESSEL_CLASSES,co2eFactorKgPerKm,CO2_PER_TONNE_FUEL,VesselClass,VesselClassSpec; subpathsearoute-ts/eca:ECA_ZONES,registerEcaZones,EcaZone. 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✅ (emits thesearoute-ts/ecasubpath in CJS/ESM/types)npm test✅ (78 tests; 5 new core CO₂e tests covering factor scaling,co2eFactorKgPerKmoverride,glecInflation, and no-emission-props-without-the-flag; 6 newsrc/eca/index.spec.tstests covering zone registration, a North Sea route ~100 % in-zone, an Indian-Ocean route ~0 % in-zone, ECA + CO₂e together,ecaDistanceKmon an explicit Mediterranean line, andregisterEcaZonescustom-zone override)Also verified end-to-end against the built
dist(CJS + ESM): Rotterdam→London = 392 km withecaKm392 / fraction 1.00 andco2eTonnes88.2 (panamax); Singapore→MumbaiecaKm0.00;glecInflation: 0.15scales CO₂e as expected.Closes #12
Generated by Claude Code