finish profile->csv exporter

This commit is contained in:
mschuetz 2017-02-07 14:14:27 +01:00
parent b07e7ae197
commit 509503d41d

View File

@ -594,15 +594,74 @@ Potree.Viewer.Profile = class ProfileWindow{
}
getPointsInProfileAsCSV(){
if(this.points.length === 0){
return "no points in profile";
}
let file = "";
let points = this.points.slice();
points.sort((a, b) => (a.distance - b.distance));
{ // header-line
let header = "x, y";
if(points[0].hasOwnProperty("color")){
header += ", r, g, b";
}
if(points[0].hasOwnProperty("intensity")){
header += ", intensity";
}
if(points[0].hasOwnProperty("classification")){
header += ", classification";
}
if(points[0].hasOwnProperty("numberOfReturns")){
header += ", numberOfReturns";
}
if(points[0].hasOwnProperty("pointSourceID")){
header += ", pointSourceID";
}
if(points[0].hasOwnProperty("returnNumber")){
header += ", returnNumber";
}
file += header + "\n";
}
// actual data
for(let point of points){
let line = point.distance.toFixed(4) + ", ";
line += point.altitude.toFixed(4) + ", ";
line += point.color.join(", ");
if(point.hasOwnProperty("color")){
line += point.color.join(", ");
}
if(point.hasOwnProperty("intensity")){
line += ", " + point.intensity;
}
if(point.hasOwnProperty("classification")){
line += ", " + point.classification;
}
if(point.hasOwnProperty("numberOfReturns")){
line += ", " + point.numberOfReturns;
}
if(point.hasOwnProperty("pointSourceID")){
line += ", " + point.pointSourceID;
}
if(point.hasOwnProperty("returnNumber")){
line += ", " + point.returnNumber;
}
line += "\n";
file = file + line;