Module:Infobox road/browselinks

local p = {} local getArgs = require('Module:Arguments').getArgs local util = require("Module:Road data/util") local yesno = require('Module:Yesno') local routeModule = require("Module:Infobox road/route") local parserModule = require("Module:Road data/parser") local parser = parserModule.parser local format = mw.ustring.format local frame = mw.getCurrentFrame

local function country(args) local state = args.state or args.province local country local countryModule = mw.loadData("Module:Road data/countrymask") local country = args.country or countryModule[state] return country end

local function the(args) if country(args) == "ALA" or country(args) == "BHS" or country(args) == "CAF" or country(args) == "COG" or country(args) == "COD" or country(args) == "COM" or country(args) == "CZE" or country(args) == "DOM" or country(args) == "FSM" or country(args) == "GMB" or country(args) == "IMN" or country(args) == "MDV" or country(args) == "MHL" or country(args) == "NLD" or country(args) == "PHL" or country(args) == "SLB" or country(args) == "ARE" or country(args) == "GBR" or country(args) == "USA" then return 'the' else return '' end end

local function africa(args) return "*Trans-African Highway network" end

local function asia(args) return "*Asian Highway Network" end

local function europe(args) if args.type == "Pan" then return "*Pan-European corridors" else return "*International E-road network\n\n*A Class\n*B Class" end end

local function browselinks(args) local ISO = require('Module:ISO 3166') local name = ISO.name({country(args)}) if country(args) == '' or country(args) == 'YUG' or country(args) == nil then return nil elseif country(args) == 'ASIA' then return asia(args) elseif country(args) == 'EUR' then return europe(args) elseif country(args) == 'TAH' then return africa(args) elseif country(args) == 'ARE' then return string.format("*Transport in %s %s\n\n*Roads in Dubai", the(args), name) elseif country(args) == 'AUS' then local state = args.state or '' local stateName = ISO.name({"AUS-" .. state}) local links = "*Highways in Australia\n\n*National Highway\n*Freeways in Australia" if state == 'ACT' then return links .. "\n\nRoad infrastructure in Canberra" elseif state == 'NSW' then return links .. "\n\nHighways in New South Wales" elseif state ~= '' then return string.format("%s \n\nHighways in %s", links, stateName, stateName) else return links end elseif country(args) == 'AUT' then return "*Highways of Austria\n\n*Autobahns\n*Expressways\n*State Roads" elseif country(args) == 'BEL' then return "*Highways of Belgium\n\n*Motorways\n*National Roads" elseif country(args) == 'BRA' then local state = args.state or '' local stateName = ISO.name({"BRA-" .. state}) local links = "*Highways in Brazil" if state == 'RS' or state == 'SP' then return string.format("%s \n\n*%s State Highways", links, stateName, stateName) else return links end elseif country(args) == 'BRN' then return "*Brunei National Roads System" elseif country(args) == 'CAN' then local province = args.province or '' local stateName = ISO.name({"CAN-" .. province}) local TCH if args.type == 'TCH' and province == '' then TCH = "*Trans-Canada Highway\n\n*National Highway System" elseif args.type == 'TCH' and province ~= '' then TCH = "*Trans-Canada Highway" else TCH = '' end local provinces if province == '' then provinces = '' elseif province == 'NT' then provinces = "Northwest Territories highways" elseif province == 'YT' or province == 'YK' then provinces = "Territorial highways in Yukon" elseif province == 'NU' then provinces = "Highways in Nunavut" elseif province == 'BC' then provinces = "British Columbia provincial highways" elseif province == 'NL' then provinces = "Highways in Newfoundland and Labrador" elseif province == 'QC' then provinces = "Quebec provincial highways" elseif province == 'ON' then if args.type == 'Fwy' or args.type == 'Hwy' or args.type == 'ON' or args.type == 'ON 1960' or args.type == 'Secondary' or args.type == 'Sec' or args.type == 'TCH' then provinces = "Ontario provincial highways" elseif args.type == 'CR' or args.type == 'DR' or args.type == 'MR' or args.type == 'RR' then provinces = "County roads in Ontario" elseif args.type == 'Parkway' then provinces = "Parkways of the Great Lakes" elseif args.type == 'Toronto' then provinces = "Roads in Toronto" else provinces = "Roads in Ontario" end else provinces = string.format("Provincial highways in %s", stateName, stateName) end local second if province == 'YT' or province == 'YK' then second = "Miscellaneous" elseif province == 'MB' then second = "Winnipeg City Routes" elseif province == 'NB' then second = "Former routes" elseif province == 'NS' then second = "100-series" elseif province == 'QC' then second = "Autoroutes\n*List\n*Former" elseif province == 'ON' then if args.type == 'Fwy' or args.type == 'Hwy' or args.type == 'ON' or args.type == 'ON 1960' or args.type == 'Secondary' or args.type == 'Sec' or args.type == 'TCH' then second = "Current\n*Former\n*400-series" elseif args.type == 'Parkway' then second = "Long Sault\n*Niagara\n*St. Clair\n*1000 Islands\n\n*Roads in Ontario" elseif args.type == 'Toronto' then second = "North–South\n*East–West\n*Diagonal" else second = '' end else second = '' end return string.format("%s\n\n*%s\n\n*%s", TCH, provinces, second)

elseif country(args) == 'CHE' then return "*Transport in Switzerland\n\n*Motorways" elseif country(args) == 'CHN' then local province = args.province or '' local stateName = ISO.name({"CHN-" .. province}) local links if args.type == "Ex" or args.type == "Expwy" then links = "*National Trunk Highway System\n\n*Primary\n*Auxiliary\n\n*National Highways\n*Transport in China" elseif args.type == "G" then links = "*China National Highways\n\n*National Trunk Highway System" else links = "*Transport in China" end if province == 'BJ' or province == 'SH' or province == 'JS' or province == 'ZJ' or province == 'HA' or province == 'GD' then return string.format("%s \n\n*Expressways of %s", links, stateName) else return links end elseif country(args) == 'CRI' then return "*National Road Network of Costa Rica" elseif country(args) == 'CYP' then return "*Motorways and roads in Cyprus" elseif country(args) == 'DEU' then if args.type == "E" then return europe(args) else return "*Roads in Germany\n\n*Autobahns\n**List\n*Federal\n**List\n\n*State\n*E-roads" end elseif country(args) == 'ESP' then local province = args.province or '' local stateName = ISO.name({"ESP-" .. province}) local links if args.type == "E" then links = europe(args) else links = "*Highways in Spain\n\n*Autopistas and autovías\n*National Roads" end local community if province ~= '' then if province == 'B' or province == 'GI' or province == 'L' or province == 'T' then community = "Primary Highways in Catalonia" elseif province == 'GC' or province == 'TF' then community = "Transport in the Canary Islands" elseif province == 'ML' then community = "Transport in Melilla" elseif province == 'M' or province == 'MD' then community = "Transport in the Community of Madrid" else community = '' end else community = '' end return string.format("%s\n\n*%s", links, community) elseif country(args) == 'FIN' then if args.type == "E" then return europe(args) else return "*Highways in Finland" end elseif country(args) == 'FRA' then if args.type == "E" then return europe(args) else return "*Roads in France\n\n*Autoroutes\n*Routes nationales" end elseif country(args) == 'GBR' or country(args) == 'ENG' or country(args) == 'SCT' or country(args) == 'WLS' then if args.type == "Roman" then return "*Roman roads in Britannia" else return "*Roads in the United Kingdom\n\n*Motorways\n*A and B road zones" end elseif country(args) == 'GEO' then return "*Roads in Georgia\n\n*International Routes\n*National Routes" elseif country(args) == 'GHA' then return "*Ghana Road Network" elseif country(args) == 'GIB' then return "*Streets in Gibraltar" elseif country(args) == 'GRC' then return "*Highways in Greece\n\n*Motorways\n*National Roads" elseif country(args) == 'HKG' then return "*Transport in Hong Kong\n\n*Routes\n*Roads and Streets" elseif country(args) == 'HUN' then return "*Roads in Hungary\n\n*Highways\n*Main roads\n*Local roads" elseif country(args) == 'IND' then local state = args.state or '' local stateName = ISO.name({"IND-" .. state}) local links = "*Roads in India\n\n*Expressways\n*National\n*State\n*Asian" if state ~= '' then return string.format("%s \n\nState Highways in %s", links, stateName, stateName) else return links end elseif country(args) == 'IRL' then return "*Roads in Ireland\n\n*Motorways\n*Primary\n*Secondary\n*Regional" elseif country(args) == 'IRN' then return "*Highways in Iran\n\n*Freeways" elseif country(args) == 'ISR' then return "*Roads in Israel\n\n*Highways" elseif country(args) == 'ITA' then return "*Roads in Italy\n\n*Autostrade\n*State\n*Regional\n*Provincial" elseif country(args) == 'JPN' then return "*National highways of Japan\n\n*Expressways of Japan" elseif country(args) == 'KOR' then return "*Highway systems of South Korea\n\n*Expressways\n*National\n*Local" elseif country(args) == 'KOS' then -- this is not an official ISO code return "*Roads in Kosovo" elseif country(args) == 'LKA' then return "*Roads in Sri Lanka\n\n*Expressways\n*A-Grade Highways" elseif country(args) == 'LUX' then return "*Motorways in Luxembourg" elseif country(args) == 'LVA' then return "*National Roads in Latvia" elseif country(args) == 'MEX' then local state = args.state or '' local stateName = ISO.name({"MEX-" .. state}) local links = "*Mexican Federal Highways\n\n*List\n*Autopistas" if state == 'SON' then return string.format("%s \n\nState Highways in %s", links, stateName, stateName) elseif state == 'DUR' then return string.format("%s \n\nState Highways in %s", links, stateName, stateName) else return links end elseif country(args) == 'MWI' then return "*Transport in Malawi\n\n*Roads" elseif country(args) == 'MYS' then return "*Highways in Malaysia\n\n*Expressways\n*Federal\n*State" elseif country(args) == 'NIR' then return "*Roads in Northern Ireland\n\n*Motorways\n*A roads in Northern Ireland" elseif country(args) == 'NLD' then if args.type == "E" then return europe(args) else return "*Roads in the Netherlands\n\n*Motorways\n*E-roads\n*Provincial\n*City routes" end elseif country(args) == 'NOR' then if args.type == "E" then return europe(args) else return "*Roads in Norway\n\n*National Roads\n*County Roads" end elseif country(args) == 'NZL' then return "*New Zealand state highways\n\n*Motorways and expressways\n*List" elseif country(args) == 'PHL' then if args.type == "AH" then return asia(args) else return "*Roads in the Philippines\n\n*Highways\n*Expressways\n**List" end elseif country(args) == 'POL' then return "*National roads in Poland\n\n*Voivodeship roads" elseif country(args) == 'ROU' then return "*Roads in Romania\n\n*Highways" elseif country(args) == 'RUS' then return "*Russian Federal Highways" elseif country(args) == 'SGP' then return "*Expressways of Singapore" elseif country(args) == 'SRB' then return "*Roads in Serbia\n\n*Motorways" elseif country(args) == 'SWE' then if args.type == "E" then return europe(args) else return "*Roads in Sweden\n\n*National Roads\n*County Roads" end elseif country(args) == 'THA' then return "*Highways in Thailand\n\n*Motorways\n*Asian Highways" elseif country(args) == 'TUR' then return "*Highways in Turkey\n\n*Motorways\n**List\n*State Highways\n**List" elseif country(args) == 'TWN' then return "*Highway system in Taiwan" elseif country(args) == 'UKR' then return "*Roads in Ukraine\n\n*State Highways" elseif country(args) == 'URY' then return "*National Routes of Uruguay" elseif country(args) == 'USA' then local state = args.state or '' local stateName = ISO.name({"USA-" .. state}) local national if args.type == nil then national = '' elseif args.type == 'ADHS' then national = "*Appalachian Development Highway System" elseif args.type == 'FFH' or args.type == 'FH' or args.type == 'FR' then national = "*Forest Highway System" elseif args.type == 'ISTEA' then national = "*High-Priority Corridors" elseif args.type == 'NER' then national = "*New England road marking system" elseif args.type == 'NHS' then national = "*National Highway System\n\n*Interstate\n*STRAHNET" elseif args.type == 'NSB' or args.type == 'NFSB' or args.type == 'FSB' or args.type == 'Byway' or args.type == 'GRR' or args.type == 'NTP' or args.type == 'BRP' or args.type == 'BCB' or args.type == 'Back Country' then national = "*Scenic Byways\n\n*National\n*National Forest\n*BLM\n*NPS" elseif args.type == 'Post' or args.type == 'Postal' then national = "*Post Roads in the United States" elseif args.type == 'Dixie' or args.type == 'Jackson' or args.type == 'Jefferson' or args.type == 'Jefferson Davis' or args.type == 'LCT' or args.type == 'Lincoln' or args.type == 'National' or args.type == 'Roosevelt' or args.type == 'Spanish' or args.type == 'National Old Trails Road' then national = "*Auto trails" elseif args.type == 'Tour' then national = "*Great Lakes Circle Tour" elseif args.type == 'USBR' then national = "*United States Bicycle Route System\n\n*List" elseif string.match( args.type, "^US" ) == 'US' then national = "*United States Numbered Highway System\n\n*List\n*Special\n*Divided" elseif args.type == 'I' or args.type == 'Interstate' or args.type == 'I' .. state or args.type == 'BL' or string.match( args.type, "^BL" ) == 'BL' or string.match( args.type, "^Fut" ) == 'Fut' or string.match( args.type, "^IS" ) == 'IS' or string.match( args.type, "^I %d" ) == 'I 1' or (state == 'OH' and args.type == 'Turnpike') then national = "*Interstate Highway System\n\n*Main\n*Auxiliary\n*Suffixed\n*Business\n*Future" else national = '' end local function routes(args) local routes if state == 'AL' or state == 'AZ' or state == 'CT' or state == 'IL' or state == 'ME' or state == 'NV' or state == 'NH' or state == 'NY' or state == 'OH' or state == 'PA' or state == 'TN' or state == 'WA' or state == 'WV' then routes = "state routes" elseif state == 'FL' or state == 'IN' or state == 'NM' then routes = "state roads" elseif state == 'KY' or state == 'VA' then routes = "primary state highways" elseif state == 'MI' then routes = "state trunkline highways" elseif state == 'WI' then routes = "state trunk highways" else routes = "state highways" end return routes end local function whoCallsThemRoutes(args) local routes if state == 'CA' or state == 'MS' or state == 'MO' or state == 'NV' or state == 'NH' or state == 'NJ' or state == 'NM' or state == 'NY' or state == 'OH' or state == 'PA' or state == 'WA' then routes = "Routes" else routes = "Highways" end return routes end local function three(args) return string.format("Interstate\n*US\n*State", stateName, whoCallsThemRoutes(args), stateName, routes(args), stateName ) end local function shs(args) return string.format("*%s State Highway System\n\n*%s", stateName, three(args)) end local function shsLinked(args) return string.format("*%s State Highway System\n\n*%s", stateName, three(args)) end local states if state == '' then states = '' elseif state == 'AL' or state == 'ID' or state == 'ND' or state == 'WY' then states = shs(args) elseif state == 'AK' then states = "*Alaska Routes\n\n*Interstate\n*Scenic Byways" elseif state == 'AS' then states = "*Highways in American Samoa" elseif state == 'AZ' then states = string.format("%s\n*Proposed\n*Former", shs(args)) elseif state == 'AR' then states = string.format("*Arkansas Highway System\n\n*%s\n*Business\n*Spurs\n*Suffixed\n*Scenic\n*Heritage", three(args)) elseif state == 'CA' then if args.type == 'CR' then states = "*County routes in California" else states = string.format("*State highways in California\n\n*%s\n*Scenic\n*History\n*Pre&#8209;1964\n*Unconstructed\n*Deleted\n*Freeways", three(args)) end elseif state == 'CO' then states = string.format("%s\n*Scenic", shs(args)) elseif state == 'CT' then states = string.format("%s\n**SSR\n**SR", shs(args)) elseif state == 'DE' then states = "*Delaware State Route System\n\n*List\n*Byways" elseif state == 'DC' then states = "*Streets and Highways of Washington, DC\n\n*Interstate\n*US\n*DC\n*State-Named Streets" elseif state == 'FL' then local county = args.county or '' if args.type == 'CR' and county ~= '' then states = string.format("*County roads in Florida\n\n*County roads in %s County", county, county) elseif args.type == 'CR' and county == '' then states = "*County roads in Florida" else states = string.format("%s\n**Former\n**Pre&#8209;1945\n*Toll\n*Scenic", shsLinked(args)) end elseif state == 'GA' then states = "*Georgia State Highway System\n\n*Interstate\n*US\n*State\n*\n*Special" elseif state == 'GU' then states = "*Guam Highways" elseif state == 'HI' then states = "*Routes in Hawaii" elseif state == 'IL' then local county = args.county or '' if args.type == 'CR' and county ~= '' then states = string.format("*%s County Roads", county) elseif args.type == 'CR' and county == '' then states = "*County roads in Illinois" else states = string.format("%s\n*Tollways", shsLinked(args)) end elseif state == 'IN' then local county = args.county or '' if args.type == 'CR' and county ~= '' then states = string.format("*%s County Roads", county) elseif args.type == 'CR' and county == '' then states = "*County roads in Indiana" else states = string.format("%s\n*Scenic", shs(args)) end elseif state == 'IA' then states = string.format("*Iowa Primary Highway System\n\n*%s\n*Secondary\n*Scenic", three(args)) elseif state == 'KS' then states = string.format("%s\n*Spurs", shs(args)) elseif state == 'KY' then states = string.format("%s\n*Parkways", shs(args)) elseif state == 'LA' then local county = args.county or args.parish or '' if args.type == 'PR' or args.type == 'CR' then if county ~= '' then states = string.format("*%s Parish Roads", county) else states = "*Parish roads in Louisiana" end else states = string.format("%s\n*Scenic", shs(args)) end elseif state == 'ME' then states = string.format("%s\n*Auto trails\n*Lettered highways", shsLinked(args)) elseif state == 'MD' then local county = args.county or '' if args.type == 'CR' and county ~= '' then states = string.format("* County Roads in %s County", county) elseif args.type == 'CR' and county == '' then states = "*County roads in Maryland" else states = string.format("*Maryland highway system\n\n*%s\n*Scenic Byways", three(args)) end elseif state == 'MA' or state == 'MS' then states = string.format("%s", shsLinked(args)) elseif state == 'MI' then local county = args.county or '' if args.type == 'CR' and county ~= '' then states = string.format("*%s County Roads", county) elseif args.type == 'CR' and county == '' then states = "*County roads in Michigan" elseif args.type == 'CDH' then states = "*County-Designated Highways" else states = string.format("*Michigan State Trunkline Highway System\n\n*%s\n*Byways", three(args)) end elseif state == 'MN' then local county = args.county or '' if args.type == 'CR' or args.type == 'CSAH' then if county ~= '' then states = string.format("*County roads of Minnesota\n\n*%s County", county, county) else states = "*County roads of Minnesota" end else states = string.format("*Minnesota Trunk Highway System\n\n*%s\n*Legislative routes", three(args)) end elseif state == 'MO' then states = string.format("%s\n*Supplemental", shsLinked(args)) elseif state == 'MT' then states = string.format("*Montana Highway System\n\n*%s\n*Secondary", three(args)) elseif state == 'NE' then states = string.format("%s\n*Link\n*Spur\n**State Spurs\n*Recreation", shsLinked(args)) elseif state == 'NV' then states = string.format("%s\n*\n*Pre&#8209;1976\n*Scenic", shs(args)) elseif state == 'NH' then states = string.format("*New Hampshire Highway System\n\n*%s\n*Turnpikes", three(args)) elseif state == 'NJ' then local county = args.county or '' if args.type == 'CR' then if county ~= '' then states = string.format("*County Routes in %s County\n\n*System\n*500-series routes", county, county) else states = "*County routes in New Jersey\n\n*500-series routes" end else states = string.format("*New Jersey State Highway Routes\n\n*%s\n*Scenic Byways", three(args)) end elseif state == 'NM' then states = string.format("%s\n*Scenic", shs(args)) elseif state == 'NY' then local county = args.county or '' if args.type == 'CR' then if county ~= '' then states = string.format("*County routes in New York\n\n*County Routes in %s County", county, county) else states = "*County routes in New York" end else states = string.format("*New York Highways\n\n*%s\n*Reference\n*Parkways", three(args)) end elseif state == 'NC' then states = string.format("*North Carolina Highway System\n\n*%s\n*Scenic", three(args)) elseif state == 'MP' then states = "*Northern Mariana Islands Highways" elseif state == 'OH' then if args.type == 'CR' then states = "*County roads in Ohio" else states = string.format("%s\n*Scenic", shs(args)) end elseif state == 'OR' then states = string.format("*Oregon Highways\n\n*%s\n*Named\n*Scenic", three(args)) elseif state == 'OK' then states = string.format("%s\n*Turnpikes", shs(args)) elseif state == 'PA' then states = string.format("*Pennsylvania State Route System\n\n*%s\n*Scenic Byways\n*Legislative", three(args)) elseif state == 'PR' then states = "*Roads in Puerto Rico\n\n*List" elseif state == 'RI' then states = "*Rhode Island Routes" elseif state == 'SC' then states = string.format("%s\n*Scenic", shsLinked(args)) elseif state == 'SD' then states = string.format("*South Dakota State Trunk Highway System\n\n*%s", three(args)) elseif state == 'TN' then states = string.format("*Tennessee State Routes\n\n*%s", three(args)) elseif state == 'TX' then states = string.format("*Highways in Texas\n\n*%s\n*Toll\n*Loops\n*Spurs\n*FM/RM\n*Park\n*Rec", three(args)) elseif state == 'UT' then states = string.format("%s\n*\n*Minor\n*Scenic", shs(args)) elseif state == 'VI' then states = "*USVI Highways" elseif state == 'VT' then states = "*State highways in Vermont" elseif state == 'VA' then states = "*Virginia Routes\n\n*Interstate\n*US\n*Primary\n*Secondary\n*Byways\n*History\n*HOT lanes" elseif state == 'WA' then states = string.format("*State highways in Washington\n\n*%s\n*Scenic\n*Pre-1964\n*1964 renumbering\n*Former", three(args)) elseif state == 'WV' then local county = args.county or '' if args.type == 'CR' then if county ~= '' then states = string.format("*County Routes in West Virginia\n\n*%s County Routes", county, county) else states = "*County Routes in West Virginia" end else states = string.format("%s", shsLinked(args)) end elseif state == 'WI' then if args.type == 'CR' or args.type == 'CTH' then states = "*County Trunk Highways" else states = string.format("*Wisconsin State Trunk Highway System\n\n*%s\n*Scenic\n*Rustic", three(args)) end end return string.format("%s\n\n%s", national, states) elseif country(args) == 'ZAF' then return "*Numbered routes of South Africa"

elseif country(args) == 'ARG' or country(args) == 'BRB' or country(args) == 'CHL' or country(args) == 'PRY' then return string.format("*Highways in %s %s", the(args), name, the(args), name)

elseif country(args) == 'BGD' or country(args) == 'IMN' or country(args) == 'ISL' or country(args) == 'MDG' or country(args) == 'NPL' or country(args) == 'UGA' then return string.format("*Roads in %s %s", the(args), name, the(args), name) elseif country(args) == 'DNK' or country(args) == 'MNE' or country(args) == 'PRK' or country(args) == 'TUN' then return string.format("*Transport in %s %s\n\n*Motorways", the(args), name, the(args), name) elseif country(args) == 'AZE' or country(args) == 'BLR' or country(args) == 'BLZ' or country(args) == 'CPV' or country(args) == 'CUB' or country(args) == 'JAM' or country(args) == 'KWT' or country(args) == 'MDA' or country(args) == 'PAK' or country(args) == 'PRT' then return string.format("*Roads in %s %s", the(args), name) elseif country(args) == 'ALB' or country(args) == 'BGR' or country(args) == 'CZE' or country(args) == 'DOM' or country(args) == 'ECU' or country(args) == 'GUF' or country(args) == 'HRV' or country(args) == 'PER' or country(args) == 'SVK' or country(args) == 'SVN' or country(args) == 'VEN' then return string.format("*Highways in %s %s", the(args), name) else return string.format("*Transport in %s %s", the(args), name) end end

function p.browselinks(frame) local args = getArgs(frame) if args.nobrowse ~= nil then return nil else return browselinks(args) end end

return p