added separate 'zoomLevels' JS config var for marker positioning use (closes #401)
This commit is contained in:
@@ -534,7 +534,7 @@ var overviewer = {
|
||||
// the width and height of all the highest-zoom tiles combined,
|
||||
// inverted
|
||||
var perPixel = 1.0 / (overviewerConfig.CONST.tileSize *
|
||||
Math.pow(2, overviewerConfig.map.maxZoom));
|
||||
Math.pow(2, overviewerConfig.map.zoomLevels));
|
||||
|
||||
// This information about where the center column is may change with
|
||||
// a different drawing implementation -- check it again after any
|
||||
@@ -542,13 +542,13 @@ var overviewer = {
|
||||
|
||||
// point (0, 0, 127) is at (0.5, 0.0) of tile (tiles/2 - 1, tiles/2)
|
||||
// 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));
|
||||
// ((tileSize / 2) / (tileSize * 2^zoomLevels))
|
||||
// or equivalently, 0.5 - (1 / 2^(zoomLevels + 1))
|
||||
var lng = 0.5 - (1.0 / Math.pow(2, overviewerConfig.map.zoomLevels + 1));
|
||||
var lat = 0.5;
|
||||
|
||||
// the following metrics mimic those in ChunkRenderer.chunk_render
|
||||
// in "chunk.py" or, equivalently, chunk_render in src/iterate.c
|
||||
// the following metrics mimic those in
|
||||
// chunk_render in src/iterate.c
|
||||
|
||||
// each block on X axis adds 12px to x and subtracts 6px from y
|
||||
lng += 12 * x * perPixel;
|
||||
@@ -586,11 +586,11 @@ var overviewer = {
|
||||
// the width and height of all the highest-zoom tiles combined,
|
||||
// inverted
|
||||
var perPixel = 1.0 / (overviewerConfig.CONST.tileSize *
|
||||
Math.pow(2, overviewerConfig.map.maxZoom));
|
||||
Math.pow(2, overviewerConfig.map.zoomLevels));
|
||||
|
||||
// Revert base positioning
|
||||
// See equivalent code in fromWorldToLatLng()
|
||||
lng -= 0.5 - (1.0 / Math.pow(2, overviewerConfig.map.maxZoom + 1));
|
||||
lng -= 0.5 - (1.0 / Math.pow(2, overviewerConfig.map.zoomLevels + 1));
|
||||
lat -= 0.5;
|
||||
|
||||
// I'll admit, I plugged this into Wolfram Alpha:
|
||||
|
||||
@@ -75,6 +75,12 @@ var overviewerConfig = {
|
||||
* This controls how close you can zoom in.
|
||||
*/
|
||||
'maxZoom': {maxzoom},
|
||||
/**
|
||||
* This tells us how many total zoom levels Overviewer rendered.
|
||||
* DO NOT change this, even if you change minZoom and maxZoom, because
|
||||
* it's used for marker position calculations and map resizing.
|
||||
*/
|
||||
'zoomLevels': {zoomlevels},
|
||||
/**
|
||||
* Center on this point, in world coordinates. Should be an array, ex:
|
||||
* [0,0,0]
|
||||
|
||||
@@ -114,6 +114,8 @@ class MapGen(object):
|
||||
"{minzoom}", str(0))
|
||||
config = config.replace(
|
||||
"{maxzoom}", str(zoomlevel))
|
||||
config = config.replace(
|
||||
"{zoomlevels}", str(zoomlevel))
|
||||
|
||||
config = config.replace("{spawn_coords}",
|
||||
json.dumps(list(self.world.spawn)))
|
||||
|
||||
@@ -120,7 +120,7 @@ class QuadtreeGen(object):
|
||||
indexfile = os.path.join(self.destdir, "overviewerConfig.js")
|
||||
if not os.path.exists(indexfile):
|
||||
return -1
|
||||
matcher = re.compile(r"maxZoom.*:\s*(\d+)")
|
||||
matcher = re.compile(r"zoomLevels(?:\'|\")\s*:\s*(\d+)")
|
||||
p = -1
|
||||
for line in open(indexfile, "r"):
|
||||
res = matcher.search(line)
|
||||
|
||||
Reference in New Issue
Block a user