Module:Sandbox/Adamw/Maki test
Module documentation
[create]
local p = {} --p stands for package
p.icons = {
"aerialway",
"airfield",
"airport",
"alcohol-shop",
"art-gallery",
"bakery",
"bank",
"bar",
"baseball",
"basketball",
"beer",
"bicycle",
"building",
"bus",
"cafe",
"campsite",
"car",
"cemetery",
"cinema",
"circle-stroked",
"circle",
"city",
"clothing-store",
"college",
"commercial",
"cricket",
"cross",
"dam",
"danger",
"dentist",
"dog-park",
"embassy",
"entrance",
"farm",
"fast-food",
"ferry",
"fire-station",
"fuel",
"garden",
"gift",
"golf",
"grocery",
"hairdresser",
"harbor",
"heart",
"heliport",
"hospital",
"ice-cream",
"land-use",
"laundry",
"library",
"lighthouse",
"lodging",
"logging",
"marker-stroked",
"marker",
"mobilephone",
"monument",
"museum",
"music",
"park",
"parking-garage",
"parking",
"pharmacy",
"pitch",
"place-of-worship",
"playground",
"police",
"post",
"prison",
"rail-light",
"rail-metro",
"rail",
"religious-christian",
"religious-jewish",
"religious-muslim",
"restaurant",
"roadblock",
"rocket",
"school",
"scooter",
"shop",
"skiing",
"slaughterhouse",
"soccer",
"square-stroked",
"square",
"star-stroked",
"star",
"suitcase",
"swimming",
"telephone",
"tennis",
"theatre",
"town-hall",
"town",
"triangle-stroked",
"triangle",
"village",
"warehouse",
"waste-basket",
"water",
"wetland",
"zoo",
}
for i = 1, 99 do
table.insert( p.icons, "-number" )
end
for i = 1, 26 do
table.insert( p.icons, "-letter" )
end
p.step = 0.05
p.columnCount = 30
function p.grid( frame )
return frame:preprocess(
[[
<mapframe text="Maki Icons" width="550" height="500" align="right" zoom="10" longitude="0.28" latitude="-0.22">
{
"type": "FeatureCollection",
"features": [
]]
..
table.concat(p.coordGrid(), ",\n")
..
[[
]
}
</mapframe>
]]
)
end
function p.coordGrid()
local outputTable = {}
local iconIndex = 1
-- Stop iterating rows when we run out of icons.
for y = 0, 999, p.step do
for x = 0, p.columnCount * p.step, p.step do
local icon = p.icons[iconIndex]
if not icon then
return outputTable
end
-- Positive Y is up, so negate to read top-to-bottom.
table.insert(outputTable, ' { "type": "Feature", "geometry": { "type":"Point", "coordinates":['..x..', -'..y..'] }, "properties": { "title":"Maki Icon: '..icon..'", "marker-symbol":"'..icon..'"} }')
iconIndex = iconIndex + 1
end
end
end
function p.list ( frame )
local outputList = '{|class="wikitable" \n |+ Maki icons \n |- \n ! Icon !! Name \n'
for key,icon in pairs(p.icons) do
outputList = outputList..' |- \n |[[File:Maki7-'..icon..'.svg|18px]] || ' ..icon..'\n'
end
return outputList..'|}'
end
return p