|
@@ -12,7 +12,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import java.io.File;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
-import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* 生成场景和计算场景
|
|
@@ -22,34 +21,30 @@ import java.util.UUID;
|
|
|
public class ComputerUtil {
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param unicode 创建文件目录码(目前是用场景吗)
|
|
|
+ * @param unicode 创建文件目录码(目前是用场景吗)
|
|
|
* @param projectNum 场景码
|
|
|
- * @param path 算法生成文件路径
|
|
|
+ * @param panoRootPath 算法生成文件路径
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static Map<String,String> computer(String unicode, String projectNum, String path) throws Exception{
|
|
|
+ public static Map<String, String> computer(String unicode, String projectNum, String panoRootPath) throws Exception {
|
|
|
// path: /data/kanfang/10002/pano
|
|
|
- log.info("path: {}", path);
|
|
|
- Map<String,String> map = new HashMap<String,String>();
|
|
|
+ log.info("建模收到的文件路径为:{}", panoRootPath);
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
|
// 生成模型oss存放路径
|
|
|
-// String ossPanoPath = ConstantFilePath.UPLOAD_HOUSE_PATH + projectNum + "/pano/";
|
|
|
//TODO:这里需要加斜杆,不然黏连在一起了
|
|
|
// String ossPanoPath = ConstantFilePath.OSS_IMAGE_PATH + "/" + projectNum + "/";
|
|
|
- String ossPanoPath = ConstantFilePath.OSS_IMAGE_PATH + projectNum + "/";
|
|
|
-// String ossVerticalPath = ossBasePath+"/pan/high/" + filename;
|
|
|
+ String ossPanoPath = ConstantFilePath.OSS_IMAGE_PATH + projectNum + "/";
|
|
|
|
|
|
- log.info("开始建模:"+projectNum);
|
|
|
+ log.info(">>>>>>>>开始建模:{}<<<<<<<<", projectNum);
|
|
|
//构建算法isModel去掉,因此改成空字符串
|
|
|
-// CreateObjUtil.build3dModel(ConstantFilePath.BUILD_MODEL_PATH + unicode, "");
|
|
|
- CreateObjUtil.build3dModel(path, "");
|
|
|
- log.info("建模完成转换数据:"+projectNum);
|
|
|
+ CreateObjUtil.build3dModel(panoRootPath, "");
|
|
|
+ log.info("建模完成转换数据:" + projectNum);
|
|
|
|
|
|
boolean vision2 = false;
|
|
|
//读取upload文件,检验需要上传的文件是否存在
|
|
|
- String uploadJsonPath = path + File.separator + "results" + File.separator + "upload.json";
|
|
|
+ String uploadJsonPath = panoRootPath + File.separator + "results" + File.separator + "upload.json";
|
|
|
boolean exist = FileUtil.exist(uploadJsonPath);
|
|
|
if (!exist) {
|
|
|
log.error("模型算法生成的upload.json不存在");
|
|
@@ -57,88 +52,83 @@ public class ComputerUtil {
|
|
|
}
|
|
|
String uploadData = FileUtils.readFile(uploadJsonPath);
|
|
|
JSONObject uploadJson = null;
|
|
|
- JSONArray array = null;
|
|
|
- if(uploadData!=null) {
|
|
|
+ JSONArray uploadFileArray = null;
|
|
|
+ if (uploadData != null) {
|
|
|
uploadJson = JSONObject.parseObject(uploadData);
|
|
|
- array = uploadJson.getJSONArray("upload");
|
|
|
+ uploadFileArray = uploadJson.getJSONArray("upload");
|
|
|
}
|
|
|
- if(array == null){
|
|
|
+ if (uploadFileArray == null) {
|
|
|
log.error("模型算法生成的upload.json数据出错");
|
|
|
throw new BaseRuntimeException(MsgCode.e_COMMON_3100, "模型算法生成的upload.json数据出错");
|
|
|
}
|
|
|
JSONObject fileJson = null;
|
|
|
String fileName = "";
|
|
|
- for(int i = 0, len = array.size(); i < len; i++){
|
|
|
- fileJson = array.getJSONObject(i);
|
|
|
+ for (int i = 0, len = uploadFileArray.size(); i < len; i++) {
|
|
|
+ fileJson = uploadFileArray.getJSONObject(i);
|
|
|
fileName = fileJson.getString("file");
|
|
|
//文件不存在抛出异常
|
|
|
- String filePath = path + File.separator + "results" + File.separator + fileName;
|
|
|
- if(!FileUtil.exist(filePath)){
|
|
|
+ String filePath = panoRootPath + File.separator + "results" + File.separator + fileName;
|
|
|
+ if (!FileUtil.exist(filePath)) {
|
|
|
log.error("文件不存在: " + filePath);
|
|
|
throw new BaseRuntimeException(MsgCode.e_COMMON_3100, "文件不存在: " + filePath);
|
|
|
}
|
|
|
|
|
|
//判断是否有vision2.txt
|
|
|
- if("vision2.txt".equals(fileName)){
|
|
|
+ if ("vision2.txt".equals(fileName)) {
|
|
|
vision2 = true;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
//tex文件夹
|
|
|
- if(fileJson.getIntValue("clazz") == 2 && !fileJson.containsKey("pack-file")){
|
|
|
+ if (fileJson.getIntValue("clazz") == 2 && !fileJson.containsKey("pack-file")) {
|
|
|
|
|
|
// param1: 文件地址, param2:oss upload 地址
|
|
|
- map.put(filePath, ossPanoPath + ConstantFileName.modelUUID+"_50k_texture_jpg_high1/"+fileName.replace("tex/", ""));
|
|
|
+ map.put(filePath, ossPanoPath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
|
|
|
}
|
|
|
|
|
|
//high文件夹
|
|
|
- if(fileJson.getIntValue("clazz") == 3){
|
|
|
- map.put(filePath, ossPanoPath +"pan/high/"+ fileName.replace("high/", ""));
|
|
|
+ if (fileJson.getIntValue("clazz") == 3) {
|
|
|
+ map.put(filePath, ossPanoPath + "pan/high/" + fileName.replace("high/", ""));
|
|
|
}
|
|
|
//low文件夹
|
|
|
- if(fileJson.getIntValue("clazz") == 4){
|
|
|
- map.put(filePath, ossPanoPath +"pan/low/"+ fileName.replace("low/", ""));
|
|
|
+ if (fileJson.getIntValue("clazz") == 4) {
|
|
|
+ map.put(filePath, ossPanoPath + "pan/low/" + fileName.replace("low/", ""));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- CreateObjUtil.convertTxtToDam( path + File.separator + "results" + File.separator+"tex"+File.separator+"modeldata.txt", path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k.dam");
|
|
|
-// CreateObjUtil.convertDamToLzma(unicode + File.separator + "results");
|
|
|
+ CreateObjUtil.convertTxtToDam(panoRootPath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", panoRootPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
|
|
|
// 服务器地址
|
|
|
// path:/data/kanfang/房源编号/pano
|
|
|
- CreateObjUtil.convertDamToLzma(path + "/results/" );
|
|
|
- CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"tex"+File.separator+"modeldata.txt", path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
+ CreateObjUtil.convertDamToLzma(panoRootPath + "/results/");
|
|
|
+ CreateObjUtil.convertTxtToDam(panoRootPath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", panoRootPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
|
|
|
//8目相机有两个vision.txt因此第二个叫vision2.txt
|
|
|
- if(vision2){
|
|
|
- CreateObjUtil.convertTxtToVisionmodeldata(path + File.separator + "results" +File.separator+"vision.txt",path + File.separator + "results" +File.separator+"vision.modeldata");
|
|
|
- CreateObjUtil.convertTxtToVisionmodeldata(path + File.separator + "results" +File.separator+"vision2.txt",path + File.separator + "results" +File.separator+"vision2.modeldata");
|
|
|
- map.put(path + File.separator + "results" +File.separator+"vision2.modeldata", "images/images"+projectNum+"/"+"vision2.modeldata");
|
|
|
- }else {
|
|
|
-
|
|
|
-// CreateObjUtil.convertTxtToVisionmodeldataCommon(path + File.separator + "results" +File.separator+"vision.txt",path + File.separator + "results" +File.separator+"vision.modeldata");
|
|
|
+ if (vision2) {
|
|
|
+ CreateObjUtil.convertTxtToVisionmodeldata(panoRootPath + File.separator + "results" + File.separator + "vision.txt", panoRootPath + File.separator + "results" + File.separator + "vision.modeldata");
|
|
|
+ CreateObjUtil.convertTxtToVisionmodeldata(panoRootPath + File.separator + "results" + File.separator + "vision2.txt", panoRootPath + File.separator + "results" + File.separator + "vision2.modeldata");
|
|
|
+ map.put(panoRootPath + File.separator + "results" + File.separator + "vision2.modeldata", "images/images" + projectNum + "/" + "vision2.modeldata");
|
|
|
+ } else {
|
|
|
// 将前端上传的vision.txt转vision.modeldata
|
|
|
- CreateObjUtil.convertTxtToVisionmodeldata(path + "/extras/vision.txt", path + "/results/vision.modeldata");
|
|
|
+ CreateObjUtil.convertTxtToVisionmodeldata(panoRootPath + "/extras/vision.txt", panoRootPath + "/results/vision.modeldata");
|
|
|
log.info("vision.modeldata创建完成");
|
|
|
}
|
|
|
- log.info("数据转换完成:"+projectNum);
|
|
|
+ log.info("场景码[{}]的数据转换完成" + projectNum);
|
|
|
|
|
|
- File file = new File(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma");
|
|
|
- while(!file.exists())
|
|
|
- {
|
|
|
+ File file = new File(panoRootPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma");
|
|
|
+ while (!file.exists()) {
|
|
|
Thread.sleep(60000);
|
|
|
}
|
|
|
|
|
|
|
|
|
// 文件上传oss
|
|
|
- map.put(path + File.separator + "results" +File.separator+"vision.modeldata", ossPanoPath+"vision.modeldata");
|
|
|
- map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma", ossPanoPath + ConstantFileName.modelUUID+"_50k.dam.lzma");
|
|
|
- map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam", ossPanoPath + ConstantFileName.modelUUID+"_50k.dam");
|
|
|
+ map.put(panoRootPath + File.separator + "results" + File.separator + "vision.modeldata", ossPanoPath + "vision.modeldata");
|
|
|
+ map.put(panoRootPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", ossPanoPath + ConstantFileName.modelUUID + "_50k.dam.lzma");
|
|
|
+ map.put(panoRootPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", ossPanoPath + ConstantFileName.modelUUID + "_50k.dam");
|
|
|
|
|
|
- log.info("准备上传文件到oss:"+projectNum);
|
|
|
+ log.info("场景[{}]准备上传文件到oss:" + projectNum);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- public static void createJson(String path, String splitType, String skyboxType, String dataDescribe) throws Exception{
|
|
|
+ public static void createJson(String path, String splitType, String skyboxType, String dataDescribe) throws Exception {
|
|
|
JSONObject dataJson = new JSONObject();
|
|
|
dataJson.put("split_type", splitType);
|
|
|
dataJson.put("skybox_type", skyboxType);
|