Module:OSM Location map and Module:OSM Location map/sandbox: Difference between pages

(Difference between pages)
Jump to navigation Jump to search
Page 1
Page 2
imported>RobinLeicester
improve lessthan sorts to group non-numeric autocaption entries
 
imported>RobinLeicester
improved lessthan for sorting
 
Line 423: Line 423:
end
end


local function maptogrid(t,r)
local function maptogrid(t,r,test)
--[[ converts mercator projection longitude and latitude coordinates to x and y pixel coordinates, within a frame of given size, centre coordinates and zoom level.
--[[ converts mercator projection longitude and latitude coordinates to x and y pixel coordinates, within a frame of given size, centre coordinates and zoom level.
t is a table of named indices: {lon, lat, lonbase, latbase, width, height, zoom}  
t is a table of named indices: {lon, lat, lonbase, latbase, width, height, zoom}  
Line 438: Line 438:
Convert lat and lat-base to meter-offsets from coord(0,0), subtract lat from latbase,
Convert lat and lat-base to meter-offsets from coord(0,0), subtract lat from latbase,
scale the resulting meter-offset to pixels, add it to height/2.
scale the resulting meter-offset to pixels, add it to height/2.
A correction factor '*(1-(0.075*(math.abs(t.latbase)/90) ) )' compensates for an error that seems to creep in towards  
A correction factor '*(1-(0.055*(t.latbase/90) ) )' compensates for an error that seems to creep in towards  
the edges of the map at higher latitudes. It was identified experimentally, and ensures a dot at the edge is  
the edges of the map at higher latitudes. It was identified experimentally, and ensures a dot at the edge is  
in the same place as if that location is positioned at the centre.
in the same place as if that location is positioned at the centre.
Line 1,292: Line 1,292:
         table.insert(result, comma .. mapSparql)
         table.insert(result, comma .. mapSparql)
         -- debugmsg('mapSparql = ' .. mapSparql)
         -- debugmsg('mapSparql = ' .. mapSparql)
        comma=', '
     end
     end
     if args['map-raw'] then
     if args['map-raw'] then