Setting the Scale in Virtual Earth

Someone asked me recently what the scales for the different zoom levels were. Of course, I went to Windows Live Local and zoomed down one level at a time and produced the following list:

Level - distance
1 - 7100 mi
2 - 3000 mi
3 - 1000 mi
4 - 600 mi
5 - 300 mi
6 - 150 mi
7 - 70 mi
8 - 30 mi
9 - 15 mi
10 - 9 mi
11 - 4 mi
12 - 2 mi
13 - 1 mi
14 - .6 mi
15 - 500 yds
16 - 250 yds
17 - 100 yds
18 - 60 yds
19 - 30 yds

After asking some folks on the product team, the came back with the following, more precise list:

Qlevel - Meters/Pixel
1 - 78271.52
2 - 39135.76
3 - 19567.88
4 - 9783.94
5 - 4891.97
6 - 2445.98
7 - 1222.99
8 - 611.5
9 - 305.75
10 - 152.87
11 - 76.44
12 - 38.22
13 - 19.11
14 - 9.55
15 - 4.78
16 - 2.39
17 - 1.19
18 - 0.6
19 - 0.3
20 - 0.15
21 - 0.07
22 - 0.04
23 - 0.02
24 - 0.01

24 levels?? Oh yeah, we're going high res baby. After looking at this the point was raised that this is not a true scale, but more of a resolution for imagery and graphics. So, in order to calcuate the scale it's a bit more complex. :) The scale is actually based on the settings of the user's monitor and calculated as such:

The resolution varies with latitude, as follows:

            Map resolution = 156543.04 meters/pixel * cos(latitude) / (2 ^ Qlevel)

To convert the map resolution into scale, you need to know (or assume) the screen resolution.  Then the formula becomes:

            Map scale = 1 : (ScreenRes pixels/inch * 39.37 inches/meter * 156543.04 meters/pixel * cos(latitude * pi/180) / (2 ^ Qlevel))

For example, assuming a ScreenRes of 100 pixels/inch, the map scale at level 10 and latitude 40 degrees is:

            Map scale = 1 : (100 pixels/inch * 39.37 inches/meter * 156543.04 meters/pixel * cos(40 * pi/180) / (2 ^ 10))
            Map scale = 1 : (100 * 39.37 * 156543.04 * 0.766 / 1024)
            Map scale = 1 : 461028.73