-- label text can be autoaligned if x,y puts it or of the dot, or centered if above/below)
-- quote marks are not needed unless including commas within the label text
-- param1 is optional items separated by spaces, and can include [nolabel nolist nomap hemisphere+1 hemisphere-1]
-- info is free wikitext, to be used in the fullscreen dot box. (use dotpic to show a picture)  
---
local result={}
local count=1
local row = convertCoords (args["dot"..dotval]) -- swap in any values so they are csv lat and lon
row=fillCommas(row,4)
result.code=dotval -- store the parameter name as the id code
for item in string.gmatch(row,"[^,]+") do -- iterate through 'row', adding each csv item in turn, if present
if count==1 then --see if it is a number or a name
local pos= string.find(item,"%d+")
if pos == 1 then
result.group=string.lower(string.gsub(item,"%s+",""))
else
item=string.match(item,"(%w+)(.*)") -- ensure just a single word
result.group=sgNames[item]
end
elseif count==2 then
result.lat=tonumber(string.match(item,"[%.%-?%d]+")) or 0-- find the number, with no non-numeric stuff
elseif count==3 then
result.lon=tonumber(string.match(item,"[%.%-?%d]+")) or 0
elseif count==4 then
result.dotTag=item:match( "^%s*(.-)%s*$" ) or "" -- dotTag allows for internal spaces, but no commas
end
count=count+1
end
row, result.labelText= extractItem(args["dotlabel"..dotval])
result.labelText= string.gsub(result.labelText,"[%^]+","
") -- convert hats to line breaks
local item=splitItem(row,6)
result.labelPos=item[2] or ''
result.dx=tonumber(string.match(item[3] or '0',"[%.%-?%d]+")) or 0
result.dy=tonumber(string.match(item[4] or '0',"[%.%-?%d]+")) or 0
result.param1=string.lower(item[5] or '')
if string.find(result.param1,"hemisphere-1",1,true) then result.lon=result.lon-360
elseif string.find(result.param1,"hemisphere+1",1,true) then result.lon=result.lon+360
end
local txt = ''
if item[6] then -- ensure all info elements are included, including commas
count=1
local max=6
for t1 in string.gmatch(fillCommas(row,max),"[^,]+") do
if count>max then txt=txt..',' end
if count>=max then txt=txt..t1 end
count=count+1
end
end
result.info=txt
result.imageName = args['dotpic'..dotval]
-- Get first wikilinked item (if any) from the args.dotlink and set this plus the delinked text
local testx=args["dotlink"..dotval] or ''
result.dotLink=testx
if testx ~= '' then
testx=stripdivs(testx)
result.title=delink({ testx })
local linkstart= string.find(testx,'',1,true) -- use true to ensure a plain search (no pattern)
if linkstart then
result.dlink=delink( { string.sub(testx,linkstart,string.find(testx,'',1,true)+1),wikilinks='target' } )
else result.dlink=''
end
else
result.dlink=''
result.title=''
end
if args['dotfeature'..dotval] then
local item=splitItem(args['dotfeature'..dotval],6)
if (item[1] or '') =='photo-panel' then
result.ppwidth= tonumber(string.match((item[3] or '110'),"%d+")) -- panel width
result.ppheight= tonumber(string.match((item[4] or '48'),"%d+") ) --panel height
result.photowidth=round(tonumber(string.match((item[2] or '1.3'),"[%.%-?%d]+")) * result.ppheight+1,0) -- dimension to set image size
result.photoImage=result.imageName
result.posType='photo-panel'
elseif (item[1] or '') == 'mark-line' then
local x=tonumber(dotval or '0')
result.markDest=item[5] or tostring(x-1)
result.mlWidth= tonumber(string.match((item[2]) or '',"%d+") or '1')
result.mlStyle= item[3] or 'solid'
result.mlGap=tonumber(string.match((item[4] or ''),"[%d]+") or '0')
result.posType='mark-line'
-- debugmsg('making line for '..tostring(x)..'to '..tostring(result.markDest)..' with width '..tostring(result.mlWidth))
end
--debugmsg('photo-panel, '..shapePos[2]..', 3='..shapePos[3]..', 4='..shapePos[4]..', 5='..(shapePos[5] or '(48')..'photononexistant' end
if argVal=='H' and not args[argName..'H'] then argVal=highlightNum or '1' end
if argVal=='' then
return (args[argName] or args[alt] or (args[argName..'D']) or args[alt..'D'] or defVal) -- unnumbered args do not inherit from D or 1
else
return (args[argName..argVal]) or (args[alt..argVal]) or (args[argName..'D']) or (args[alt..'D']) or (args[argName..'1']) or (args[alt..'1']) or defVal
end
end  
local function assignTradstyleShape(shapeResult,default,dotResult,args,nval)
local item,itemTab
local autoDotTag=''
local shapeWidth,shapeHeight=0,0
local argval=nval -- to catch the unnumbered shape series
if argval=='0' then argval='' end
if nval=='H' then shapeResult.H={} end
item=string.lower(multiCheck(args,'shape',argval,'image'))
if string.find(item,'n-',0,true)==1 or string.find(item,'l-',0,true)==1 then
autoDotTag=string.sub(item,0,1)
item=string.sub(item,3)
end
if item == 'image' then
shapeResult[nval].shape = 'image:'
shapeResult[nval].shapeFile =multiCheck(args,'mark',argval,'Red pog.svg')
shapeWidth=-1
else shapeResult[nval].shape = item
end
item= multiCheck(args,'mark-size',argval,'')
local a,b,c= getsize(string.gsub(string.gsub(item,',','px')..'px','pxpx','px'))
if b==a and args['mark-dim'..argval] then
b= b / tonumber(string.match(args['mark-dim'..argval],"[%.%-?%d]+"))
end
shapeHeight=b/2
item=tostring(a)..'px'..tostring(b)..'px'..tostring(c)..'px'
shapeResult[nval].shapeSize= item
itemTab=splitItem(multiCheck(args,'shape-color',argval,'hard red'),2)
shapeResult[nval].shapeColor=itemTab[1] or 'hardred'
item=itemCheck(itemTab[2],'%') -- jump through the various opacity hoops and add to color if needed
if not item then item=itemCheck(args['shape-opacity'..argval],'%') end
if item and item~='0%' and item~='100%' then shapeResult[nval].shapeColor=shapeResult[nval].shapeColor..item end
shapeResult[nval].shapeAngle=itemCheck(multiCheck(args,'shape-angle',argval,'0'),'deg') or '0deg'
--sort out the outline entry
itemTab=splitItem(multiCheck(args,'shape-outline',argval,'transparent,0,100,solid'),4)
shapeResult[nval].outlineColor=itemTab[1] or 'dark grey'
shapeResult[nval].outlineWidth=itemCheck(itemTab[2],'px') or ''
if itemTab[3] and itemTab[3]~='100' and itemTab[3]~='0' then
shapeResult[nval].outlineColor=shapeResult[nval].outlineColor..itemCheck(itemTab[3],'%')
end
shapeResult[nval].outlineStyle=itemTab[4] or 'solid'
-- label size, background, outline
itemTab=splitItem( multiCheck(args,'label-size',argval,'12'),3)
shapeResult[nval].textSZ=itemCheck(itemTab[1],'px') or ''
if itemTab[2]=='outline' then
shapeResult[nval].textBG=itemTab[3] or 'transparent'
shapeResult[nval].textOL=''
elseif itemTab[3]=='outline' then
shapeResult[nval].textBG=itemTab[2] or 'transparent'
shapeResult[nval].textOL=''
else shapeResult[nval].textOL=''
shapeResult[nval].textBG=itemTab[2] or 'transparent'
end
if getColor(shapeResult[nval].textBG)==CTB['hardgrey'] and shapeResult[nval].textBG~='hardgrey' then shapeResult[nval].textBG= 'transparent' end
--label color etc
itemTab=splitItem(multiCheck(args,'label-color',argval, 'darkgrey','label-colour'),2)
shapeResult[nval].textCL=itemTab[1] or 'darkgrey'
if itemTab[2] and itemTab[2]~='0%' and itemTab[2]~='100%' then shapeResult[nval].textCL=shapeResult[nval].textCL..itemTab[2] end
shapeResult[nval].textSP=itemCheck( multiCheck(args,'label-spacing',argval,'0'),'px') -- sets letter-spacing in px
shapeResult[nval].textLH=itemCheck( multiCheck(args,'label-height',argval,'120'),'%') -- sets line height, 120% default
shapeResult[nval].textNG=itemCheck(multiCheck(args,'label-angle',argval,'0'),'deg')
--sgd=dotTag attributes
shapeResult[nval].tagSize=tostring(shapeHeight*1.5)..'px'
local c1,c2=checkColors(shapeResult[nval].shapeColor)
shapeResult[nval].tagColor=c2
shapeResult[nval].tagSpacer=''
shapeResult[nval].tagAngle='0deg'
-- sge extension line attributes
local shapePos=splitItem(multiCheck(args,'label-pos',argval,''),6)
if shapePos[2]=='with-line' or shapePos[2]=='n-line' then
shapeResult[nval].textEW=(shapePos[3] or '1')..'px' -- width
shapeResult[nval].textEC=(shapePos[4] or shapeResult[nval].shapeColor or 'darkgrey')
elseif shapePos[2]=='photo-panel' then
shapeResult[nval].textEW='' -- width