# Convert Map Coordinates

## Background

The map is made of 4 tile sections per level where as you add more tile sections together they increase the focus of the map 4x and pick 1 of the 4 corners of the larger tile. Converting the coordinates of the map to its corresponding map image is useful if you want to automate a process involving the live map. This process can be done for the historical maps as well but some of them require adjustments to the normal procedure.

## Steps

The basic procedure that is taken is to find the center of tile where the original coordinates were given and use that to find the next tile which gives a new center and this continues till all the levels are added. To accomplish this procedure there are 4 main steps that need to be taken.

1) Offset x and z coordinates based on y coordinate

2) Assign lengths of each tile section for a level

3) Get tile section for a level

4) Recenter coordinates based on tile that you find from step 3

Continue steps 2-4 till the max number of levels is achieved.

### Step 1

The live map's default y height is 64. If another y value is given then both the x and z coordinate will need to be offset so that the y height can be set back to 64. The equations are *x=x+y-64* and *z=z-y+64*.

### Step 2

Since the live map is at a 45 degree angle the lengths for each tile requires special scaling to for every level that is added to it. See figure below to for further example.

Now with the proper scaling we can find out the corners of all the tiles for a given level. In the live map currently there are 14 levels but some of the historical maps have less levels making things challenging to use the same process. For each level that is added the length that is used to scale the tiles is divided by 2. Use this equation for figuring out the length where the level starts at 1 and increase as more tile sections are added. 2^{18-level}

### Step 3

To figure out the tile section that a coordinate the work is split between figuring out if its either top or bottom and left or right. Also knowing the center of the each tile is needed to compare it with the coordinate that is given. At first this center coordinate starts at x=199 and z=-184 as its the center of the map and it gets updated as more levels are added. For figuring out if its left or right corner we call it xsub and use this equation *xsub = (x-centerx+z-centerz)>=0* where it is a Boolean(0 = False, 1 = True) 0 means left and 1 means right. This process is similar for whether its top or bottom which we will call zsub and use the equation *zsub = (((x-centerx)-(z-centerz))<=0)*2* where 0 means top and 2 means bottom. Using the equation *xsub+zsub=sub* gives the tile sub section for that particular level.

### Step 4

Now that the tile section for a particular level is found the center coordinates need to be adjusted to using xsub and zsub. For readjusting the x coordinate center use this equation *xcenter=(0.5+xsub-zsub)*tilelength+xcenter* where the tilelength is just the one found in step 2. For readjusting the z coordinate center use this equation *zcenter=(-1.5+xsub+zsub)*tilelength+zcenter*.

### Repeat

Once the center is readjusted do step 2-4 till you reach level 14 or whichever one is best to stop at. For every level take the sub section and a / before till you get your full url needed for the image on the map. To get the actual image get "minecraftonline.com/map/" and add "lighting" or "night" for day or night time. After this add your full string of tile subsections in the order that you found them with a / at the start of it and not the end. Finally add ".png" to the end of it.

## Area maps

Knowing how to get the map image is nice but it doesn't allow you to make more detailed images as they would require more map images. What is needed is a way to pick a certain radius of the map and you get a list of map images that are inside of this radius. The steps for this process will be documented soon.