@@ -22,35 +22,34 @@ RasterOverviews::RasterOverviews(UniqueRasterPointer input_raster, int min_zoom,
22
22
// Guesses (numerically) maximal zoom level from a raster resolution
23
23
int RasterOverviews::guess_max_zoom_level (double resolution)
24
24
{
25
- // pixel_size_z0 is a magic number that is number of meters per pixel on zoom level 0, given tile size is 256 pixels.
26
- // This number is approximate and does not account for latitude, i.e. uses pixel size on equator.
27
- // The formula is: earth circumference * 2 * pi / 256
28
- // "Real" number can be off up to 30% depending on the latitude. More details here: https://msdn.microsoft.com/en-us/library/aa940990.aspx
29
- const double pixel_size_z0 = 156543.04 ;
25
+ // pixel_size_z0 is a magic number that is number of meters per pixel on zoom level 0, given tile size is 256 pixels.
26
+ // This number is approximate and does not account for latitude, i.e. uses pixel size on equator.
27
+ // The formula is: earth circumference * 2 * pi / 256
28
+ // "Real" number can be off up to 30% depending on the latitude. More details here: https://msdn.microsoft.com/en-us/library/aa940990.aspx
29
+ const double pixel_size_z0 = 156543.04 ;
30
30
return static_cast <int >(round (log2 (pixel_size_z0 / resolution)));
31
31
}
32
32
33
33
// Guesses (numerically) minimal zoom level from a raster resolution and it's size
34
34
int RasterOverviews::guess_min_zoom_level (int max_zoom_level)
35
35
{
36
- // This constant is an arbitrary number representing some minimal size to which the raster can be downsized when 'zooming out' a map.
37
- // Math is simple:
38
- // 2**max_zoom = raster_size; 2**min_zoom = 128
39
- // Solve it in regards to min_zoom and there you have it.
40
- const int MINIMAL_RASTER_SIZE = 128 ;
36
+ // This constant is an arbitrary number representing some minimal size to which the raster can be downsized when 'zooming out' a map.
37
+ // Math is simple:
38
+ // 2**max_zoom = raster_size; 2**min_zoom = 128
39
+ // Solve it in regards to min_zoom and there you have it.
40
+ const int MINIMAL_RASTER_SIZE = 128 ;
41
41
const double quotient = MINIMAL_RASTER_SIZE * (1 << max_zoom_level);
42
42
43
43
int raster_width = m_base_raster->get_width ();
44
44
int raster_height = m_base_raster->get_height ();
45
45
46
- TNTN_LOG_DEBUG (" guess_min_zoom_level: raster_width: {}, raster_height: {}" ,
47
- raster_width,
48
- raster_height);
46
+ TNTN_LOG_DEBUG (
47
+ " guess_min_zoom_level: raster_width: {}, raster_height: {}" , raster_width, raster_height);
49
48
50
49
int zoom_x = static_cast <int >(floor (log2 (quotient / raster_width)));
51
50
int zoom_y = static_cast <int >(floor (log2 (quotient / raster_height)));
52
51
53
- // Cap the resulting value so it won't go below 0 and we wouldn't end up with negative zoom levels
52
+ // Cap the resulting value so it won't go below 0 and we wouldn't end up with negative zoom levels
54
53
return std::max (0 , std::min (zoom_x, zoom_y));
55
54
}
56
55
@@ -71,7 +70,10 @@ void RasterOverviews::compute_zoom_levels()
71
70
std::swap (m_min_zoom, m_max_zoom);
72
71
}
73
72
74
- TNTN_LOG_INFO (" After checking with data, tiles will be generated in a range between {} and {}" , m_min_zoom, m_max_zoom);
73
+ TNTN_LOG_INFO (
74
+ " After checking with data, tiles will be generated in a range between {} and {}" ,
75
+ m_min_zoom,
76
+ m_max_zoom);
75
77
}
76
78
77
79
bool RasterOverviews::next (RasterOverview& overview)
@@ -94,11 +96,12 @@ bool RasterOverviews::next(RasterOverview& overview)
94
96
overview.resolution = output_raster->get_cell_size ();
95
97
overview.raster = std::move (output_raster);
96
98
97
- TNTN_LOG_DEBUG (" Generated next overview at zoom {}, window size {}, min zoom level {}, max zoom level {}" ,
98
- m_current_zoom + 1 ,
99
- window_size,
100
- m_min_zoom,
101
- m_max_zoom);
99
+ TNTN_LOG_DEBUG (
100
+ " Generated next overview at zoom {}, window size {}, min zoom level {}, max zoom level {}" ,
101
+ m_current_zoom + 1 ,
102
+ window_size,
103
+ m_min_zoom,
104
+ m_max_zoom);
102
105
103
106
return true ;
104
107
}
0 commit comments