From ad0e38f7bbbb7ea5f8380a7c58649833e4e2a55b Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Mon, 18 Apr 2011 09:44:10 -0400 Subject: [PATCH 01/16] live updating hashes instead of permalinks --- web_assets/functions.js | 23 ++++++++--------------- web_assets/style.css | 12 +++++++++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/web_assets/functions.js b/web_assets/functions.js index 96742af..19e3902 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -240,11 +240,7 @@ function initMarkers() { function makeLink() { - var a=location.href.substring(0,location.href.lastIndexOf(location.search)) - + "?lat=" + map.getCenter().lat().toFixed(6) - + "&lng=" + map.getCenter().lng().toFixed(6) - + "&zoom=" + map.getZoom(); - document.getElementById("link").innerHTML = a; + location.hash = "#/"+map.getCenter().lat().toFixed(3)+"/"+map.getCenter().lng().toFixed(3)+"/"+map.getZoom(); } function initialize() { @@ -254,17 +250,14 @@ function initialize() { var lat = 0.5; var lng = 0.5; var zoom = config.defaultZoom; - var pairs = query.split("&"); - for (var i=0; i 1) { + lat = parseFloat(params[1]) + lng = parseFloat(params[2]) + zoom = parseInt(params[3]) } var mapTyepControlToggle = false diff --git a/web_assets/style.css b/web_assets/style.css index e6029dc..e4e9f6e 100644 --- a/web_assets/style.css +++ b/web_assets/style.css @@ -1,7 +1,14 @@ -html { height: 100% } +html { + height: 100%; + font-family: lucida grande, lucida sans console, sans-serif; +} body { height: 100%; margin: 0px; padding: 0px ; background-color: #000; } #mcmap { height: 100% } +#mcmap div div a img, #mcmap div div div a { + display:none; +} + .infoWindow { height: 100px; } @@ -20,10 +27,10 @@ body { height: 100%; margin: 0px; padding: 0px ; background-color: #000; } #signControl { padding: 5px; height: 15px; - font-family: Arial, sans-serif; } #signControl > div#top { + display:none; background-color: #fff; border: 2px solid #000; text-align: center; @@ -44,7 +51,6 @@ body { height: 100%; margin: 0px; padding: 0px ; background-color: #000; } #link { background-color: #fff; /* fallback */ background-color: rgba(255,255,255,0.55); - border: 1px solid rgb(0, 0, 0); font-size: 9pt; padding-left: 2px; padding-right: 2px; From 4c07eb0c7aedda03e5f3f70d7e7f31fc35c96d8d Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Sat, 30 Apr 2011 15:08:29 -0400 Subject: [PATCH 02/16] live URL hash rewriting as you drag/zoom instead of permalink at bottom, hard named permalinks such as foo.com/#/jeffs-island --- web_assets/overviewer.css | 18 ++-------- web_assets/overviewer.js | 71 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 20 deletions(-) diff --git a/web_assets/overviewer.css b/web_assets/overviewer.css index e29ec4f..6b5cff4 100644 --- a/web_assets/overviewer.css +++ b/web_assets/overviewer.css @@ -1,25 +1,13 @@ html { height: 100%; -<<<<<<< HEAD:web_assets/style.css font-family: lucida grande, lucida sans console, sans-serif; } body { height: 100%; margin: 0px; padding: 0px ; background-color: #000; } -#mcmap { height: 100% } -======= -} - -body { - height: 100%; - margin: 0px; - padding: 0px; - background-color: #000; -} #mcmap { width: 100%; height: 100%; } ->>>>>>> f20d81c39f0302a44e02a6f42f6eb0d13b9fcc18:web_assets/overviewer.css #mcmap div div a img, #mcmap div div div a { display:none; @@ -43,14 +31,13 @@ body { #customControl { padding: 5px; height: 15px; + display:none; } -<<<<<<< HEAD:web_assets/style.css #signControl > div#top { display:none; -======= +} #customControl > div#top { ->>>>>>> f20d81c39f0302a44e02a6f42f6eb0d13b9fcc18:web_assets/overviewer.css background-color: #fff; border: 2px solid #000; text-align: center; @@ -76,6 +63,7 @@ body { #link { + display:none; background-color: #fff; /* fallback */ background-color: rgba(255,255,255,0.55); font-size: 9pt; diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index f927625..ab2ad51 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -58,6 +58,7 @@ var overviewer = { overviewer.util.initializeMarkers(); overviewer.util.initializeRegions(); overviewer.util.createMapControls(); + setInterval(overviewer.goToHash,500); }, /** * This adds some methods to these classes because Javascript is stupid @@ -141,11 +142,14 @@ var overviewer = { var defaultCenter = overviewer.util.fromWorldToLatLng( overviewerConfig.map.center[0], overviewerConfig.map.center[1], overviewerConfig.map.center[2]); + var lat = defaultCenter.lat(); var lng = defaultCenter.lng(); var zoom = overviewerConfig.map.defaultZoom; + var mapcenter; queryParams = overviewer.util.parseQueryString(); + queryParams = overviewer.readHash(queryParams); if (queryParams.lat) { lat = parseFloat(queryParams.lat); } @@ -162,10 +166,10 @@ var overviewer = { if (zoom < 0 && zoom + overviewerConfig.map.maxZoom >= 0) { //if zoom is negative, try to treat as "zoom out from max zoom" zoom += overviewerConfig.map.maxZoom; - } else { + } //else { //fall back to default zoom - zoom = overviewerConfig.map.defaultZoom; - } + //zoom = overviewerConfig.map.defaultZoom; + //} } } if (queryParams.x && queryParams.y && queryParams.z) { @@ -234,6 +238,14 @@ var overviewer = { }); // We can now set the map to use the 'coordinate' map type overviewer.map.setMapTypeId(overviewer.util.getDefaultMapTypeId()); + + // Make the link again whenever the map changes + google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { + overviewer.setHash(); + }); + google.maps.event.addListener(overviewer.map, 'center_changed', function() { + overviewer.setHash(); + }); }, /** * Read through overviewer.collections.markerDatas and create Marker @@ -301,7 +313,7 @@ var overviewer = { 'map': overviewer.map, 'title': jQuery.trim(item.msg), 'icon': iconURL, - 'visible': false + 'visible': true }); overviewer.util.debug(label); overviewer.collections.markers[label].push(marker); @@ -889,5 +901,54 @@ var overviewer = { return(urlBase + url); } } - } + }, + setHash: function() { + var hash = window.location.hash + var params = hash.split("/") + if (params.length > 1) { + if (overviewer.permalinks[params[1]]) { + hard_permalink = true; + } + } + location.hash = "#/"+overviewer.map.getCenter().lat().toFixed(3)+"/"+overviewer.map.getCenter().lng().toFixed(3)+"/"+overviewer.map.getZoom(); + }, + permalinks: { + "rent": { + text: "Rent is $200/month jeff@ unterbahn.com", + position: {lat: 0.546875, lng: 0.48046875, zoom: 6} + } + }, + openSign: function(markerName) { + var marker = null; + for (i=0;i 1) { + if (params[1] == "rent") { + mapOptions = overviewer.permalinks[params[1]].position + if (overviewer.collections.markers.All) openSign("rent"); + } else { + mapOptions.lat = parseFloat(params[1]) + mapOptions.lng = parseFloat(params[2]) + mapOptions.zoom = parseInt(params[3]) + } + } + return mapOptions + }, + goToHash: function() { + mapOptions = overviewer.readHash(); + if (overviewer.map) overviewer.map.setCenter(new google.maps.LatLng(mapOptions.lat, mapOptions.lng)) + if (overviewer.map) overviewer.map.setZoom(mapOptions.zoom) + } }; From bac0c7604d18171ca800a8292ede82d686c41179 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 5 May 2011 14:23:04 -0400 Subject: [PATCH 03/16] switched to dragend event for optimization --- web_assets/overviewer.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index ab2ad51..9732511 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -58,6 +58,8 @@ var overviewer = { overviewer.util.initializeMarkers(); overviewer.util.initializeRegions(); overviewer.util.createMapControls(); + //window.addEventListener("hashchange",overviewer.goToHash,false); + //window.onhashchange = overviewer.goToHash; setInterval(overviewer.goToHash,500); }, /** @@ -240,10 +242,7 @@ var overviewer = { overviewer.map.setMapTypeId(overviewer.util.getDefaultMapTypeId()); // Make the link again whenever the map changes - google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { - overviewer.setHash(); - }); - google.maps.event.addListener(overviewer.map, 'center_changed', function() { + google.maps.event.addListener(overviewer.map, 'dragend', function() { overviewer.setHash(); }); }, From 1983036ac9587dd0e8c1c4436cfc1147d08f6a30 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 5 May 2011 14:46:33 -0400 Subject: [PATCH 04/16] putting back in zoom_changed event... oops --- web_assets/overviewer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index 9732511..e472881 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -245,6 +245,9 @@ var overviewer = { google.maps.event.addListener(overviewer.map, 'dragend', function() { overviewer.setHash(); }); + google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { + overviewer.setHash(); + }); }, /** * Read through overviewer.collections.markerDatas and create Marker From 5a483ba4cc5fd36f2e6fbaeb9dad1bcfbcdba058 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Tue, 10 May 2011 20:34:09 -0400 Subject: [PATCH 05/16] added pironic to CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index e251b41..cc5acef 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -28,6 +28,7 @@ for many different parts of the code. * Aaron Griffith * Alex Headley * Alex Jurkiewicz + * Michael Writhe * Xon ------------------------ From ec6fb82c7f3aca57a6cb8e1d57c42f1669c71487 Mon Sep 17 00:00:00 2001 From: Michael Writhe Date: Wed, 11 May 2011 15:36:39 -0600 Subject: [PATCH 06/16] regin click should show clicked spot in xyz not lat/lng --- web_assets/overviewer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index eea2f7d..dc02467 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -775,9 +775,11 @@ var overviewer = { overviewer.collections.infoWindow.close(); } // Replace our Info Window's content and position + var point = overviewer.util.fromLatLngToWorld(event.latLng.lat(),event.latLng.lng()); var contentString = 'Region: ' + shape.name + '
' + - 'Clicked Location:
' + event.latLng.lat() + ', ' + - event.latLng.lng() + '
'; + 'Clicked Location:
' + Math.round(point.x,1) + ', ' + point.y + + ', ' + Math.round(point.z,1) + + '
'; infowindow.setContent(contentString); infowindow.setPosition(event.latLng); infowindow.open(overviewer.map); From 2db3f57d38229249825cc3583409d3c82184d4ad Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Thu, 12 May 2011 14:54:25 +0200 Subject: [PATCH 07/16] Add signposts. Add transform_image_angle function. --- textures.py | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/textures.py b/textures.py index b5fb86a..80de34b 100644 --- a/textures.py +++ b/textures.py @@ -19,7 +19,7 @@ import os.path import zipfile from cStringIO import StringIO import math - +from random import randint import numpy from PIL import Image, ImageEnhance, ImageOps, ImageDraw @@ -189,7 +189,47 @@ def transform_image_slope(img, blockID=None): newimg = img.transform((24,24), Image.AFFINE, transform) return newimg + + +def transform_image_angle(img, angle, blockID=None): + """Takes an image an shears it in arbitrary angle with the axis of + rotation being vertical. + WARNING! Don't use angle = pi/2 (or multiplies), it will return + a blank image (or maybe garbage). + + NOTE: angle is in the image not in game, so for the left side of a + block angle = 30 degree. + """ + + # Take the same size as trasform_image_side + img = img.resize((12,12), Image.ANTIALIAS) + + # some values + cos_angle = math.cos(angle) + sin_angle = math.sin(angle) + + # function_x and function_y are used to keep the result image in the + # same position, and constant_x and constant_y are the coordinates + # for the center for angle = 0. + constant_x = 6. + constant_y = 6. + function_x = 6.*(1-cos_angle) + function_y = -6*sin_angle + big_term = ( (sin_angle * (function_x + constant_x)) - cos_angle* (function_y + constant_y))/cos_angle + + # The numpy array is not really used, but is helpful to + # see the matrix used for the transformation. + transform = numpy.array([[1./cos_angle, 0, -(function_x + constant_x)/cos_angle], + [-sin_angle/(cos_angle), 1., big_term ], + [0, 0, 1.]]) + + transform = tuple(transform[0]) + tuple(transform[1]) + + newimg = img.transform((24,24), Image.AFFINE, transform) + + return newimg + def _build_block(top, side, blockID=None): """From a top texture and a side texture, build a block image. @@ -982,6 +1022,49 @@ def generate_special_texture(blockID, data): return (img.convert("RGB"), img.split()[3]) + if blockID == 63: # singposts + + texture = terrain_images[4].copy() + # cut the wood to the size of a signpost + ImageDraw.Draw(texture).rectangle((0,12,15,15),outline=(0,0,0,0),fill=(0,0,0,0)) + + # If the signpost is looking directly to the image, draw some + # random dots, they will look as text. + if data in (0,1,2,3,4,5,15): + for i in range(15): + x = randint(4,11) + y = randint(3,7) + texture.putpixel((x,y),(0,0,0,255)) + + # Minecraft uses wood texture for the signpost stick + texture_stick = terrain_images[20] + texture_stick = texture_stick.resize((12,12), Image.ANTIALIAS) + ImageDraw.Draw(texture_stick).rectangle((2,0,12,12),outline=(0,0,0,0),fill=(0,0,0,0)) + + img = Image.new("RGBA", (24,24), (38,92,255,0)) + + # W N ~90 E S ~270 + angles = (330.,345.,0.,15.,30.,55.,95.,120.,150.,165.,180.,195.,210.,230.,265.,310.) + angle = math.radians(angles[data]) + post = transform_image_angle(texture, angle) + + # choose the position of the "3D effect" + incrementx = 0 + if data in (1,6,7,8,9,14): + incrementx = -1 + elif data in (3,4,5,11,12,13): + incrementx = +1 + + composite.alpha_over(img, texture_stick,(11, 8),texture_stick) + # post2 is a brighter signpost pasted with a small sift, + # gives to the signpost some 3D effect. + post2 = ImageEnhance.Brightness(post).enhance(1.2) + composite.alpha_over(img, post2,(incrementx, -3),post2) + composite.alpha_over(img, post, (0,-2), post) + + return (img.convert("RGB"), img.split()[3]) + + if blockID in (64,71): #wooden door, or iron door if data & 0x8 == 0x8: # top of the door raw_door = terrain_images[81 if blockID == 64 else 82] @@ -1492,8 +1575,8 @@ def getBiomeData(worlddir, chunkX, chunkY): # please, if possible, keep the ascending order of blockid value) special_blocks = set([ 2, 6, 9, 17, 18, 26, 23, 27, 28, 35, 43, 44, 50, - 51, 53, 54, 55, 58, 59, 61, 62, 64, 65, 66, 67, 71, - 75, 76, 85, 86, 90, 91, 92, 93, 94]) + 51, 53, 54, 55, 58, 59, 61, 62, 63, 64, 65, 66, 67, + 71, 75, 76, 85, 86, 90, 91, 92, 93, 94]) # this is a map of special blockIDs to a list of all # possible values for ancillary data that it might have. @@ -1519,6 +1602,7 @@ special_map[58] = (0,) # crafting table special_map[59] = range(8) # crops, grow from 0 to 7 special_map[61] = range(6) # furnace, orientation special_map[62] = range(6) # burning furnace, orientation +special_map[63] = range(16) # signpost, orientation special_map[64] = range(16) # wooden door, open/close and orientation special_map[65] = (2,3,4,5) # ladder, orientation special_map[66] = range(10) # minecrart tracks, orientation, slope From 04fe00e315b30c559ad7f583217e215f6720b769 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Thu, 12 May 2011 15:31:46 +0200 Subject: [PATCH 08/16] Add wall signs. Fix torch positios for south oriented repeater. --- textures.py | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/textures.py b/textures.py index 80de34b..ec77795 100644 --- a/textures.py +++ b/textures.py @@ -1025,7 +1025,7 @@ def generate_special_texture(blockID, data): if blockID == 63: # singposts texture = terrain_images[4].copy() - # cut the wood to the size of a signpost + # cut the planks to the size of a signpost ImageDraw.Draw(texture).rectangle((0,12,15,15),outline=(0,0,0,0),fill=(0,0,0,0)) # If the signpost is looking directly to the image, draw some @@ -1223,6 +1223,39 @@ def generate_special_texture(blockID, data): return (img.convert("RGB"), img.split()[3]) + if blockID == 68: # wall sign + texture = terrain_images[4].copy() + # cut the planks to the size of a signpost + ImageDraw.Draw(texture).rectangle((0,12,15,15),outline=(0,0,0,0),fill=(0,0,0,0)) + + # draw some random black dots, they will look as text + if data in (3,4): + for i in range(15): + x = randint(4,11) + y = randint(3,7) + texture.putpixel((x,y),(0,0,0,255)) + + img = Image.new("RGBA", (24,24), (38,92,255,0)) + + incrementx = 0 + if data == 2: # east + incrementx = +1 + sign = _build_full_block(None, None, None, None, texture) + elif data == 3: # west + incrementx = -1 + sign = _build_full_block(None, texture, None, None, None) + elif data == 4: # north + incrementx = +1 + sign = _build_full_block(None, None, texture, None, None) + elif data == 5: # south + incrementx = -1 + sign = _build_full_block(None, None, None, texture, None) + + sign2 = ImageEnhance.Brightness(sign).enhance(1.2) + composite.alpha_over(img, sign2,(incrementx, 2),sign2) + composite.alpha_over(img, sign, (0,3), sign) + + return (img.convert("RGB"), img.split()[3]) if blockID == 85: # fences # create needed images for Big stick fence @@ -1443,15 +1476,15 @@ def generate_special_texture(blockID, data): static_torch = (5,-1) elif (data & 0xC) == 4: # two ticks delay - moving_torch = (2,0) + moving_torch = (0,2) static_torch = (5,-1) elif (data & 0xC) == 8: # three ticks delay - moving_torch = (3,0) + moving_torch = (-1,2) static_torch = (5,-1) elif (data & 0xC) == 12: # four ticks delay - moving_torch = (4,-1) + moving_torch = (-2,3) static_torch = (5,-1) elif (data & 0x3) == 2: # pointing west @@ -1576,7 +1609,7 @@ def getBiomeData(worlddir, chunkX, chunkY): special_blocks = set([ 2, 6, 9, 17, 18, 26, 23, 27, 28, 35, 43, 44, 50, 51, 53, 54, 55, 58, 59, 61, 62, 63, 64, 65, 66, 67, - 71, 75, 76, 85, 86, 90, 91, 92, 93, 94]) + 68, 71, 75, 76, 85, 86, 90, 91, 92, 93, 94]) # this is a map of special blockIDs to a list of all # possible values for ancillary data that it might have. @@ -1607,6 +1640,7 @@ special_map[64] = range(16) # wooden door, open/close and orientation special_map[65] = (2,3,4,5) # ladder, orientation special_map[66] = range(10) # minecrart tracks, orientation, slope special_map[67] = range(4) # cobblestone stairs, orientation +special_map[68] = (2,3,4,5) # wall sing, orientation special_map[71] = range(16) # iron door, open/close and orientation special_map[75] = (1,2,3,4,5) # off redstone torch, orientation special_map[76] = (1,2,3,4,5) # on redstone torch, orientation From cb934ef18f8aca363f7f0a410db9cfefb7ff31e7 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Thu, 12 May 2011 16:30:32 +0200 Subject: [PATCH 09/16] Remove "text" from wall signs, they are used for chairs! --- textures.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/textures.py b/textures.py index ec77795..b740420 100644 --- a/textures.py +++ b/textures.py @@ -1229,12 +1229,15 @@ def generate_special_texture(blockID, data): ImageDraw.Draw(texture).rectangle((0,12,15,15),outline=(0,0,0,0),fill=(0,0,0,0)) # draw some random black dots, they will look as text + """ don't draw text at the moment, they are used in blank for decoration + if data in (3,4): for i in range(15): x = randint(4,11) y = randint(3,7) texture.putpixel((x,y),(0,0,0,255)) - + """ + img = Image.new("RGBA", (24,24), (38,92,255,0)) incrementx = 0 From 027419fa5fcdc77a432ffe3d6b67b7493b182c29 Mon Sep 17 00:00:00 2001 From: CounterPillow Date: Tue, 10 May 2011 18:28:25 +0200 Subject: [PATCH 10/16] Moved the blockid check further up in the for-loop to increase performance while rendering empty chunks. --- src/iterate.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/iterate.c b/src/iterate.c index 7fd3d3f..9f9be9a 100644 --- a/src/iterate.c +++ b/src/iterate.c @@ -364,6 +364,12 @@ chunk_render(PyObject *self, PyObject *args) { for (state.z = 0; state.z < 128; state.z++) { state.imgy -= 12; + + /* get blockid */ + state.block = getArrayByte3D(blocks_py, state.x, state.y, state.z); + if (state.block == 0) { + continue; + } /* make sure we're rendering inside the image boundaries */ if ((state.imgx >= imgsize0 + 24) || (state.imgx <= -24)) { @@ -373,11 +379,6 @@ chunk_render(PyObject *self, PyObject *args) { continue; } - /* get blockid */ - state.block = getArrayByte3D(blocks_py, state.x, state.y, state.z); - if (state.block == 0) { - continue; - } /* decref'd on replacement *and* at the end of the z for block */ if (blockid) { From 58034780603b3b6a89b8530688a0fa0524b196fc Mon Sep 17 00:00:00 2001 From: CounterPillow Date: Wed, 11 May 2011 21:33:24 +0200 Subject: [PATCH 11/16] Re-Implemented jywarrens live hash updating --- web_assets/overviewer.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index eea2f7d..8b3cd97 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -225,13 +225,23 @@ var overviewer = { overviewer.collections.mapTypes[i].name, overviewer.collections.mapTypes[i]); } - + + /* // Make the link again whenever the map changes google.maps.event.addListener(overviewer.map, 'maptypeid_changed', function() { $('#'+overviewerConfig.CONST.mapDivId).css( 'background-color', overviewer.util.getMapTypeBackgroundColor( overviewer.map.getMapTypeId())); }); + */ + + // Add live hash update listener + google.maps.event.addListener(overviewer.map, 'dragend', function() { overviewer.updateHash(); }); + google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { overviewer.updateHash(); }); + // Jump to the hash if given + overviewer.initHash(); + + // We can now set the map to use the 'coordinate' map type overviewer.map.setMapTypeId(overviewer.util.getDefaultMapTypeId()); }, @@ -858,6 +868,22 @@ var overviewer = { this.tileSize = tileSize; } }, + 'initHash': function() { + if(window.location.hash.split("/").length > 1) { + overviewer.goToHash(); + } + }, + 'setHash': function(lat, lng, zoom) { + window.location.replace("#/" + lat + "/" + lng + "/" + zoom); + }, + 'updateHash': function() { + overviewer.setHash(overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng(), overviewer.map.getZoom()); + }, + 'goToHash': function() { + coords = window.location.hash.split("/"); + overviewer.map.setCenter(coords[1], coords[2]); + overviewer.map.setZoom(coords[3]); + }, /** * Stuff that we give to the google maps code instead of using ourselves * goes in here. From 4b9307d769da103cc7a99c67a8538695a6935eb1 Mon Sep 17 00:00:00 2001 From: CounterPillow Date: Wed, 11 May 2011 22:25:22 +0200 Subject: [PATCH 12/16] various fixes --- web_assets/overviewer.js | 46 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index 8b3cd97..5760101 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -236,10 +236,14 @@ var overviewer = { */ // Add live hash update listener - google.maps.event.addListener(overviewer.map, 'dragend', function() { overviewer.updateHash(); }); - google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { overviewer.updateHash(); }); + google.maps.event.addListener(overviewer.map, 'dragend', function() { + overviewer.util.updateHash(); + }); + google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { + overviewer.util.updateHash(); + }); // Jump to the hash if given - overviewer.initHash(); + overviewer.util.initHash(); // We can now set the map to use the 'coordinate' map type @@ -812,7 +816,25 @@ var overviewer = { infowindow.open(overviewer.map, marker); overviewer.collections.infoWindow = infowindow; }); - } + }, + 'initHash': function() { + if(window.location.hash.split("/").length > 1) { + overviewer.util.goToHash(); + } + }, + 'setHash': function(x, z, zoom) { + window.location.replace("#/" + x.toFixed(3) + "/" + z.toFixed(3) + "/" + zoom); + }, + 'updateHash': function() { + var coordinates = overviewer.util.fromLatLngToWorld(overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng()); + overviewer.util.setHash(coordinates.x, coordinates.z, overviewer.map.getZoom()); + }, + 'goToHash': function() { + var coords = window.location.hash.split("/"); + var latlngcoords = overviewer.util.fromWorldToLatLng(parseFloat(coords[1]), parseFloat(coords[2]), 64); + overviewer.map.setCenter(latlngcoords); + overviewer.map.setZoom(parseInt(coords[3])); + }, }, /** * The various classes needed in this file. @@ -868,22 +890,6 @@ var overviewer = { this.tileSize = tileSize; } }, - 'initHash': function() { - if(window.location.hash.split("/").length > 1) { - overviewer.goToHash(); - } - }, - 'setHash': function(lat, lng, zoom) { - window.location.replace("#/" + lat + "/" + lng + "/" + zoom); - }, - 'updateHash': function() { - overviewer.setHash(overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng(), overviewer.map.getZoom()); - }, - 'goToHash': function() { - coords = window.location.hash.split("/"); - overviewer.map.setCenter(coords[1], coords[2]); - overviewer.map.setZoom(coords[3]); - }, /** * Stuff that we give to the google maps code instead of using ourselves * goes in here. From 8a38fa859d1de8d437bf6f46fb2abd066181fdf4 Mon Sep 17 00:00:00 2001 From: CounterPillow Date: Thu, 12 May 2011 00:17:26 +0200 Subject: [PATCH 13/16] Switched to x y z zoom format, using floor(), removed viewURL box --- web_assets/overviewer.js | 102 ++++++++++++--------------------------- 1 file changed, 31 insertions(+), 71 deletions(-) diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index 5760101..9c1d005 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -225,27 +225,25 @@ var overviewer = { overviewer.collections.mapTypes[i].name, overviewer.collections.mapTypes[i]); } - - /* + // Make the link again whenever the map changes google.maps.event.addListener(overviewer.map, 'maptypeid_changed', function() { $('#'+overviewerConfig.CONST.mapDivId).css( 'background-color', overviewer.util.getMapTypeBackgroundColor( overviewer.map.getMapTypeId())); }); - */ - - // Add live hash update listener - google.maps.event.addListener(overviewer.map, 'dragend', function() { - overviewer.util.updateHash(); - }); - google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { - overviewer.util.updateHash(); - }); - // Jump to the hash if given - overviewer.util.initHash(); - - + + // Add live hash update listener + google.maps.event.addListener(overviewer.map, 'dragend', function() { + overviewer.util.updateHash(); + }); + google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { + overviewer.util.updateHash(); + }); + // Jump to the hash if given + overviewer.util.initHash(); + + // We can now set the map to use the 'coordinate' map type overviewer.map.setMapTypeId(overviewer.util.getDefaultMapTypeId()); }, @@ -471,29 +469,6 @@ var overviewer = { } return results; }, - /** - * Set the link (at the bottom of the screen) to the current view. - * TODO: make this preserve the mapTypeId as well - */ - 'setViewUrl': function() { - var displayZoom = overviewer.map.getZoom(); - if (displayZoom == overviewerConfig.map.maxZoom) { - displayZoom = 'max'; - } else { - displayZoom -= overviewerConfig.map.maxZoom; - } - var point; - var point = overviewer.util.fromLatLngToWorld( - overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng()); - var viewUrl = location.href.substring(0, location.href.lastIndexOf( - location.search)) - + '?x=' + Math.floor(point.x) - + '&y=' + Math.floor(point.y) - + '&z=' + Math.floor(point.z) - + '&zoom=' + displayZoom; - document.getElementById('link').innerHTML = viewUrl; - - }, 'getDefaultMapTypeId': function() { return overviewer.collections.mapTypeIds[0]; }, @@ -593,21 +568,6 @@ var overviewer = { * like the compass, current view link, etc. */ 'createMapControls': function() { - // viewstate link (little link to where you're looking at the map, - // normally bottom left) - var viewStateDiv = document.createElement('DIV'); - viewStateDiv.id='link'; - // add it to the map, bottom left. - if (overviewerConfig.map.controls.link) { - google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { - overviewer.util.setViewUrl(); - }); - google.maps.event.addListener(overviewer.map, 'center_changed', function() { - overviewer.util.setViewUrl(); - }); - overviewer.map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(viewStateDiv); - } - // compass rose, in the top right corner var compassDiv = document.createElement('DIV'); compassDiv.style.padding = '5px'; @@ -817,24 +777,24 @@ var overviewer = { overviewer.collections.infoWindow = infowindow; }); }, - 'initHash': function() { - if(window.location.hash.split("/").length > 1) { - overviewer.util.goToHash(); - } - }, - 'setHash': function(x, z, zoom) { - window.location.replace("#/" + x.toFixed(3) + "/" + z.toFixed(3) + "/" + zoom); - }, - 'updateHash': function() { - var coordinates = overviewer.util.fromLatLngToWorld(overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng()); - overviewer.util.setHash(coordinates.x, coordinates.z, overviewer.map.getZoom()); - }, - 'goToHash': function() { - var coords = window.location.hash.split("/"); - var latlngcoords = overviewer.util.fromWorldToLatLng(parseFloat(coords[1]), parseFloat(coords[2]), 64); - overviewer.map.setCenter(latlngcoords); - overviewer.map.setZoom(parseInt(coords[3])); - }, + 'initHash': function() { + if(window.location.hash.split("/").length > 1) { + overviewer.util.goToHash(); + } + }, + 'setHash': function(x, y, z, zoom) { + window.location.replace("#/" + Math.floor(x) + "/" + Math.floor(y) + "/" + Math.floor(z) + "/" + zoom); + }, + 'updateHash': function() { + var coordinates = overviewer.util.fromLatLngToWorld(overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng()); + overviewer.util.setHash(coordinates.x, coordinates.y, coordinates.z, overviewer.map.getZoom()); + }, + 'goToHash': function() { + var coords = window.location.hash.split("/"); + var latlngcoords = overviewer.util.fromWorldToLatLng(parseInt(coords[1]), parseInt(coords[2]), parseInt(coords[3])); + overviewer.map.setCenter(latlngcoords); + overviewer.map.setZoom(parseInt(coords[4])); + }, }, /** * The various classes needed in this file. From 63d387c2808ac613c5db548f337347309d1967aa Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Thu, 12 May 2011 14:14:27 -0400 Subject: [PATCH 14/16] added Jeffrey Warren and CounterPillow to CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index cc5acef..ae100b4 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -42,6 +42,7 @@ feature. * Kyle Brantley * cbarber * Alex Cline + * CounterPillow * Stephen Fluin * Benjamin Herr * Ryan Hitchman @@ -52,3 +53,4 @@ feature. * Gregory Short * Sam Steele * timwolla + * Jeffrey Warren From 2bca2b6db3f468ab2a3b84aa93523135aca5661a Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Thu, 12 May 2011 17:53:13 -0400 Subject: [PATCH 15/16] added generator meta tag --- googlemap.py | 1 + web_assets/index.html | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/googlemap.py b/googlemap.py index af56fbe..331a4ea 100644 --- a/googlemap.py +++ b/googlemap.py @@ -128,6 +128,7 @@ class MapGen(object): index = open(indexpath, 'r').read() index = index.replace( "{time}", str(strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()))) + index = index.replace("{version}", util.findGitVersion()) with open(os.path.join(self.destdir, "index.html"), 'w') as output: output.write(index) diff --git a/web_assets/index.html b/web_assets/index.html index 3798f17..7fa8e31 100644 --- a/web_assets/index.html +++ b/web_assets/index.html @@ -1,15 +1,22 @@ + + + + + + +
From d2c9b8023978c2fdac2818d6b41a7612cf018095 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Thu, 12 May 2011 18:42:13 -0400 Subject: [PATCH 16/16] live hash Spawn button fix, negative zoom, and markers --- web_assets/overviewer.js | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index 90856e6..4cbfc11 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -145,7 +145,7 @@ var overviewer = { var lng = defaultCenter.lng(); var zoom = overviewerConfig.map.defaultZoom; var mapcenter; - queryParams = overviewer.util.parseQueryString(); + var queryParams = overviewer.util.parseQueryString(); if (queryParams.lat) { lat = parseFloat(queryParams.lat); } @@ -782,6 +782,15 @@ var overviewer = { 'initHash': function() { if(window.location.hash.split("/").length > 1) { overviewer.util.goToHash(); + + // Add a marker indicating the user-supplied position + var coordinates = overviewer.util.fromLatLngToWorld(overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng()); + overviewer.collections.markerDatas.push([{ + 'msg': 'Coordinates ' + Math.floor(coordinates.x) + ', ' + Math.floor(coordinates.y) + ', ' + Math.floor(coordinates.z), + 'x': coordinates.x, + 'y': coordinates.y, + 'z': coordinates.z, + 'type': 'querypos'}]); } }, 'setHash': function(x, y, z, zoom) { @@ -789,13 +798,37 @@ var overviewer = { }, 'updateHash': function() { var coordinates = overviewer.util.fromLatLngToWorld(overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng()); - overviewer.util.setHash(coordinates.x, coordinates.y, coordinates.z, overviewer.map.getZoom()); + var zoom = overviewer.map.getZoom(); + if (zoom == overviewerConfig.map.maxZoom) { + zoom = 'max'; + } else if (zoom == overviewerConfig.map.minZoom) { + zoom = 'min'; + } else { + // default to (map-update friendly) negative zooms + zoom -= overviewerConfig.map.maxZoom; + } + overviewer.util.setHash(coordinates.x, coordinates.y, coordinates.z, zoom); }, 'goToHash': function() { var coords = window.location.hash.split("/"); var latlngcoords = overviewer.util.fromWorldToLatLng(parseInt(coords[1]), parseInt(coords[2]), parseInt(coords[3])); + var zoom = coords[4]; + if (zoom == 'max') { + zoom = overviewerConfig.map.maxZoom; + } else if (zoom == 'min') { + zoom = overviewerConfig.map.minZoom; + } else { + zoom = parseInt(zoom); + if (zoom < 0 && zoom + overviewerConfig.map.maxZoom >= 0) { + // if zoom is negative, treat it as a "zoom out from max" + zoom += overviewerConfig.map.maxZoom; + } else { + // fall back to default zoom + zoom = overviewerConfig.map.defaultZoom; + } + } overviewer.map.setCenter(latlngcoords); - overviewer.map.setZoom(parseInt(coords[4])); + overviewer.map.setZoom(zoom); }, }, /** @@ -829,6 +862,7 @@ var overviewer = { overviewerConfig.map.center[0], overviewerConfig.map.center[1], overviewerConfig.map.center[2])); + overviewer.util.updateHash(); }); }, /**