Modul:Wikidata/Formatters/globecoordinate

Z Wikipedie, otevřené encyklopedie
Jump to navigation Jump to search

Dokumentaci tohoto modulu lze vytvořit na stránce Modul:Wikidata/Formatters/globecoordinate/Dokumentace

require 'Modul:No globals'

local p = {}

function p.getRawValue(value, options)
	local lib = require 'Modul:Wikidata/lib'
	if not options.field then
		local GlobeCoordinate = require 'Modul:GlobeCoordinate'
		return GlobeCoordinate.newFromWikidataValue(value)
	elseif options.field == 'latitude' or options.field == 'longitude' or options.field == 'precision' or options.field == 'globe' then
		return value[options.field]
	else
		return error(lib.formatError('invalid-field', options.field))
	end
end

function p.formatValue(value, options)
	--local GlobeCoordinate = require 'Modul:GlobeCoordinate'
	--local _value = GlobeCoordinate.newFromWikidataValue(value)
	local Coord = require 'Modul:Souřadnice'
	local args = {
		value.latitude,
		value.longitude,
	}
	setmetatable(args, { __index = options })
	return Coord._renderCoordinates(args, mw.getCurrentFrame())
end

return p