|
2 | 2 |
|
3 | 3 | package.path = '../?.lua'
|
4 | 4 |
|
5 |
| -local osm_tile=require "osm.tile" |
| 5 | +local osm_tile = require "osm.tile" |
6 | 6 | local map = "data"
|
7 |
| -local uri = "/18/233816/100256.png" |
8 | 7 |
|
9 |
| -print('test with map data and uri:', uri) |
| 8 | +print('TESTS FOR osm_tile') |
10 | 9 |
|
11 |
| -local x, y, z = osm_tile.get_cordination(uri, "", "png") |
| 10 | +-- |
| 11 | +-- test wrong uri first |
| 12 | +-- |
| 13 | +local uri = '/data/-1/4294967295/4294967295.png' |
12 | 14 |
|
13 |
| -print('get_cordination test:') |
14 |
| -print('x', assert(tonumber(x), 233816)) |
15 |
| -print('y', assert(tonumber(y), 100256)) |
16 |
| -print('z', assert(tonumber(z), 18)) |
17 |
| -print('ok') |
| 15 | +print('TEST: get_mapname (wrong uri): uri='..uri) |
| 16 | +assert(osm_tile.get_mapname(uri, "png") == nil) |
| 17 | +print(' OK') |
| 18 | + |
| 19 | +print('TEST: tile coordinations: uri='..uri) |
| 20 | +local x, y, z = osm_tile.get_cordination(uri, map, "png") |
| 21 | +print('TEST: get_cordination') |
| 22 | +assert(tonumber(x) == nil) |
| 23 | +assert(tonumber(y) == nil) |
| 24 | +assert(tonumber(z) == nil) |
| 25 | +print(' OK') |
| 26 | + |
| 27 | +-- |
| 28 | +-- test good uri |
| 29 | +-- |
| 30 | +local uri = '/data/18/233816/100256.png' |
| 31 | +print('TEST: get_mapname (good uri): uri='..uri) |
| 32 | +assert(osm_tile.get_mapname(uri, "png") == map) |
| 33 | +print(' OK') |
| 34 | + |
| 35 | +print('TEST: tile coordinations: uri='..uri) |
| 36 | +local x, y, z = osm_tile.get_cordination(uri, map, "png") |
| 37 | +print('TEST: get_cordination') |
| 38 | +assert(tonumber(x) == 233816) |
| 39 | +assert(tonumber(y) == 100256) |
| 40 | +assert(tonumber(z) == 18) |
| 41 | +print(' OK') |
| 42 | + |
| 43 | +print('TEST: check_integrity_xyzm') |
18 | 44 | local minz=15
|
19 | 45 | local maxz=18
|
20 |
| -print('check_integrity_xyzm test:') |
21 | 46 | assert(osm_tile.check_integrity_xyzm(x, y, z, minz, maxz))
|
22 | 47 | maxz=17
|
23 |
| -assert(not(osm_tile.check_integrity_xyzm(x, y, z, minz, maxz))) |
24 |
| -print('ok') |
| 48 | +assert(osm_tile.check_integrity_xyzm(x, y, z, minz, maxz) == nil) |
| 49 | +print(' OK') |
25 | 50 |
|
26 |
| -print('xyz_to_metatile_filename test:') |
| 51 | +print('TEST: xyz_to_metatile_filename') |
27 | 52 | local tilefile = osm_tile.xyz_to_metatile_filename(x, y, z)
|
28 |
| -print(assert(tilefile, "18/49/152/23/90/128.meta")) |
29 |
| -print('ok') |
30 |
| -print('get_tile test:') |
| 53 | +assert(tilefile == "18/49/152/23/90/128.meta") |
| 54 | +print(' OK') |
| 55 | + |
| 56 | +print('TEST: get_tile') |
31 | 57 | local tilepath = "./"..map.."/"..tilefile
|
32 | 58 | local png, err = assert(osm_tile.get_tile(tilepath, x, y, z))
|
33 |
| -print('ok') |
34 |
| - |
| 59 | +assert(png) |
| 60 | +assert(err == nil) |
| 61 | +assert(#png == 2054) |
| 62 | +print(' OK: length is '..#png) |
0 commit comments