Dokumentation für das Modul Mapshapes[Ansicht] [Bearbeiten] [Versionsgeschichte] [Aktualisieren]

Anwendung

Der Modul wird direkt von der Vorlage {{Mapshapes}} aufgerufen. Parameterbeschreibung siehe dort.

Versionsbezeichnung auf Wikidata: 2023-05-03 Ok!

Benötigte weitere Module

Dieses Modul benötigt folgende weitere Module: Mapshapes/Params • Mapshape utilities • Mapshape utilities/i18n • Wikidata utilities
Hinweise
-- getting a set of mapshape objects  -- documentation local Mapshapes = { 	suite  = 'Mapshapes', 	serial = '2023-05-03', 	item   = 50361901 }  -- module import -- require( 'strict' ) local mi = require( 'Module:Mapshape utilities/i18n' ) local mp = require( 'Module:Mapshapes/Params' ) local mu = require( 'Module:Mapshape utilities' ) local wu = require( 'Module:Wikidata utilities' )  -- modul variable and administration local ms = { 	moduleInterface = Mapshapes }  -- check if the child item should be shown local function idMatch( args, id ) 	local key = 2 	if mw.text.trim( args[ key ] or '' ) == '' then 		-- empty list of child items to show 		return true  	end  	while mw.text.trim( args[ key ] or '' ) ~= '' do 		if mw.text.trim( id ) == mw.text.trim( args[ key ] ) then 			return true 		end 		key = key + 1 	end 	return false end  local function getShapes( args, frame ) 	ms.entityId = mw.wikibase.getEntityIdForCurrentPage() 	ms.wikiLang = mw.getContentLanguage():getCode() 	 	local values = mu.getMapshapes( args[ 1 ] ) 	if #values == 0 then 		return mi.mssNoChilds 	end  	local content = {} 	local tagArgs = { 		text = '', 		group = mu.translateGroup( mu.checkGroup( args.group ) ), 		class = 'no-icon' 	} 	local colorId, description, geojson, id, result, rgb, title 	for i = 1, #values, 1 do 		id = values[ i ].id 		if idMatch( args, id ) then 			title = mu.addLink( mw.wikibase.label( id ) or id, id, ms.entityId, 				ms.wikiLang ) 			description = mu.getImage( id ) 			if description == '' then 				description = nil 			else 				description = '[[file:' .. description .. '|141px]]' 			end  			rgb = mu.getColor( id ) 			if rgb == '' then 				rgb = args.defaultColor 			end  			geojson = { 				type = 'ExternalData', 				service = args.defaultType, 				ids = id, 				properties = { 					title = title, 					description = description, 					fill = mi.defaultFill, 					[ 'fill-opacity' ] = mi.defaultFillOpacity, 					stroke = rgb, 					[ 'stroke-width' ] = args.strokeWidth, 					[ 'stroke-opacity' ] = args.strokeOpacity 				} 			} 			-- collecting multiple geojson codes 			table.insert( content, mw.text.jsonEncode( geojson ) ) 		end 	end 	if #content == 0 then 		geojson = nil 	elseif #content == 1 then 		geojson = content[ 1 ] 	else 		geojson = '[' .. table.concat( content, ',') .. ']' 	end 	if geojson then 		-- only one expensive call 		result = frame:extensionTag( 'maplink', geojson, tagArgs ) 	else 		result = '' 	end 	if mw.title.getCurrentTitle().namespace == 0 and mi.usePropertyCategs then -- main ns 		result = result .. wu.getCategories( mi.properties ) 			.. mu.getCategories( mi.properties ) 	end 	return result end  function ms.show( frame ) 	if mi.excludeOSM then 		return '' 	end  	local args, errorMsg = 		mu.checkParams( frame:getParent().args, mp, 'Mapshapes', mi.mssUnknown ) 	if args[ 1 ] == '' then 		return mi.mssMissingFirst 	end  	args.strokeWidth   = mu.getNumber( args.strokeWidth, mi.defaultShapesWidth ) 	args.strokeOpacity = mu.getNumber( args.strokeOpacity, mi.defaultShapesOpacity ) 	args.defaultType   = mu.getParameter( args.defaultType, 'geoline' ) 	args.defaultColor  = mu.getParameter( args.defaultColor, mi.defaultStroke ) 	if not string.find( args.defaultColor, '#', 1, true ) then 		args.defaultColor = '#' .. args.defaultColor 	end  	return getShapes( args, frame ) .. errorMsg end  return ms