Modulo:Coord/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
aggiornato alla versione in campo |
con Wikidata aggiunta selezione dei claim con rank preferred se presenti |
||
Riga 51:
-- la parentesi () extra serve per non ritornare anche il gsub.count
return (string.format("%f", num):gsub("%.?0+$", ""))
end
-- Ritorna i claim con il rank richiesto
local function filterRankValue(claims, rank)
local ret = {}
for i, claim in pairs(claims) do
if claim.rank == rank then
table.insert(ret, claim)
end
end
return ret
end
Riga 56 ⟶ 67:
-- o nil nel caso non siano presenti
local function getWikidataCoordinates()
local entity, claims, value, lat, long
entity = mw.wikibase.getEntityObject()
if entity and entity.claims and entity.claims.P625 and #entity.claims.P625 > 0 then
if
end
lat = round(value.latitude, 6)▼
if #claims > 0 and claims[1].mainsnak.snaktype == "value" then
long = round(value.longitude, 6)▼
value = claims[1].mainsnak.datavalue.value
▲ lat = round(value.latitude, 6)
▲ long = round(value.longitude, 6)
end
end
|