2011-07-18 03:40:24 +02:00
|
|
|
var KzedProjection = DynmapProjection.extend({
|
|
|
|
fromLocationToLatLng: function(location) {
|
|
|
|
var dx = location.x;
|
|
|
|
var dy = location.y - 127;
|
|
|
|
var dz = location.z;
|
|
|
|
var px = dx + dz;
|
|
|
|
var py = dx - dz - dy;
|
|
|
|
var scale = 2 << this.options.extrazoom;
|
|
|
|
|
|
|
|
var lat = px / scale - 64;
|
|
|
|
var lng = py / scale;
|
|
|
|
return new L.LatLng(-lat, lng, true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var KzedMapType = DynmapTileLayer.extend({
|
|
|
|
options: {
|
|
|
|
minZoom: 0,
|
|
|
|
maxZoom: 4
|
|
|
|
},
|
|
|
|
initialize: function(options) {
|
|
|
|
options.maxZoom = options.mapzoomin + options.world.extrazoomout;
|
|
|
|
L.Util.setOptions(this, options);
|
|
|
|
this.projection = new KzedProjection({extrazoom: this.options.world.extrazoomout});
|
|
|
|
},
|
|
|
|
getTileName: function(tilePoint, zoom) {
|
|
|
|
var tileSize = 128;
|
|
|
|
var tileName = '';
|
2011-05-30 00:24:46 +02:00
|
|
|
var dnprefix = '';
|
2011-07-18 03:40:24 +02:00
|
|
|
|
|
|
|
if(this.options.nightandday && this.options.dynmap.serverday) {
|
|
|
|
dnprefix = '_day';
|
|
|
|
}
|
|
|
|
var extrazoom = this.options.world.extrazoomout;
|
|
|
|
if (zoom <= extrazoom) {
|
|
|
|
var zpre = 'zzzzzzzzzzzzzzzz'.substring(0, extrazoom-zoom);
|
|
|
|
// Most zoomed out tiles.
|
2011-06-22 23:43:41 +02:00
|
|
|
var tilescale = 2 << (extrazoom-zoom);
|
2011-07-18 03:40:24 +02:00
|
|
|
if (this.options.bigmap) {
|
2011-06-24 09:46:16 +02:00
|
|
|
if(zoom < extrazoom) zpre = zpre + '_';
|
2011-07-18 03:40:24 +02:00
|
|
|
tileName = 'z' + this.options.prefix + dnprefix + '/' + ((-tilePoint.x * tileSize*tilescale)>>12) + '_' + ((tilePoint.y * tileSize*tilescale) >> 12) + '/' + zpre + (-tilePoint.x * tileSize*tilescale) + '_' + (tilePoint.y * tileSize*tilescale) + '.png';
|
|
|
|
} else {
|
|
|
|
tileName = zpre + 'z' + this.options.prefix + dnprefix + '_' + (-tilePoint.x * tileSize*tilescale) + '_' + (tilePoint.y * tileSize*tilescale) + '.png';
|
2011-06-14 04:43:02 +02:00
|
|
|
}
|
2011-07-18 03:40:24 +02:00
|
|
|
} else {
|
|
|
|
if(this.options.bigmap) {
|
|
|
|
tileName = this.options.prefix + dnprefix + '/' + ((-tilePoint.x*tileSize) >> 12) + '_' + ((tilePoint.y*tileSize)>>12) + '/' + (-tilePoint.x*tileSize) + '_' + (tilePoint.y*tileSize) + '.png';
|
|
|
|
} else {
|
|
|
|
tileName = this.options.prefix + dnprefix + '_' + (-tilePoint.x*tileSize) + '_' + (tilePoint.y*tileSize) + '.png';
|
2011-06-14 04:43:02 +02:00
|
|
|
}
|
2011-07-18 03:40:24 +02:00
|
|
|
}
|
|
|
|
return tileName;
|
|
|
|
},
|
|
|
|
calculateTileSize: function(zoom) {
|
|
|
|
var extrazoomout = this.options.dynmap.world.extrazoomout;
|
|
|
|
return (zoom <= extrazoom)
|
|
|
|
? 128
|
|
|
|
: Math.pow(2, 6+zoom-extrazoomout);
|
|
|
|
}
|
|
|
|
});
|
2011-02-06 15:09:15 +01:00
|
|
|
|
|
|
|
maptypes.KzedMapType = function(configuration) { return new KzedMapType(configuration); };
|