Bureaucrats, Moderators (CommentStreams), Interface administrators, Push subscription managers, Suppressors, Administrators
12,626
edits
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
function p.getMapData(frame) | function p.getMapData(frame) | ||
local saintName = frame.args.saintName or frame:getParent().args.saintName | |||
local result = {} | local result = {} | ||
local queries = { | local queries = { | ||
| Line 12: | Line 13: | ||
} | } | ||
for _, q in ipairs(queries) do | for _, q in ipairs(queries) do | ||
local query = '{{#cargo_query:tables=Saints|fields=' .. q.field .. '=Coordinates,' .. q.label .. '=Label|where=SaintName="' . | local query = '{{#cargo_query:tables=Saints|fields=' .. q.field .. '=Coordinates,' .. q.label .. '=Label|where=SaintName="' .. saintName .. '" AND ' .. q.field .. ' IS NOT NULL AND ' .. q.label .. ' IS NOT NULL|format=template|template=SaintMapPoint|default=}}' | ||
local queryResult = frame:preprocess(query) | local queryResult = frame:preprocess(query) | ||
if queryResult and queryResult ~= '' then | if queryResult and queryResult ~= '' then | ||
if q.offset then | if q.offset then | ||
local lat, lon, label = queryResult:match('^(%-?%d+%.%d+),(%-?%d+%.%d+)~(.+)$') | |||
local lat, lon = queryResult:match('^(%-?%d+%.%d+),(%-?%d+%.%d+)~(.+)$') | |||
if lat and lon then | if lat and lon then | ||
lat = tonumber(lat) + 0.0001 | lat = tonumber(lat) + 0.0001 | ||
queryResult = string.format('%.6f,%.6f~%s', lat, tonumber(lon), | queryResult = string.format('%.6f,%.6f~%s', lat, tonumber(lon), label) | ||
end | end | ||
end | end | ||