Google maps JS handle north_direction
Modifies coords conversion to handle configurable north direction
This commit is contained in:
@@ -492,6 +492,22 @@ var overviewer = {
|
||||
var perPixel = 1.0 / (overviewerConfig.CONST.tileSize *
|
||||
Math.pow(2, overviewerConfig.map.maxZoom));
|
||||
|
||||
if(overviewerConfig.map.north_direction == 'lower-left'){
|
||||
x = x;
|
||||
y = y;
|
||||
} else if(overviewerConfig.map.north_direction == 'upper-right'){
|
||||
x = -x-1;
|
||||
y = -y-1;
|
||||
} else if(overviewerConfig.map.north_direction == 'upper-left'){
|
||||
temp = x;
|
||||
x = -y-1;
|
||||
y = temp-16;
|
||||
} else if(overviewerConfig.map.north_direction == 'lower-right'){
|
||||
temp = x;
|
||||
x = y;
|
||||
y = -temp-1+16;
|
||||
}
|
||||
|
||||
// This information about where the center column is may change with
|
||||
// a different drawing implementation -- check it again after any
|
||||
// drawing overhauls!
|
||||
@@ -500,8 +516,14 @@ var overviewer = {
|
||||
// so the Y coordinate is at 0.5, and the X is at 0.5 -
|
||||
// ((tileSize / 2) / (tileSize * 2^maxZoom))
|
||||
// or equivalently, 0.5 - (1 / 2^(maxZoom + 1))
|
||||
var lng = 0.5 - (1.0 / Math.pow(2, overviewerConfig.map.maxZoom + 1));
|
||||
var lat = 0.5;
|
||||
lng = 0.5 - (1.0 / Math.pow(2, overviewerConfig.map.maxZoom + 1));
|
||||
lat = 0.5;
|
||||
if(overviewerConfig.map.north_direction == 'upper-right'){
|
||||
lng = 0.5 + (1.0 / Math.pow(2, overviewerConfig.map.maxZoom + 1));
|
||||
} else if(overviewerConfig.map.north_direction == 'upper-left'){
|
||||
lng = 0.5 + (1.0 / Math.pow(2, overviewerConfig.map.maxZoom + 1));
|
||||
}
|
||||
|
||||
|
||||
// the following metrics mimic those in ChunkRenderer.chunk_render
|
||||
// in "chunk.py" or, equivalently, chunk_render in src/iterate.c
|
||||
@@ -549,6 +571,12 @@ var overviewer = {
|
||||
lng -= 0.5 - (1.0 / Math.pow(2, overviewerConfig.map.maxZoom + 1));
|
||||
lat -= 0.5;
|
||||
|
||||
if(overviewerConfig.map.north_direction == 'upper-right'){
|
||||
lng -= 0.5 + (1.0 / Math.pow(2, overviewerConfig.map.maxZoom + 1));
|
||||
} else if(overviewerConfig.map.north_direction == 'upper-left'){
|
||||
lng -= 0.5 + (1.0 / Math.pow(2, overviewerConfig.map.maxZoom + 1));
|
||||
}
|
||||
|
||||
// I'll admit, I plugged this into Wolfram Alpha:
|
||||
// a = (x * 12 * r) + (z * 12 * r), b = (z * 6 * r) - (x * 6 * r)
|
||||
// And I don't know the math behind solving for for X and Z given
|
||||
@@ -563,6 +591,22 @@ var overviewer = {
|
||||
point.x += 64;
|
||||
point.z -= 64;
|
||||
|
||||
if(overviewerConfig.map.north_direction == 'lower-left'){
|
||||
point.x = point.x;
|
||||
point.z = point.z;
|
||||
} else if(overviewerConfig.map.north_direction == 'upper-right'){
|
||||
point.x = -point.x;
|
||||
point.z = -point.z;
|
||||
} else if(overviewerConfig.map.north_direction == 'upper-left'){
|
||||
temp = point.z;
|
||||
point.z = -point.x;
|
||||
point.x = temp+16;
|
||||
} else if(overviewerConfig.map.north_direction == 'lower-right'){
|
||||
temp = point.z;
|
||||
point.z = point.x;
|
||||
point.x = -temp+16;
|
||||
}
|
||||
|
||||
return point;
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user