Documentação do módulo[ver] [editar] [histórico] [purgar]


Descrição

Este Módulo tem funções auxiliares para criar infocaixas {{Info/Cratera}} e {{Info/Galáxia}}.

Uso

Outra documentação:

local localdata = require "Módulo:Infobox/Localdata"
local general = require "Módulo:Infobox/Funções"
local geolocalisation = require "Módulo:Infobox/Funções/Geolocalização"
local wd = require "Módulo:Infobox/Wikidata"
local wdGlobe = require "Módulo:Wikidata/Globes"
local convert = require "Módulo:Conversão"

local function colongitude()
    local value = function(localdata)
        local posicao = localdata['colon']
        if not posicao then
           return nil
        end
        posicao = posicao .. '° no nascer do Sol'
        return posicao
    end
 
    return {type = 'row', label = '[[Coordenadas selenográficas|Colongitude]]', value = value }
end

local function getMapPoint() -- tipo de ponto no mapa
    local bodytype = localdata['tipo'] or wd.formatStatements{property = 'P31', entity = localdata.item, displayformat = "raw", numval = 1}  
    local points = {
    -- para parâmetro local |type =
        ["[[lacus]]"] = "lago",
  
    -- id wikidata
        Q3215913 = "lago",
    }
  
    return points[mw.ustring.lower(bodytype or '')] or 'default'
end

local function age()
    local s = wd.formatAndCat{entity = localdata.item, property = "P571", conjtype= "or"}
    if s then
        return "ele tem " .. s
    end
end

local function globe()
    if localdata.globe then
        return localdata.globe
    end
    local p376 = wd.formatStatements{property = 'P376', entity = localdata.item, displayformat = "raw"}
    if p376 then
        return wdGlobe[ "http://www.wikidata.org/entity/" .. p376 ]
    end
end

local function coordenadasLocais(localdata)
    local value = function(localdata)
        local posicao = localdata['coordenadas']
        if not posicao and localdata['latG'] then
            posicao = localdata['latG'] .. '° ' .. localdata['latP'] .. ', ' .. localdata['lonG'] .. '° ' .. localdata['lonP']
    end
        return posicao
    end
 
    return geolocalisation.coordenadas{ globe = globe(), coordenadas = posicao  }

end

return {
    maincolor = '#FFDEAD',
    parts = {
        general.title(),
        general.mainimage('!Artigos de geografia sem imagens'), --ajustar upright
        {type = 'table', title = 'Geografia', rows = {
            {type = 'row', label = 'Nome internacional', value = 'nome internacional', property = 'P1448'}, -- nome dado pela UAI
            {type = 'row', label = 'Astro', value = {'astro', 'planeta'}, wikidata = {property = 'P376'}}, -- corpos astronomicos ou se recupera local ou algures
            {type = 'row', label = 'Continente', value = 'continente', property = 'P30'}, -- dentro do caso de um planeta de tipo terrestre únicamente
            {type = 'row', label = 'País', plurallabel = 'País', value = {'país', 'país1', 'país2', 'país3'}, property = 'P17'}, -- o ou os países ou se recupera de facto a estrutura se ela se encontra na Terra
            {type = 'row', label = 'Subdivisão administrativa', plurallabel = 'Subdivisões administrativas', value = {'unidade_admin', 'país1_nome_subdivisão1', 'país1_nome_subdivisão2', 'país1_nome_subdivisão3'}, property = 'P131'}, -- unidade administrativa minima para as estruturas terrestres
            {type = 'row', label = 'Região', plurallabel = 'Regiões', value = 'região', property = 'P706'}, -- regiões geograficas sem quadrângulo
            {type = 'row', label = 'Cordilheira', value = 'cordilheira', property = 'P170'}, -- dentro do caso de uma montanha ou uma cratera
        coordenadasLocais,
--            geolocalisation.coordenadas{ globe = globe()  },
            {type = 'row', label = 'Altitude', value = function ( localdata ) return convert.displayvalue( localdata['altitude'] or localdata['pculminante'], 'metro', {showunit = 'short'} ) end, property = 'P2044'},
            {type = 'row', label = 'Raio', value = 'raio', property = 'P2120'},
            {type = 'row', label = 'Diâmetro', value = 'diâmetro', property = 'P2386'}, -- propriedade a mostrar prioritario no raio
            {type = 'row', label = 'Comprimento', value = function ( localdata ) return convert.displayvalue( localdata['comprimento'], 'km', {showunit = 'short'} ) end, property = 'P2043'},
            {type = 'row', label = 'Largura', value = function ( localdata ) return convert.displayvalue( localdata['largura'], 'km', {showunit = 'short'} ) end, property = 'P2049'},
            {type = 'row', label = 'Inclinação', value = 'inclinação', property = 'P4184'},
            {type = 'row', label = 'Superfície', value = function ( localdata ) return convert.displayvalue( localdata['superfície'], 'squre kilometer', {showunit = 'short'} ) end, wikidata = {property = 'P2046', targetunit = 'square kilometer'}},
            {type = 'row', label = 'Altura', value = function ( localdata ) return convert.displayvalue( localdata['altura'], 'm', {showunit = 'short'} ) end, wikidata = {property = 'P2048', targetunit = 'm'}},
            {type = 'row', label = '[[Profundidade de cratera|Profundidade]]', value = function ( localdata ) return convert.displayvalue( localdata['profundidade'], 'm', {showunit = 'short'} ) end, wikidata = {property = 'P4511', targetunit = 'm'}},
            colongitude,
            {type = 'row', label = 'Dimensões da caldeira', value = function ( localdata ) return convert.displayvalue( localdata['dcaldeira'], 'm', {showunit = 'short'} ) end },-- para um vulcão
            {type = 'row', label = 'Profundidade da caldeira', value = function ( localdata ) return convert.displayvalue( localdata['pcaldeira'], 'metro', {showunit = 'short'} ) end},-- para um vulcão
            {
                type = 'row', --quadrangles (Q7268308) indicados com a propriedade ligada
                label = 'Quadrângulo',
                plurallabel = 'Quadrângulos',
                value = {'quadrangle', 'quadrângulo'},
                wikidata = {
                    property = 'P276',
                    conjtype = 'and',
                    labelformat = function(entity)
                        local label = wd.getLabel(entity)
                        if not label then
                            return nil
                        end
                        label = mw.ustring.gsub(label, "quadrângulo de", "")
                        return label
                    end,
                    condition = function(claim) -- verificado que se encontra num quadrângulo
                        local v = wd.getMainId(claim)
                        return wd.isInstance("Q7268308", v, 1)
                    end,
                }
            },
        }},
        {type = 'table', title = 'Geologia', rows = {
            {type = 'row', label = 'Época de formação', value = 'idade', wikidata = age()},
            {type = 'row', label = 'Tipo', plurallabel = 'Tipos', value = 'tipo', property = 'P31'},
            {type = 'row', label = 'Natureza', value = 'natureza'}, -- obsoleto mas mantido na propriedade tipo
            {type = 'row', label = 'Atividade', value = 'atividade'},
        }},
            {type = 'table', title = 'Impactor', rows = {
            {type = 'row', label = 'Natureza', value = 'impactor natural'},
            {type = 'row', label = 'Diâmetro', value = 'impactor diamêtro'},
            {type = 'row', label = 'Velocidade', value = 'impactor velocidade'},
            {type = 'row', label = 'Ângulo', value = 'impactor ângulo'},
            {type = 'row', label = 'Densidade', value = 'impactor densidade'},
        }},
            {type = 'table', title = 'Etiqueta', rows = {
            {type = 'row', label = 'Natureza', value = 'etiqueta natureza'},
            {type = 'row', label = 'Densidade', value = 'etiqueta densidade'},
        }},
        {type = 'table', title = 'Exploração', rows = {
            {type = 'row', label = 'Descobridor', plurallabel = 'Descobridores', value = 'descobridor', property = 'P61'},
            {type = 'row', label = 'Data de descoberta', value = 'data', property = 'P575'},
            {type = 'row', label = 'Epónimo', value = {'epónimo', 'epônimo', 'eponym'}, property = 'P138'}
        }},
        geolocalisation.geoloc{ pointtype = getMapPoint(), globe = globe() },
    }
}