{{i}} Документація модуля[створити]
local p = {}

function ine(var)
	if(var) then
		if(string.len(var)>0) then return true; else return false; end
	else return false;
	end
end

function marker_prefix(mar)
	if(mar=="number" or mar=="letter") 
		then return "-"..mar;
	else return mar; end
end

function p.main(frame)
	parent = frame:getParent();
	args = parent.args;
	
	if(not ine(args["ширина"])) then args["ширина"] = 400; end
	if(not ine(args["висота"])) then args["висота"] = 400; end
	if(not ine(args["масштаб"])) then args["масштаб"] = 10; end
	if(not ine(args["широта"])) then args["широта"] = 0; end
	if(not ine(args["довгота"])) then args["довгота"] = 0; end
	if(not ine(args["вирівнювання"])) then args["вирівнювання"] = "center"; end
	if(args["текст"]) then 
		args["текст"] = string.gsub(args["текст"], '"', """);
		args["текст"] = string.gsub(args["текст"], "'", "'")
		args["текст"] = ' text="'..args["текст"]..'"';
	else args["текст"] = ""; end
	mapframe_tag = {'<mapframe width=', args["ширина"], ' height=', args["висота"], ' zoom=', args["масштаб"], 
		' longitude=', args["довгота"], ' latitude=', args["широта"], 
		' align=', args["вирівнювання"], args["текст"], '>'};
	
	if(ine(args["geoshape"]) or ine(args["geomask"])) then 
		if(ine(args["geoshape"])) then geo_type = "geoshape"; el = args["geoshape"];
		else geo_type = "geomask"; el = args["geomask"]; end
		contour = '{"type": "ExternalData","service": "'..geo_type..'","ids": "'..
		el..'","properties": {"fill-opacity": 0.3}}, ';
	else contour = ""; end
	
	if(ine(args["лінії"])) then
		local_res = {
			',\n{ "type": "ExternalData", "service": "geoline", "properties": { "stroke-width": 3 }, "query": "', 
			'SELECT ?id ?length (if(BOUND(?idhexcolor), ', "concat('#', str(?idhexcolor)), if(BOUND(?hexcolor), ", 
			  "concat('#', str(?hexcolor)), '#07c63e' ) ) as ?stroke) (concat('Line length: ', str(?length), ' km') as ?description) ", 
			  "(if(BOUND(?link), concat('[[', substr(str(?link),31,500), '|', ?idLabel, ']]'), ?idLabel) as ?title) ", 
			"WHERE { { ?id p:P361/ps:P361/wdt:P361* wd:", args["лінії"], ". hint:Prior hint:gearing 'forward' } ", 
			"OPTIONAL { ?id wdt:P465 ?idhexcolor. } OPTIONAL { ?id wdt:P462 ?color. ?color wdt:P465 ?hexcolor.} ", 
			"SERVICE wikibase:label { bd:serviceParam wikibase:language 'uk,en' . ?id rdfs:label ?idLabel . } ", 
			"OPTIONAL {?link schema:about ?id. ?link schema:isPartOf <https://uk.wikipedia.org/> . } } ", 
			'GROUP BY ?id ?link ?idLabel ?length ?hexcolor ?idhexcolor "}'};
		osm_lines = table.concat(local_res);
	else osm_lines = ""; end

	top_res = {'[', contour, '{"type": "FeatureCollection", "features": [', {}, ']}', osm_lines, ']</mapframe>'};
	
	index = 1;
	while(ine(args["лінія_точки"..tostring(index)])) do
		s_in = tostring(index);
		if(not ine(args["лінія_колір"..s_in])) then args["лінія_колір"..s_in] = "000"; end
		args["лінія_колір"..s_in] = '"stroke": "#'..args["лінія_колір"..s_in]..'", ';
		if(not ine(args["лінія_товщина"..s_in])) then args["лінія_товщина"..s_in] = "5"; end
		args["лінія_товщина"..s_in] = '"stroke-width": '..args["лінія_товщина"..s_in]..', ';
		if(not ine(args["лінія_непрозорість"..s_in])) then args["лінія_непрозорість"..s_in] = "1"; end
		args["лінія_непрозорість"..s_in] = '"stroke-opacity": '..args["лінія_непрозорість"..s_in];
		local_res = {'{"type": "Feature", "properties": {', 
			args["лінія_колір"..s_in], args["лінія_товщина"..s_in], args["лінія_непрозорість"..s_in], 
			'}, "geometry": {"type": "LineString", "coordinates":[', args["лінія_точки"..s_in], ']}},'};
		table.insert(top_res[4], table.concat(local_res));
		index = index+1;
	end

	index = 1;
	while(ine(args["шир"..tostring(index)]) and ine(args["дов"..tostring(index)])) do
		s_in = tostring(index);
		if(args["наз"..s_in]) then
			args["наз"..s_in] = string.gsub(args["наз"..s_in], '"', "&quot;");
			args["наз"..s_in] = string.gsub(args["наз"..s_in], "'", "&#39;");
		else args["наз"..s_in] = ""; end
		if(args["опис"..s_in]) then
			args["опис"..s_in] = string.gsub(args["опис"..s_in], '"', "&quot;");
			args["опис"..s_in] = string.gsub(args["опис"..s_in], "'", "&#39;");
		else args["опис"..s_in] = ""; end
		if(args["мар"..s_in]) then args["мар"..s_in] = marker_prefix(args["мар"..s_in]);
		else args["мар"..s_in] = "-number"; end
		if(not ine(args["колір"..s_in])) then args["колір"..s_in] = "000"; end
		local_res = {'{"type": "Feature", "properties": {"title": "', args["наз"..tostring(index)], 
			'", "description": "', args["опис"..s_in], '", "marker-symbol": "', args["мар"..s_in], 
			'", "marker-color": "', args["колір"..s_in], '"}, "geometry": {"type": "Point", "coordinates": [', 
			args["дов"..s_in], ', ', args["шир"..s_in], ']}},'};
		table.insert(top_res[4], table.concat(local_res));
		index = index+1;
	end

	index_group = 1;
	while(ine(args["шир"..tostring(index_group).."_1"]) and ine(args["дов"..tostring(index_group).."_1"])) do
		gi = tostring(index_group);
		gp = gi.."_";
		if(args["група_назва"..gi]) then 
			args["група_назва"..gi] = "-"..args["група_назва"..gi];
		else args["група_назва"..gi] = ""; end
		if(args["група_мар"..gi]) then args["група_мар"..gi] = marker_prefix(args["група_мар"..gi]);
		else args["група_мар"..gi] = "-number"; end
		if(not ine(args["група_колір"..gi])) then args["група_колір"..gi] = "000"; end

		index = 1;
		while(ine(args["шир"..gp..tostring(index)]) and ine(args["дов"..gp..tostring(index)])) do
			s_in = gp..tostring(index);
			if(args["наз"..s_in]) then
				args["наз"..s_in] = string.gsub(args["наз"..s_in], '"', "&quot;");
				args["наз"..s_in] = string.gsub(args["наз"..s_in], "'", "&#39;");
			else args["наз"..s_in] = ""; end
			if(args["опис"..s_in]) then
				args["опис"..s_in] = string.gsub(args["опис"..s_in], '"', "&quot;");
				args["опис"..s_in] = string.gsub(args["опис"..s_in], "'", "&#39;");
			else args["опис"..s_in] = ""; end
			if(not ine(args["мар"..s_in])) then args["мар"..s_in] = args["група_мар"..gi]; end
			if(not ine(args["колір"..s_in])) then args["колір"..s_in] = args["група_колір"..gi]; end
			local_res = {'{"type": "Feature", "properties": {"title": "', args["наз"..s_in], 
				'", "description": "', args["опис"..s_in], '", "marker-symbol": "', args["мар"..s_in], 
				args["група_назва"..gi], 
				'", "marker-color": "', args["колір"..s_in], '"}, "geometry": {"type": "Point", "coordinates": [', 
				args["дов"..s_in], ', ', args["шир"..s_in], ']}},'};
			table.insert(top_res[4], table.concat(local_res));
			index = index+1;
		end
		index_group = index_group+1
	end

	top_res[4] = table.concat(top_res[4]);
	return frame:preprocess(table.concat(mapframe_tag)..table.concat(top_res));
end

return p;