Skip to content

Resolve duplicated port codes and reject port-list namesakes - #25

Merged
skuirrels merged 1 commit into
mainfrom
fix/resolver-port-list-fallback
Oct 30, 2026
Merged

skuirrels merged 1 commit into
mainfrom
fix/resolver-port-list-fallback

Conversation

@skuirrels

Copy link
Copy Markdown
Owner

Summary

  • Duplicated port codes no longer throw. Twelve codes have two port-list records and no UN/LOCODE position (INNSA, PHDVO, IDPLM and others). Resolution called the throwing GetByCode overload, so every movement and Locate through them failed, whatever the mode. Port-to-port CalculateRoute threw for all 38 duplicated codes, CAVAN included. A new SelectPortRecord takes the record nearest the UN/LOCODE position or, without one, the terminal record of a group lying within 50 km. It throws only when the records are further apart.
  • Port-list namesakes are rejected. When UN/LOCODE lists a code without a position, the last fallback took the port-list record even when it named a different place: Locate("USLBE") returned Laguna Beach, California, not Latrobe, Pennsylvania. The names must now agree, allowing for spelling variants such as Haerbin and Harbin, and Helsinki and Helsingfors. 27 codes now throw an ArgumentException naming both places, 21 of them in the United States.

Behaviour changes to note

  • CNSWA and CNWUX now throw: UN/LOCODE files them as airports, and the ports are CNSTG and CNWXS. INCOO (Kundapur and Coondapur) is spelt too differently to match.

Testing

  • dotnet test -m:1 -nr:false: 580 passed on net8.0 and net10.0.
  • New tests cover rejected namesakes, kept spelling variants, every duplicated code resolving, a Nhava Sheva sea movement, and code-only routes for INNSA and CAVAN.
  • Resolved all 3,924 port-list codes: exactly 27 rejected as namesakes, no other failures.

Twelve codes have two port-list records and no UN/LOCODE position, so
resolution called the throwing GetByCode overload and every movement
through them failed, Nhava Sheva (INNSA) included. Port-to-port routes
threw for all 38 duplicated codes. Resolution now takes the record
nearest the UN/LOCODE position or, without one, the terminal record of
a group lying within 50 km, and throws only for records further apart.

When UN/LOCODE lists a code without a position, the port-list record
was used even when it named a different place: Latrobe (USLBE) resolved
to Laguna Beach, California. The names must now agree, allowing for
spelling variants such as Haerbin and Harbin. 27 codes now throw an
ArgumentException naming both places.
@skuirrels
skuirrels merged commit 8211bc4 into main Oct 30, 2026
1 check passed
@skuirrels skuirrels mentioned this pull request Oct 30, 2026
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