Přeskočit na obsah

Modul:Wikidata/Formatters/globecoordinate

Tato stránka je zamčena
Z Wikipedie, otevřené encyklopedie
require 'Modul:No globals'

local p = {}

local lib = require 'Modul:Wikidata/lib'

function p.getRawValue(value, options)
	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,
	}
	local globe = lib.getItemIdFromURI(value.globe)
	if globe and globe ~= 'Q2' then
		args.globe = Coord.myGlobes[globe]
	end
	setmetatable(args, { __index = options })
	return Coord._renderCoordinates(args, mw.getCurrentFrame())
end

return p