Module:User:Catonif/rup-map

Hello, you have come here looking for the meaning of the word Module:User:Catonif/rup-map. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Catonif/rup-map, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Catonif/rup-map in singular and plural. Everything you need to know about the word Module:User:Catonif/rup-map you have here. The definition of the word Module:User:Catonif/rup-map will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Catonif/rup-map, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local points = require("Module:User:Catonif/rup-map/points")

-- link utilities
local lang_rup = require("Module:languages").getByCode("rup")
local full_link = require("Module:links").full_link
local function link(term, written_forms)
	if not written_forms then
		written_forms = true
	end
	return full_link { lang = lang_rup, term = term }
end

-- colour utilities
local color_list = {
	"c94c4c", "cfa34a", "6b9d72", "5f9ea0", "5d81a5",
	"8273a9", "ba7097", "8c6d5d", "8b9fa5", "d97e5c",
	"d0b45b", "7db88a", "7db6b3", "7a99c4", "9589c3",
	"c589b9", "a98476", "a3b3bb", "d46a6a", "b18e3d",
	"7ba773", "76abae", "5f7aa4", "847bbf", "bb7a9e",
	"9a7866", "88989f", "d88a6f", "d8ba68", "88b08b",
	"66a5a0", "6b8bb8", "7665a8", "c573b5", "b39688",
	"a1a8af", "b75454", "c9a065", "5d8c63", "4c8f8c",
	"4b6c9a", "64528f", "a45886", "7a5c49", "707e86",
}
local max_color_index = 1
local writ_combinations = {}

local function make_description(input, written_forms)

	local ret = {}
	local ret_color_index
	
	-- headwords, i.e. written form, orthographic transcriptions
	if input.h then
		local writ_current = writ_combinations
		if type(input.h) == "table" then
			for k, v in ipairs(input.h) do
				if not writ_current] then
					writ_current] = {}
				end
				writ_current = writ_current]
				input.h = link(v, written_forms)
			end
			table.insert(ret, table.concat(input.h, ", "))
		elseif type(input.h) == "string" then
			table.insert(ret, link(input.h, written_forms))
			if not writ_current then
				writ_current = {}
			end
			writ_current = writ_current
		end
		if not writ_current._color then
			writ_current._color = max_color_index
			max_color_index = max_color_index + 1
		end
		ret_color_index = writ_current._color
	end

	-- pronunciations, in ALAR notation
	if input.p then
		table.insert(ret, '<span class="IPA">'..input.p..'</span>')
	end

	-- plain text, currently only for the /dialects map
	if input.t then
		table.insert(ret, input.t)
		if not input.h then ret_color_index = -1 end
	end

	return table.concat(ret, "<br>"), ret_color_index

end

function export.render_map(frame)

	local forms = require("Module:User:Catonif/rup-map/data/"..frame.args.map)

	local geojson = {}
	local written_forms = {}

	-- builds map's GeoJSON
	for transcription_index, transcription in ipairs(forms) do
		for _, alar_id in ipairs(transcription) do
			local alar_point = points
			local description, color_id = make_description(transcription, written_forms)
			if color_id == -1 then color_id = transcription_index end
			table.insert(geojson, {
				type = "Feature",
				properties = {
					title = alar_point.name,
					description = description,
					 = color_list,
				},
				geometry = {
					type = "Point",
					coordinates = { alar_point.lon, alar_point.lat },
				},
			})
		end
	end
	local ret = frame:extensionTag(
		"mapframe",
		mw.text.jsonEncode { type = "FeatureCollection", features = geojson },
		{ width = "full", height = 600 }
	)

	-- list of all attested orthographic forms
	local col_args = {"rup"}
	for k in pairs(written_forms) do
		table.insert(col_args, k)
	end
	if #col_args > 1 then
		ret = ret..frame:expandTemplate { title = "col", args = col_args }
	end

	return ret

end

return export