MapInfo Spatial Server Map Tiling Service - Product Documentation ...
MapInfo Spatial Server Map Tiling Service - Product Documentation ...
MapInfo Spatial Server Map Tiling Service - Product Documentation ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Transforming a Pixel to a <strong>Map</strong> Coordinate<br />
Transforming a Pixel to a <strong>Map</strong> Coordinate<br />
To pan or zoom a map based on tiles from the <strong>Map</strong> <strong>Tiling</strong> <strong>Service</strong> the client must have the ability to<br />
convert a pixel to a location on the Earth. To do this the client must create an affine transform that when<br />
given a coordinate in pixels returns a coordinate in the projection of the tiles. You need to know the<br />
projection of the tiles, the bounds of the map being tiled, and the dimensions of a tile. Given this information<br />
you must do the following:<br />
1. Calculate the maximum number of tiles across that represents the map.<br />
2. Calculate the maximum number of tiles down that represents the map.<br />
3. Calculate the maximum number of pixels across that represents the map.<br />
4. Calculate the maximum number of pixels down that represents the map.<br />
5. Create an affine transform based on the bounds of the map and the bounds of the map in pixels.<br />
6. Feed your location in pixels into the affine transform. The result will be a location on the earth in the<br />
projection of the map.<br />
To perform these steps, and transform a pixel into your map's coordinate system:<br />
1. Calculate the maximum number of tiles across the map using the following equation: tilesAcross<br />
= 2 level<br />
2. Calculate the maximum number of tiles down the map using the following equation: tilesDown =<br />
2 level<br />
3. Calculate the number of pixels across the entire map using the following equation: pixelsAcross<br />
= tileWidth × tileAcross<br />
4. Calculate the number of pixels down the entire map using the following equation: pixelsDown =<br />
tileHeight × tileDown<br />
5. Given the bounds of the map in the map's projection and the bounds of the map in pixels an affine<br />
transform from pixels to map coordinates can be constructed. The pixel coordinate passed must be<br />
in the map's pixel space. It may not be enough to directly feed a pixel coordinate from a mouse location<br />
on the screen. For instance, you may have to convert the mouse location to a location in the<br />
map's pixel space. This involves keeping track of the location in map pixels space of the upper righthand<br />
corner of the image control and offsetting the mouse location with that location.<br />
The getDescription method provides all the information needed to construct the affine transform like<br />
tileWidth, tileHeight, map projection, and map bounds. See getDescription on page 29.<br />
Transforming a Pixel to a Tile Coordinate<br />
54<br />
To perform pan and zoom, and locate items in a particular map tile, you need to be able to determine<br />
which tile a pixel is in. To do this the client must be able to calculate the column and row or the tile when<br />
given a coordinate in pixels. To perform this step, and transform a pixel into a tile coordinate, you can<br />
use the following calculations:<br />
<strong><strong>Map</strong>Info</strong> <strong>Spatial</strong> <strong>Server</strong> 1.0