|
@@ -107,6 +107,127 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
|
|
|
return ResultData.ok(website);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResultData createVirtualSceneV2(CreateFicTitiousSceneParamVO param) throws Exception {
|
|
|
+
|
|
|
+ this.checkParams4createVirtualScene(param);
|
|
|
+
|
|
|
+ this.buildScene4CreateVirtualScene(param);
|
|
|
+
|
|
|
+ this.cutPanorama4CreateVirtualScene(param);
|
|
|
+
|
|
|
+ String website = this.updateScene4CreateVirtualScene(param);
|
|
|
+
|
|
|
+ return ResultData.ok(website);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void cutPanorama4CreateVirtualScene(CreateFicTitiousSceneParamVO param) throws Exception {
|
|
|
+ if(!param.getSceneKind().equals(SceneKind.TILES.code())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String num = param.getNum();
|
|
|
+
|
|
|
+ //检测原始图片是否存在
|
|
|
+ String ossImagePath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
+ String ossCaptruePath = ossImagePath.concat("captrue");
|
|
|
+ List<String> captrueList = fYunFileService.listRemoteFiles(ossCaptruePath);
|
|
|
+ if(CollUtil.isEmpty(captrueList)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3018.code(), "全景图不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ String target = String.format(ConstantFilePath.SCENE_IMAGES_PATH_V4, num);
|
|
|
+ String targetImagesPath = target + "extras/images/";
|
|
|
+ FileUtils.deleteDirectory(targetImagesPath);
|
|
|
+ String ossVisionTxtPath = ossImagePath + "vision.txt";
|
|
|
+ fYunFileService.downloadFile(ossVisionTxtPath, target + "extras" + File.separator + "vision.txt");
|
|
|
+
|
|
|
+ //下载全景图
|
|
|
+ fYunFileService.downloadFileByCommand(targetImagesPath, ossCaptruePath);
|
|
|
+
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
+ dataJson.put("split_type", "SPLIT_V8");
|
|
|
+ //V5表示不需要生成high,low文件
|
|
|
+ String skyboxType = "SKYBOX_V6";
|
|
|
+ SceneResolution sceneResolution = SceneResolution.valueOf(param.getSceneResolution());
|
|
|
+ switch (sceneResolution){
|
|
|
+ case one_k:
|
|
|
+ skyboxType = "SKYBOX_V9";
|
|
|
+ break;
|
|
|
+ case two_K:
|
|
|
+ skyboxType = "SKYBOX_V7";
|
|
|
+ break;
|
|
|
+ case four_K:
|
|
|
+ skyboxType = "SKYBOX_V8";
|
|
|
+ }
|
|
|
+ dataJson.put("skybox_type", skyboxType);
|
|
|
+ FileUtil.writeUtf8String(dataJson.toJSONString(), target + File.separator+"data.json");
|
|
|
+
|
|
|
+ //调用算法切图
|
|
|
+ CreateObjUtil.build3dModel(target , "1");
|
|
|
+
|
|
|
+ String uploadJsonPath= target + File.separator + "results" +File.separator+"upload.json";
|
|
|
+ Thread.sleep(2000);
|
|
|
+ boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 5, 200);
|
|
|
+ if(!exist){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
+ }
|
|
|
+ String uploadData = FileUtils.readFile(uploadJsonPath);
|
|
|
+ JSONObject uploadJson = null;
|
|
|
+ JSONArray array = null;
|
|
|
+ if(uploadData!=null) {
|
|
|
+ uploadJson = JSONObject.parseObject(uploadData);
|
|
|
+ array = uploadJson.getJSONArray("upload");
|
|
|
+ }
|
|
|
+ if(array == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
+ }
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ JSONObject fileJson = null;
|
|
|
+ String fileName = "";
|
|
|
+ for(int i = 0, len = array.size(); i < len; i++) {
|
|
|
+ fileJson = array.getJSONObject(i);
|
|
|
+ fileName = fileJson.getString("file");
|
|
|
+ //文件不存在抛出异常
|
|
|
+ if (!new File(target + File.separator + "results" + File.separator + fileName)
|
|
|
+ .exists()) {
|
|
|
+ throw new Exception(
|
|
|
+ target + File.separator + "results" + File.separator + fileName + "文件不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //high文件夹
|
|
|
+ if (fileJson.getIntValue("clazz") == 3) {
|
|
|
+ map.put(target + File.separator + "results" + File.separator + fileName,
|
|
|
+ ossImagePath + "pan/high/" + fileName.replace("high/", ""));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //low文件夹
|
|
|
+ if (fileJson.getIntValue("clazz") == 4) {
|
|
|
+ map.put(target + File.separator + "results" + File.separator + fileName,
|
|
|
+ ossImagePath + "pan/low/" + fileName.replace("low/", ""));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
|
|
|
+ if (fileJson.getIntValue("clazz") == 5) {
|
|
|
+ map.put(target + File.separator + "results" + File.separator + fileName,
|
|
|
+ ossImagePath + fileName);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //tiles文件夹,亚马逊瓦片图
|
|
|
+ if (fileJson.getIntValue("clazz") == 7) {
|
|
|
+ map.put(target + File.separator + "results" + File.separator + fileName,
|
|
|
+ ossImagePath + fileName);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(map.size()>0) {
|
|
|
+ fYunFileService.uploadMulFiles(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void checkParams4createVirtualScene(CreateFicTitiousSceneParamVO param){
|
|
|
SceneFrom sceneFrom = SceneFrom.get(param.getSceneFrom());
|
|
|
if(Objects.isNull(sceneFrom)){
|