モジュール:日本地図

local function create(args)
	local imageSize=tonumber(args2)
	local createProjection=require("Module:地図/正射図法")
	local projection=createProjection({imageSize,imageSize},1850000/imageSize,{137.6,37.9})
	local subprojection=createProjection({imageSize/2,imageSize/2},1850000/imageSize,{127.3,25})
	local background=require("Module:地図")
	local outerdata=background("00",1)
	local outerpath="";
	for _,curve in ipairs(outerdata) do
		local ps=projection.convertMulti(false,curve)
		if #ps>=3 then
			local s=""
			for k,v in ipairs(ps) do
				s=s..string.format("%s %.1f %.1f ",(k==1 and "M") or "L",v1,v2)
			end
			s=s.."Z"
			outerpath=outerpath..s.." "
		end
	end
	for _,curve in ipairs(outerdata) do
		local ps=subprojection.convertMulti(false,curve)
		if #ps>=3 then
			local s=""
			for k,v in ipairs(ps) do
				s=s..string.format("%s %.1f %.1f ",(k==1 and "M") or "L",v1,v2)
			end
			s=s.."Z"
			outerpath=outerpath..s.." "
		end
	end
	local innerpath="";
	for _,curve in ipairs(background("00",2)) do
		local ps=projection.convertMulti(true,curve)
		if #ps>=2 then
			local s=""
			for k,v in ipairs(ps) do
				s=s..string.format("%s %.1f %.1f ",(k==1 and "M") or "L",v1,v2)
			end
			innerpath=innerpath..s.." "
		end
	end
	local pointlist={}
	for line in string.gmatch(mw.text.trim(args3),"^\n+") do
		local ss={}
		for s in string.gmatch(string.gsub(line,"/",","),"^,+") do
			table.insert(ss,mw.text.trim(s))
		end
		local p=projection.convert({tonumber(ss2),tonumber(ss3)})
		table.insert(pointlist,{text=ss1,x=tonumber(string.format("%.1f",p1)),y=tonumber(string.format("%.1f",p2))})
	end
	return {
		width=imageSize,
		height=imageSize,
		signals={
			{
				name="active",
				init={},
				streams={
					{
						type="path:mouseover,path:touchstart",
						expr="datum"
					},
					{
						type="path:mouseout,touchend",
						expr="{}"
					}
				}
			},
			{
				name="link",
				init={},
				streams={
					{
						type="path:click",
						expr="open('https://ja.wikipedia.org/wiki/'+active.text)"
					}
				}
			}
		},
		data={
			{
				name="point",
				values=pointlist,
				transform={
					{
						type="voronoi",
						x="x",
						y="y",
						clipExtent=
					}
				}
			}
		},
		marks={
			{
				type="path",
				properties={
					enter={
						path={value=string.format("M 0 0 H %d V %d H 0 Z",imageSize,imageSize)},
						fill={value="lavender"}
					}
				}
			},
			{
				type="path",
				properties={
					enter={
						path={value=outerpath},
						fill={value="white"},
						stroke={value="black"},
						strokeWidth={value=0.25}
					}
				}
			},
			{
				type="path",
				properties={
					enter={
						path={value=innerpath},
						stroke={value="black"},
						strokeWidth={value=0.5},
						strokeDash={value={10,2,2,2}}
					}
				}
			},
			{
				type="symbol",
				from={data="point"},
				properties={
					enter={
						size={value=16},
						fill={value="deeppink"},
						x={field="x"},
						y={field="y"}
					}
				}
			},
			{
				type="path",
				properties={
					enter={
						path={value=string.format("M %d 0 V %d L %d %d H 0",imageSize/2,imageSize/4,imageSize/8*3,imageSize/8*3)},
						stroke={value="white"},
						strokeWidth={value=2}
					}
				}
			},
			{
				type="path",
				properties={
					enter={
						path={value=string.format("M 0 0 H %d V %d H 0 Z",imageSize,imageSize)},
						stroke={value="white"},
						strokeWidth={value=2}
					}
				}
			},
			{
				type="symbol",
				properties={
					update={
						size={value=64},
						fill={value="red"},
						x={signal="active.x"},
						y={signal="active.y"}
					}
				}
			},
			{
				type="text",
				properties={
					update={
						fill={value="black"},
						x={signal="active.x"},
						y={signal="active.y", offset=-32},
						align={value="center"},
						baseline={value="middle"},
						fontSize={value=24},
						text={signal="active.text"}
					}
				}
			},
			{
				type="path",
				from={data="point"},
				properties={
					enter={
						fill={value="transparent"},
						path={field="layout_path"}
					}
				}
			}
		}
	}
end
return {
	_=function(frame)
		return frame:extensionTag('templatestyles',,{src='Graph:Chart/styles.css'})..frame:extensionTag('graph',mw.text.jsonEncode(create(frame:getParent().args)),{mode='interactive'})..frame:extensionTag('ref','国土交通省 国土数値情報（行政区域・湖沼）を加工して作成')
	end
}