Zoom levels: Yahoo, Google , VE and Sharpmap

Topics: General Topics, Algorithms
May 1, 2007 at 9:52 PM
Hi.
Has anyone figured out the correlation between SharpMap's zoom levels
and Yahoo Ajax Map zoom levels?

I've looked in OpenLayers' Yahoo.js file and they use a mapping array
with the following values (which just seem to be 2* the previous level):
/** @final @type int */
MINZOOMLEVEL: 0,
/** @final @type int */
MAXZOOMLEVEL: 15,
/** Hardcode these resolutions so that they are more closely
  • tied with the standard wms projection
*
  • @final @type Array(float) */
RESOLUTIONS:
[1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.\
010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.00068664550781\
25,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.000042915344\
23828125],

Any ideas?
Thanks,
Step
May 4, 2007 at 4:28 PM
Hi,
Have fixed this. Passing SharpMap the following zoom levels when using Yahoo Maps.

obj.yahooZoomLevels = Array(0.010728836 , 0.021457672 , 0.042915344 , 0.085830688 , 0.171661377 , 0.343322754 , 0.686645508 , 1.373291016 , 2.746582031 , 5.493164063 , 10.98632813 , 21.97265625 , 43.9453125 , 87.890625 , 175.78125 , 351.5625 );

If anyone can see a problem, please let me know. The Yahoo maps are being returned off center as it it!
Step.
May 5, 2007 at 9:00 AM
Edited Jun 6, 2007 at 5:10 AM
First of all, you will need to have your data in or use a on-the-fly projection to a Mercator projection, having an spherical ellipsoid equals to that of the semi-major axis of WGS84 (6378137.0 meters). This is the projection that both Google Maps, Live Maps and Yahoo maps uses. Funny enough, I think they also use the same tile scheme, so the following applies to all of them.

The map has the following extents in degrees:
Lower left: -180, -85.05112877980659
Upper Right: 180, 85.05112877980659

If you transform this to a Mercator projection using a spherical datum with radius 6378137, gives you a perfect square:
Lower left: -20037508.3427892, -20037508.3427892
Upper Right: 20037508.3427892, 20037508.3427892

At the lowest zoom level, the map has a size of 512 x 512 pixels, resulting in a resolution of:
78271.5169640203125 meters / pixels, or 20037508.3427892 meters / tile
This means that you will have to set the zoom-width to 20037508.3427892 and the width and height to 256x256 to match the size of that tile.

Since the zoom value is halfed for each zoomlevel, the zoom sizes then becomes:
20037508.3427892
10018754.1713946
5009377.0856973
2504688.54284865
1252344.271424325
626172.1357121625
313086.06785608125
156543.033928040625
78271.5169640203125
39135.75848201015625
19567.879241005078125
9783.9396205025390625
4891.96981025126953125
2445.984905125634765625
1222.9924525628173828125
611.49622628140869140625
305.748113140704345703125

The projection string would be:
PROJCS["Mercator", GEOGCS["WGS84_Sphere", DATUM["WGS84_Sphere", SPHEROID["WGS84_Sphere", 6378137, 0], TOWGS84[0, 0, 0, 0, 0, 0, 0]], PRIMEM["Greenwich", 0, AUTHORITY["EPSG", "8901"]], UNIT["degree", 0.0174532925199433, AUTHORITY["EPSG", "9102"]], AXIS["E", EAST], AXIS["N", NORTH]], PROJECTION["Mercator_1SP"], PARAMETER["False_Easting", 0], PARAMETER["False_Northing", 0], PARAMETER["Central_Meridian", 0], PARAMETER["Latitude_of_origin", 0], UNIT["metre", 1, AUTHORITY["EPSG", "9001"]], AXIS["East", EAST], AXIS["North", NORTH]]

Here's some more info to read up on:
http://msdn2.microsoft.com/en-us/library/bb259689.aspx
http://cfis.savagexi.com/articles/2006/05/03/google-maps-deconstructed (Note that the datum stated here is wrong - It's NOT WGS84)
http://cfis.savagexi.com/articles/2006/05/05/google-maps-revisited

NB: Note that SharpMap currently has a bug that results in not applying the datum change when transforming from a geographical-based reference system to a projection with a different datum.
May 5, 2007 at 3:55 PM
Wow Odegaard, now that's what will go down in the annals as "the answer". Bedankt!
I will examine it over the weekend.
thank you again.
Step van Schalkwyk
Jun 5, 2007 at 6:55 PM
Just a quick nitpick. A radius of 6378137.0 isn't the authalic sphere of GRS80 or WGS84. The authalic sphere has the same surface area. For GRS80, the radius of its authalic sphere is 6371007.0 meters. The sphere being used by Google Maps et al might be called the "major sphere". I couldn't confirm that with a quick google search.

And if you want to use the WKT string in an ESRI product use:

PROJCS"Mercator", GEOGCS["WGS84_Sphere", DATUM["WGS84_Sphere", SPHEROID["WGS84_Sphere", 6378137, 0]], PRIMEM["Greenwich", 0], UNIT["degree", 0.0174532925199433]], PROJECTION["Mercator"], PARAMETER["False_Easting", 0], PARAMETER["False_Northing", 0], PARAMETER["Central_Meridian", 0], PARAMETER["Latitude_of_origin", 0], UNIT["Meter", 1]

Melita
Jun 6, 2007 at 5:06 AM
Edited Jun 6, 2007 at 5:09 AM
Thanks Melita. Your are perfectly right as always. I forgot to change the name and remove the authority of the ellipsoid. It wouldn't really matter though. Its just names of the parameters. The parameter values are correct and these are the only ones that are actually used by this projection engine.
I have updated my post above to reflect this.