From b75eb7e5b5b67e03843d18be592350d4a576810d Mon Sep 17 00:00:00 2001 From: Freakus Geekus Date: Sat, 16 Feb 2013 21:05:36 +0000 Subject: [PATCH 1/8] POI dict and polyline support Added support for filter functions to return dicts. Added support for filter functions to return a list of coordinates to draw lines between when shown. --- overviewer_core/aux_files/genPOI.py | 48 ++++++++++++++++++++++++++++ overviewer_core/data/js_src/views.js | 16 ++++++++++ 2 files changed, 64 insertions(+) diff --git a/overviewer_core/aux_files/genPOI.py b/overviewer_core/aux_files/genPOI.py index e25a053..f41e93e 100755 --- a/overviewer_core/aux_files/genPOI.py +++ b/overviewer_core/aux_files/genPOI.py @@ -216,6 +216,22 @@ def main(): d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) elif type(result) == tuple: d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) + # Dict support to allow more flexible things in the future as well as polylines on the map. + elif type(result) == dict: + d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text']) + # Use custom hovertext if provided... + if 'hovertext' in result and isinstance(result['hovertext'], basestring): + d['hovertext'] = result['hovertext'] + else: # ...otherwise default to display text. + d['hovertext'] = result['text'] + if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple: + d['polyline'] = [] + for point in result['polyline']: + # This poor man's validation code almost definately needs improving. + if type(point) == dict: + d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z'])) + if isinstance(result['color'], basestring): + d['strokeColor'] = result['color'] if "icon" in poi: d.update({"icon": poi['icon']}) if "createInfoWindow" in poi: @@ -228,6 +244,22 @@ def main(): d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) elif type(result) == tuple: d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) + # Dict support to allow more flexible things in the future as well as polylines on the map. + elif type(result) == dict: + d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text']) + # Use custom hovertext if provided... + if 'hovertext' in result and isinstance(result['hovertext'], basestring): + d['hovertext'] = result['hovertext'] + else: # ...otherwise default to display text. + d['hovertext'] = result['text'] + if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple: + d['polyline'] = [] + for point in result['polyline']: + # This poor man's validation code almost definately needs improving. + if type(point) == dict: + d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z'])) + if isinstance(result['color'], basestring): + d['strokeColor'] = result['color'] if "icon" in poi: d.update({"icon": poi['icon']}) if "createInfoWindow" in poi: @@ -240,6 +272,22 @@ def main(): d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) elif type(result) == tuple: d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) + # Dict support to allow more flexible things in the future as well as polylines on the map. + elif type(result) == dict: + d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text']) + # Use custom hovertext if provided... + if 'hovertext' in result and isinstance(result['hovertext'], basestring): + d['hovertext'] = result['hovertext'] + else: # ...otherwise default to display text. + d['hovertext'] = result['text'] + if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple: + d['polyline'] = [] + for point in result['polyline']: + # This poor man's validation code almost definately needs improving. + if type(point) == dict: + d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z'])) + if isinstance(result['color'], basestring): + d['strokeColor'] = result['color'] if "icon" in poi: d.update({"icon": poi['icon']}) if "createInfoWindow" in poi: diff --git a/overviewer_core/data/js_src/views.js b/overviewer_core/data/js_src/views.js index bbd75c1..2421b11 100644 --- a/overviewer_core/data/js_src/views.js +++ b/overviewer_core/data/js_src/views.js @@ -474,6 +474,22 @@ overviewer.views.SignControlView = Backbone.View.extend({ } } dataRoot[i].markerObjs.push(marker); + // Polyline stuff added by FreakusGeekus. Probably needs work. + if (typeof entity['polyline'] != 'undefined') { + var polypath = new Array(); + for (point in entity.polyline) { + polypath.push(overviewer.util.fromWorldToLatLng(entity.polyline[point].x, entity.polyline[point].y, entity.polyline[point].z, overviewer.mapView.options.currentTileSet)); + } + + var polyline = new google.maps.Polyline({ + 'path': polypath, + 'clickable': false, + 'map': overviewer.map, + 'visible': false, + 'strokeColor': entity['strokeColor'] + }); + dataRoot[i].markerObjs.push(polyline); + } } dataRoot[i].created = true; } From 6e3556ab1214bfe256f2bb9c14144202f10e5e42 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Mon, 6 May 2013 18:11:45 -0300 Subject: [PATCH 2/8] nbt timestamps are probably signed (like time_t) Besides, we get overflow errors with utime on windows for large unsigned 32-bit integers. --- overviewer_core/nbt.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/overviewer_core/nbt.py b/overviewer_core/nbt.py index 3d69f8b..cadeccf 100644 --- a/overviewer_core/nbt.py +++ b/overviewer_core/nbt.py @@ -199,7 +199,8 @@ class MCRFileReader(object): listing chunks contained in the file. """ - _table_format = struct.Struct(">1024I") + _location_table_format = struct.Struct(">1024I") + _timestamp_table_format = struct.Struct(">1024i") _chunk_header_format = struct.Struct(">I B") def __init__(self, fileobj): @@ -217,8 +218,8 @@ class MCRFileReader(object): raise CorruptRegionError("invalid timestamp table") # turn this data into a useful list - self._locations = self._table_format.unpack(location_data) - self._timestamps = self._table_format.unpack(timestamp_data) + self._locations = self._location_table_format.unpack(location_data) + self._timestamps = self._timestamp_table_format.unpack(timestamp_data) def close(self): """Close the region file and free any resources associated From 478d44f48002d4fbb1b79ecb8055aefb770ecb30 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Tue, 7 May 2013 21:34:31 -0400 Subject: [PATCH 3/8] Docs updates for #882 (JSObserver formatting strings) --- docs/config.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index a72e5dd..b1047ac 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -294,7 +294,7 @@ the form ``key = value``. Two items take a different form:, ``worlds`` and * ``messages=dict(totalTiles=, renderCompleted=, renderProgress=)`` Customises messages displayed in browser. All three messages must be - defined as follows: + defined similar to the following: * ``totalTiles="Rendering %d tiles"`` The ``%d`` format string will be replaced with the total number of @@ -304,9 +304,9 @@ the form ``key = value``. Two items take a different form:, ``worlds`` and The three format strings will be replaced with the number of hours. minutes and seconds taken to complete this render. - * ``renderProgress="Rendered %d of %d tiles (%d%%)"`` - The three format strings will be replaced with the number of tiles - completed, the total number of tiles and the percentage complete + * ``renderProgress="Rendered %d of %d tiles (%d%% ETA:%s)""`` + The four format strings will be replaced with the number of tiles + completed, the total number of tiles, the percentage complete, and the ETA. Format strings are explained here: http://docs.python.org/library/stdtypes.html#string-formatting All format strings must be present in your custom messages. From 4b1e8fd3e45d7f3314a05e700b36d9ffa786c3b9 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Sat, 11 May 2013 16:11:50 +0200 Subject: [PATCH 4/8] Add all stem and all cap blocks for big mushrooms. --- overviewer_core/textures.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/overviewer_core/textures.py b/overviewer_core/textures.py index 115a892..75f78f6 100644 --- a/overviewer_core/textures.py +++ b/overviewer_core/textures.py @@ -3159,7 +3159,7 @@ def stone_brick(self, blockid, data): return img # huge brown and red mushroom -@material(blockid=[99,100], data=range(11), solid=True) +@material(blockid=[99,100], data= range(11) + [14,15], solid=True) def huge_mushroom(self, blockid, data): # rotation if self.rotation == 1: @@ -3232,6 +3232,12 @@ def huge_mushroom(self, blockid, data): if data == 10: # stem img = self.build_full_block(porous, None, None, stem, stem) + if data == 14: # all cap + img = self.build_block(cap,cap) + + if data == 15: # all stem + img = self.build_block(stem,stem) + return img # iron bars and glass pane From 372b4e5e448b2a4eab20877ebc7c8aece976c5c6 Mon Sep 17 00:00:00 2001 From: Kang Seonghoon Date: Thu, 2 May 2013 01:22:55 +0900 Subject: [PATCH 5/8] added support for hashchange event for recent browsers --- overviewer_core/data/js_src/util.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/overviewer_core/data/js_src/util.js b/overviewer_core/data/js_src/util.js index d3c9515..156640e 100644 --- a/overviewer_core/data/js_src/util.js +++ b/overviewer_core/data/js_src/util.js @@ -138,8 +138,9 @@ overviewer.util = { overviewer.mapView.render(); - // Jump to the hash if given + // Jump to the hash if given (and do so for any further hash changes) overviewer.util.initHash(); + $(window).on('hashchange', function() { overviewer.util.initHash(); }); // create this control after initHash so it can correctly select the current world var worldSelector = new overviewer.views.WorldSelectorView({tagName:'DIV'}); From e466f891e1cf9875f05bc077206c22107e8d4c64 Mon Sep 17 00:00:00 2001 From: Kang Seonghoon Date: Sun, 12 May 2013 00:32:44 +0900 Subject: [PATCH 6/8] hashchange triggered by setHash is now properly ignored --- overviewer_core/data/js_src/util.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/overviewer_core/data/js_src/util.js b/overviewer_core/data/js_src/util.js index 156640e..59e884f 100644 --- a/overviewer_core/data/js_src/util.js +++ b/overviewer_core/data/js_src/util.js @@ -3,7 +3,9 @@ overviewer.util = { // vars for callback readyQueue: [], isReady: false, - + + lastHash: null, + /* fuzz tester! */ 'testMaths': function(t) { @@ -466,18 +468,23 @@ overviewer.util = { }); }, 'initHash': function() { - if(window.location.hash.split("/").length > 1) { - overviewer.util.goToHash(); - // Clean up the hash. - overviewer.util.updateHash(); - + var newHash = window.location.hash; + if (overviewer.util.lastHash !== newHash) { + overviewer.util.lastHash = newHash; + if(newHash.split("/").length > 1) { + overviewer.util.goToHash(); + // Clean up the hash. + overviewer.util.updateHash(); + } } }, 'setHash': function(x, y, z, zoom, w, maptype) { // save this info is a nice easy to parse format var currentWorldView = overviewer.mapModel.get("currentWorldView"); currentWorldView.options.lastViewport = [x,y,z,zoom]; - window.location.replace("#/" + Math.floor(x) + "/" + Math.floor(y) + "/" + Math.floor(z) + "/" + zoom + "/" + w + "/" + maptype); + var newHash = "#/" + Math.floor(x) + "/" + Math.floor(y) + "/" + Math.floor(z) + "/" + zoom + "/" + w + "/" + maptype; + overviewer.util.lastHash = newHash; // this should not trigger initHash + window.location.replace(newHash); }, 'updateHash': function() { var currTileset = overviewer.mapView.options.currentTileSet; From 0783cdbee740d8b2841287d855ecdbb4221c9d4d Mon Sep 17 00:00:00 2001 From: Nicolas Frattaroli Date: Mon, 13 May 2013 14:32:50 +0200 Subject: [PATCH 7/8] Changed default poititle to "Markers" I feel this is more accurate and it has been bugging me for a while now. --- overviewer_core/settingsDefinition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overviewer_core/settingsDefinition.py b/overviewer_core/settingsDefinition.py index 22509de..557c7cb 100644 --- a/overviewer_core/settingsDefinition.py +++ b/overviewer_core/settingsDefinition.py @@ -83,7 +83,7 @@ renders = Setting(required=True, default=util.OrderedDict(), "overlay": Setting(required=False, validator=validateOverlays, default=[]), "showspawn": Setting(required=False, validator=validateBool, default=True), "base": Setting(required=False, validator=validateStr, default=""), - "poititle": Setting(required=False, validator=validateStr, default="Signs"), + "poititle": Setting(required=False, validator=validateStr, default="Markers"), "customwebassets": Setting(required=False, validator=validateWebAssetsPath, default=None), "maxzoom": Setting(required=False, validator=validateInt, default=None), "manualpois": Setting(required=False, validator=validateManualPOIs, default=[]), From 3986e10af2dbd3d34ef4026a5e12e0c5081e3e85 Mon Sep 17 00:00:00 2001 From: Nicolas Frattaroli Date: Mon, 13 May 2013 15:38:54 +0200 Subject: [PATCH 8/8] Added option showlocationmarker --- docs/config.rst | 6 ++++++ overviewer.py | 2 +- overviewer_core/assetmanager.py | 4 ++-- overviewer_core/data/js_src/views.js | 2 +- overviewer_core/settingsDefinition.py | 1 + overviewer_core/tileset.py | 3 ++- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index b1047ac..02afe1d 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -529,6 +529,12 @@ values. The valid configuration keys are listed below. **Default:** Automatically set to most detailed zoom level +``showlocationmarker`` + Allows you to specify whether to show the location marker when accessing a URL + with coordinates specified. + + **Default:** ``True`` + ``base`` Allows you to specify a remote location for the tile folder, useful if you rsync your map's images to a remote server. Leave a trailing slash and point diff --git a/overviewer.py b/overviewer.py index 2948eab..232f176 100755 --- a/overviewer.py +++ b/overviewer.py @@ -460,7 +460,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces. # only pass to the TileSet the options it really cares about render['name'] = render_name # perhaps a hack. This is stored here for the asset manager - tileSetOpts = util.dict_subset(render, ["name", "imgformat", "renderchecks", "rerenderprob", "bgcolor", "defaultzoom", "imgquality", "optimizeimg", "rendermode", "worldname_orig", "title", "dimension", "changelist", "showspawn", "overlay", "base", "poititle", "maxzoom"]) + tileSetOpts = util.dict_subset(render, ["name", "imgformat", "renderchecks", "rerenderprob", "bgcolor", "defaultzoom", "imgquality", "optimizeimg", "rendermode", "worldname_orig", "title", "dimension", "changelist", "showspawn", "overlay", "base", "poititle", "maxzoom", "showlocationmarker"]) tileSetOpts.update({"spawn": w.find_true_spawn()}) # TODO find a better way to do this tset = tileset.TileSet(w, rset, assetMrg, tex, tileSetOpts, tileset_dir) tilesets.append(tset) diff --git a/overviewer_core/assetmanager.py b/overviewer_core/assetmanager.py index abc50f2..be3b083 100644 --- a/overviewer_core/assetmanager.py +++ b/overviewer_core/assetmanager.py @@ -95,7 +95,7 @@ directory. 'queryMarker': 'http://google-maps-icons.googlecode.com/files/regroup.png' } dump['CONST']['mapDivId'] = 'mcmap' - dump['CONST']['regionStrokeWeight'] = 2 + dump['CONST']['regionStrokeWeight'] = 2 # Obselete dump['CONST']['UPPERLEFT'] = world.UPPER_LEFT; dump['CONST']['UPPERRIGHT'] = world.UPPER_RIGHT; dump['CONST']['LOWERLEFT'] = world.LOWER_LEFT; @@ -122,7 +122,7 @@ directory. 'mapType': True, 'overlays': True, 'coordsBox': True, - 'searchBox': True + 'searchBox': True # Lolwat. Obselete } diff --git a/overviewer_core/data/js_src/views.js b/overviewer_core/data/js_src/views.js index bbd75c1..56fa9f9 100644 --- a/overviewer_core/data/js_src/views.js +++ b/overviewer_core/data/js_src/views.js @@ -571,7 +571,7 @@ overviewer.views.LocationIconView = Backbone.View.extend({ 'icon': overviewerConfig.CONST.image.queryMarker, 'visible': false }); - overviewer.collections.locationMarker.setVisible(true); + overviewer.collections.locationMarker.setVisible(overviewer.mapView.options.currentTileSet.get("showlocationmarker")); } }); diff --git a/overviewer_core/settingsDefinition.py b/overviewer_core/settingsDefinition.py index 557c7cb..cffdd0a 100644 --- a/overviewer_core/settingsDefinition.py +++ b/overviewer_core/settingsDefinition.py @@ -87,6 +87,7 @@ renders = Setting(required=True, default=util.OrderedDict(), "customwebassets": Setting(required=False, validator=validateWebAssetsPath, default=None), "maxzoom": Setting(required=False, validator=validateInt, default=None), "manualpois": Setting(required=False, validator=validateManualPOIs, default=[]), + "showlocationmarker": Setting(required=False, validator=validateBool, default=True), # 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")), diff --git a/overviewer_core/tileset.py b/overviewer_core/tileset.py index 251e701..825816a 100644 --- a/overviewer_core/tileset.py +++ b/overviewer_core/tileset.py @@ -528,7 +528,8 @@ class TileSet(object): last_rendertime = self.max_chunk_mtime, imgextension = self.imgextension, isOverlay = isOverlay, - poititle = self.options.get("poititle") + poititle = self.options.get("poititle"), + showlocationmarker = self.options.get("showlocationmarker") ) if isOverlay: