From 0b34c7f1c3fb48844342d5aa6c1ca9df90e07a35 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 25 Feb 2012 16:17:49 -0500 Subject: [PATCH] changed JS to properly compute coords for anvil format --- overviewer_core/data/js_src/util.js | 26 ++++++++++++++------------ overviewer_core/world.py | 4 ++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/overviewer_core/data/js_src/util.js b/overviewer_core/data/js_src/util.js index 0ac5f25..2daa770 100644 --- a/overviewer_core/data/js_src/util.js +++ b/overviewer_core/data/js_src/util.js @@ -235,7 +235,7 @@ overviewer.util = { * * @return google.maps.LatLng */ - 'fromWorldToLatLng': function(x, z, y, model) { + 'fromWorldToLatLng': function(x, y, z, model) { var zoomLevels = model.get("zoomLevels"); var north_direction = model.get('north_direction'); @@ -248,15 +248,15 @@ overviewer.util = { if (north_direction == overviewerConfig.CONST.UPPERRIGHT){ temp = x; - x = -y+16; - y = temp; + x = -z+16; + z = temp; } else if(north_direction == overviewerConfig.CONST.LOWERRIGHT){ x = -x+16; - y = -y+16; + z = -z+16; } else if(north_direction == overviewerConfig.CONST.LOWERLEFT){ temp = x; - x = y; - y = -temp+16; + x = z; + z = -temp+16; } // This information about where the center column is may change with @@ -278,11 +278,11 @@ overviewer.util = { lat -= 6 * x * perPixel; // each block on Y axis adds 12px to x and adds 6px to y - lng += 12 * y * perPixel; - lat += 6 * y * perPixel; + lng += 12 * z * perPixel; + lat += 6 * z * perPixel; // each block down along Z adds 12px to y - lat += 12 * (128 - z) * perPixel; + lat += 12 * (256 - y) * perPixel; // add on 12 px to the X coordinate to center our point lng += 12 * perPixel; @@ -329,9 +329,11 @@ overviewer.util = { point.z = Math.floor((lng + 2 * lat) / (24 * perPixel)); // Adjust for the fact that we we can't figure out what Y is given - // only latitude and longitude, so assume Y=64. - point.x += 64; - point.z -= 64; + // only latitude and longitude, so assume Y=64. Since this is lowering + // down from the height of a chunk, it depends on the chunk height as + // so: + point.x += 256-64; + point.z -= 256-64; if(north_direction == overviewerConfig.CONST.UPPERRIGHT){ temp = point.z; diff --git a/overviewer_core/world.py b/overviewer_core/world.py index 33456d8..1d50983 100644 --- a/overviewer_core/world.py +++ b/overviewer_core/world.py @@ -468,9 +468,9 @@ class RotatedRegionSet(RegionSet): for section in chunk_data['Sections']: for arrayname in ['Blocks', 'Data', 'SkyLight', 'BlockLight']: array = section[arrayname] - # New arrays are arranged with axes Y,Z,X + # Since the anvil change, arrays are arranged with axes Y,Z,X # numpy.rot90 always rotates the first two axes, so for it to - # work, we need to temporarily more the X axis to the 0th axis. + # work, we need to temporarily move the X axis to the 0th axis. array = numpy.swapaxes(array, 0,2) array = numpy.rot90(array, self.north_dir) array = numpy.swapaxes(array, 0,2)