Skip to content

Match a numbered route published without its class - #169

Merged
jinskeep-morpc merged 1 commit into
mainfrom
fix/bare-number-route-names
Aug 4, 2026
Merged

Match a numbered route published without its class#169
jinskeep-morpc merged 1 commit into
mainfrom
fix/bare-number-route-names

Conversation

@jinskeep-morpc

Copy link
Copy Markdown
Collaborator

The counties disagree about whether a numbered route street name carries the class that qualifies it. Most of the region publishes US 42 and SR 104, but 4,328 points name the route by number alone — Delaware 2,646, Union 1,502, Fayette 128, Franklin 51, Logan 1. Delaware holds the point for 844 US 42 N under the street name 42, so a query normalized to the regional form finds nothing.

Found while running the geocoder benchmark that morpc/morpc-addresspoints-standardize#7 uses as its acceptance test.

Approach

The index carries the route number as a separate key beside the full name, and a new route_number tier matches on it after the full name has found nothing.

Deliberately a separate key rather than a normalization of the street name. Folding the class away would merge roads that are genuinely different — Logan publishes both CR 32 and TR 32, and 15 other county-and-number pairs are likewise two roads sharing a number:

('Logan', '32')  ['CR 32', 'TR 32']
('Logan', '68')  ['CR 68', 'US 68']
('Logan', '117') ['CR 117', 'SR 117']
('Delaware', '605') ['(bare) 605', 'CR 605']
...

Running the tier last means the looser key is consulted only where the exact name failed, so those pairs still resolve by name. Where the tier itself finds several roads, the existing distance guard reports the ambiguity rather than averaging across them — covered by a test.

CONST_GEOCODE_INDEX_VERSION goes to 2 so existing indexes rebuild.

Effect

Against the 359 DODD, CMS and ODRC facility addresses used to validate morpc/morpc-addresspoints-standardize#7, rebuilding the index from the real 1.25 M-row reference data:

Before After
Overall 320 / 359 (89.1%) 324 / 359 (90.3%)
ODRC 68.5% 74.1%
CMS 95.3% 96.1%

Four addresses reached the new tier and all four matched correctly: 844 US 42 N (Delaware, ×3) and 14442 STATE ROUTE 33 WEST (Logan).

No regressions — the exact, components and number_name tiers are unchanged at 277, 35 and 8, so nothing previously matched was displaced.

Tests

Four added, covering the helper, a match through the new tier, the full name winning ahead of it, and ambiguity being reported rather than averaged. The fixture gains the routenum column and two route rows.

All 39 tests in test_geocode.py pass. Note that 4 tests in test_utils.py fail on this branch — they fail identically on main with these changes stashed, are datetime parsing rather than geocoding, and are untouched here.

Related

🤖 Generated with Claude Code

The counties disagree about whether a route street name carries the class that
qualifies it. Most of the region publishes "US 42" and "SR 104", but 4,328
points across Delaware (2,646), Union (1,502), Fayette (128), Franklin (51) and
Logan (1) name the route by number alone. Delaware holds the point for
"844 US 42 N" under the street name "42", so a query normalized to the regional
form finds nothing.

The index now carries the route number as a separate key beside the full name,
and a route_number tier matches on it after the full name has found nothing.

Deliberately a separate key rather than a normalization of the name. Folding
the class away would merge roads that are genuinely different: Logan publishes
both CR 32 and TR 32, and fifteen other county-and-number pairs are likewise
two roads sharing a number. Running last means the looser key is consulted only
where the exact name failed, so those pairs still resolve by name, and where
the tier does find several roads the existing distance guard reports the
ambiguity rather than averaging across them.

CONST_GEOCODE_INDEX_VERSION goes to 2 so that existing indexes rebuild.

Against the 359 DODD, CMS and ODRC facility addresses used to validate
morpc/morpc-addresspoints-standardize#7, this takes matching from 320/359
(89.1%) to 324/359 (90.3%). The exact, components and number_name tiers are
unchanged at 277, 35 and 8, so nothing previously matched was displaced.

Refs morpc/morpc-addresspoints-standardize#7
@jinskeep-morpc
jinskeep-morpc merged commit fdd7dde into main Aug 4, 2026
1 check 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.

1 participant