inital commit

This commit is contained in:
Micho 2013-05-18 17:15:23 +02:00
commit 2c08fe4957
11 changed files with 1947553 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
sources/
Analyse/
backups/

620
cleaned/accesspoints.json Normal file
View File

@ -0,0 +1,620 @@
{
"ap-r5-m2-001": {
"id": "ap-r5-m2-001",
"x": 0.6305722152167912,
"y": 0.9018257033384726,
"group": "workshop4"
},
"ap-r5-m5-001": {
"id": "ap-r5-m5-001",
"x": 0.6305722152167912,
"y": 0.9018257033384726,
"group": "workshop4"
},
"ap-r5-m2-002": {
"id": "ap-r5-m2-002",
"x": 0.5526915529424054,
"y": 0.9018257033384726,
"group": "workshop3"
},
"ap-r5-m5-002": {
"id": "ap-r5-m5-002",
"x": 0.5526915529424054,
"y": 0.9018257033384726,
"group": "workshop3"
},
"ap-r5-m2-003": {
"id": "ap-r5-m2-003",
"x": 0.39445453392328184,
"y": 0.8987726877222977,
"group": "workshop1"
},
"ap-r5-m2-004": {
"id": "ap-r5-m2-004",
"x": 0.39445453392328184,
"y": 0.8987726877222977,
"group": "workshop1"
},
"ap-r5-m5-003": {
"id": "ap-r5-m5-003",
"x": 0.4463575654924901,
"y": 0.8987726877222977,
"group": "workshop2"
},
"ap-r5-m5-004": {
"id": "ap-r5-m5-004",
"x": 0.4463575654924901,
"y": 0.8987726877222977,
"group": "workshop2"
},
"ap-r4-m2-002": {
"id": "ap-r4-m2-002",
"x": 0.5648566290860524,
"y": 0.55974140957731,
"group": "stage5"
},
"ap-r4-m5-002": {
"id": "ap-r4-m5-002",
"x": 0.5648566290860524,
"y": 0.55974140957731,
"group": "stage5"
},
"ap-r4-m2-001": {
"id": "ap-r4-m2-001",
"x": 0.6020681524812905,
"y": 0.55974140957731,
"group": "stage5"
},
"ap-r4-m5-001": {
"id": "ap-r4-m5-001",
"x": 0.6020681524812905,
"y": 0.55974140957731,
"group": "stage5"
},
"ap-r4-m2-003": {
"id": "ap-r4-m2-003",
"x": 0.7045445930922304,
"y": 0.581091147781221,
"group": "stage6"
},
"ap-r4-m5-003": {
"id": "ap-r4-m5-003",
"x": 0.7045445930922304,
"y": 0.581091147781221,
"group": "stage6"
},
"ap-r4-m2-004": {
"id": "ap-r4-m2-004",
"x": 0.7550732336986934,
"y": 0.581091147781221,
"group": "stage6"
},
"ap-r4-m5-004": {
"id": "ap-r4-m5-004",
"x": 0.7550732336986934,
"y": 0.581091147781221,
"group": "stage6"
},
"ap-r4-m2-020": {
"id": "ap-r4-m2-020",
"x": 0.7302401826552158,
"y": 0.44599520676548265,
"group": ""
},
"ap-r4-m5-020": {
"id": "ap-r4-m5-020",
"x": 0.7302401826552158,
"y": 0.44599520676548265,
"group": ""
},
"ap-r1-m2-002": {
"id": "ap-r1-m2-002",
"x": 0.5577533706901054,
"y": 0.10696392862049484,
"group": ""
},
"ap-r1-m5-002": {
"id": "ap-r1-m5-002",
"x": 0.5577533706901054,
"y": 0.10696392862049484,
"group": ""
},
"ap-r1-m2-005": {
"id": "ap-r1-m2-005",
"x": 0.5735849816822486,
"y": 0.23955639683096974,
"group": ""
},
"ap-r1-m5-005": {
"id": "ap-r1-m5-005",
"x": 0.5735849816822486,
"y": 0.23955639683096974,
"group": ""
},
"ap-r1-m2-007": {
"id": "ap-r1-m2-007",
"x": 0.5212133738238959,
"y": 0.23955639683096974,
"group": ""
},
"ap-r1-m5-007": {
"id": "ap-r1-m5-007",
"x": 0.5212133738238959,
"y": 0.23955639683096974,
"group": ""
},
"ap-r1-m2-008": {
"id": "ap-r1-m2-008",
"x": 0.4589777873947009,
"y": 0.23955639683096974,
"group": ""
},
"ap-r1-m5-008": {
"id": "ap-r1-m5-008",
"x": 0.4589777873947009,
"y": 0.23955639683096974,
"group": ""
},
"ap-r1-m2-001": {
"id": "ap-r1-m2-001",
"x": 0.6523833968796401,
"y": 0.16703811689996795,
"group": ""
},
"ap-r1-m5-001": {
"id": "ap-r1-m5-001",
"x": 0.6523833968796401,
"y": 0.16703811689996795,
"group": ""
},
"ap-r1-m2-009": {
"id": "ap-r1-m2-009",
"x": 0.631345216865762,
"y": 0.31025202643911515,
"group": ""
},
"ap-r1-m5-009": {
"id": "ap-r1-m5-009",
"x": 0.631345216865762,
"y": 0.31025202643911515,
"group": ""
},
"ap-r1-m2-006": {
"id": "ap-r1-m2-006",
"x": 0.6199994030875298,
"y": 0.4179929475339266,
"group": ""
},
"ap-r1-m5-006": {
"id": "ap-r1-m5-006",
"x": 0.6199994030875298,
"y": 0.4179929475339266,
"group": ""
},
"ap-r3-m2-007": {
"id": "ap-r3-m2-007",
"x": 0.40454086238929143,
"y": 0.214524721793952,
"group": ""
},
"ap-r3-m5-007": {
"id": "ap-r3-m5-007",
"x": 0.40454086238929143,
"y": 0.214524721793952,
"group": ""
},
"ap-r3-m2-003": {
"id": "ap-r3-m2-003",
"x": 0.3930577587429024,
"y": 0.4288403120181959,
"group": ""
},
"ap-r3-m5-003": {
"id": "ap-r3-m5-003",
"x": 0.3930577587429024,
"y": 0.4288403120181959,
"group": ""
},
"ap-r3-m2-001": {
"id": "ap-r3-m2-001",
"x": 0.45714377382986504,
"y": 0.4179929475339266,
"group": ""
},
"ap-r3-m5-001": {
"id": "ap-r3-m5-001",
"x": 0.45714377382986504,
"y": 0.4179929475339266,
"group": ""
},
"ap-r3-m2-002": {
"id": "ap-r3-m2-002",
"x": 0.5272093595875335,
"y": 0.4179929475339266,
"group": ""
},
"ap-r3-m5-002": {
"id": "ap-r3-m5-002",
"x": 0.5272093595875335,
"y": 0.4179929475339266,
"group": ""
},
"ap-r3-m2-008": {
"id": "ap-r3-m2-008",
"x": 0.40269938741857736,
"y": 0.55974140957731,
"group": "stage4"
},
"ap-r3-m5-008": {
"id": "ap-r3-m5-008",
"x": 0.40269938741857736,
"y": 0.55974140957731,
"group": "stage4"
},
"ap-r3-m2-005": {
"id": "ap-r3-m2-005",
"x": 0.4433730031412519,
"y": 0.55974140957731,
"group": "stage4"
},
"ap-r3-m5-005": {
"id": "ap-r3-m5-005",
"x": 0.4433730031412519,
"y": 0.55974140957731,
"group": "stage4"
},
"ap-r2-m2-002": {
"id": "ap-r2-m2-002",
"x": 0.3568923244517732,
"y": 0.214524721793952,
"group": ""
},
"ap-vi-m2-002": {
"id": "ap-vi-m2-002",
"x": 0.7548195458988383,
"y": 0.2606038864888793,
"group": ""
},
"ap-vi-m5-002": {
"id": "ap-vi-m5-002",
"x": 0.7548195458988383,
"y": 0.2606038864888793,
"group": ""
},
"ap-vi-m2-003": {
"id": "ap-vi-m2-003",
"x": 0.9330620863583116,
"y": 0.36500786151521153,
"group": ""
},
"ap-vi-m2-001": {
"id": "ap-vi-m2-001",
"x": 0.8290083045447423,
"y": 0.25331023218183757,
"group": ""
},
"ap-vi-m5-001": {
"id": "ap-vi-m5-001",
"x": 0.8290083045447423,
"y": 0.25331023218183757,
"group": ""
},
"ap-vi-m2-020": {
"id": "ap-vi-m2-020",
"x": 0.722893682427643,
"y": 0.3561266390877589,
"group": ""
},
"ap-vi-m5-020": {
"id": "ap-vi-m5-020",
"x": 0.722893682427643,
"y": 0.3561266390877589,
"group": ""
},
"ap-r7-m2-013": {
"id": "ap-r7-m2-013",
"x": 0.2763733090588929,
"y": 0.5353417087728404,
"group": "stage3"
},
"ap-r7-m5-013": {
"id": "ap-r7-m5-013",
"x": 0.2763733090588929,
"y": 0.5353417087728404,
"group": "stage3"
},
"ap-r7-m2-014": {
"id": "ap-r7-m2-014",
"x": 0.23320459921058329,
"y": 0.5353417087728404,
"group": "stage3"
},
"ap-r7-m5-014": {
"id": "ap-r7-m5-014",
"x": 0.23320459921058329,
"y": 0.5353417087728404,
"group": "stage3"
},
"ap-r7-m2-004": {
"id": "ap-r7-m2-004",
"x": 0.2353609455093529,
"y": 0.3811552611091606,
"group": "stage1"
},
"ap-r7-m5-004": {
"id": "ap-r7-m5-004",
"x": 0.2353609455093529,
"y": 0.3811552611091606,
"group": "stage1"
},
"ap-r7-m2-001": {
"id": "ap-r7-m2-001",
"x": 0.28980980876416734,
"y": 0.3811552611091606,
"group": "stage1"
},
"ap-r7-m5-001": {
"id": "ap-r7-m5-001",
"x": 0.28980980876416734,
"y": 0.3811552611091606,
"group": "stage1"
},
"ap-r7-m2-005": {
"id": "ap-r7-m2-005",
"x": 0.2353609455093529,
"y": 0.2980399639744156,
"group": "stage1"
},
"ap-r7-m5-005": {
"id": "ap-r7-m5-005",
"x": 0.2353609455093529,
"y": 0.2980399639744156,
"group": "stage1"
},
"ap-r7-m2-002": {
"id": "ap-r7-m2-002",
"x": 0.28980980876416734,
"y": 0.2980399639744156,
"group": "stage1"
},
"ap-r7-m5-002": {
"id": "ap-r7-m5-002",
"x": 0.28980980876416734,
"y": 0.2980399639744156,
"group": "stage1"
},
"ap-r7-m2-006": {
"id": "ap-r7-m2-006",
"x": 0.2353609455093529,
"y": 0.20544505335144786,
"group": "stage1"
},
"ap-r7-m5-006": {
"id": "ap-r7-m5-006",
"x": 0.2353609455093529,
"y": 0.20544505335144786,
"group": "stage1"
},
"ap-r7-m2-003": {
"id": "ap-r7-m2-003",
"x": 0.28980980876416734,
"y": 0.20544505335144786,
"group": "stage1"
},
"ap-r7-m5-003": {
"id": "ap-r7-m5-003",
"x": 0.28980980876416734,
"y": 0.20544505335144786,
"group": "stage1"
},
"ap-r7-m2-007": {
"id": "ap-r7-m2-007",
"x": 0.17332830932004206,
"y": 0.3811552611091606,
"group": "stage1"
},
"ap-r7-m5-007": {
"id": "ap-r7-m5-007",
"x": 0.17332830932004206,
"y": 0.3811552611091606,
"group": "stage1"
},
"ap-r7-m2-008": {
"id": "ap-r7-m2-008",
"x": 0.17332830932004206,
"y": 0.2980399639744156,
"group": "stage1"
},
"ap-r7-m5-008": {
"id": "ap-r7-m5-008",
"x": 0.17332830932004206,
"y": 0.2980399639744156,
"group": "stage1"
},
"ap-r7-m2-009": {
"id": "ap-r7-m2-009",
"x": 0.17332830932004206,
"y": 0.20544505335144786,
"group": "stage1"
},
"ap-r7-m5-009": {
"id": "ap-r7-m5-009",
"x": 0.17332830932004206,
"y": 0.20544505335144786,
"group": "stage1"
},
"ap-r7-m2-010": {
"id": "ap-r7-m2-010",
"x": 0.10971534736575066,
"y": 0.3811552611091606,
"group": "stage1"
},
"ap-r7-m5-010": {
"id": "ap-r7-m5-010",
"x": 0.10971534736575066,
"y": 0.3811552611091606,
"group": "stage1"
},
"ap-r7-m2-011": {
"id": "ap-r7-m2-011",
"x": 0.10971534736575066,
"y": 0.2980399639744156,
"group": "stage1"
},
"ap-r7-m5-011": {
"id": "ap-r7-m5-011",
"x": 0.10971534736575066,
"y": 0.2980399639744156,
"group": "stage1"
},
"ap-r7-m2-012": {
"id": "ap-r7-m2-012",
"x": 0.10971534736575066,
"y": 0.20544505335144786,
"group": "stage1"
},
"ap-r7-m5-012": {
"id": "ap-r7-m5-012",
"x": 0.10971534736575066,
"y": 0.20544505335144786,
"group": "stage1"
},
"ap-r7-m2-020": {
"id": "ap-r7-m2-020",
"x": 0.206991188079658,
"y": 0.32117876932940503,
"group": "stage1"
},
"ap-r7-m5-020": {
"id": "ap-r7-m5-020",
"x": 0.206991188079658,
"y": 0.32117876932940503,
"group": "stage1"
},
"ap-r7-m2-021": {
"id": "ap-r7-m2-021",
"x": 0.206991188079658,
"y": 0.254696301271581,
"group": "stage1"
},
"ap-r7-m5-021": {
"id": "ap-r7-m5-021",
"x": 0.206991188079658,
"y": 0.254696301271581,
"group": "stage1"
},
"ap-r2-m5-002": {
"id": "ap-r2-m5-002",
"x": 0.3568923244517732,
"y": 0.214524721793952,
"group": ""
},
"ap-r1-m2-004": {
"id": "ap-r1-m2-004",
"x": 0.41579863157816194,
"y": 0.10261032835182951,
"group": "stage2"
},
"ap-r1-m5-004": {
"id": "ap-r1-m5-004",
"x": 0.41579863157816194,
"y": 0.10261032835182951,
"group": "stage2"
},
"ap-r1-m2-003": {
"id": "ap-r1-m2-003",
"x": 0.47989658491452963,
"y": 0.10261032835182951,
"group": "stage2"
},
"ap-r1-m5-003": {
"id": "ap-r1-m5-003",
"x": 0.47989658491452963,
"y": 0.10261032835182951,
"group": "stage2"
},
"ap-r1-m2-020": {
"id": "ap-r1-m2-020",
"x": 0.44265969273930594,
"y": 0.10261032835182951,
"group": "stage2"
},
"ap-r1-m5-020": {
"id": "ap-r1-m5-020",
"x": 0.44265969273930594,
"y": 0.10261032835182951,
"group": "stage2"
},
"ap-r1-m2-021": {
"id": "ap-r1-m2-021",
"x": 0.39143415682382876,
"y": 0.10261032835182951,
"group": "stage2"
},
"ap-lo-m2-001": {
"id": "ap-lo-m2-001",
"x": 0.8620444252105982,
"y": 0.6600635027248163,
"group": "VIP"
},
"ap-lo-m5-001": {
"id": "ap-lo-m5-001",
"x": 0.8620444252105982,
"y": 0.6600635027248163,
"group": "VIP"
},
"ap-lo-m2-002": {
"id": "ap-lo-m2-002",
"x": 0.8610460891041088,
"y": 0.6061716710680974,
"group": "VIP"
},
"ap-lo-m5-002": {
"id": "ap-lo-m5-002",
"x": 0.8610460891041088,
"y": 0.6061716710680974,
"group": "VIP"
},
"ap-lo-m2-003": {
"id": "ap-lo-m2-003",
"x": 0.8504270162584033,
"y": 0.5450014501824176,
"group": "VIP"
},
"ap-lo-m5-003": {
"id": "ap-lo-m5-003",
"x": 0.8504270162584033,
"y": 0.5450014501824176,
"group": "VIP"
},
"ap-r3-m2-004": {
"id": "ap-r3-m2-004",
"x": 0.4994230840975057,
"y": 0.31343632172678554,
"group": ""
},
"ap-r3-m5-004": {
"id": "ap-r3-m5-004",
"x": 0.4994230840975057,
"y": 0.31343632172678554,
"group": ""
},
"ap-r4-m2-005": {
"id": "ap-r4-m2-005",
"x": 0.7004781268886684,
"y": 0.9290097543848936,
"group": "stage7"
},
"ap-r4-m5-005": {
"id": "ap-r4-m5-005",
"x": 0.7004781268886684,
"y": 0.9290097543848936,
"group": "stage7"
},
"ap-noc-test": {
"id": "ap-noc-test",
"x": 0.31858546667363064,
"y": 0.260701582988597,
"group": ""
}
}

1946399
clients/anim/data.js Normal file

File diff suppressed because it is too large Load Diff

43
clients/anim/index.html Normal file
View File

@ -0,0 +1,43 @@
<html>
<head>
<title>re:publica - Animation</title>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="data.js"></script>
<script type="text/javascript" src="main.js"></script>
<style type="text/css">
body {
position: relative;
}
#canvas, #map {
position: absolute;
top: 0;
left: 0;
}
#timer {
position: absolute;
top: 520;
left: 0px;
font-size: 20px;
font-family: georgia;
}
#menu {
position: absolute;
top: 550px;
left: 0;
}
.button {
margin-right: 10px;
background: #eee;
padding: 3px;
cursor: pointer;
}
</style>
</head>
<body>
<img id="map" src="map.jpg" width="1024" height="500">
<canvas id="canvas" width="1024" height="500"></canvas>
<div id="timer"></div>
<div id="menu"></div>
</body>
</html>

5
clients/anim/jquery-1.9.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

177
clients/anim/main.js Normal file
View File

@ -0,0 +1,177 @@
var currentTime = 60*(24*2+9);
var clients = [];
var context;
var width = 1024;
var height = 500;
var decay = 0.5;
var timeStep = 1;
var stepSize = 50*timeStep;
var frameDuration = 50;
var interval;
$(function () {
init();
start();
})
function start() {
if (!interval) interval = setInterval(update, frameDuration);
setTimeout(stop, 10000);
}
function stop() {
if (interval) {
clearInterval(interval);
interval = false;
}
}
function update() {
currentTime += timeStep;
if (currentTime >= 4*24*60) {
stop();
return;
}
renderTime();
updateData();
updatePosition();
renderCanvas();
}
function init() {
context = $('#canvas')[0].getContext('2d');
clients = [];
data.matrix.forEach(function (times, index) {
clients[index] = {point:undefined, x:0, y:0, r:0, x0:0, y0:0, r0:0};
});
var menu = $('#menu');
for (var i = 2; i < 16; i++) {
(function () {
var time = i*6*60;
var d = Math.floor(i/4);
var h = (i % 4)*6;
var node = $('<span class="button">T'+d+' '+h+':00</span>');
node.click(function () {
currentTime = time;
start();
})
menu.append(node);
})();
}
}
function renderTime() {
var d = Math.floor(currentTime/1440);
var h = Math.floor(currentTime/60) % 24;
var m = Math.floor(currentTime) % 60;
h = (h+100+'').substr(1);
m = (m+100+'').substr(1);
$('#timer').html('Tag '+d+' - '+h+':'+m);
}
function updateData() {
var timeId = -1;
data.times.forEach(function (time, index) {
if (time < currentTime) timeId = index;
});
var points = [];
data.points.forEach(function (point, index) {
points[index] = [];
})
data.matrix.forEach(function (times, index) {
var point = undefined;
if (isFinite(times[timeId])) point = times[timeId];
var client = clients[index];
if ((client.point != point) && (Math.random() > 0.8)) {
if (valid(point)) {
client.x0 = data.points[point].x;
client.y0 = data.points[point].y;
client.r0 = 1;
if (!valid(client.point)) client.x = undefined;
} else {
client.r0 = 0;
}
client.point = point;
}
if (valid(client.point)) points[client.point].push(index);
});
points.forEach(function (clientList, pointIndex) {
var point = data.points[pointIndex];
var x0 = point.x*width;
var y0 = point.y*height;
clientList.forEach(function (clientIndex, index) {
var client = clients[clientIndex];
var a = Math.sqrt(index)*4;
var r = Math.sqrt(index)*1.5;
client.x0 = x0 + Math.cos(a)*r;
client.y0 = y0 + Math.sin(a)*r;
if (client.x === undefined) {
client.x = client.x0;
client.y = client.y0;
}
})
});
}
function updatePosition() {
clients.forEach(function (client) {
client.xo = client.x;
client.yo = client.y;
var dx = (client.x0 - client.x);
var dy = (client.y0 - client.y);
var r = Math.sqrt(dx*dx + dy+dy);
if (r > 1e-2) {
var rn = Math.max(r-stepSize, 0);
var f = 1-rn/r;
client.x += (client.x0 - client.x)*f;
client.y += (client.y0 - client.y)*f;
} else {
client.x = client.x0;
client.y = client.y0;
}
client.r += (client.r0 - client.r)*decay;
})
}
function renderCanvas() {
context.clearRect(0, 0, width, height);
context.fillStyle = '#F00';
clients.forEach(function (client) {
if (client.r > 1e-2) {
var dx = client.x - client.xo;
var dy = client.y - client.yo;
var r = Math.sqrt(dx*dx + dy*dy);
if (r > 1) {
var a = Math.min(10/r, 1);
context.strokeStyle = 'rgba(255,0,0,'+a+')';
context.beginPath();
context.moveTo(client.xo, client.yo);
context.lineTo(client.x, client.y );
context.stroke();
} else {
context.beginPath();
context.arc(client.x, client.y, client.r, 0, 2*Math.PI, false);
context.fill();
}
}
});
}
function valid(point) {
return (point != null) && (point !== undefined);
}

BIN
clients/anim/map.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

91
node.js/1 convert log.js Normal file
View File

@ -0,0 +1,91 @@
var path = '../sources/rp13-hashed/';
var fs = require('fs');
var entriesObj = [];
var entriesArr = [];
var files = fs.readdirSync(path);
files.sort();
files.forEach(function (file, index) {
if (/clients_0[5-8]\.05\._[0-3][0-9][0-5][0-9]_hashed/.test(file)) {
var day = file.substr(8,2);
var hour = file.substr(15,2);
var minute = file.substr(17,2);
var date = new Date(2013, 4, day, hour, minute, 0, 0);
console.log(file);
processFile(path+file, index, date);
//process.exit();
} else {
//
console.warn('unknown file: '+file);
}
})
console.log('Schreibe Object-JSON');
fs.writeFileSync('../cleaned/rp13-obj.json', JSON.stringify(entriesObj), 'utf8');
fs.writeFileSync('../cleaned/rp13-obj-pretty.json', JSON.stringify(entriesObj, null, '\t'), 'utf8');
console.log('Schreibe Array-JSON');
fs.writeFileSync('../cleaned/rp13-arr.json', JSON.stringify(entriesArr), 'utf8');
fs.writeFileSync('../cleaned/rp13-arr-pretty.json', JSON.stringify(entriesArr, null, '\t'), 'utf8');
console.log('Schreibe TSV');
fs.writeFileSync('../cleaned/rp13.tsv', entriesArr.map(function (o) { return o.join('\t'); }).join('\n'), 'utf8');
console.log('Schreibe CSV');
fs.writeFileSync('../cleaned/rp13.csv', entriesArr.map(function (o) { return o.join(','); }).join('\n'), 'utf8');
function processFile(file, index, date) {
var lines = fs.readFileSync(file, 'utf8').split('\n');
lines.forEach(function (line) {
if (line != '') {
line = line.split('\t');
var vendor = line[0];
line = line[1].split(' ');
if ((line.length == 17) && (line[0] != 'Total:')) {
var access_point = line[0];
var i = access_point.lastIndexOf('ap-');
if (i < 0) {
console.error(access_point);
process.exit();
}
access_point = access_point.substr(i);
var obj = {
date: date,
file_id: index,
access_point: access_point,
vendor: vendor,
mac_hash: line[1],
signal_strength: parseInt(line[2], 10),
mb_in: parseInt(line[4], 10),
mb_out: parseInt(line[7], 10),
speed_in: parseInt(line[12], 10),
speed_out: parseInt(line[10], 10),
duration: parseInt(line[14], 10)
};
entriesObj.push(obj);
entriesArr.push([
obj.date,
obj.file_id,
obj.access_point,
obj.vendor,
obj.mac_hash,
obj.signal_strength,
obj.mb_in,
obj.mb_out,
obj.speed_in,
obj.speed_out,
obj.duration
]);
}
}
})
}

43
node.js/2 convert svg.js Normal file
View File

@ -0,0 +1,43 @@
var svg = '../sources/access points_wtf.svg';
var fs = require('fs');
svg = fs.readFileSync(svg, 'utf8');
var image = svg.match(/\<image.*?\>/g)[0];
var w = parseFloat(image.match(/width\=\"(.*?)\"/)[1]);
var h = parseFloat(image.match(/height\=\"(.*?)\"/)[1]);
var matrix = image.match(/matrix\((.*?)\)/)[1].split(' ');
matrix = matrix.map(function (v) { return parseFloat(v) });
var width = w*matrix[0] + h*matrix[1];
var height = w*matrix[2] + h*matrix[3];
var x0 = matrix[4];
var y0 = matrix[5];
svg = svg.split('\r\n');
var group = '';
var accesspoints = {};
svg.forEach(function (line) {
if (line.match(/\<line id\=/) != null) {
var id = line.match(/id\=\"(.*?)\"/)[1].toLowerCase();
var x = parseFloat(line.match(/x1\=\"(.*?)\"/)[1]);
var y = parseFloat(line.match(/y1\=\"(.*?)\"/)[1]);
x = (x - x0)/width;
y = (y - y0)/height;
accesspoints[id] = {id:id, x:x, y:y, group:group}
} else if (line.match(/\<g id\=/) != null) {
group = line.match(/id\=\"(.*?)\"/)[1];
} else if (line.match(/\<\/g\>/) != null) {
group = '';
}
//console.log(line);
});
fs.writeFileSync('../cleaned/accesspoints.json', JSON.stringify(accesspoints, null, '\t'), 'utf8');

75
node.js/3 scan4social.js Normal file
View File

@ -0,0 +1,75 @@
var fs = require('fs');
var data = fs.readFileSync('../cleaned/rp13-arr.json', 'utf8');
data = JSON.parse(data);
var points = [];
var addresses = {};
data.forEach(function (o) {
var point = o[2]+o[0];
var address = o[4];
if (points[point] === undefined) points[point] = [];
points[point].push(address);
if (addresses[address] === undefined) addresses[address] = 0;
addresses[address]++;
});
var addressList = [];
Object.keys(addresses).forEach(function (address) {
if (addresses[address] > 100) addressList.push(address);
});
addresses = {};
addressList.forEach(function (address, index) {
addresses[address] = index;
});
console.log(addressList.length);
var matrix = [];
var visible = [];
var n = 0;
for (var i = 0; i < addressList.length; i++) {
matrix[i] = [];
visible[i] = 0;
for (var j = 0; j < addressList.length; j++) matrix[i][j] = 0;
}
Object.keys(points).forEach(function (point) {
var subAddressList = points[point];
var list = [];
subAddressList.forEach(function (address) {
if (addresses[address] !== undefined) list.push(addresses[address]);
});
for (var i = 0; i < list.length; i++) {
var a = list[i];
visible[a]++;
for (var j = i+1; j < list.length; j++) {
var b = list[j];
matrix[a][b]++;
matrix[b][a]++;
}
}
n++;
});
var result = ['target\tsource\tweight'];
for (var i = 0; i < addressList.length; i++) {
for (var j = i+1; j < addressList.length; j++) {
var v = (matrix[i][j] - visible[i]*visible[j]/n)/n;
v *= 20;
if (v > 1e-2) {
v = Math.pow(v, 0.5);
result.push([i, j, v.toFixed(4)].join('\t'));
}
}
}
console.log(result.length);
fs.writeFileSync('./edges.tsv', result.join('\n'), 'utf8');

View File

@ -0,0 +1,96 @@
var fs = require('fs');
var log = fs.readFileSync('../cleaned/rp13-obj.json', 'utf8');
log = JSON.parse(log);
var accesspoints = fs.readFileSync('../cleaned/accesspoints.json', 'utf8');
accesspoints = JSON.parse(accesspoints);
var ap = new Lookup();
Object.keys(accesspoints).forEach(function (name) {
var point = accesspoints[name];
var name = Math.round(point.x*100)+'_'+Math.round(point.y*50);
point.name = name;
ap.add(name);
});
var condensedAccesspoints = [];
Object.keys(accesspoints).forEach(function (name) {
var point = accesspoints[name];
point.index = ap.getId(point.name);
condensedAccesspoints[point.index] = {
x: point.x,
y: point.y,
room: point.group
};
});
var macs = new Lookup();
var times = new Lookup();
log.forEach(function (entry) {
if (accesspoints[entry.access_point] === undefined) return;
entry.time = ((new Date(entry.date)).getTime()-1367712000000)/60000+60;
times.add(entry.time);
macs.add(entry.mac_hash);
});
times.sort(function (a,b) { return a-b });
var newEntries = [];
log.forEach(function (entry) {
if (accesspoints[entry.access_point] === undefined) return;
var mac = macs.getId(entry.mac_hash);
var time = times.getId(entry.time);
var point = accesspoints[entry.access_point].index;
if (newEntries[mac] === undefined) newEntries[mac] = [];
newEntries[mac][time] = point;
});
var result = {
/*macs: macs.getJSON(),*/
times: times.getJSON(),
points: condensedAccesspoints,
matrix: newEntries
};
fs.writeFileSync('../clients/anim/data.js', 'var data = '+JSON.stringify(result, null, '\t'), 'utf8');
function Lookup() {
var me = this;
var entry2index = {};
var index2entry = [];
me.add = function (entry) {
if (entry2index[entry] === undefined) {
var index = index2entry.length;
entry2index[entry] = index;
index2entry[index] = entry;
}
}
me.sort = function (callback) {
entry2index = {};
index2entry = index2entry.sort(callback);
index2entry.forEach(function (entry, index) {
entry2index[entry] = index;
})
}
me.getId = function (entry) {
return entry2index[entry];
}
me.getJSON = function () {
return index2entry.slice(0);
}
return me;
}