--[==[
To inspect the content of this data module, use [[Special:ExpandTemplates]]
and enter the following input text:
  {{#invoke:Road data/dump|dump|module=Module:<name-of-this-module>}}

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"]`.
]==]

-- West Virginia
local WV = {}

local util = require("Module:Road data/util")
local format = mw.ustring.format
util.addAll(WV, require("Module:Road data/strings/USA"))

local suffix = " ([dab||%dab%, |]West Virginia)"
local maint = "[[West Virginia Division of Highways|WVDOH]]"

WV.I.maint = maint
WV.I.link = {
	["68"]	= "Interstate 68",
	["79"]	= "Interstate 79",
	["470"]	= "Interstate 470 (Ohio–West Virginia)",
	default = "Interstate %route% in West Virginia"
}

for k, v in pairs(WV) do if k:find ("^I") then 
	v.link = WV.I.link
	end
end

WV.US.link = {
	["35"] = "U.S. Route 35",
	["48"] = "U.S. Route 48",
	["119"] = "U.S. Route 119",
	["121"] = "U.S. Route 121",
	["340"] = "U.S. Route 340",
	["460"] = "U.S. Route 460",
	["522"] = "U.S. Route 522",
	default = "U.S. Route %route% in West Virginia"
}

for k, v in pairs(WV) do if k:find ("^US %d") then 
	v.link = WV.US.link
	end
end

for _,auxType in ipairs({"Alt", "Bus", "Byp", "City", "Conn", "Emerg", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
	local spec = WV[" aux "][auxType]
		for k, v in pairs(WV) do if k:find (auxType) then if k:find ("^US") then
			v.link = WV.US.base .. " " .. spec.name .. suffix
			v.banner = spec.banneralt .. " plate.svg"
			end
		end
	end
end

WV.WV = {
	base = "West Virginia Route %route%",
	shield = "WV-%route%.svg",
	name = "West Virginia Route %route%",
    link = "West Virginia Route %route%" .. WV[" dab "],
    abbr = "WV&nbsp;%route%",
    width = "expand"
}

for _,type in ipairs({"WV"}) do
	for _,year in ipairs({"1922", "1948"}) do
		WV["WV " .. year] = {
			shield = format("WV-%%route%% (%s).svg", year),
			name = WV.WV.name,
			link = WV.WV.link,
			abbr = WV.WV.abbr,
			width = "square"
		}
	end
end

for _,type in ipairs({'WV'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Spur", "Truck"}) do
		local spec = WV[" aux "][auxType]
		WV[type .. "-" .. auxType] = {
			shield = WV.WV.shield,
			name = WV.WV.name .. " " .. spec.name,
			link = WV.WV.base .. " " .. spec.name .. "[dab|| (%dab%)|]",
			abbr = WV.WV.abbr .. " " .. spec.abbrsuffix,
			banner = spec.banneralt .. " plate.svg",
			aux = spec.aux,
			width = WV.WV.width
		}
	end
end
         
WV["WV-Alt"] = {
	shield = WV.WV.shield,
	name = WV.WV.name .. " Alternate",
	link = "West Virginia Route %route% Alternate [dab||(%dab%)|]",
	abbr = "WV&nbsp;%route% Alt.",
	banner = "Alt plate.svg",
	width = "expand"
}

-- add new types above this line if you want it to have the state highway browse and maint
for k, v in pairs(WV) do if k:find ("^%a") then
	v.maint = "[[West Virginia Division of Highways|WVDOH]]"
	v.browse = "[[West Virginia State Highway System]]"
	v.browselinks = {
		[1] = "[[List of Interstate Highways in West Virginia|Interstate]]",
		[2] = "[[List of U.S. Highways in West Virginia|US]]",
		[3] = "[[List of state routes in West Virginia|State]]"
	}
	end
end

WV.WVTP = {
	shield = "",
	name = "West Virginia Turnpike",
	link = "West Virginia Turnpike",
	abbr = "West Virginia Turnpike",
	maint = "[[West Virginia Parkways Authority]]"
}

local CRFraction = '<span class="nowrap" style="display:inline-block; vertical-align:-0.5em; font-size:85%; text-align:center;"><span style="display:block; line-height:1em; padding:0 0.1em;">%route%</span><span style="display:block; line-height:1em; padding:0 0.1em; border-top:1px solid;">%denom%</span></span>'

WV.CR = {
	shield = {["507"] = "Ellipse sign 507.svg",
	["707"] = "Ellipse sign 707.svg",
	["857"] = "Ellipse sign 857.svg",
	default = "Circle sign %route%[denom||-%denom%|].svg"
	},
	link = {
		ifexists = true,
		default = "County Route %route% (%county% County, West Virginia)"
	},
	abbr = "CR&nbsp;[denom||" .. CRFraction .. "|%route%]",
	maint = "",
	browse = "[[List of county routes in West Virginia|County Routes in West Virginia]]",
	browselinks = ""
}

WV.FR.link = ""

WV.OH = {alias = {module = "USA/OH", type = "SR"}}
WV["US-VA"] = {alias = {module = "USA/VA", type = "US"}}

return WV