Module:Infobox road/abbrev/USA
Documentation for this module may be created at Module:Infobox road/abbrev/USA/doc
local p = {} local format = mw.ustring.format local typesModule = require "Module:Infobox road/abbrev/defs" Country = typesModule.Country Type = typesModule.Type Abbr = typesModule.Abbr local abbrs = Country:new() do -- Abbreviation definitions function abbrs:typeOverride(args) local type = args.type local state = args.state if not(state) then return end local stateVarTypes = {"%s", "%s-old", "%s 1926", "%s 1940", "%s 1948", "%s 1950", "%s 1955"} local typesToCheck = {} for i,v in ipairs(stateVarTypes) do local type = format(v, state) typesToCheck[type] = true end if typesToCheck[type] then return self["SR"] else return nil end end do -- Interstates local type = Type:new{formatStr = "I-%s"} abbrs["I"] = type abbrs["Interstate"] = type abbrs["I 1957"] = type type["HI"] = Abbr:new{formatStr = "H-%s"} type["PR"] = Abbr:new{formatStr = "PRI-%s"} end -- Interstates abbrs["Future"] = Abbr:new{formatStr = "Future I-%s"} -- Future Interstates do -- U.S. Routes local type = Type:new{formatStr = "US %s"} abbrs["US"] = type abbrs["US 1926"] = type abbrs["US 1948"] = type abbrs["US 1950"] = type do -- US-x local states = {"AL", "ID", "KS", "OK", "TN", "UT"} local abbr = Abbr:new{formatStr = "US-%s"} for i,v in ipairs(states) do type[v] = abbr end end -- US-x end -- U.S. Routes abbrs["USBR"] = Type:new{formatStr = "USBR %s"} -- U.S. Bicycle Routes abbrs["NER"] = Abbr:new{formatStr = "Route %s"} -- New England Routes do -- State highways local type = Type:new{formatStr = "%s %s", formatArgs = {"state", "route"}} do local types = {"SH", "SR", "Route", "M", "K", "U", "SH-old", "SR-old", "Route-old", "DE 1964", "LA 1990", "M-old", "M 1919", "M 1926", "M 1948", "NJ 1956", "NY 1927", "NY 1960", "NC 1945", "NC 1957", "SC 1971", "Town"} for i,v in ipairs(types) do abbrs[v] = type end end do -- SR-x local abbr = Abbr:new{formatStr = "SR-%s"} type["AL"] = abbr end -- SR-x do -- SR x local abbr = Abbr:new{formatStr = "SR %s"} local states = {"AZ", "CA", "FL", "GA", "IN", "ME", "NV", "OH", "TN", "VA", "WA"} for i,v in ipairs(states) do type[v] = abbr end end -- SR x do -- SH x local abbr = Abbr:new{formatStr = "SH %s"} type["CO"] = abbr type["TX"] = abbr end -- SH x do -- SH-x local abbr = Abbr:new{formatStr = "SH-%s"} type["ID"] = abbr type["OK"] = abbr end -- SH-x do -- Route x local abbr = Abbr:new{formatStr = "Route %s"} local states = {"CT", "HI", "MA", "MO", "NJ", "RI"} for i,v in ipairs(states) do type[v] = abbr end end -- Route x do -- <State>-x local abbr = Abbr:new{formatStr = "%s-%s", formatArgs = {"state", "route"}} type["AK"] = abbr type["PR"] = abbr end -- <State>-x do -- New York local function dabStr(args) local dab = args.dab if dab and #dab > 0 then args.dabStr = format(" (%s)", dab) else args.dabStr = "" end end type["NY"] = Abbr:new{formatStr = "NY %s%s", formatArgs = {"route", "dabStr"}, preprocessors = {dabStr}} end -- New York type["VI"] = Abbr:new{formatStr = "Highway %s"} -- Virgin Islands type["AR"] = Abbr:new{formatStr = "Hwy. %s"} -- Arkansas type["GU"] = Abbr:new{formatStr = "GH-%s"} -- Guam type["IA"] = Abbr:new{formatStr = "Iowa %s"} -- Iowa type["KS"] = Abbr:new{formatStr = "K-%s"} -- Kansas type["MI"] = Abbr:new{formatStr = "M-%s"} -- Michigan type["NE"] = Abbr:new{formatStr = "N-%s"} -- Nebraska type["WI"] = Abbr:new{formatStr = "WIS %s"} -- Wisconsin type["WY"] = Abbr:new{formatStr = "WYO %s"} -- Wyoming type["UT"] = Abbr:new{formatStr = "SR-%s", exceptions = {["281-320"] = "SR-281 to SR-320"}} -- Utah end -- State highways do -- Former routes local type = Abbr:new{formatStr = "ex-SR %s"} abbrs["Former"] = type abbrs["Former Toll"] = type end -- Former routes do -- Secondary routes local type = Type:new{formatStr = "SR %s"} abbrs["Sec"] = type abbrs["Secondary"] = type local abbr = Abbr:new{formatStr = "SR-%s"} type["MT"] = abbr type["TN"] = abbr end -- Secondary routes do -- County routes local type = Type:new{formatStr = "CR %s"} abbrs["CR"] = type type["LA"] = Abbr:new{formatStr = "PR %s"} local abbr = Abbr:new{formatStr = "CR-%s"} type["AL"] = abbr type["ID"] = abbr end -- County routes abbrs["CDH"] = Abbr:new{formatStr = "%s"} -- County Designated Highways (Michigan) abbrs["E"] = Abbr:new{formatStr = "E-%s"} -- E-470 (Colorado) do -- Forest Highways local type = Type:new{formatStr = "FH %s"} abbrs["FR"] = type abbrs["FH"] = type abbrs["FFH"] = type type["CA"] = Abbr:new{formatStr = "F.H. %s"} type["MI"] = Abbr:new{formatStr = "FFH %s"} end -- Forest Highways do -- Toll roads local type = Type:new() abbrs["Toll"] = type type["FL"] = Abbr:new{formatStr = "SR %s"} type["PA"] = Abbr:new{formatStr = "PA %s"} do -- Texas local exceptions = {["1"] = "Loop 1", ["183A"] = "183A"} type["TX"] = Abbr:new{formatStr = "SH %s", exceptions = exceptions} end -- Texas end -- Toll roads abbrs["LA 1924"] = Abbr:new{formatStr = "SR %s"} -- 1924 Louisiana State Routes do -- Farm to Market Roads local abbr = Abbr:new{formatStr = "FM %s"} abbrs["FM"] = abbr abbrs["Farm"] = abbr end -- Farm to Market Roads abbrs["Link"] = Abbr:new{formatStr = "L-%s"} -- Nebraska Links abbrs["Loop"] = Abbr:new{formatStr = "Loop %s"} -- Loops abbrs["PSH"] = Abbr:new{formatStr = "PSH %s"} -- Primary State Highways (Washington) abbrs["SSH"] = Abbr:new{formatStr = "SSH %s"} -- Secondary State Highways (Washington) abbrs["Park"] = Abbr:new{formatStr = "PR %s"} -- Park Roads do -- Parkways local abbr = Abbr:new{formatStr = "%s Parkway"} abbrs["Pkwy"] = abbr abbrs["Parkway"] = abbr end -- Parkways do -- Ranch to Market Roads local abbr = Abbr:new{formatStr = "RM %s"} abbrs["RM"] = abbr abbrs["Ranch"] = abbr end -- Ranch to Market Roads do -- Recreational Roads local type = Type:new{formatStr = "RE %s"} abbrs["Rec"] = type abbrs["RE"] = type type["NE"] = Abbr:new{formatStr = "R-%s"} end -- Recreational Roads do -- Spurs local type = Type:new{formatStr = "Spur %s"} abbrs["Spur"] = type type["NE"] = Abbr:new{formatStr = "S-%s"} end -- Spurs end p.abbrs = abbrs return p