Uno Sguardo nel Buio:CustomTiles

Da Uno Sguardo nel Buio.

Indice


Map Tiles basic concepts

In Google Map all start from lowest zoom level that is zero. More you zoom in, more the zoom level increase.

At zoom level 0, all the world is painted on just one square tile of 256x256 pixel and at zoom level 1, all the world is painted on 4 square tile of 256x256 pixel each, as in the follow picture:

Immagine:Fig-gm0.png

Each succeeding zoom level divides the map into 4^N tiles, where N refers to the zoom level. For example, at zoom level 1, Google Maps divides the world up into a 2x2 grid for a total of 4 tiles; at zoom level 2, Google Maps divides up the world into a 4x4 grid for a total of 16 tiles, etc.

In other words, zooming in, implies that the same area rapresented by one tile in the starting zoom level, is rapresented by four tiles in the next zoom level.

This kind of approach is widely used in several software such as Google Map and Microsoft Virtual Earth. But, why? Of course, the problem is that while for the first zoom levels could be possible to have simply one big picture, at highest zoom level the single image will be too large: 256x256 pixel at zoom level 0, 512x512 pixel at zoom level 1, 1024x1024 pixel at zoom level 2, ...

The map will be too large for download or managing, and the pixel coordinates values will be too high to be stored and used by computer.

Coordinates

All the system based on tiles relies on almost 3 kind of coordinates system: pixel coordinates, tiles coordinates

pixel coordinates

These x, y coordinates define the position of a pixel in a generic tile. In other words, each pixel of a given tile is indicated by two numbers. As example, the (0, 0) point is the upper left corner of the tile, while the (255, 255) is the lower right corner.

tiles coordinates

There are basically two kind of coordinates for tiles:

  • a couple of x,y coordinates value define the position of a tile in the layer at generic zoom level. Thus to locate a single tile 3 values are required: x, y, z (Google Map). Usually the origin of tile numbering is the tile on the upper left corner of the map (remember that the world map is placed having the intersection point of equator and greenwich meridian in center of the map).
  • a QuadTree numbering system is adopted (Virtual Earth).

geographical coordinates

This is the well known Lat Lng system (and in most cases the decimal degrees are adopted).

put all together

Thus, as example, when I decide to place a marker at coordinates 42° N, 12.5° E (Rome) on my map, where it will be placed/painted? On which tile? And on which pixel of that tile?

1. first of all, we must decide the zoom level, because this states the tile layer and, as example, we decide to place our marker at zoom level 5

2. then we must decide on which tile of the zoom level 5 the marker must be placed. At this zoom level each tile near the equator, assuming Mercator projection, cover a little bit more than 11° both in latitude and longitude, as you can see in the following picture:

Immagine:Fig-gm1.png

Thus, with few computing (!) it is possible to indentify the tile required, based on the fact that for each tile the North, South, East and West side coordinates are computed depending of zoom level (and thus, number of tiles required to cover all the world, which is boxed between 180° E and 180* W and between 90° N and 90° S) and geographical projection (Spherical Mercator, in most cases).

3. to identify the specific pixel in a tile, a simple ratio pixel/degree allows to computing the pixel coordinates in the given tile.


Strumenti personali
Translate
Facebook