Skip to content

Commit

Permalink
fix output directory suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
potree committed Dec 30, 2019
1 parent d9f48c3 commit 922e582
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 24 deletions.
21 changes: 21 additions & 0 deletions .vscode/keybindings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+l",
"command": "editor.action.deleteLines",
"when": "editorTextFocus && !editorReadonly"
},{
"key": "ctrl+shift+i",
"command": "editor.action.toggleRenderWhitespace"
},{
"key": "ctrl+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus"
},{
"key": "alt+2",
"command": "type",
"args": {
"text": "`"
}
}
]
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
"*.vs": "cpp",
"*.fs": "cpp"
},
"editor.fontSize": 16,
"files.trimTrailingWhitespace": false,
"editor.fontSize": 28,
"editor.autoIndent": false,
"editor.detectIndentation": false,
"editor.renderWhitespace": "all",
"editor.insertSpaces": false,
"editor.minimap.enabled": false,
"editor.autoClosingBrackets": false,
"editor.formatOnType": false,
"editor.acceptSuggestionOnEnter": "off",
"editor.acceptSuggestionOnCommitCharacter": false,
"editor.mouseWheelZoom": true,
"editor.renderWhitespace": "all",
}
79 changes: 57 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,52 @@

const fs = require("fs");
const npath = require("path");

const first = inputPaths[0];
const stat = await fs.promises.lstat(first);
const fsp = fs.promises;

let convName = "converted";

if(stat.isFile()){
convName = npath.basename(first, npath.extname(first));
}else if(stat.isDirectory()){
convName = npath.basename(first);
const whitelist = [".las", ".laz"];
const lasLazFiles = [];

let suggestedDirectory = null;
let suggestedName = null;

for(const path of inputPaths){
const stat = await fs.promises.lstat(path);

if(suggestedName === null){
suggestedDirectory = npath.normalize(`${path}/..`);
suggestedName = npath.basename(path, npath.extname(path)) + "_converted";
}

if(stat.isFile()){
const extension = npath.extname(path).toLowerCase();

if(whitelist.includes(extension)){
//lasLazFiles.push(`${path}/${file}`);
lasLazFiles.push(path);
}
}else if(stat.isDirectory()){
const files = await fsp.readdir(path);

for(const file of files){
const extension = npath.extname(file).toLowerCase();

if(whitelist.includes(extension)){
lasLazFiles.push(`${path}/${file}`);
}

};
}
}

const suggestedPath = npath.normalize(`${first}/../${convName}`);
let suggestedPath = `${suggestedDirectory}/${suggestedName}`;
//let suggestedPath = npath.normalize(`${first}/../${suggestedName}`);

let i = 1;
while(fs.existsSync(suggestedPath)){
suggestedPath = `${suggestedDirectory}/${suggestedName}_${i}`;
//suggestedPath = npath.normalize(`${first}/../${suggestedName}_${i}`);
i++;
}

const dialog = require('electron').remote.dialog;
const chosenPath = dialog.showSaveDialogSync(null, {
Expand Down Expand Up @@ -225,7 +258,7 @@
let message = `conversion finished, now loading ${cloudJS}`;
viewer.postMessage(message, {duration: 15000});

Potree.loadPointCloud(cloudJS, convName, function(e){
Potree.loadPointCloud(cloudJS, suggestedName, function(e){
viewer.scene.addPointCloud(e.pointcloud);

let material = e.pointcloud.material;
Expand Down Expand Up @@ -273,19 +306,21 @@
}else if(fs.lstatSync(path).isDirectory()){
// handle directory

const files = await fsp.readdir(path);
for(const file of files){

const extension = np.extname(file).toLowerCase();
const whitelist = [".las", ".laz"];
lasLazFiles.push(path);

if(file === "cloud.js"){
cloudJsFiles.push(`${path}/${file}`);
}else if(whitelist.includes(extension)){
lasLazFiles.push(`${path}/${file}`);
}
// const files = await fsp.readdir(path);
// for(const file of files){

// const extension = np.extname(file).toLowerCase();
// const whitelist = [".las", ".laz"];

// if(file === "cloud.js"){
// cloudJsFiles.push(`${path}/${file}`);
// }else if(whitelist.includes(extension)){
// lasLazFiles.push(`${path}/${file}`);
// }

};
// };

// console.log(files);

Expand Down

0 comments on commit 922e582

Please sign in to comment.