/**
The function uses the given links ans samples it in defined steps. It returns an Array with the coordinates and the value of the link.
@param {Array} selectedLinks The links which should be sampled
@param {number} steps Steps (amount) in which the lines should be sampled
@param {Array} linkValues Array of Values which the respective line should get
(in Example the result of a Metric which can be used by the Heatmap)
@return {Array} structure Array of objects with coordinates on the a svg and the corresponding value (comDistr) {x, y, comDistr}
*/
function EdgeSampling(selectedLinks, steps, linkValues){
var structure = [{x: 0, y: 0, comDistr: 0}];
// Loop through all links
for(var i = 0; i < selectedLinks.length; i++){
var travelRatio_link = 100/(steps-1);// -1 because we start at the startpoint
var link_x1 = parseFloat(d3.select(selectedLinks[i]).attr("x1"));
var link_x2 = parseFloat(d3.select(selectedLinks[i]).attr("x2"));
var link_y1 = parseFloat(d3.select(selectedLinks[i]).attr("y1"));
var link_y2 = parseFloat(d3.select(selectedLinks[i]).attr("y2"));
var link_currentX = link_x1; // Startvalues
var link_currentY = link_y1; // Startvalues
for(var j= 1; j <=steps; j++) {
// Take Startpoint
if (j != 1){
link_currentX = link_x1 + (link_x2 - link_x1) * ( travelRatio_link/100);
link_currentY = link_y1 + (link_y2 - link_y1) * (travelRatio_link/100);
// Adds up to 100% of the range
travelRatio_link += 100/(steps-1);
}
structure.push({x: link_currentX, y: link_currentY, comDistr: linkValues[i]});
}
}
return structure;
}