A modult a Modul:kartographer/doc lapon tudod dokumentálni

local json = require("json")
local http = require("socket.http")

-- Function to make an HTTP GET request
local function http_get(url)
    local response_body = {}
    local res, code, response_headers = http.request{
        url = url,
        sink = ltn12.sink.table(response_body),
    }
    return table.concat(response_body), code
end

-- Function to fetch latitude and longitude coordinates from Wikidata
local function fetch_coordinates(entity_id)
    local url = "https://www.wikidata.org/wiki/Special:EntityData/" .. entity_id .. ".json"
    local response, code = http_get(url)
    if code == 200 then
        local data = json.decode(response)
        local entity = data["entities"][entity_id]
        if entity and entity["claims"] and entity["claims"]["P625"] then
            local coordinate_claim = entity["claims"]["P625"][1]
            if coordinate_claim and coordinate_claim["mainsnak"] and coordinate_claim["mainsnak"]["datavalue"] then
                local latitude = coordinate_claim["mainsnak"]["datavalue"]["value"]["latitude"]
                local longitude = coordinate_claim["mainsnak"]["datavalue"]["value"]["longitude"]
                return latitude, longitude
            end
        end
    end
    return nil, nil
end

-- Example usage
local entity_id = "Q42"  -- Example entity ID (replace with the desired Wikidata entity ID)
local latitude, longitude = fetch_coordinates(entity_id)

-- Function to generate Kartographer map template
local function generate_map_template(latitude, longitude)
    local map_template = "{{#invoke:Map/data|coord_map|coords=" .. latitude .. "|" .. longitude .. "|zoom=10}}"
    return map_template
end

-- Generate Kartographer map template using fetched coordinates
local map_template = generate_map_template(latitude, longitude)
print(map_template)  -- Print the map template, you can use it in your Wiktionary page