Skip to content
Snippets Groups Projects
Commit 008a1d0b authored by Florian Klink's avatar Florian Klink
Browse files

use node_id hash to calculate startAngle for client layer

parent 47c7fcbf
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,8 @@ require.config({
"numeral-intl": "../bower_components/numeraljs/min/languages.min",
"virtual-dom": "../bower_components/virtual-dom/dist/virtual-dom",
"rbush": "../bower_components/rbush/rbush",
"helper": "../helper"
"helper": "../helper",
"jshashes": "../bower_components/jshashes/hashes"
},
shim: {
"leaflet.label": ["leaflet"],
......
......@@ -24,7 +24,8 @@
"roboto-fontface": "~0.3.0",
"virtual-dom": "~2.0.1",
"leaflet-providers": "~1.0.27",
"rbush": "https://github.com/mourner/rbush.git#~1.3.5"
"rbush": "https://github.com/mourner/rbush.git#~1.3.5",
"jshashes": "~1.0.5"
},
"authors": [
"Nils Schneider <nils@nilsschneider.net>"
......
define(["leaflet"],
function (L) {
define(["leaflet", "jshashes"],
function (L, jsHashes) {
var MD5 = new jsHashes.MD5()
return L.TileLayer.Canvas.extend({
setData: function (d) {
this.data = d
//pre-calculate start angles
this.data.all().forEach(function (d) {
var hash = MD5.hex(d.node.nodeinfo.node_id)
d.startAngle = (parseInt(hash.substr(0, 2), 16) / 255) * 2 * Math.PI
})
this.redraw()
},
drawTile: function (canvas, tilePoint) {
......@@ -33,7 +41,6 @@ define(["leaflet"],
var radius = 3
var a = 1.2
var startDistance = 12
var startAngle = Math.PI
ctx.beginPath()
nodes.forEach(function (d) {
......@@ -47,6 +54,7 @@ define(["leaflet"],
p.y -= s.y
var distance = startDistance
var startAngle = d.startAngle
var angle = startAngle
for (var i = 0; i < clients; i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment