There are no reviewed versions of this page, so it may not have been checked for adherence to standards.

Documentation for this module may be created at Module:Highway shields/USA/doc

local p = {}

local shieldDefs = require "Module:Highway shields/defs"
local Country = shieldDefs.Country
local Shield = shieldDefs.Shield
local Type = shieldDefs.Type
local UniqueType = shieldDefs.UniqueType
local Alias = shieldDefs.Alias
local ShieldPreprocessors = shieldDefs.ShieldPreprocessors

do
    local statesModule = require "Module:U.S. States"
    local mapping = statesModule.stateAbbrToName
    function ShieldPreprocessors.stateName(args)
        args.stateName = mapping[args.state]
    end
end

local shields = Country:new()

do -- Definitions
    -- BEGIN: Function definitions
    
    local function stateRoute(state, shield, types)
        local stateType = shields:uniqueType(state)
        stateType:update{state = state, shield = shield}
        for i,typeStr in ipairs(types) do
            shields:type(typeStr):addShield(state, shield)
        end
    end
    
    -- END: Function definitions
    -- BEGIN: Type definitions
    
    do -- Interstates
        local type = Type:new{formatStr = "I-%s.svg"}
        shields:addType("I", type)
        shields:addType("Interstate", type)
        
        local function defStates(states)
            for i,state in ipairs(states) do
                type:addShield(state, Shield:new{formatStr = string.format("I-%s (%s).svg", "%s", state)})
            end
        end
        local defaultStateSpecific = {"AL", "AZ", "CA", "IA", "KS", "MO", "NV", "NM", "OK", "SC", "WV"}
        defStates(defaultStateSpecific)
        
        type:addShield("AR", Shield:new{formatStr = "I-%s (AR) Metric.svg"}) -- Arkansas
        type:addShield("HI", Shield:new{formatStr = "I-H%s.svg"}) -- Hawaii
        type:addShield("PR", Shield:new{formatStr = "I-PR%s.svg"}) -- Puerto Rico
        
        do -- New York
            local exceptions = {["90N"] = "I-90N.svg"}
            local by100 = {["less"] = "I-%s.svg", ["more"] = "I-%s (long).svg"}
            type:addShield("NY", Shield:new{exceptions = exceptions, by100 = by100})
        end -- New York
        
        do -- Big shield
            local big = Shield:new{formatStr = "I-%s (big).svg"}
            type:addShield("MT", big) -- Montana
            type:addShield("OR", big) -- Oregon
            type:addShield("UT", big) -- Utah
            type:addShield("WA", big) -- Washington
        end -- Big shield
    end -- Interstates
    
    do -- 1957 Interstates
        local type = Type:new{formatStr = "I-%s (%s 1957).svg", formatArgs = {"route", "state"}}
        shields:addType("I 1957", type)
        local by100 = {["less"] = "I-%s (%s).svg", ["more"] = "I-%s (%s 1957).svg"}
        local shieldCA = Shield:new{exceptions = {["80N"] = "I-80N (CA 1957).svg"}, by100 = by100, formatArgs = {"route", "state"}}
        local shieldIA = Shield:new{exceptions = {["80N"] = "I-80N (IA 1957).svg"}, by100 = by100, formatArgs = {"route", "state"}}
        type:addShield("CA", shieldCA) -- California
        type:addShield("IA", shieldIA) -- Iowa
    end -- 1957 Interstates
    
    shields:addType("Future", Shield:new{formatStr = "I-%s (Future).svg"}) -- Future Interstates
    
    do -- Business Loops
        local exceptions = {["496"] = "CapitolLoop.svg"}
        shields:addType("BL", Shield:new{formatStr = "Business Loop %s.svg", exceptions = exceptions})
    end -- Business Loops
    
    shields:addType("BS", Shield:new{formatStr = "Business Spur %s.svg"}) -- Business Spurs
    shields:addType("BL 1957", Shield:new{formatStr = "Business Loop %s (1957).svg"}) -- 1957 Business Loops
    shields:addType("BS 1957", Shield:new{formatStr = "Business Spur %s (1957).svg"}) -- 1957 Business Spurs
    
    do -- U.S. Routes
        local typeExceptions = {["141"] = "US 141 (WI).svg", ["151"] = "US 151 (WI).svg", ["218"] = "US 218 (IA).svg"}
        local type = Type:new{formatStr = "US %s.svg", exceptions = typeExceptions}
        shields:addType("US", type)
        
        do -- Arkansas
            local subtypes = {["Bus"] = "US %sB.svg", ["Conn"] = "US %sY.svg", ["Spr"] = "US %sS.svg",
                              ["Spur"] = "US %sS.svg", ["Trk"] = "US %sT.svg", ["Truck"] = "US %sT.svg"}
            local by100 = {["less"] = "US %s (1961).svg", ["more"] = "US %s (AR).svg"}
            type:addShield("AR", Shield:new{subtypes = subtypes, by100 = by100})
        end -- Arkansas
        
        type:addShield("CA", Shield:new{formatStr = "US %s (CA).svg"}) -- California
        type:addShield("IA", Shield:new{formatStr = "US %s (IA).svg"}) -- Iowa
        
        do -- Connecticut
            local exceptions = {["1A"] = "US 1A.svg", ["6A"] = "US 6A.svg"}
            local by100 = {["less"] = "US %s.svg", ["more"] = "US %s (NH).svg"}
            type:addShield("CT", Shield:new{exceptions = exceptions, by100 = by100})
        end -- Connecticut
        
        do -- Maryland
            local subtypes = {["Bus"] = "US %s Business (MD).svg"}
            type:addShield("MD", Shield:new{subtypes = subtypes})
        end -- Maryland
        
        do -- New Hampshire
            local subtypes = {["Byp"] = "US %s Bypass.svg"}
            type:addShield("NH", Shield:new{by100 = {["more"] = "US %s (NH).svg", ["less"] = "US %s.svg"}, subtypes = subtypes})
        end -- New Hampshire
        
        do -- New Jersey
            local exceptions = {["1/9"] = "US 1-9.svg"}
            type:addShield("NJ", Shield:new{exceptions = exceptions})
        end -- New Jersey
        
        do -- Oklahoma
            local subtypes = {["Scenic"] = "Scenic US %s.svg"}
            type:addShield("OK", Shield:new{subtypes = subtypes})
        end -- Oklahoma
        
        type:addShield("MN", Shield:new{by100 = {["more"] = "US %s (MN).svg", ["less"] = "US %s.svg"}}) -- Minnesota
        type:addShield("WI", Shield:new{by100 = {["more"] = "US %s (WI).svg", ["less"] = "US %s.svg"}}) -- Wisconsin
        
        do -- Aliases
            shields:addType("US-Alt", Alias:new{type = type, subtype = "Alt"})
            shields:addType("US-Bus", Alias:new{type = type, subtype = "Bus"})
            shields:addType("US-Byp", Alias:new{type = type, subtype = "Byp"})
            shields:addType("US-Conn", Alias:new{type = type, subtype = "Conn"})
            shields:addType("US-Scenic", Alias:new{type = type, subtype = "Scenic"})
            shields:addType("US-Spur", Alias:new{type = type, subtype = "Spur"})
            shields:addType("US-Truck", Alias:new{type = type, subtype = "Truck"})
        end -- Aliases
    end -- U.S. Routes
    
    do -- Historic U.S. Routes
        local stateName = ShieldPreprocessors.stateName
        shields:addType("US 1926", Shield:new{formatStr = "US %s %s 1926.svg", formatArgs = {"route", "stateName"}, preprocessors = {stateName}}) -- 1926 U.S. Routes
        shields:addType("US 1948", Shield:new{formatStr = "US %s %s 1948.svg", formatArgs = {"route", "stateName"}, preprocessors = {stateName}}) -- 1948 U.S. Routes
        
        do -- 1950 U.S. Routes
            local type = Type:new{formatStr = "US %s %s 1950.svg", formatArgs = {"route", "stateName"}, preprocessors = {stateName}}
            shields:addType("US 1950", type)
            local NCAltShield = "US %sA North Carolina 1950.svg"
            local subtypes = {["Alt"] = NCAltShield, ["Alternate"] = NCAltShield}
            type:addShield("NC", Shield:new{subtypes = subtypes})
        end -- 1950 U.S. Routes
        
        shields:addType("US 1961", Shield:new{formatStr = "US %s 1961.svg"}) -- 1961 U.S. Routes
    end -- Historic U.S. Routes
    
    do -- State Routes
        do -- Alabama
            local shield = Shield:new{formatStr = "Alabama %s.svg"}
            stateRoute("AL", shield, {"SR"})
        end -- Alabama
        
        do -- Alaska
            local shield = Shield:new{formatStr = "Alaska %s shield.svg"}
            stateRoute("AK", shield, {})
        end -- Alaska
        
        do -- Arizona
            local exceptions = {["101"] = "Arizona Loop 101.svg", ["202"] = "Arizona Loop 202.svg", ["303"] = "Arizona Loop 303.svg"}
            local shield = Shield:new{formatStr = "Arizona %s.svg", exceptions = exceptions}
            local types = {"SR", "Loop"}
            stateRoute("AZ", shield, types)
            shields:type("SR-Spur"):addShield("AZ", Shield:new{formatStr = "Arizona %sS.svg"})
            shields:type("US-Hist"):addShield("AZ", Shield:new{formatStr = "US %s (historic).svg"})
        end -- Arizona
        
        do -- Arkansas
            local exceptions = {["917"] = "Arkansas 917-1.svg", ["980"] = "Arkansas 980(Airport).svg"}
            local subtypes = {["Bus"] = "Arkansas %sB.svg", ["Spur"] = "Arkansas %sS.svg", ["Truck"] = "Arkansas %sT.svg"}
            local shield = Shield:new{formatStr = "Arkansas %s.svg", exceptions = exceptions, subtypes = subtypes}
            stateRoute("AR", shield, {"Hwy"})
            shields:type("Hwy-Bus"):addShield("AR", Alias:new{type = shield, subtype="Bus"})
            shields:uniqueType("GRR"):update{state = "AR"}
        end -- Arkansas
        
        do -- California
            local shield = Shield:new{formatStr = "California %s.svg"}
            stateRoute("CA", shield, {"SR"})
        end -- California
        
        do -- Colorado
            local shield = Shield:new{formatStr = "Colorado %s.svg"}
            stateRoute("CO", shield, {"SH"})
            shields:type("E"):addShield("CO", Shield:new{formatStr = "E%s.svg"})
        end -- Colorado
        
        do -- Connecticut
            local shield = Shield:new{formatStr = "Connecticut Highway %s.svg"}
            stateRoute("CT", shield, {"Route"})
            do -- Connecticut Turnpike
                local shield = Shield:new{formatStr = "Conn Tpk.gif", formatArgs = {}}
                shields:type("Turnpike"):addShield("CT", shield)
                shields:uniqueType("CTTP"):update{state = "CT", shield = shield}
            end -- Connecticut Turnpike
            do -- Merritt Parkway
                local shield = Shield:new{formatStr = "Merritt Pkwy Shield.svg", formatArgs = {}}
                shields:uniqueType("Merritt"):update{state = "CT", shield = shield}
            end -- Merritt Parkway
        end -- Connecticut
        
        do -- Delaware
            local shield = Shield:new{formatStr = "Elongated circle %s.svg"}
            stateRoute("DE", shield, {"SR"})
            do -- Bannered routes
                shields:type("SR-Alt"):addShield("DE", shield)
                shields:type("SR-Bus"):addShield("DE", shield)
                shields:type("SR-Truck"):addShield("DE", shield)
                local stateType = shields:uniqueType("DE")
                shields:addType("DE-Alt", stateType)
                shields:addType("DE-Bus", stateType)
                shields:addType("DE-Truck", stateType)
            end -- Bannered routes
            do -- Delaware Turnpike
                local shield = Shield:new{formatStr = "Delaware Turnpike logo.gif", formatArgs = {}}
                shields:type("Turnpike"):addShield("DE", shield)
                shields:uniqueType("DETP"):update{state = "DE", shield = shield}
            end -- Delaware Turnpike
            do -- New Jersey Turnpike
                shields:uniqueType("NJTP"):update{state = "DE"}
            end -- New Jersey Turnpike
        end -- Delaware
        
        do -- District of Columbia
            local shield = Shield:new{formatStr = "DC-%s.svg"}
            stateRoute("DC", shield, {})
        end -- District of Columbia
        
        do -- Florida
            local shield = Shield:new{formatStr = "Florida %s.svg"}
            stateRoute("FL", shield, {"SR"})
            do -- Bannered routes
                shields:type("SR-Bus"):addShield("FL", shield)
                shields:type("SR-Spur"):addShield("FL", shield)
                shields:type("SR-Truck"):addShield("FL", shield)
            end -- Bannered routes
            do -- Florida's Turnpike
                local shield = Shield:new{formatStr = "Florida's Turnpike shield.png", formatArgs = {}}
                shields:type("Turnpike"):addShield("FL", shield)
                shields:uniqueType("FLTP"):update{state = "FL", shield = shield}
                shields:uniqueType("HEFT"):update{state = "FL", shield = shield}
            end -- Florida's Turnpike
            do -- Toll roads
                local shield = Shield:new{formatStr = "Toll Florida %s.svg"}
                shields:type("Toll"):addShield("FL", shield)
            end -- Toll roads
        end -- Florida
        
        do -- Georgia
            local subtypes = {["Alt"] = "Georgia %s Alternate.svg", ["Bus"] = "Georgia %s Business.svg", ["Byp"] = "Georgia %s Bypass.svg",
                              ["Conn"] = "Georgia %s Connector.svg", ["Loop"] = "Georgia %s Loop.svg", ["Spur"] = "Georgia %s Spur.svg"}
            local shield = Shield:new{formatStr = "Georgia %s.svg", subtypes = subtypes}
            stateRoute("GA", shield, {"SH", "SR", "Route"})
            do -- Bannered routes
                do -- Alternate
                    local alias = Alias:new{type = shield, subtype = "Alt"}
                    shields:type("SR-Alt"):addShield("GA", alias)
                    shields:uniqueType("GA-Alt"):update{state = "GA", shield = alias}
                end -- Alternate
                shields:type("SR-Bus"):addShield("GA", Alias:new{type = shield, subtype="Bus"})
                do -- Bypass
                    local alias = Alias:new{type = shield, subtype = "Byp"}
                    shields:type("SR-Byp"):addShield("GA", alias)
                    shields:uniqueType("GA-Byp"):update{state = "GA", shield = alias}
                end -- Bypass
                do -- Connector
                    local alias = Alias:new{type = shield, subtype = "Conn"}
                    shields:type("SR-Conn"):addShield("GA", alias)
                    shields:uniqueType("GA-Conn"):update{state = "GA", shield = alias}
                end -- Connector
                shields:type("SR-Loop"):addShield("GA", Alias:new{type = shield, subtype="Loop"})
                do -- Spur
                    local alias = Alias:new{type = shield, subtype = "Spur"}
                    shields:type("SR-Spur"):addShield("GA", alias)
                    shields:uniqueType("GA-Spur"):update{state = "GA", shield = alias}
                end -- Spur
            end -- Bannered routes
        end -- Georgia
        
        do -- Hawaii
            local shield = Shield:new{formatStr = "HI-%s.svg"}
            stateRoute("HI", shield, {"Route"})
        end -- Hawaii
        
        do -- Idaho
            local subtypes = {["Scenic"] = "ID-Scenic-%s.svg"}
            local shield = Shield:new{formatStr = "ID-%s.svg", subtypes = subtypes}
            stateRoute("ID", shield, {"SH"})
            do -- Bannered routes
                shields:type("SH-Bus"):addShield("ID", shield)
                shields:type("SH-Conn"):addShield("ID", shield)
                shields:type("SH-Spur"):addShield("ID", shield)
                local stateType = shields:uniqueType("ID")
                shields:addType("ID-Bus", stateType)
                shields:addType("ID-Conn", stateType)
            end -- Bannered routes
            do -- Washington State Routes
                shields:uniqueType("WA"):update{state = "ID"}
            end -- Washington State Routes
        end -- Idaho
        
        do -- Illinois
            local shield = Shield:new{formatStr = "Illinois %s.svg"}
            stateRoute("IL", shield, {})
            do -- Elgin–O'Hare Expressway
                local shield = Shield:new{formatStr = "Illinois Elgin–O'Hare Expressway.svg", formatArgs = {}}
                shields:uniqueType("E-OH"):update{state = "IL", shield = shield}
            end -- Elgin–O'Hare Expressway
            do -- Great River Road
                shields:uniqueType("GRR"):update{state = "IL"}
                shields:uniqueType("GRR-Spur"):update{state = "IL"}
            end -- Great River Road
            do -- Chicago Skyway
                local shield = Shield:new{formatStr = "Chicago Skyway logo.svg", formatArgs = {}}
                shields:uniqueType("Skyway"):update{state = "IL", shield = shield}
            end -- Chicago Skyway
            do -- Indiana Toll Road
                local type = shields:type("Toll")
                local alias = Alias:new{type = type, state = "IN"}
                type:addShield("IL", alias)
            end -- Indiana Toll Road
            shields:type("US-Hist"):addShield("IL", Shield:new{formatStr = "US %s (IL historic).svg"})
            shields:uniqueType("Lincoln"):update{state = "IL"}
        end -- Illinois
        
        do -- Indiana
            local shield = Shield:new{formatStr = "Indiana %s.svg"}
            stateRoute("IN", shield, {"SR"})
            do -- Auto trails
                shields:uniqueType("Dixie"):update{state = "IN"}
                shields:uniqueType("Lincoln"):update{state = "IN"}
                shields:uniqueType("National"):update{state = "IN"}
            end -- Auto trails
            do -- Indiana Toll Road
                local shield = Shield:new{formatStr = "Indiana Toll Road logo 1968.svg", formatArgs = {}}
                shields:type("Toll"):addShield("IN", shield)
            end -- Indiana Toll Road
        end -- Indiana
        
        do -- Iowa
            local shield = Shield:new{formatStr = "Iowa %s.svg"}
            stateRoute("IA", shield, {})
            local stateType = shields:uniqueType("IA")
            shields:addType("IA-Bus", stateType)
            shields:uniqueType("GRR"):update{state = "IA"}
        end -- Iowa
        
        -- Gap
        
        do -- Michigan (incomplete)
            do -- Capitol Loop alias
                local alias = Alias:new{type = shields["BL"], route = "496"}
                shields:uniqueType("Capitol Loop"):update{state = "MI", shield = alias}
            end -- Capitol Loop alias
        end -- Michigan (incomplete)
        
        -- Gap
        
        do -- Montana
            local shield = Shield:new{formatStr = "MT-%s.svg"}
            stateRoute("MT", shield, {})
            do -- Secondary
                local shield = Shield:new{formatStr = "MT-sec-%s.svg"}
                shields:type("Sec"):addShield("MT", shield)
            end -- Secondary
        end -- Montana
        
        -- Gap
        
        do -- Nevada
            local shield = Shield:new{formatStr = "Nevada %s.svg"}
            stateRoute("NV", shield, {"SR"})
            do -- Clark County
                local shield = Shield:new{formatStr = "Clark County Route %s NV.svg"}
                shields:uniqueType("CC"):update{state = "NV", shield = shield}
            end -- Clark County
            do -- California State Routes
                shields:uniqueType("CA"):update{state = "NV"}
            end -- California State Routes
        end -- Nevada
        
        -- Gap
        
        do -- New Jersey (incomplete)
            do -- New Jersey Turnpike
                local shield = Shield:new{formatStr = "New Jersey Turnpike Shield.svg", formatArgs = {}}
                shields:type("Turnpike"):addShield("NJ", shield)
                shields:uniqueType("NJTP"):update{state = "NJ", shield = shield}
            end -- New Jersey Turnpike
        end -- New Jersey (incomplete)
        
        -- Gap
        
        do -- Washington (incomplete)
            local shield = Shield:new{formatStr = "WA-%s.svg"}
            stateRoute("WA", shield, {"SR"})
        end -- Washington (incomplete)
        
        -- Gap
        
        do -- Territories
            do -- American Samoa
                local shield = Shield:new{formatStr = "American Samoa Highway %s.svg"}
                stateRoute("AS", shield, {})
            end -- American Samoa
            
            do -- Guam
                local shield = Shield:new{formatStr = "Guam route marker %s.svg"}
                stateRoute("GU", shield, {})
            end -- Guam
            
            -- Gap
        end -- Territories
        
    end -- State Routes
    
    do -- Historic types
        shields:uniqueType("AR 1926"):update{state = "AR", shield = Shield:new{formatStr = "Arkansas %s 1926.svg"}} -- 1926 Arkansas Highways
        shields:uniqueType("IA 1926"):update{state = "IA", shield = Shield:new{formatStr = "Iowa %s 1926.svg"}} -- 1926 Iowa Highways
        shields:uniqueType("IN 1940"):update{state = "IN", shield = Shield:new{formatStr = "Indiana %s (1940).svg"}} -- 1940 Indiana State Roads
    end -- Historic types
    
    do -- Special types
        do -- Dixie Highway
            local shield = Shield:new{formatStr = "Dixie Highway marker.svg", formatArgs = {}}
            shields:uniqueType("Dixie"):update{shield = shield}
        end -- Dixie Highway
        
        do -- Forest Highways
            local shield = Shield:new{formatStr = "Forest Route %s.svg"}
            shields:addType("FR", shield)
            shields:addType("FH", shield)
            shields:addType("FFH", shield)
        end -- Forest Highways
        
        do -- Great River Road
            local shield = Shield:new{formatStr = "GreatRiverRoad.svg", formatArgs = {}}
            shields:uniqueType("GRR"):update{shield = shield}
            local spurShield = Shield:new{formatStr = "GreatRiverRoad brown.svg", formatArgs = {}}
            shields:uniqueType("GRR-Spur"):update{shield = spurShield}
        end -- Great River Road
        
        do -- Lincoln Highway
            local shield = Shield:new{formatStr = "LincolnHighwayMarker.svg", formatArgs = {}}
            shields:uniqueType("Lincoln"):update{shield = shield}
        end -- Lincoln Highway
        
        do -- National Old Trails Road
            local shield = Shield:new{formatStr = "National Old Trails Road marker.svg", formatArgs = {}}
            shields:uniqueType("National"):update{shield = shield}
        end -- National Old Trails Road
        
    end -- Special types
    
    -- END: Type definitions
end -- Definitions

p.shields = shields
return p