区块链技术博客
www.b2bchain.cn

cesium 爬取别人的3dtiles (nodejs 实现)求职学习资料

本文介绍了cesium 爬取别人的3dtiles (nodejs 实现)求职学习资料,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

我们用node js 来 一个小工具 爬取别人的3dtiles 但是不保证 复杂节点 类似点云这种不行

“`javascript

let axios = require(‘axios’);
const fs = require(‘fs’);
const path = require(‘path’);

function downloadFile(urlPath, file) {
return new Promise((resolve, reject) => {
var lashIndex1 = file.lastIndexOf(“\”);
var lashIndex2 = file.lastIndexOf(“/”);
var lashIndex = lashIndex1 > lashIndex2 ? lashIndex1 : lashIndex2;
let lastPath = file.substring(0, lashIndex);
fs.mkdir(lastPath, {recursive: true}, async (err) => {
if (err) {
console.log(“目录创建错误”);
return;
};
const writer = fs.createWriteStream(file);
const response = await axios({
url: urlPath,
method: “GET”,
responseType: “stream”,
});
response.data.pipe(writer);
writer.on(“finish”, (e)=>{
console.log(“downloadFile下载完成”,urlPath)
resolve(e)
});
writer.on(“error”, (error) => {
console.log(“downloadFile报错了”, urlPath, error)
reject();
});
});
});
}

const writeFileRecursive = function (downPath, buffer) {
return new Promise((reslove, reject) => {
let lastPath = downPath.substring(0, downPath.lastIndexOf(“\”));
fs.mkdir(lastPath, {recursive: true}, (err) => {
if (err) return reject(err);
fs.writeFile(downPath, buffer, function (err) {
if (err) {
console.log(“writeFileRecursive报错”, downPath, err)
return reject(err);
}
console.log(“下载json完成”, downPath);
return reslove();
});
});
});

}

async function loop2(root, absolutePath, downPath, rootDir) {
if (root.content) {

我们用node js 来 一个小工具 爬取别人的3dtiles 但是不保证 复杂节点 类似点云这种不行

“`javascript

let axios = require(‘axios’);
const fs = require(‘fs’);
const path = require(‘path’);

function downloadFile(urlPath, file) {
return new Promise((resolve, reject) => {
var lashIndex1 = file.lastIndexOf(“\”);
var lashIndex2 = file.lastIndexOf(“/”);
var lashIndex = lashIndex1 > lashIndex2 ? lashIndex1 : lashIndex2;
let lastPath = file.substring(0, lashIndex);
fs.mkdir(lastPath, {recursive: true}, async (err) => {
if (err) {
console.log(“目录创建错误”);
return;
};
const writer = fs.createWriteStream(file);
const response = await axios({
url: urlPath,
method: “GET”,
responseType: “stream”,
});
response.data.pipe(writer);
writer.on(“finish”, (e)=>{
console.log(“downloadFile下载完成”,urlPath)
resolve(e)
});
writer.on(“error”, (error) => {
console.log(“downloadFile报错了”, urlPath, error)
reject();
});
});
});
}

const writeFileRecursive = function (downPath, buffer) {
return new Promise((reslove, reject) => {
let lastPath = downPath.substring(0, downPath.lastIndexOf(“\”));
fs.mkdir(lastPath, {recursive: true}, (err) => {
if (err) return reject(err);
fs.writeFile(downPath, buffer, function (err) {
if (err) {
console.log(“writeFileRecursive报错”, downPath, err)
return reject(err);
}
console.log(“下载json完成”, downPath);
return reslove();
});
});
});

}

async function loop2(root, absolutePath, downPath, rootDir) {
if (root.content) {

我们用node js 来 一个小工具 爬取别人的3dtiles 但是不保证 复杂节点 类似点云这种不行

“`javascript

let axios = require(‘axios’);
const fs = require(‘fs’);
const path = require(‘path’);

function downloadFile(urlPath, file) {
return new Promise((resolve, reject) => {
var lashIndex1 = file.lastIndexOf(“\”);
var lashIndex2 = file.lastIndexOf(“/”);
var lashIndex = lashIndex1 > lashIndex2 ? lashIndex1 : lashIndex2;
let lastPath = file.substring(0, lashIndex);
fs.mkdir(lastPath, {recursive: true}, async (err) => {
if (err) {
console.log(“目录创建错误”);
return;
};
const writer = fs.createWriteStream(file);
const response = await axios({
url: urlPath,
method: “GET”,
responseType: “stream”,
});
response.data.pipe(writer);
writer.on(“finish”, (e)=>{
console.log(“downloadFile下载完成”,urlPath)
resolve(e)
});
writer.on(“error”, (error) => {
console.log(“downloadFile报错了”, urlPath, error)
reject();
});
});
});
}

const writeFileRecursive = function (downPath, buffer) {
return new Promise((reslove, reject) => {
let lastPath = downPath.substring(0, downPath.lastIndexOf(“\”));
fs.mkdir(lastPath, {recursive: true}, (err) => {
if (err) return reject(err);
fs.writeFile(downPath, buffer, function (err) {
if (err) {
console.log(“writeFileRecursive报错”, downPath, err)
return reject(err);
}
console.log(“下载json完成”, downPath);
return reslove();
});
});
});

}

async function loop2(root, absolutePath, downPath, rootDir) {
if (root.content) {

部分转自互联网,侵权删除联系

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » cesium 爬取别人的3dtiles (nodejs 实现)求职学习资料
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们