Zum Inhalt springen
Willkommen in der InkluPedia
Wenn dir dieses Wiki geholfen hat, würde sich die InkluPedia über eine Bewertung auf der Trustpilot-Website hierüber als Dankeschön freuen. Feedback zu diesem Wiki ist über das Kontaktformular oder nach eine Anmeldung möglich. Für eine Mitarbeit ist eine Anmeldung erforderlich, Angaben persönlicher Daten sind dabei nicht notwendig. Derzeit ist das wegen monatelangen Attacken von weltweit aktiven SPAM-Bots [1] nur über ein Formular möglich.

Modul:Coordinates/kml

Aus InkluPedia
  • Dieses Modul enthält Code in der Programmiersprache Lua.
  • Module werden über #invoke in Vorlagen eingebunden.
  • Dieses Modul wird über Vorlagen auf folgenden Seiten verwendet: Seiten anzeigen

	local coordinates = { suite  = "Coordinates/kml",
	                      serial = "2021-02-23	",
	                      item   = 50976437 }
	--[=[
	Overcome a limitation in kmlexport in 2018.
	
	There are three functions below which might be copied into an existing
	       [[Module:Coordinates]] ([[d:Q7348344]])
	or this module might be used stand-alone.
	
	In templates it can be used then by
	        {{#invoke:Coordinates|kmlTitle|Some title for geohack}}
	or respectively (as is)
	        {{#invoke:Coordinates/kml|kmlTitle|Some title for geohack}}
	]=]
	
	
	
	coordinates.utf8max2bytes = function ( adjust )
	    -- Save characters > 0x7FF by simplification
	    -- Precondition:
	    --     adjust  -- string to be adjusted
	    -- Postcondition:
	    --     returns  string
	    local r = adjust
	    local lucky, translate = pcall( mw.loadData,
	                                    "Module:Sort/utf8max2bytes" )
	    if type( translate ) == "table" then
	        local Sort
	        lucky, Sort = pcall( require, "Module:Sort" )
	        if type( Sort ) == "table" and
	           type( Sort.Sort ) == "function" then
	           Sort = Sort.Sort()
	            if type( Sort ) == "table" and
	               type( Sort.lex ) == "function" then
	                local s = Sort.lex( r, translate )
	                if type( s ) == "string" then
	                    r = s
	                end
	            end
	        end
	    end
	    return r
	end -- coordinates.utf8max2bytes()
	
	
	
	coordinates._kmlTitle = function ( adjust )
	    -- Hack kmlexport title as of 2018 UTF-8 limitation
	    -- Precondition:
	    --     adjust  -- string to be adjusted
	    -- Postcondition:
	    --     returns  string
	    local pattern = mw.ustring.char( 91, 0x0800, 45, 0x7FFFF, 93 )
	    local r = mw.text.decode( adjust, true )
	    r = mw.text.trim( r )
	    if mw.ustring.find( r, pattern ) then
	        r = coordinates.utf8max2bytes( r )
	        r = mw.ustring.gsub( r, pattern, "" )
	    end
	    if mw.text.trim( r ) == "" then
	        -- fall back to original string if all characters removed
	        r = adjust
	    end
	    return r
	end -- coordinates._kmlTitle()
	
	
	
	coordinates.kmlTitle = function ( frame )
	    -- #invoke to adjust kmlexport title
	    local r = frame.args[ 1 ]
	    if r and r ~= "" then
	        r = coordinates._kmlTitle( r )
	    end
	    return r or ""
	end -- coordinates.kmlTitle
	
	
	
	return coordinates