Module:Infobox mapframe/sandbox: Difference between revisions

Content deleted Content added
use wikidataId param
generalise "has wikidata property" checking
Line 16:
end
 
function hasWikidataCoordshasWikidataProperty(item_id, property_id)
if not(item_id) or not(mw.wikibase.isValidEntityId(item_id)) or not(mw.wikibase.entityExists(item_id)) then
return false
end
local coordStatementsstatements = mw.wikibase.getBestStatements(item_id, 'P625'property_id)
if not coordStatementsstatements or #coordStatementsstatements == 0 then
return false
end
Line 27:
end
 
function hasWikidataOSMrelation(item_id)
if not(item_id) or not(mw.wikibase.isValidEntityId(item_id)) or not(mw.wikibase.entityExists(item_id)) then
return false
end
local OSMRelationStatements = mw.wikibase.getBestStatements(item_id, 'P402')
if not OSMRelationStatements or #OSMRelationStatements == 0 then
return false
end
return true
end
 
function getZoom(length_km)
Line 62 ⟶ 52:
 
-- Require wikidata item with coords, so something will be centred somewhere
local hasCoordinates = hasWikidataProperty(wikidataId, 'P625') -- P625 = coordinate ___location
if not hasWikidataCoords(wikidataId) then
if not hasCoordinates then
return ''
end
Line 102 ⟶ 93:
 
-- Point
local hasOsmRelationId = hasWikidataProperty(wikidataId, 'P402') -- P402 is OSM relation ID
if not hasWikidataOSMrelation(wikidataId) then
if not hasOsmRelationId then
args.type3 = "point"
if config.id then args.id3 = config.id end