@@ -22,35 +22,34 @@ RasterOverviews::RasterOverviews(UniqueRasterPointer input_raster, int min_zoom,
2222// Guesses (numerically) maximal zoom level from a raster resolution
2323int RasterOverviews::guess_max_zoom_level (double resolution)
2424{
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 ;
3030 return static_cast <int >(round (log2 (pixel_size_z0 / resolution)));
3131}
3232
3333// Guesses (numerically) minimal zoom level from a raster resolution and it's size
3434int RasterOverviews::guess_min_zoom_level (int max_zoom_level)
3535{
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 ;
4141 const double quotient = MINIMAL_RASTER_SIZE * (1 << max_zoom_level);
4242
4343 int raster_width = m_base_raster->get_width ();
4444 int raster_height = m_base_raster->get_height ();
4545
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);
4948
5049 int zoom_x = static_cast <int >(floor (log2 (quotient / raster_width)));
5150 int zoom_y = static_cast <int >(floor (log2 (quotient / raster_height)));
5251
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
5453 return std::max (0 , std::min (zoom_x, zoom_y));
5554}
5655
@@ -71,7 +70,10 @@ void RasterOverviews::compute_zoom_levels()
7170 std::swap (m_min_zoom, m_max_zoom);
7271 }
7372
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);
7577}
7678
7779bool RasterOverviews::next (RasterOverview& overview)
@@ -94,11 +96,12 @@ bool RasterOverviews::next(RasterOverview& overview)
9496 overview.resolution = output_raster->get_cell_size ();
9597 overview.raster = std::move (output_raster);
9698
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);
102105
103106 return true ;
104107}
0 commit comments