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;
|
2011-07-24 17:11:34 +02:00
|
|
|
var scale = 1 << this.options.mapzoomout;
|
2011-07-18 03:40:24 +02:00
|
|
|
|
2011-07-24 17:11:34 +02:00
|
|
|
var xx = (128 - px) / scale;
|
|
|
|
var yy = py / scale;
|
|
|
|
return new L.LatLng(xx, yy, true);
|
2011-08-03 17:21:29 +02:00
|
|
|
},
|
|
|
|
fromLatLngToLocation: function(latlon, y) {
|
|
|
|
var scale = 1 << this.options.mapzoomout;
|
|
|
|
var px = 128 - (latlon.lat * scale);
|
|
|
|
var py = latlon.lng * scale;
|
|
|
|
var x = (px + py + (y-127))/2;
|
|
|
|
var z = (px - x);
|
|
|
|
return { x: x, y: y, z: z };
|
2011-07-18 03:40:24 +02:00
|
|
|
}
|
2011-08-03 17:21:29 +02:00
|
|
|
|
2011-07-18 03:40:24 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
var KzedMapType = DynmapTileLayer.extend({
|
|
|
|
options: {
|
|
|
|
minZoom: 0,
|
2011-08-02 07:07:17 +02:00
|
|
|
maxZoom: 4,
|
2011-08-14 07:11:57 +02:00
|
|
|
errorTileUrl: 'images/blank.png',
|
|
|
|
continuousWorld: true
|
2011-07-18 03:40:24 +02:00
|
|
|
},
|
|
|
|
initialize: function(options) {
|
2011-07-24 17:11:34 +02:00
|
|
|
options.maxZoom = options.mapzoomin + options.mapzoomout;
|
2011-07-18 03:40:24 +02:00
|
|
|
L.Util.setOptions(this, options);
|
2011-07-24 17:11:34 +02:00
|
|
|
this.projection = new KzedProjection({mapzoomout: this.options.mapzoomout});
|
2011-07-18 03:40:24 +02:00
|
|
|
},
|
|
|
|
getTileName: function(tilePoint, zoom) {
|
2011-07-24 17:11:34 +02:00
|
|
|
var info = this.getTileInfo(tilePoint, zoom);
|
|
|
|
return namedReplace(this.options.bigmap
|
2011-08-02 23:10:04 +02:00
|
|
|
? '{zprefix}{nightday}/{scaledx}_{scaledy}/{zoomprefix}{x}_{y}.png'
|
2011-07-24 17:11:34 +02:00
|
|
|
: '{zoom}{prefix}{nightday}_{x}_{y}.png'
|
|
|
|
, this.getTileInfo(tilePoint, zoom));
|
2011-07-18 03:40:24 +02:00
|
|
|
},
|
2011-07-24 17:11:34 +02:00
|
|
|
getTileInfo: function(tilePoint, zoom) {
|
|
|
|
// Custom tile-info-calculation for KzedMap: *128 and >>12
|
|
|
|
var izoom = this.options.maxZoom - zoom;
|
|
|
|
var zoomoutlevel = Math.max(0, izoom - this.options.mapzoomin);
|
|
|
|
var scale = 1 << zoomoutlevel;
|
|
|
|
var x = -scale*tilePoint.x*128;
|
|
|
|
var y = scale*tilePoint.y*128;
|
|
|
|
return {
|
|
|
|
prefix: this.options.prefix,
|
|
|
|
nightday: (this.options.nightandday && this.options.dynmap.serverday) ? '_day' : '',
|
|
|
|
scaledx: x >> 12,
|
|
|
|
scaledy: y >> 12,
|
|
|
|
zoom: this.zoomprefix(zoomoutlevel),
|
2011-08-02 23:10:04 +02:00
|
|
|
zoomprefix: (zoomoutlevel<2)?"":(this.zoomprefix(zoomoutlevel-1)+"_"),
|
|
|
|
zprefix: (zoomoutlevel==0)?this.options.prefix:("z"+this.options.prefix),
|
2011-07-24 17:11:34 +02:00
|
|
|
x: x,
|
|
|
|
y: y
|
|
|
|
};
|
2011-07-18 03:40:24 +02:00
|
|
|
}
|
|
|
|
});
|
2011-02-06 15:09:15 +01:00
|
|
|
|
|
|
|
maptypes.KzedMapType = function(configuration) { return new KzedMapType(configuration); };
|