Module:Infobox mapframe: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
imported>Lingam "local mf = require('Module:Mapframe') local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local infoboxImage = require('Module:InfoboxImage').InfoboxImage -- Defaults local DEFAULT_FRAME_WIDTH = "270" local DEFAULT_FRAME_HEIGHT = "200" local DEFAULT_ZOOM = 10 local DEFAULT_GEOMASK_STROKE_WIDTH = "1" local DEFAULT_GEOMASK_STRO..."-இப்பெயரில் புதிய பக்கம் உருவாக்கப்பட்டுள்ளது |
imported>Kanags சிNo edit summary |
||
வரிசை 77:
end
function shouldAutoRun(frame)
-- Check if should be running
local
local explicitlyOn = yesno(mw.text.trim(pargs.mapframe or "")) -- true of false or nil
if pargs.coordinates == "{{{coordinates}}}" then explicitlyOn = false end
local onByDefault = (explicitlyOn == nil) and yesno(mw.text.trim(frame.args.onByDefault or ""), false) -- true or false
return explicitlyOn or onByDefault
வரி 177 ⟶ 158:
return frame:preprocess(mapframe)
end
--A list of types for objects that are too small to allow Kartographer to take over zoom
local tinyType = {
landmark=true,
railwaystation=true,
edu=true,
pass=true,
camera=true
}
p._main = function(_config)
வரி 182 ⟶ 172:
local config = trimArgs(_config)
-- allow alias for config.coord
config.coord = config.coord or config.coordinates
-- Require wikidata item, or specified coords
local wikidataId = config.id or mw.wikibase.getEntityIdForCurrentPage()
வரி 190 ⟶ 183:
-- Require coords (specified or from wikidata), so that map will be centred somewhere
-- (P625 = coordinate location)
local hasCoordinates = hasWikidataProperty(wikidataId, 'P625')
if not hasCoordinates then
return ''
வரி 214 ⟶ 207:
args["frame-long"] = config["frame-long"] or config["frame-longitude"] or ""
-- if zoom isn't specified from config:
if not zoom then
-- Calculate zoom from length or area (converted to km or km2)
-- Zoom so that length or area is completely included in mapframe
local getZoom = require('Module:Infobox dim')._zoom
width_km=config.width_km, width_mi=config.width_mi,
area_ha=config.area_ha, area_acre=config.area_acre,
type=config.type, population=config.population,
viewport_px=math.min(args["frame-width"],args["frame-height"])})
end
args.zoom = zoom or DEFAULT_ZOOM
-- Use OSM relation ID if available; otherwise use geoshape if that is available
-- (geoshape is required for defunct entities, which are outside OSM's scope)
local hasOsmRelationId = hasWikidataProperty(wikidataId, 'P402') -- P402 is OSM relation ID
local hasGeoshape = hasWikidataProperty(wikidataId, 'P3896') -- P3896 is geoshape
local wikidataProvidesGeo = hasOsmRelationId or hasGeoshape
local shouldShowPointMarker;
-- determine marker argument value, determine whether to show marker
local pointValue = config.point
if pointValue == 'none' then
pointValue = 'no'
end
pointValue = yesno(pointValue,'other')
local markerValue = config.marker
if markerValue == 'none' then
markerValue = 'no'
end
markerValue = yesno(markerValue,true)
if pointValue == true then
shouldShowPointMarker = true
elseif
shouldShowPointMarker = false
else
shouldShowPointMarker = not(
end
-- determine shape parameter value, determine whether to show or suppress shape
-- also determine whether to invert shape
local shapeValue = config.shape
if shapeValue == 'none' then
shapeValue = 'no'
end
shapeValue = yesno(shapeValue,'other')
local forceShape = shapeValue == true and wikidataProvidesGeo
local suppressShape = shapeValue == false
local shapeType = config.shape == 'inverse' and 'shape-inverse' or 'shape'
-- determine line parameter value, determine whether to show or suppress line
local lineValue = config.line
if lineValue == 'none' then
lineValue = 'no'
end
local lineValue = yesno(lineValue,'other')
local forceLine = lineValue == true and wikidataProvidesGeo
local suppressLine = lineValue == false
-- determine whether to use wikidata (independent of shape/line)
local maskItem
local useWikidata = wikidataId
-- But do not use wikidata when local coords are specified (and not turned off), unless explicitly set
if useWikidata and config.coord and shouldShowPointMarker then
useWikidata = yesno(config.wikidata
end
வரி 301 ⟶ 333:
end
end
-- if asking for shape or line from Wikidata
-- and if Wikidata actually has shape/line data (wikidataProvidesGeo=true)
-- and if no geomask
-- and if zoom not explicitly set
-- and if the object size inferred from its type is not too small
-- then let Kartographer "take over" zoom
if (forceLine or forceShape or (useWikidata and not (suppressShape and suppressLine)))
and wikidataProvidesGeo and not maskItem and not config.zoom
and not (config.type and tinyType[config.type]) then
args.zoom = nil
end
-- Keep track of arg numbering
வரி 339 ⟶ 383:
-- Shape (or shape-inverse)
if forceShape or (useWikidata and
args["type"..argNumber] = shapeType
if hasGeoshape and not hasOsmRelationId then
args["from"..argNumber] = string.sub( getStatementValue( getBestStatement(wikidataId, 'P3896') ), 6)
elseif config.id then
args["id"..argNumber] = config.id
end
args["stroke-width"..argNumber] = config["shape-stroke-width"] or config["stroke-width"] or DEFAULT_SHAPE_STROKE_WIDTH
args["stroke-color"..argNumber] = config["shape-stroke-color"] or config["shape-stroke-colour"] or config["stroke-color"] or config["stroke-colour"] or DEFAULT_SHAPE_STROKE_COLOR
வரி 350 ⟶ 398:
-- Line
if forceLine or (useWikidata and
args["type"..argNumber] = "line"
if hasGeoshape and not hasOsmRelationId then
args["from"..argNumber] = string.sub( getStatementValue( getBestStatement(wikidataId, 'P3896') ), 6)
elseif config.id then
args["id"..argNumber] = config.id
end
args["stroke-width"..argNumber] = config["line-stroke-width"] or config["stroke-width"] or DEFAULT_LINE_STROKE_WIDTH
args["stroke-color"..argNumber] = config["line-stroke-color"] or config["line-stroke-colour"] or config["stroke-color"] or config["stroke-colour"] or DEFAULT_LINE_STROKE_COLOR
| |||