use node_id hash to calculate startAngle for client layer

This commit is contained in:
Florian Klink 2015-06-01 22:36:10 +02:00
parent 47c7fcbfb5
commit 008a1d0b0b
3 changed files with 15 additions and 5 deletions

View file

@ -1,8 +1,16 @@
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++) {