This project has moved and is read-only. For the latest updates, please go here.

Zoom levels: Yahoo, Google , VE and Sharpmap

Topics: General Topics, Algorithms
May 1, 2007 at 9:52 PM
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 */
/** @final @type int */
/** Hardcode these resolutions so that they are more closely
  • tied with the standard wms projection
  • @final @type Array(float) */

Any ideas?
May 4, 2007 at 4:28 PM
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!
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:

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: (Note that the datum stated here is wrong - It's NOT WGS84)

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]

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.