Moduuli:Mapframe

Wikipediasta
Siirry navigaatioon Siirry hakuun

Tämän moduulin ohjeistuksen voi tehdä sivulle Moduuli:Mapframe/ohje

local mapframe = {}


function mapframe.is_osm(frame)
	entity=frame.args[1]
	local osm = mw.loadData 'module:mapframe/osmpoints'
     if osm.is_osm[entity] then
   	 return true
   else
     return false
   end
end

local hemisphereMultipliers = {
	longitude = { W = -1, w = -1, E = 1, e = 1 },
	latitude = { S = -1, s = -1, N = 1, n = 1 }
}

-- Kopioitu sivulta https://fr.wikipedia.org/wiki/Module:Location_map
function mapframe.decdeg(degrees, minutes, seconds, hemisphere, decimal, direction)
	if not degrees then
		if not decimal then
			error('No value was provided for ' .. direction, 2)
		end
		local retval = tonumber(decimal)
		if retval then
			return retval
		end
		error('The value "' .. decimal .. '" provided for ' .. direction .. ' is not valid', 2)
	end
	decimal = tonumber(degrees)
	if not decimal then
		error('The degree value "' .. degrees .. '" provided for ' .. direction .. ' is not valid', 2)
	end
	if minutes and not tonumber(minutes) then
		error('The minute value "' .. minutes .. '" provided for ' .. direction .. ' is not valid', 2)
	end
	if seconds and not tonumber(seconds) then
		error('The second value "' .. seconds .. '" provided for ' .. direction .. ' is not valid', 2)
	end
	decimal = decimal + (minutes or 0)/60 + (seconds or 0)/3600
	if hemisphere then
		local multiplier = hemisphereMultipliers[direction][hemisphere]
		if not multiplier then
			error('The hemisphere "' .. hemisphere .. '" provided for ' .. direction .. ' is not valid', 2)
		end
		decimal = decimal * multiplier
	end
	return decimal
end

return mapframe