shapeResult[nval].textEC=(shapePos[4] or shapeResult[nval].shapeColor or 'darkgrey')
elseif shapePos[2]=='photo-panel' then
shapeResult[nval].textEW='' -- width
shapeResult[nval].textEC=shapeResult[nval].textCL
else
shapeResult[nval].textEW='' -- width
shapeResult[nval].textEC='grey'-- colour
end
shapeResult[nval].textES='solid'
if argval=='H' then return dotResult end
--Assign dot values
local dotItem={}
dotItem.group=nval
dotItem.code=nval
dotItem.posType=shapePos[2] or 'nil'
if (shapePos[2] or '') =='photo-panel' then
dotItem.ppwidth= tonumber(string.match((shapePos[4] or '110'),"%d+"))
dotItem.ppheight= tonumber(string.match((shapePos[5] or '48'),"%d+") )
dotItem.photowidth=round(tonumber(string.match((shapePos[3] or '1.3'),"[%.%-?%d]+")) * dotItem.ppheight+1,0)
dotItem.photoImage=args['mark-image'..argval]
--debugmsg('photo-panel, '..shapePos[2]..', 3='..shapePos[3]..', 4='..shapePos[4]..', 5='..(shapePos[5] or '(48')..'photo') =='mark-line' then
local x=tonumber(argval or '1')
dotItem.markDest=shapePos[6] or tostring(x-1)
dotItem.mlWidth= tonumber(string.match((shapePos[3] or '1'),"%d+"))
dotItem.mlStyle= shapePos[4] or 'solid'
dotItem.mlGap=tonumber(string.match((shapePos[5] or '0'),"[%d]+"))
shapeResult[nval].textEC=shapeResult[nval].outlineColor or 'darkgrey'
end
if args['mark-coord'..argval] then
itemTab=splitItem(convertCoordsTrad (args['mark-coord'..argval]),2)
dotItem.lat=tonumber(string.match(itemTab[1],"[%.%-?%d]+")) or 0
dotItem.lon=tonumber(string.match(itemTab[2],"[%.%-?%d]+")) or 0
else
dotItem.lat=tonumber(string.match(args['mark-lat'..argval],"[%.%-?%d]+")) or 0
dotItem.lon=tonumber(string.match(args['mark-lon'..argval],"[%.%-?%d]+")) or 0
end
if args['dateline'..argval] and (args['dateline'..argval]=='1' or args['dateline'..argval]=='-1') then
dotItem.lon=dotItem.lon+(tonumber(args['dateline'..argval] ) *360)
end
maplist.lon=dotItem.lon
maplist.lat=dotItem.lat
dotItem.gridx, dotItem.gridy = maptogrid(maplist,1)  
local item=args['mark-title'..argval] or '' -- sort out the caption, wikilink and plaintext tooltip items from dotLink
if item==* then dotItem.param1='nomap nolist' item=* end
dotItem.dotLink=item
if item ~= '' then
item=stripdivs(item)
dotItem.title=delink({item})
local linkstart= string.find(item,'',1,true) -- use true to ensure a plain search (no pattern)
if linkstart then
dotItem.dlink=delink({string.sub(item,linkstart,string.find(item,'',1,true)+1),wikilinks='target'})
else dotItem.dlink=''
end
else
dotItem.dlink=''
dotItem.title=''
end
if autoDotTag=='n' then item=nval
elseif autoDotTag=='l' then item=string.char(64+tonumber(nval))
else item='' end
dotItem.dotTag = args['numbered'..argval] or item
if shapePos[2]=='n-line' and (args['label'..argval] or args['label'..argval]=='') then
if dotItem.dlink =='' then
item=dotItem.dotTag..' '..args['label'..argval]
else
item=''..dotItem.dotTag..' '..args['label'..argval]
end
else item=(args['label'..argval] or '') end
if args['labela'..argval] then item = item..'^'..args['labela'..argval] end
if args['labelb'..argval] then item = item..'^'..args['labelb'..argval] end
local a='' for c in item:gmatch('.') do a=a..(c:gsub('%^','
') or c) end
dotItem.labelText = a -- convert hats to line breaks
if argval=='' then item = (args['label-offset-x']) or (args.ldx) or '0'
else item=args['label-offset-x'..argval] or args['ldx'..argval] or args['label-offset-xD'] or args.ldxD or args['label-offset-x1'] or args.ldx1 or '0'
end
dotItem.dx=tonumber(string.match(item,"[%.%-?%d]+"))
if argval=='' then item = (args['label-offset-y']) or (args.ldy) or '0'
else item=args['label-offset-y'..argval] or args['ldy'..argval] or args['label-offset-yD'] or args.ldyD or args['label-offset-y1'] or args.ldy1 or '0'
end
dotItem.dy=tonumber(string.match(item,"[%.%-?%d]+"))
dotItem.labelPos=shapePos[1]
if args['mark-image'..argval] then dotItem.imageName= args['mark-image'..argval] end
dotItem.info=args['mark-description'..argval] or ''
table.insert(dotResult,1,dotItem) -- add to start of list, so they are in reverese order for displaying
return dotResult
end  
local function tradstyleParseShapes(args,dotTable,dotmax)
local sgNumbers,sgSortable={},{}
for argindex=1,dotmax do -- build a list of all the numbered coords or lat,lons that have been used
local x=tostring(argindex)
if args['mark-coord'..x] or (args['mark-lat'..x] and args['mark-lon'..x]) then
sgNumbers[x]=x -- add it to the list
end
end
for indx,sgnum in pairs(sgNumbers) do table.insert(sgSortable,sgnum) end
table.sort(sgSortable,lessthan) -- put the list in a sortable form TODO this must be possible in a single list!
if args['mark-coord'] or (args['mark-lat'] and args['mark-lon']) then table.insert(sgSortable,'0') end -- add it to the end of the list
local default={} default.D={}
local dotResult={}
for k,sgnum in pairs(sgSortable) do -- work through the sorted list, parsing each set of shapes in turn, from 1 upwards
shapeList[sgnum]={}
dotTable=assignTradstyleShape(shapeList,default,dotTable,args,sgnum)
end
dotTable=assignTradstyleShape(shapeList,default,dotTable,args,'H') -- construct an extra highlight shapeitem
return dotTable
end  
local function checkfortooltip (title,dx,dy,dotlabel,dlink,nolabel) -- returns tlink if available, and dlink, if needed and tshape=true if shape needed
local tshape,tlink = false,""
if dlink~='' and not nolabel then tlink=dlink end
if (tlink=="" or nolabel) and title~="" then tshape=true end -- tshape flags True if title is wanted for shape
if (not (dx==0 or dy==0) or dotlabel==*) and title~=* then tshape=true end -- add tooltip to shape if its number has moved
return tshape,tlink
end  
local function tshift(angle) -- adjustment to place text near the centre of a triangle, shifted to allow rotation of triangle shape
local x=tonumber(string.match(angle,"%-?%d+"))
if x<0 then x=360+x end -- set to a single degree direction, 0 to 360
if x>359 then return 0,0 end
-- shift the centre of the triangle based on rotation value
if x <=40 or x>=320 then return -0.17,0 -- triangle up= -shiftv
elseif x>=140 and x<=220 then return 0.17,0 --triangle down= +shiftv
elseif x >220 then return 0,-0.17 --triangle = -shifth
elseif x >40 then return 0,0.22 --triangle = +shifth
end
return 0,0
end  
local function makeTriangle(result,row,shape,outline,tlink)
local w,h,r=getsize(shape.shapeSize)
if outline then
local p=tonumber(string.match(shape.outlineWidth,"[%.%d]+"))
w=w+p*2
h=h+p*2
end
table.insert(result,'<div ')
if tlink then
table.insert(result,' title="'..row.title..'" ')
end
table.insert(result,'>')
else
table.insert(result,'; -bottom: '..tostring(h)..'px solid '..getColor(shape.shapeColor).. '">')
end
table.insert(result,'</div>')
end  
local function makeSquare(result,row,shape,tshape)
local w,h,r=getsize(shape.shapeSize)
if shape.shape=='square' then h=w end -- squares are always square!. box can stretch
local div=mw.html.create ('div')
if tshape then -- Add tooltip if needed
div:attr('title',row.title)
end
div:css('position', "absolute")
if shape.outlineWidth ~= "" then
div:css('outline', shape.outlineWidth.." "..shape.outlineStyle.." "..getColor(shape.outlineColor))
end
if shape.shapeAngle ~= "0deg" then
div:css('transform',"rotate("..shape.shapeAngle..")")
end
if r~=0 then div:css('-radius',tostring(r).."px") end
if shape.shape=='panel' then
div:css('top', tostring(row.gridy).."px")
div:css('', tostring(row.gridx).."px")
else
div:css('top', tostring(row.gridy-h/2).."px")
div:css('', tostring(row.gridx-w/2).."px")
end
div:css('width', tostring(w).."px")
div:css('height', tostring(h).."px")
div:css('background-color', getColor(shape.shapeColor) )
div:css('color', 'inherit')
table.insert(result,tostring(div))
end  
local function makeCircle(result,row,shape,tshape)
local w,h,r=getsize(shape.shapeSize) -- = width,height,rounding
if shape.shape=='circle' then h=w end -- circles are always round. ellipse can stretch
local div=mw.html.create ('div')
if tshape then -- Add tooltip if needed
div:attr('title',row.title)
end