Add "center" config option
This option allows you to specify your own initial center for a tileset, which is useful if your map is extremely asymmetric or you don't really care about what's around the spawn. Future work needs to be done on the JS side in order to fix the fromWorldToLatLng and friends, as they're currently off by -24 in X and +24 in Z direction. Closes #1350.
This commit is contained in:
@@ -128,7 +128,6 @@ top-level directory.
|
||||
dump['map']['debug'] = True
|
||||
dump['map']['cacheTag'] = str(int(time.time()))
|
||||
dump['map']['north_direction'] = 'lower-left' # only temporary
|
||||
dump['map']['center'] = [-314, 67, 94]
|
||||
dump['map']['controls'] = {
|
||||
'pan': True,
|
||||
'zoom': True,
|
||||
|
||||
@@ -422,8 +422,8 @@ overviewer.util = {
|
||||
myLayer["tileSetConfig"] = obj;
|
||||
|
||||
|
||||
if (typeof(obj.spawn) == "object") {
|
||||
var latlng = overviewer.util.fromWorldToLatLng(obj.spawn[0], obj.spawn[1], obj.spawn[2], obj);
|
||||
if (typeof(obj.center) == "object") {
|
||||
var latlng = overviewer.util.fromWorldToLatLng(obj.center[0], obj.center[1], obj.center[2], obj);
|
||||
overviewer.collections.centers[obj.world] = [ latlng, obj.defaultZoom ];
|
||||
} else {
|
||||
overviewer.collections.centers[obj.world] = [ [0, 0], obj.defaultZoom ];
|
||||
|
||||
@@ -93,6 +93,7 @@ renders = Setting(required=True, default=OrderedDict(),
|
||||
"minzoom": Setting(required=False, validator=validateInt, default=0),
|
||||
"manualpois": Setting(required=False, validator=validateManualPOIs, default=[]),
|
||||
"showlocationmarker": Setting(required=False, validator=validateBool, default=True),
|
||||
"center": Setting(required=False, validator=validateCoords, default=None),
|
||||
# Remove this eventually (once people update their configs)
|
||||
"worldname": Setting(required=False, default=None,
|
||||
validator=error("The option 'worldname' is now called 'world'. Please update your config files")),
|
||||
|
||||
@@ -308,6 +308,20 @@ def validateManualPOIs(d):
|
||||
return d
|
||||
|
||||
|
||||
def validateCoords(c):
|
||||
if not isinstance(c, (list, tuple)):
|
||||
raise ValidationException("Your coordinates '{}' are not a list or a tuple.".format(c))
|
||||
if len(c) not in [2, 3]:
|
||||
raise ValidationException("'{}' is not a valid list or tuple of coordinates, "
|
||||
"because we expect either 2 or 3 elements.".format(c))
|
||||
if len(c) == 2:
|
||||
x, z = [validateInt(i) for i in c]
|
||||
y = 64
|
||||
else:
|
||||
x, y, z = [validateInt(i) for i in c]
|
||||
return (x, y, z)
|
||||
|
||||
|
||||
def make_dictValidator(keyvalidator, valuevalidator):
|
||||
"""Compose and return a dict validator -- a validator that validates each
|
||||
key and value in a dictionary.
|
||||
|
||||
@@ -589,7 +589,9 @@ class TileSet(object):
|
||||
imgextension=self.imgextension,
|
||||
isOverlay=isOverlay,
|
||||
poititle=self.options.get("poititle"),
|
||||
showlocationmarker=self.options.get("showlocationmarker")
|
||||
showlocationmarker=self.options.get("showlocationmarker"),
|
||||
center=(self.options.get("center") or self.options.get("spawn")
|
||||
or [0, 64, 0])
|
||||
)
|
||||
d['maxZoom'] = self.options.get('maxzoom', self.treedepth)
|
||||
if d['maxZoom'] < 0:
|
||||
|
||||
Reference in New Issue
Block a user