Skip to content

Commit

Permalink
fix some parsing, fix last range
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbX authored Jun 8, 2018
1 parent 3ef08ba commit 98be262
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,45 @@
var data = [];
for(var i in src) {
var tmp = src[i].replace(/\s+/g, ' ').split(' ');
if(tmp.length > 1 && !isNaN(parseInt(tmp[0])))
if(tmp.length > 1 && !isNaN(parseInt(tmp[0]))) {
if(tmp.length == 2 && !isNaN(parseInt(tmp[1])))
data.push([parseInt(tmp[0]), parseInt(tmp[1])]);
else if(tmp.length == 3 && !isNaN(parseInt(tmp[1])) && !isNaN(parseInt(tmp[2])))
data.push([parseInt(tmp[1]), parseInt(tmp[2])]);
else if(tmp.length == 3 && !isNaN(parseInt(tmp[0])) && !isNaN(parseInt(tmp[1])) && isNaN(parseInt(tmp[2])))
data.push([parseInt(tmp[0]), parseInt(tmp[1])]);
}
}
console.log(data);
if(data[data.length-1][1] > data[data.length-1][0]) {
for(var i in data) {
var t = data[i][0];
data[i][0] = data[i][1];
data[i][1] = t;
}
}
console.log(data);
for(var i in data) {
data[i][0] *= 100;
}
var base = data[0][0];
var range = 0;
var res = []
var j = 0;
for(var i = 1; i < data.length; i++) {
range = (data[i][0] - data[i-1][0])/(data[i][1] - data[i-1][1]);
for(j = data[i-1][1]; j < data[i][1]; j++) {
//console.log(range, j, Math.round(base));
res.push([j, base]);
base += range;
}
}
var pullup = Math.ceil(base/500)*500;
var pullup = Math.ceil(base/50000)*50000;
for(var u = base; base <= pullup; base+=range) {
res.push([j, base]);
j++;
}
res.push([j, base]);
var dst = '';
for(var i in res) {
dst += Math.round(res[i][1])+';'+res[i][0]+'\r\n';
dst += Math.round(res[i][1]/100)+';'+res[i][0]+'\r\n';
}
$('#area').val(dst);
}
Expand Down

0 comments on commit 98be262

Please sign in to comment.