This module provides a thin object-style wrapper around osm_tile module methods.
osm_tile = require 'osm.tileobj'
local tile, err = osm_tile.new_from_uri('/mystyle1/18/233816/100256.png')
if err then
ngx.log(ngx.ERR, 'unable to create tile object: '..err)
end
if tile:is_inside_maps({'mystyle1', 'mystyle2'}) then
ngx.log(ngx.ERR, 'tile'..tile..' belongs to selected styles')
end
data, err = tile:get_tile()
if data then
ngx.header.content_type = tile.content_type
ngx.print(data)
return ngx.OK
end
syntax: tile, err = new_from_uri(uri, metatiles_dir?)
Returns new tile object with attributes:
- x, y, z (number): tile coordinates
- map (string): mapname
- ext (string): tile extension
- content_type (string): content_type (based on ext)
- is_vector (bool): true if given uri ends with '.mvt'
If something goes wrong, returns nil and error message.
metatiles_dir is the optional argument ('/var/lib/mod_tile' if not set)
syntax: is_inside = tile:is_inside_maps(maps)
Checks if tile.map contains in maps list.
syntax: is_inside = tile:is_inside_region(region)
where region is the region from osm_data module.
syntax: data, err = tile:get_tile()
Gets tile from metatile file.
syntax: ok = tile:check_integrity_xyzm(minz, maxz)
syntax: metatile = tile:xyz_to_metatile_filename()