--[==[
To inspect the content of this data module, use Special:ExpandTemplates
and enter the following input text:  
To inspect the content of this data module when editing, enter the following
into the Debug console:
local util = require("Module:Road data/util")
print(util.arrayToString(p))
To inspect a particular route type, change `p` above to include the route type,
e.g., `p.I` and `p["US-Hist"]`.
]==]  
-- Texas
local TX = {}  
local util = require("Module:Road data/util")
local format = mw.ustring.format
util.addAll(TX, require("Module:Road data/strings/USA"))  
local suffix = " ([dab||%dab%, |]Texas)"
local suffix2 = " [dab||(%dab%)|]"  
-- Interstate types
TX.I.link = {
["2"] = "Interstate 2",
["14"] = "Interstate 14",
["27"] = "Interstate 27",
["30"] = "Interstate 30",
["35E"] = "Interstate 35E (Texas)",
["35W"] = "Interstate 35W (Texas)",
["37"] = "Interstate 37",
["45"] = "Interstate 45",
["69C"] = "Interstate 69C",
["69E"] = "Interstate 69E",
["69W"] = "Interstate 69W",
["410"] = "Interstate 410",
["820"] = "Interstate 820",
default = {
hook = "split",
split = 100,
above = "Interstate %route% (Texas)",
below = "Interstate %route% in Texas"
}
}
TX.IH = TX.I  
for _,auxType in ipairs({"Alt", "Express", "Future", "Local", "Spur", "Temp", "Toll", "Truck"}) do
local spec = TX[" aux "][auxType]
for k, v in pairs(TX) do if k:find (auxType) then if k:find ("^I-") then
v.link = "Interstate %route% " .. spec.name .. suffix
end
end
end
TX["I-Toll"].shield = "Toll Texas Interstate Highway %route%.svg"
TX["I-Express"].shield = "%route% Express Lane free.svg"
TX["I-Express"].banner = ""
TX["I-Future"].shield = TX.I.shield
TX["I-Future"].link = TX.I.link
TX["I-Future"].banner = "Future plate blue.svg"  
TX.BL.shieldmain = "Business Interstate %route% (TX).svg"
TX.BL.name = "Business " .. TX.I.name
TX.BL.link = "Interstate %route% Business" .. suffix  
for k, v in pairs(TX) do if k:find ("^B%a") then
v.shieldmain = TX.BL.shieldmain
v.name = TX.BL.name
v.link = TX.BL.link
end
end
TX["I-Bus"]=TX.BL
TX.BLBS.shieldmain = {TX.BL.shield, TX.BS.shield}  
-- US types
TX.US.name = "U.S. Highway %route%"
TX.US.link = "U.S. Route %route% in Texas"  
for k, v in pairs(TX) do if k:find ("^US %d") then
v.name = TX.US.name
v.link = TX.US.link
end
end  
for _,auxType in ipairs({"Alt", "Bus", "Byp", "City", "Conn", "Emerg", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
local spec = TX[" aux "][auxType]
for k, v in pairs(TX) do if k:find (auxType) then if k:find ("^US") then
v.shieldmain = TX.US.shield
v.name = spec.name .. " " .. TX.US.name
v.link = TX.US.base .. " " .. spec.name .. suffix
v.abbr = TX.US.abbr .. " " .. spec.abbrsuffix
end
end
end
end
TX.UA = TX["US-Alt"]
TX.BU = TX["US-Bus"]  
for _,year in ipairs({'1926', '1948', '1961'}) do
for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Truck"}) do
local type = "US " .. year
local spec = TX[" aux "][auxType]
TX[type .. "-" .. auxType] = {
shield = TX[type].shield,
shieldmain = TX[type].shieldmain,
name = spec.name .. " " .. TX[type].name,
link = TX[type].base .. " " .. spec.name .. suffix,
abbr = TX[type].abbr .. " " .. spec.abbrsuffix,
banner = spec.bannerprefix .. " plate " .. year .. ".svg",
aux = spec.aux,
}
end
end  
TX["US-Bus"] = {
shield = TX.US.shield,
name = "Business " .. TX.US.name,
link = "U.S. Route %route% Business" .. suffix,
abbr = "Bus. " .. TX.US.abbr,
banner = "Business plate.svg", -- see SHSD p. 3-7 https://ftp.dot.state.tx.us/pub/txdot-info/trf/shsd/2012/section3.pdf,
aux = TX[" aux "]
}
TX["Bus-US"] = TX["US-Bus"]  
TX["US-Alt-Bus"] = {
shield = TX.US.shield,
name = "Business " .. TX["US-Alt"].name,
link = "U.S. Route %route% Business Alternate" .. suffix,
abbr = "Bus. " .. TX["US-Alt"].abbr,
banner = "Business alternate plate.svg",,
aux = TX[" aux "].Alt
}  
-- SH (main) types
TX.SH = {
shield = "Texas %route%.svg",
shieldmain = {
["249"] = {"Texas %route%.svg", "Tomball Tollway.svg"},
default = "Texas %route%.svg"
},
base = "Texas State Highway %route%",
name = "State Highway %route%",
link = "Texas State Highway %route%" .. suffix2,
abbr = "SH&nbsp;%route%"
}
TX.TX = TX.SH  
for _,type in ipairs({"SH", "TX"}) do
for _,auxType in ipairs({"Alt", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Truck"}) do
local spec = TX[" aux "][auxType]
TX[type .. "-" .. auxType] = {
shield = TX.SH.shield,
name = spec.name .. " " .. TX.SH.name,
link = TX.SH.base .. " " .. spec.name .. suffix2,
abbr = TX.SH.abbr .. " " .. spec.abbrsuffix,
banner = spec.bannerprefix .. " plate.svg",
aux = spec.aux,
}
end
end  
TX["SH-Bus"] = {
shield = "Texas %route%.svg",
name = "Business&nbsp;" .. TX.SH.name,
link = "Texas State Highway %route% Business" .. suffix2,
abbr = "Bus.&nbsp;" .. TX.SH.abbr,
banner = "Business plate.svg",
aux = TX[" aux "],
}
TX["TX-Bus"] = TX["SH-Bus"]
TX["Bus-SH"] = TX["SH-Bus"]
TX["Bus-TX"] = TX["SH-Bus"]  
TX["SH-Bus 1969"] = {
shield = "Texas Business %route%.svg",
name = TX["SH-Bus"].name,
link = TX["SH-Bus"].link,
abbr = TX["SH-Bus"].abbr,
}
TX["TX-Bus 1969"] = TX["SH-Bus 1969"]  
for _,type in ipairs({"SH", "TX"}) do
for _,year in ipairs({"1917", "1935", "old"}) do
TX[type .. "-" .. year] = {
shield = format("Texas %%route%% %s.svg", year),
name = TX.SH.name,
link = TX.SH.link,
abbr = TX.SH.abbr,
}
end
end
end
TX["SH-old"].shield = "Old Texas %route%.svg"
TX["TX-old"].shield = TX["SH-old"].shield  
-- Loop/Spur types
TX.Beltway = {
shield = "Texas Beltway %route%.svg",
shieldmain = {
hook = "pagename",
article = "Texas State Highway Beltway 8",
iftrue = {"Texas Beltway %route%.svg", "Sam Houston Tollway.svg"},
default = "Texas Beltway %route%.svg"
},
name = "State Highway Beltway %route%",
link = "Texas State Highway Beltway %route%",
abbr = "Beltway&nbsp;%route%"
}
TX.BW = TX.Beltway  
TX.Loop = {
shield = "Texas Loop %route%.svg",
base = "Texas State Highway Loop %route%",
name = "State Highway Loop %route%",
link = {
default = "Texas State Highway Loop %route%" .. suffix2,
["1910"] = "Andrews Loop 1910"
},
abbr = "Loop&nbsp;%route%"}
TX.SL = TX.Loop  
TX.Spur = {
shield = "Texas Spur %route%.svg",
base = "Texas State Highway Spur %route%",
name = "State Highway Spur %route%",
link = "Texas State Highway Spur %route%" .. suffix2,
abbr = "Spur&nbsp;%route%"
}
TX.SS = TX.Spur  
-- FM/RM types
TX.FM = {
shield = "Texas FM %route%.svg",
name = "Farm to Market Road %route%",
base = "Farm to Market Road %route%",
link = "Farm to Market Road %route%",
abbr = "FM&nbsp;%route%"
}
TX.Farm = TX.FM  
TX.RM = {
shield = "Texas RM %route%.svg",
base = "Ranch to Market Road %route%",
name = "Ranch to Market Road %route%",
link = "Ranch to Market Road %route%",
abbr = "RM&nbsp;%route%"
}
TX.Ranch = TX.RM  
for _,type in ipairs({"FM", "RM"}) do
for _,year in ipairs({"1956"}) do
TX[type .. "-" .. year] = {
shield = format("Texas %s %%route%% (%s).svg", type, year),
name = TX[type].name,
link = TX[type].link,
abbr = TX[type].abbr,
}
end
end
TX["FM 1956"] = TX["FM-1956"]  
for _,type in ipairs({"FM", "RM"}) do
for _,auxType in ipairs({"Bus", "Loop", "Spur"}) do
local spec = TX[" aux "][auxType]
TX[type .. "-" .. auxType] = {
name = TX[type].name .. " " .. spec.name,
link = TX[type].base .. " " .. spec.name .. suffix2,
abbr = type .. " " .. spec.abbrsuffix .. " %route%",
aux = spec.aux,
}
end
end
TX["FM-Bus"].shield = "Texas Business FM %route%.svg"
TX["FM-Loop"].shield = TX.Loop.shield
TX["FM-Spur"].shield = TX.Spur.shield  
-- Misc SH types --
TX.Park = {
shield = "Texas Park Road %route%.svg",
link = "Texas Park Road %route%",
abbr = "PR&nbsp;%route%",
color = "hist"
}
TX.PR = TX.Park  
TX.NASA = {
shield = "Texas NASA Road %route%.svg",
name = "NASA Road %route%",
link = "NASA Road %route%",
abbr = "NASA&nbsp;%route%"
}  
TX.RR = {
shield = "Texas RM %route%.svg",
name = "Ranch Road %route%",
link = "Ranch Road %route%",
abbr = "RR&nbsp;%route%"
}  
TX.RE = {
shield = "Texas Recreational Road %route%.svg",
name = "Recreational Road %route%",