Module:ResourceMap

local p = {}

local UnrecognizedTypeLabel = 'not or wrongly specified'

local function getNodeTooltip( class ) local labels = mw.loadData('Module:ResourceMap/labels') -- try a cheaper lookup by full name local fullLookup = labels[class] if fullLookup ~= nil then return fullLookup end -- resort to a lookup by first word return labels[mw.text.split(class, ' ', true)[1]] or UnrecognizedTypeLabel end

function p.nodes( f ) local args = f:getParent.args local borderCoordTop = args.borderCoordTop local borderCoordBottom = args.borderCoordBottom local borderCoordLeft = args.borderCoordLeft local borderCoordRight = args.borderCoordRight local allNodes = {} for _, v in ipairs(args) do        if _ > 1 and #v > 0 then local info = mw.text.split(v, ', ', true) local resourceType = mw.text.trim(info[3]) local lat = tonumber(info[1]) local long = tonumber(info[2]) local customTitle = info[4] or '' local title = getNodeTooltip(resourceType) .. '&#10;lat ' .. lat .. ', lon ' .. long if customTitle ~= nil then title = title .. '&#10;' .. customTitle end local markerSize = args['marker ' .. resourceType] or 7 local top = 100 * ((lat - borderCoordTop) / (borderCoordBottom - borderCoordTop) - markerSize/(2*args.mapsize)) local left = 100 * ((long - borderCoordLeft) / (borderCoordRight - borderCoordLeft) - markerSize/(2*args.mapsize)) local html = ' ' if allNodes[resourceType] == nil then allNodes[resourceType] = { html } else table.insert(allNodes[resourceType], html) end end end

local html = '' for resourceType, nodes in pairs(allNodes) do html = html .. ' '   	html = html .. table.concat(nodes, '\n') html = html .. ' '	end return html end

return p