Fix zoom-out coordinate consistency on HDMaps

This commit is contained in:
Mike Primm 2011-07-04 10:18:05 -05:00
parent e2244ddda5
commit 961eb17536
6 changed files with 38 additions and 9 deletions

View File

@ -107,6 +107,7 @@ public class DynmapWorld {
int stepsize;
int[] stepseq;
boolean neg_step_x;
boolean neg_step_y;
String baseprefix;
int zoomlevel;
String zoomprefix;
@ -152,15 +153,26 @@ public class DynmapWorld {
int stepsize = mt.baseZoomFileStepSize();
int bigworldshift = mt.getBigWorldShift();
boolean neg_step_x = false;
if(stepsize < 0) {
stepsize = -stepsize;
neg_step_x = true;
boolean neg_step_y = false;
switch(mt.zoomFileMapStep()) {
case X_PLUS_Y_PLUS:
break;
case X_MINUS_Y_PLUS:
neg_step_x = true;
break;
case X_PLUS_Y_MINUS:
neg_step_y = true;
break;
case X_MINUS_Y_MINUS:
neg_step_x = neg_step_y = true;
break;
}
int[] stepseq = mt.zoomFileStepSequence();
for(String p : pfx) {
PrefixData pd = new PrefixData();
pd.stepsize = stepsize;
pd.neg_step_x = neg_step_x;
pd.neg_step_y = neg_step_y;
pd.stepseq = stepseq;
pd.baseprefix = p;
pd.zoomlevel = zoomlevel;
@ -285,7 +297,9 @@ public class DynmapWorld {
int[] argb = new int[width*height];
int step = pd.stepsize << pd.zoomlevel;
int ztx = tx;
int zty = ty;
tx = tx - (pd.neg_step_x?step:0); /* Adjust for negative step */
ty = ty - (pd.neg_step_y?step:0); /* Adjust for negative step */
/* create image buffer */
kzIm = KzedMap.allocateBufferedImage(width, height);
@ -338,7 +352,7 @@ public class DynmapWorld {
TileHashManager hashman = MapManager.mapman.hashman;
long crc = hashman.calculateTileHash(kzIm.argb_buf); /* Get hash of tile */
int tilex = ztx/step/2;
int tiley = ty/step/2;
int tiley = zty/step/2;
String key = world.getName()+".z"+pd.zoomprefix+pd.baseprefix;
if((!zf.exists()) || (crc != MapManager.mapman.hashman.getImageHashCode(key, null, tilex, tiley))) {
try {

View File

@ -27,7 +27,14 @@ public abstract class MapType {
public boolean isHightestBlockYDataNeeded() { return false; }
public boolean isRawBiomeDataNeeded() { return false; }
public boolean isBlockTypeDataNeeded() { return true; }
public enum MapStep {
X_PLUS_Y_PLUS,
X_PLUS_Y_MINUS,
X_MINUS_Y_PLUS,
X_MINUS_Y_MINUS
}
public abstract MapStep zoomFileMapStep();
public abstract List<String> baseZoomFilePrefixes();
public abstract int baseZoomFileStepSize();
/* How many bits of coordinate are shifted off to make big world directory name */

View File

@ -22,6 +22,7 @@ import org.dynmap.MapManager;
import org.dynmap.TileHashManager;
import org.dynmap.MapTile;
import org.dynmap.MapType;
import org.dynmap.MapType.MapStep;
import org.dynmap.debug.Debug;
import org.dynmap.kzedmap.KzedMap;
import org.dynmap.kzedmap.KzedMap.KzedBufferedImage;
@ -426,6 +427,8 @@ public class FlatMap extends MapType {
private static final int[] stepseq = { 1, 3, 0, 2 };
public MapStep zoomFileMapStep() { return MapStep.X_PLUS_Y_PLUS; }
public int[] zoomFileStepSequence() { return stepseq; }
/* How many bits of coordinate are shifted off to make big world directory name */

View File

@ -26,6 +26,7 @@ import org.dynmap.MapManager;
import org.dynmap.MapTile;
import org.dynmap.MapType;
import org.dynmap.TileHashManager;
import org.dynmap.MapType.MapStep;
import org.dynmap.debug.Debug;
import org.dynmap.flat.FlatMap.FlatMapTile;
import org.dynmap.kzedmap.KzedMap.KzedBufferedImage;
@ -547,6 +548,8 @@ public class HDMap extends MapType {
private static final int[] stepseq = { 3, 1, 2, 0 };
public MapStep zoomFileMapStep() { return MapStep.X_PLUS_Y_MINUS; }
public int[] zoomFileStepSequence() { return stepseq; }
/* How many bits of coordinate are shifted off to make big world directory name */

View File

@ -17,6 +17,7 @@ import org.dynmap.Log;
import org.dynmap.MapManager;
import org.dynmap.MapTile;
import org.dynmap.MapType;
import org.dynmap.MapType.MapStep;
import org.dynmap.utils.MapChunkCache;
import org.json.simple.JSONObject;
import java.awt.image.DataBufferInt;
@ -335,8 +336,9 @@ public class KzedMap extends MapType {
}
return s;
}
/* Return negative to flag negative X walk */
public int baseZoomFileStepSize() { return -zTileWidth; }
public int baseZoomFileStepSize() { return zTileWidth; }
public MapStep zoomFileMapStep() { return MapStep.X_MINUS_Y_PLUS; }
private static final int[] stepseq = { 0, 2, 1, 3 };

View File

@ -2,10 +2,10 @@ function HDProjection() {}
HDProjection.prototype = {
extrazoom: 0,
fromLatLngToPoint: function(latLng) {
return new google.maps.Point(latLng.lng()*config.tileWidth,latLng.lat()*config.tileHeight);
return new google.maps.Point(latLng.lng()*config.tileWidth, latLng.lat()*config.tileHeight);
},
fromPointToLatLng: function(point) {
return new google.maps.LatLng(point.y/config.tileHeight, point.x/config.tileWidth);
return new google.maps.LatLng( point.y/config.tileHeight, point.x/config.tileWidth);
},
fromWorldToLatLng: function(x, y, z) {
return new google.maps.LatLng(-z / config.tileWidth / (1 << this.extrazoom), x / config.tileHeight / (1 << this.extrazoom));