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 getZoom(value, unit)
local length_km
if unit == 'km' then
length_km = tonumber(value)
elseif unit == 'mi' then
length_km = tonumber(value)*1.609344
elseif unit == 'km2' then
length_km = math.sqrt(tonumber(value))
elseif unit == 'mi2' then
length_km = math.sqrt(tonumber(value))*1.609344
end
-- max for zoom 2 is 6400km, for zoom 3 is 3200km, for zoom 4 is 1600km, etc
local zoom = math.floor(8 - (math.log10(length_km) - 2)/(math.log10(2)))
-- limit to values below 17
zoom = math.min(17, zoom)
-- take off 1 when calculated from area, to account for unusual shapes
if unit == 'km2' or unit == 'mi2' then
zoom = zoom - 1
end
-- minimum value is 1
return math.max(1, zoom)
end
 
function shouldAutoRun(frame)
-- Check if should be running
local explicitlyOnpargs = yesno(mw.text.trim(frame.getParent(frame).args.mapframe or "")) -- true of false or nil
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') or config.coordinates or config.coord
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:
-- Calculate zoom from length or area (converted to km or km2)
if local zoom = config.length_km thenzoom
if not zoom then
args.zoom = getZoom(config.length_km, 'km')
-- Calculate zoom from length or area (converted to km or km2)
elseif config.length_mi then
-- Zoom so that length or area is completely included in mapframe
args.zoom = getZoom(config.length_mi, 'mi')
local getZoom = require('Module:Infobox dim')._zoom
elseif config.area_km2 then
args. zoom = getZoom({length_km=config.area_km2length_km, 'km2')length_mi=config.length_mi,
width_km=config.width_km, width_mi=config.width_mi,
elseif config.area_mi2 then
args.zoom area_km2=config.area_km2, getZoom(area_mi2=config.area_mi2, 'mi2')
area_ha=config.area_ha, area_acre=config.area_acre,
else
type=config.type, population=config.population,
args.zoom = config.zoom or DEFAULT_ZOOM
viewport_px=math.min(args["frame-width"],args["frame-height"])})
end
end
args.zoom = zoom or DEFAULT_ZOOM
 
-- Use OSM relation ID if available; otherwise use geoshape if that is available
-- Conditionals: whether point, geomask should be shown
-- (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;
 
if config.point == "on" then
-- 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 config.pointpointValue == "none"false then
shouldShowPointMarker = false
else
shouldShowPointMarker = not(hasOsmRelationIdwikidataProvidesGeo) or (config.marker and config.marker ~= 'none') or (config.coordinatesmarkerValue or config.coord)
end
 
local shouldShowShape = config.shape ~= 'none'
-- 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'
 
local shouldShowLine = config.line ~= 'none'
-- 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 and true or false -- Useby shapes/linesdefault, based onif wikidata idis supplied, ifuse there is onewikidata
-- 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 and ,true or false)
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 shouldShowShapenot suppressShape) then
args["type"..argNumber] = shapeType
if hasGeoshape and not hasOsmRelationId then
if config.id then args["id"..argNumber] = config.id end
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 shouldShowLinenot suppressLine) then
args["type"..argNumber] = "line"
if hasGeoshape and not hasOsmRelationId then
if config.id then args["id"..argNumber] = config.id end
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
"https://tamilar.wiki/w/Module:Infobox_mapframe" இலிருந்து மீள்விக்கப்பட்டது