• API
• FAQ
• Tools
• Archive
daily pastebin goal
5%
SHARE
TWEET

# Untitled

a guest Nov 15th, 2017 64 Never
ENDING IN00days00hours00mins00secs

1. from math import log, ceil, sqrt
2.
3. # Gennemsnitlig stoerrelse af en tile. 25kB passer nogenlunde med ortofoto
4. size_per_tile = 25 * 1024 # 25kB
5.
6.
7.
8. # --------GSTs standard skema ---------------
9. # Koordinater paa tilet omraade (xmin, ymin, xmax, ymax)
10. #bbox = [120000, 5900000, 1000000, 6500000]
11. # Pyramidens oploesninger
12. #[1638.4, 819.2, 409.6, 204.8, 102.4, 51.2, 25.6, 12.8, 6.4, 3.2, 1.6, 0.8, 0.4, 0.2, 0.1]
13. #top_res    = 1638.4
14. #bottom_res = 0.05
15. #res_factor =  sqrt(2)
16.
17. # -------Box indsnaevret til at daekke Jylland og Sjaelland
18. # Koordinater paa tilet omraade (xmin, ymin, xmax, ymax)
19. bbox = [430000, 6040000, 750000, 6400000]
20. # # Pyramidens oploesninger
21. top_res    = 1638.4
22. bottom_res = 0.1
23. res_factor = 2 #sqrt(2)
24.
25. # ==============================================================================
26.
27. def resolutions(maxres, minres, factor):
28.   res = maxres
29.   z = 0
30.   # Allow small numeric error
31.   while res > (minres - minres * 0.001 * factor):
32.     yield res
33.     z = z + 1
34.     res = maxres / (factor ** z)
35.
36. unit_list = zip(['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'], [0, 0, 1, 2, 2, 2])
37. def sizeof_fmt( size_bytes ):
38.     """Human friendly file size"""
39.     if size_bytes > 1:
40.         exponent = min(int(log(size_bytes, 1024)), len(unit_list) - 1)
41.         quotient = float(size_bytes) / 1024**exponent
42.         unit, num_decimals = unit_list[exponent]
43.         format_string = '{:.%sf} {}' % (num_decimals)
44.         return format_string.format(quotient, unit)
45.     if size_bytes == 0:
46.         return '0 bytes'
47.     if size_bytes == 1:
48.         return '1 byte'
49.
50. def wmts_scaledenom( resolution ):
51.   return resolution / 0.00028
52.
53. res = list( resolutions(top_res, bottom_res, res_factor) )
54. bboxsize = (bbox[2] - bbox[0], bbox[3] - bbox[1])
55. print "BBoxsize: ", bboxsize, "m, Area: ", bboxsize[0] * bboxsize[1] / (1000 * 1000), "km2"
56. print "Average tile size: ", sizeof_fmt( size_per_tile )
57. print "Resolutions: ", res, "m/pixel"
58.
59. tiles = 0
60.
61. for z, r in enumerate(res):
62.   size_m = r * 256
63.
64.   tilesw = int(ceil( bboxsize[0] / size_m ))
65.   tilesh = int(ceil( bboxsize[1] / size_m ))
66.   lyrtiles = tilesw * tilesh
67.   tiles = tiles + lyrtiles
68.
69.   print "  Zoom: ", z, ", Resolution: ", r, "m, Tile size: ", size_m, "m, WMTS ScaleDenominator", wmts_scaledenom( r )
70.   print "     Dimensions: ",tilesw, "x", tilesh, " tiles"
71.   print "     Tiles: ", lyrtiles
72.   print "     Size: ", sizeof_fmt(lyrtiles * size_per_tile)
73.   print "     Accum size: ", sizeof_fmt(tiles * size_per_tile)
74. print "Tiles: ", tiles
75. print "Size: ", sizeof_fmt(tiles * size_per_tile)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top