mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 21:25:46 +01:00
Fix zoom-out coordinate consistency on HDMaps
This commit is contained in:
parent
e2244ddda5
commit
961eb17536
@ -107,6 +107,7 @@ public class DynmapWorld {
|
|||||||
int stepsize;
|
int stepsize;
|
||||||
int[] stepseq;
|
int[] stepseq;
|
||||||
boolean neg_step_x;
|
boolean neg_step_x;
|
||||||
|
boolean neg_step_y;
|
||||||
String baseprefix;
|
String baseprefix;
|
||||||
int zoomlevel;
|
int zoomlevel;
|
||||||
String zoomprefix;
|
String zoomprefix;
|
||||||
@ -152,15 +153,26 @@ public class DynmapWorld {
|
|||||||
int stepsize = mt.baseZoomFileStepSize();
|
int stepsize = mt.baseZoomFileStepSize();
|
||||||
int bigworldshift = mt.getBigWorldShift();
|
int bigworldshift = mt.getBigWorldShift();
|
||||||
boolean neg_step_x = false;
|
boolean neg_step_x = false;
|
||||||
if(stepsize < 0) {
|
boolean neg_step_y = false;
|
||||||
stepsize = -stepsize;
|
switch(mt.zoomFileMapStep()) {
|
||||||
neg_step_x = true;
|
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();
|
int[] stepseq = mt.zoomFileStepSequence();
|
||||||
for(String p : pfx) {
|
for(String p : pfx) {
|
||||||
PrefixData pd = new PrefixData();
|
PrefixData pd = new PrefixData();
|
||||||
pd.stepsize = stepsize;
|
pd.stepsize = stepsize;
|
||||||
pd.neg_step_x = neg_step_x;
|
pd.neg_step_x = neg_step_x;
|
||||||
|
pd.neg_step_y = neg_step_y;
|
||||||
pd.stepseq = stepseq;
|
pd.stepseq = stepseq;
|
||||||
pd.baseprefix = p;
|
pd.baseprefix = p;
|
||||||
pd.zoomlevel = zoomlevel;
|
pd.zoomlevel = zoomlevel;
|
||||||
@ -285,7 +297,9 @@ public class DynmapWorld {
|
|||||||
int[] argb = new int[width*height];
|
int[] argb = new int[width*height];
|
||||||
int step = pd.stepsize << pd.zoomlevel;
|
int step = pd.stepsize << pd.zoomlevel;
|
||||||
int ztx = tx;
|
int ztx = tx;
|
||||||
|
int zty = ty;
|
||||||
tx = tx - (pd.neg_step_x?step:0); /* Adjust for negative step */
|
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 */
|
/* create image buffer */
|
||||||
kzIm = KzedMap.allocateBufferedImage(width, height);
|
kzIm = KzedMap.allocateBufferedImage(width, height);
|
||||||
@ -338,7 +352,7 @@ public class DynmapWorld {
|
|||||||
TileHashManager hashman = MapManager.mapman.hashman;
|
TileHashManager hashman = MapManager.mapman.hashman;
|
||||||
long crc = hashman.calculateTileHash(kzIm.argb_buf); /* Get hash of tile */
|
long crc = hashman.calculateTileHash(kzIm.argb_buf); /* Get hash of tile */
|
||||||
int tilex = ztx/step/2;
|
int tilex = ztx/step/2;
|
||||||
int tiley = ty/step/2;
|
int tiley = zty/step/2;
|
||||||
String key = world.getName()+".z"+pd.zoomprefix+pd.baseprefix;
|
String key = world.getName()+".z"+pd.zoomprefix+pd.baseprefix;
|
||||||
if((!zf.exists()) || (crc != MapManager.mapman.hashman.getImageHashCode(key, null, tilex, tiley))) {
|
if((!zf.exists()) || (crc != MapManager.mapman.hashman.getImageHashCode(key, null, tilex, tiley))) {
|
||||||
try {
|
try {
|
||||||
|
@ -27,7 +27,14 @@ public abstract class MapType {
|
|||||||
public boolean isHightestBlockYDataNeeded() { return false; }
|
public boolean isHightestBlockYDataNeeded() { return false; }
|
||||||
public boolean isRawBiomeDataNeeded() { return false; }
|
public boolean isRawBiomeDataNeeded() { return false; }
|
||||||
public boolean isBlockTypeDataNeeded() { return true; }
|
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 List<String> baseZoomFilePrefixes();
|
||||||
public abstract int baseZoomFileStepSize();
|
public abstract int baseZoomFileStepSize();
|
||||||
/* How many bits of coordinate are shifted off to make big world directory name */
|
/* How many bits of coordinate are shifted off to make big world directory name */
|
||||||
|
@ -22,6 +22,7 @@ import org.dynmap.MapManager;
|
|||||||
import org.dynmap.TileHashManager;
|
import org.dynmap.TileHashManager;
|
||||||
import org.dynmap.MapTile;
|
import org.dynmap.MapTile;
|
||||||
import org.dynmap.MapType;
|
import org.dynmap.MapType;
|
||||||
|
import org.dynmap.MapType.MapStep;
|
||||||
import org.dynmap.debug.Debug;
|
import org.dynmap.debug.Debug;
|
||||||
import org.dynmap.kzedmap.KzedMap;
|
import org.dynmap.kzedmap.KzedMap;
|
||||||
import org.dynmap.kzedmap.KzedMap.KzedBufferedImage;
|
import org.dynmap.kzedmap.KzedMap.KzedBufferedImage;
|
||||||
@ -426,6 +427,8 @@ public class FlatMap extends MapType {
|
|||||||
|
|
||||||
private static final int[] stepseq = { 1, 3, 0, 2 };
|
private static final int[] stepseq = { 1, 3, 0, 2 };
|
||||||
|
|
||||||
|
public MapStep zoomFileMapStep() { return MapStep.X_PLUS_Y_PLUS; }
|
||||||
|
|
||||||
public int[] zoomFileStepSequence() { return stepseq; }
|
public int[] zoomFileStepSequence() { return stepseq; }
|
||||||
|
|
||||||
/* How many bits of coordinate are shifted off to make big world directory name */
|
/* How many bits of coordinate are shifted off to make big world directory name */
|
||||||
|
@ -26,6 +26,7 @@ import org.dynmap.MapManager;
|
|||||||
import org.dynmap.MapTile;
|
import org.dynmap.MapTile;
|
||||||
import org.dynmap.MapType;
|
import org.dynmap.MapType;
|
||||||
import org.dynmap.TileHashManager;
|
import org.dynmap.TileHashManager;
|
||||||
|
import org.dynmap.MapType.MapStep;
|
||||||
import org.dynmap.debug.Debug;
|
import org.dynmap.debug.Debug;
|
||||||
import org.dynmap.flat.FlatMap.FlatMapTile;
|
import org.dynmap.flat.FlatMap.FlatMapTile;
|
||||||
import org.dynmap.kzedmap.KzedMap.KzedBufferedImage;
|
import org.dynmap.kzedmap.KzedMap.KzedBufferedImage;
|
||||||
@ -547,6 +548,8 @@ public class HDMap extends MapType {
|
|||||||
|
|
||||||
private static final int[] stepseq = { 3, 1, 2, 0 };
|
private static final int[] stepseq = { 3, 1, 2, 0 };
|
||||||
|
|
||||||
|
public MapStep zoomFileMapStep() { return MapStep.X_PLUS_Y_MINUS; }
|
||||||
|
|
||||||
public int[] zoomFileStepSequence() { return stepseq; }
|
public int[] zoomFileStepSequence() { return stepseq; }
|
||||||
|
|
||||||
/* How many bits of coordinate are shifted off to make big world directory name */
|
/* How many bits of coordinate are shifted off to make big world directory name */
|
||||||
|
@ -17,6 +17,7 @@ import org.dynmap.Log;
|
|||||||
import org.dynmap.MapManager;
|
import org.dynmap.MapManager;
|
||||||
import org.dynmap.MapTile;
|
import org.dynmap.MapTile;
|
||||||
import org.dynmap.MapType;
|
import org.dynmap.MapType;
|
||||||
|
import org.dynmap.MapType.MapStep;
|
||||||
import org.dynmap.utils.MapChunkCache;
|
import org.dynmap.utils.MapChunkCache;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import java.awt.image.DataBufferInt;
|
import java.awt.image.DataBufferInt;
|
||||||
@ -335,8 +336,9 @@ public class KzedMap extends MapType {
|
|||||||
}
|
}
|
||||||
return s;
|
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 };
|
private static final int[] stepseq = { 0, 2, 1, 3 };
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ function HDProjection() {}
|
|||||||
HDProjection.prototype = {
|
HDProjection.prototype = {
|
||||||
extrazoom: 0,
|
extrazoom: 0,
|
||||||
fromLatLngToPoint: function(latLng) {
|
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) {
|
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) {
|
fromWorldToLatLng: function(x, y, z) {
|
||||||
return new google.maps.LatLng(-z / config.tileWidth / (1 << this.extrazoom), x / config.tileHeight / (1 << this.extrazoom));
|
return new google.maps.LatLng(-z / config.tileWidth / (1 << this.extrazoom), x / config.tileHeight / (1 << this.extrazoom));
|
||||||
|
Loading…
Reference in New Issue
Block a user