模組:北京地铁客流量

文档图示 模块文档[查看] [编辑] [历史] [清除缓存]

概要

展示部分北京地铁车站的日均进出站、换乘客流量,数据来自北京交通发展研究院(原“北京交通发展研究中心”)发布的《年度报告》[1][2]

參數及使用方法

仅有一个可选参数:车站名称。

若省略此参数,则取当前页面标题作为车站名称(对于有消歧义后缀的条目,会去除消歧义括号)。

範例

重定向

模板编辑说明

模板 {{北京地铁客流量}} 用于包装同名 Lua 模块:北京地铁客流量。如需更新数据或修改输出结果,请参考该模块的源代码。

參見

-- vi: set noexpandtab tabstop=4 shiftwidth=0: --

local mod = {}

mod.annuals = {
	["2019"] = {
		ref = [[<ref>{{cite book
|author=北京交通发展研究院
|title=2020北京市交通发展年度报告
|pages=70-71
|url=https://www.bjtrc.org.cn/Show/download/id/66/at/0.html
|format=PDF
|date=2020-07
}}</ref>]],
		["进站"] = {
			-- 车站名称		早高峰	占全天百分比
			{'宋家庄',		2.62,	45.69},
			{'天通苑',		2.48,	49.54},
			{'霍营',		2.43,	54.36},
			{'天通苑北',	2.42,	45.38},
			{'立水桥',		1.89,	48.46},
			{'回龙观',		1.87,	51.68},
			{'十里河',		1.84,	33.03},
			{'回龙观东大街',1.80,	59.16},
			{'沙河',		1.74,	44.64},
			{'龙泽',		1.63,	47.74},
			{'物资学院路',	1.58,	47.75},
			{'北京南站',	1.51,	14.17},
			{'新宫',		1.45,	44.95},
			{'草房',		1.41,	43.46},
			{'朱辛庄',		1.32,	50.44},
			{'北运河西',	1.24,	52.47},
			{'通州北关',	1.23,	49.90},
			{'土桥',		1.21,	51.34},
			{'角门西',		1.20,	43.96},
			{'八宝山',		1.18,	43.97},
		},
		["出站"] = {
			{'西二旗',		3.25,	38.50},
			{'朝阳门',		3.06,	41.54},
			{'国贸',		2.29,	30.33},
			{'复兴门',		2.23,	56.67},
			{'西直门',		2.17,	33.31},
			{'阜成门',		2.14,	50.14},
			{'大望路',		1.98,	25.12},
			{'丰台科技园',	1.96,	50.72},
			{'东单',		1.78,	42.28},
			{'西单',		1.75,	27.61},
			{'东直门',		1.73,	20.93},
			{'亮马桥',		1.65,	38.40},
			{'三元桥',		1.59,	27.15},
			{'北京南站',	1.59,	14.97},
			{'北京西站',	1.56,	14.57},
			{'海淀黄庄',	1.56,	30.44},
			{'金台夕照',	1.53,	39.91},
			{'东大桥',		1.53,	33.30},
			{'苏州街',		1.46,	35.88},
			{'将台',		1.44,	30.35},
		},
		["换乘"] = {
			{'宋家庄',		6.07,	25.54},
			{'西直门',		5.66,	24.04},
			{'郭公庄',		4.74,	30.15},
			{'呼家楼',		4.59,	23.92},
			{'惠新西街南口',4.55,	25.37},
			{'西二旗',		3.85,	26.17},
			{'海淀黄庄',	3.68,	23.78},
			{'国家图书馆',	3.48,	24.34},
			{'金台路',		3.39,	21.35},
			{'四惠',		3.38,	26.14},
			{'六里桥',		3.24,	28.22},
			{'公主坟',		3.20,	28.66},
			{'望京',		3.17,	22.75},
			{'磁器口',		3.12,	21.74},
			{'北土城',		3.08,	25.07},
			{'角门西',		3.06,	23.41},
			{'菜市口',		3.03,	21.15},
			{'国贸',		2.96,	22.77},
			{'建国门',		2.92,	21.30},
			{'西苑',		2.87,	29.04},
		},
	},
	["2020"] = {
		ref = [[<ref>{{cite book
|author=北京交通发展研究院
|title=2021北京市交通发展年度报告
|pages=81-82
|url=https://www.bjtrc.org.cn/Show/download/id/68/at/0.html
|format=PDF
|date=2021-09
}}</ref>]],
		["进站"] = {
			{'天通苑北',	1.94,	52.90},
			{'天通苑',		1.80,	52.99},
			{'沙河',		1.78,	55.36},
			{'宋家庄',		1.71,	47.60},
			{'霍营',		1.56,	55.95},
			{'回龙观',		1.30,	53.88},
			{'十里河',		1.26,	36.72},
			{'回龙观东大街',1.26,	59.91},
			{'立水桥',		1.22,	48.11},
			{'物资学院路',	1.12,	50.47},
			{'龙泽',		1.08,	48.34},
			{'新宫',		1.01,	49.26},
			{'草房',		0.95,	47.05},
			{'通州北关',	0.91,	51.96},
			{'朱辛庄',		0.90,	53.17},
			{'长阳',		0.88,	58.05},
			{'古城',		0.85,	47.56},
			{'北京南站',	0.85,	18.49},
			{'金安桥',		0.83,	49.72},
			{'北运河西',	0.81,	53.47},
		},
		["出站"] = {
			{'西二旗',		2.21,	38.41},
			{'朝阳门',		1.95,	46.16},
			{'丰台科技园',	1.49,	54.43},
			{'西直门',		1.48,	36.09},
			{'国贸',		1.43,	31.85},
			{'复兴门',		1.41,	61.12},
			{'阜成门',		1.35,	54.03},
			{'大望路',		1.25,	27.61},
			{'东单',		1.09,	45.60},
			{'西单',		1.08,	33.09},
			{'金台夕照',	1.06,	41.74},
			{'东直门',		1.05,	24.61},
			{'将台',		1.05,	33.03},
			{'亮马桥',		1.01,	41.17},
			{'三元桥',		1.00,	31.53},
			{'苏州街',		0.97,	37.64},
			{'东大桥',		0.97,	36.86},
			{'海淀黄庄',	0.93,	31.97},
			{'西土城',		0.93,	39.51},
			{'望京东',		0.88,	30.77},
		},
		["换乘"] = {
			{'宋家庄',		4.31,	28.64},
			{'郭公庄',		3.73,	33.13},
			{'西直门',		3.57,	26.43},
			{'呼家楼',		3.28,	26.14},
			{'惠新西街南口',3.02,	27.22},
			{'西二旗',		2.71,	29.17},
			{'六里桥',		2.30,	30.95},
			{'海淀黄庄',	2.24,	25.55},
			{'金台路',		2.24,	23.05},
			{'望京',		2.23,	23.85},
			{'四惠',		2.19,	29.83},
			{'国家图书馆',	2.17,	26.39},
			{'角门西',		2.08,	26.66},
			{'公主坟',		2.06,	32.13},
			{'北土城',		1.99,	26.93},
			{'西苑',		1.98,	30.65},
			{'知春路',		1.96,	26.20},
			{'磁器口',		1.91,	24.37},
			{'菜市口',		1.91,	24.03},
			{'国贸',		1.83,	25.52},
		},
	},
}

-- 西土城站 (北京市) => 西土城
function mod.disambiguation(frame)
	-- 默认使用模板中的 {{PAGENAME}} 魔术字
	local title = frame.args[1]

	-- 如果从引用模板的正文页面手动指定了页面名称,以手动指定为准
	frame = frame:getParent()
	if frame.args.title and #frame.args.title > 0 then
		title = frame.args.title
	elseif frame.args[1] and #frame.args[1] > 0 then
		title = frame.args[1]
	end

	local parentheses = string.find(title, " %(")
	if not parentheses then
		parentheses = 0
	end

	-- 站 => %e7%ab%99 (3 bytes in UTF-8)
	return string.sub(title, 1, parentheses - 1 - #"站")
end

function mod.wiki_text(frame)
	local title = mod.disambiguation(frame)
	local wiki_text = ""

	for year, annual in pairs(mod.annuals) do
		local passengers = ""
		for category, list in pairs(annual) do
			if category ~= "ref" then
				for rank, station in ipairs(list) do
					if station[1] == title then
						passengers = (
							passengers .. ";" .. category .. " " ..
							string.format("%.1f", station[2] * 100 / station[3]) ..
							" 万人次,其中早高峰 " .. station[2] .. " 万人次," ..
							category .. "量位列第 " .. rank .. " 名"
						)
						break
					end
				end
			end
		end

		if #passengers > 0 then
			wiki_text = wiki_text .. frame:expandTemplate{
				title = "rail pass box",
				args = {
					passengers = (
						"工作日日均" .. string.sub(passengers, 1 + #",") ..
						frame:preprocess(annual.ref)
					),
					pass_year = year,
				},
			}
		end
	end
	
	return wiki_text
end

return mod