|
@@ -13,9 +13,7 @@ import com.fdkankan.indoor.base.util.AliYunOssUtil;
|
|
|
import com.fdkankan.indoor.base.util.CmdUtils;
|
|
|
import com.fdkankan.indoor.base.util.Result;
|
|
|
import com.fdkankan.indoor.core.entity.*;
|
|
|
-import com.fdkankan.indoor.core.entity.dto.CropDto;
|
|
|
-import com.fdkankan.indoor.core.entity.dto.CutModelDto;
|
|
|
-import com.fdkankan.indoor.core.entity.dto.MapDto;
|
|
|
+import com.fdkankan.indoor.core.entity.dto.*;
|
|
|
import com.fdkankan.indoor.core.entity.po.DataSetPo;
|
|
|
import com.fdkankan.indoor.core.entity.po.MapPo;
|
|
|
import com.fdkankan.indoor.core.mapper.CutModelMapper;
|
|
@@ -150,100 +148,100 @@ public class CutModelServiceImpl extends IBaseServiceImpl implements CutModelSer
|
|
|
// return null;
|
|
|
// }
|
|
|
|
|
|
-// @Override
|
|
|
-// public Result crop(String sceneCode, CropDto param) {
|
|
|
-// Double[] transformation_matrix = param.getTransformation_matrix();
|
|
|
-// String matrix = format(transformation_matrix);
|
|
|
-// JSONObject pa = new JSONObject();
|
|
|
-// log.info("aa: {}", matrix);
|
|
|
-// pa.put("aabb", "b-0.5 -0.5 -0.5 0.5 0.5 0.5");
|
|
|
-// pa.put("cut_transformation", "b" + matrix);
|
|
|
-//
|
|
|
-// InitEntity entity = initService.findById(sceneCode);
|
|
|
-// if (entity == null) {
|
|
|
-// throw new BaseRuntimeException("对象不存在");
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// String path = entity.getPath();
|
|
|
-//// String basePath = path + "/laserData/";
|
|
|
-// String basePath = path ;
|
|
|
-//
|
|
|
-// String savePath = basePath + "cut_param.json";
|
|
|
-// log.info("剪切参数:{}", savePath);
|
|
|
-// FileUtil.writeUtf8String(pa.toJSONString(), savePath);
|
|
|
-// log.info("剪切参数json写入完成");
|
|
|
-//
|
|
|
-// // 调用命令切模型
|
|
|
-// String cmd = CmdConstant.CUT_MODEL;
|
|
|
-// String inPath = basePath + "laser.las";
|
|
|
-//
|
|
|
-// String time = DateUtil.format(LocalDateTime.now(), "yyyyMMdd_HHmmss");
|
|
|
-// String cutDir = basePath + "cut/";
|
|
|
-// String outPath = cutDir + time + ".las";
|
|
|
-// // 检查目录
|
|
|
-// if (!FileUtil.isFile(cutDir)) {
|
|
|
-// FileUtil.mkdir(cutDir);
|
|
|
-// }
|
|
|
-// String cutParam = basePath + "cut_param.json";
|
|
|
-//
|
|
|
-// cmd = cmd.replace("@inPath", inPath);
|
|
|
-// cmd = cmd.replace("@outPath", outPath);
|
|
|
-// cmd = cmd.replace("@cutParam", cutParam);
|
|
|
-//
|
|
|
-// CmdUtils.callLineSh(cmd);
|
|
|
-// log.info("剪切模型完成: {}", outPath);
|
|
|
-//
|
|
|
-// // 将剪裁后的las上传oss
|
|
|
-// String ossPath = "data/" +sceneCode + "/data/chunk1/cut/" + time + ".las";
|
|
|
-// aliYunOssUtil.upload(outPath, ossPath);
|
|
|
-//
|
|
|
-// String ossUrl = configConstant.ossDomain + ossPath;
|
|
|
-// log.info("剪切模型上传oss完成: {}", ossUrl);
|
|
|
-//
|
|
|
-// // 保存数据到数据库
|
|
|
-// Integer maxId = 0;
|
|
|
-// CutModelEntity cutEntity = findById(sceneCode);
|
|
|
-// if (cutEntity == null) {
|
|
|
-// cutEntity = new CutModelEntity();
|
|
|
-// cutEntity.setId(sceneCode);
|
|
|
-// cutEntity.setCreateTime(LocalDateTime.now());
|
|
|
-// cutEntity.setData(initCutModelDto(ossUrl, null));
|
|
|
-// maxId = 1;
|
|
|
-// } else {
|
|
|
-// // 修改一次,加一条记录
|
|
|
-// cutEntity.setUpdateTime(LocalDateTime.now());
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// List<CutModelDto> data = getDataBySceneCode(sceneCode);
|
|
|
-// if (data.size() != 0){
|
|
|
-//
|
|
|
-// // 遍历参数,获取id, 保存新list
|
|
|
-// List<Integer> collectId = data.stream().map(CutModelDto::getId).collect(Collectors.toList());
|
|
|
-// log.info("参数id: {}", collectId);
|
|
|
-// // 获取最大id
|
|
|
-// if (data.size() != 0) {
|
|
|
-// Optional<CutModelDto> max = data.stream().max(Comparator.comparingInt(CutModelDto::getId));
|
|
|
-// maxId = max.get().getId();
|
|
|
-// maxId ++;
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// List<CutModelDto> cutModelDtos = initCutModelDto(ossUrl, maxId);
|
|
|
-// // 合并两个流,
|
|
|
-// data.addAll(cutModelDtos);
|
|
|
-// cutEntity.setData(data);
|
|
|
-//
|
|
|
-// }
|
|
|
-// entityMapper.save(cutEntity);
|
|
|
-//
|
|
|
-// JSONObject result = new JSONObject();
|
|
|
-// result.put("job_id", maxId);
|
|
|
-// return Result.success(result);
|
|
|
-// }
|
|
|
+ @Override
|
|
|
+ public Result crop1(String sceneCode, CropDto param) {
|
|
|
+ Double[] transformation_matrix = param.getTransformation_matrix();
|
|
|
+ String matrix = format(transformation_matrix);
|
|
|
+ JSONObject pa = new JSONObject();
|
|
|
+ log.info("matrix: {}", matrix);
|
|
|
+ pa.put("aabb", "b-0.5 -0.5 -0.5 0.5 0.5 0.5");
|
|
|
+ pa.put("cut_transformation", "b" + matrix);
|
|
|
+
|
|
|
+ InitEntity entity = initService.findById(sceneCode);
|
|
|
+ if (entity == null) {
|
|
|
+ throw new BaseRuntimeException("对象不存在");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String path = entity.getPath();
|
|
|
+// String basePath = path + "/laserData/";
|
|
|
+ String basePath = path ;
|
|
|
+
|
|
|
+ String savePath = basePath + "cut_param.json";
|
|
|
+ log.info("剪切参数:{}", savePath);
|
|
|
+ FileUtil.writeUtf8String(pa.toJSONString(), savePath);
|
|
|
+ log.info("剪切参数json写入完成");
|
|
|
+
|
|
|
+ // 调用命令切模型
|
|
|
+ String cmd = CmdConstant.CUT_MODEL;
|
|
|
+ String inPath = basePath + "laser.las";
|
|
|
+
|
|
|
+ String time = DateUtil.format(LocalDateTime.now(), "yyyyMMdd_HHmmss");
|
|
|
+ String cutDir = basePath + "cut/";
|
|
|
+ String outPath = cutDir + time + ".las";
|
|
|
+ // 检查目录
|
|
|
+ if (!FileUtil.isFile(cutDir)) {
|
|
|
+ FileUtil.mkdir(cutDir);
|
|
|
+ }
|
|
|
+ String cutParam = basePath + "cut_param.json";
|
|
|
+
|
|
|
+ cmd = cmd.replace("@inPath", inPath);
|
|
|
+ cmd = cmd.replace("@outPath", outPath);
|
|
|
+ cmd = cmd.replace("@cutParam", cutParam);
|
|
|
+
|
|
|
+ CmdUtils.callLineSh(cmd);
|
|
|
+ log.info("剪切模型完成: {}", outPath);
|
|
|
+
|
|
|
+ // 将剪裁后的las上传oss
|
|
|
+ String ossPath = "data/" +sceneCode + "/data/chunk1/cut/" + time + ".las";
|
|
|
+ aliYunOssUtil.upload(outPath, ossPath);
|
|
|
+
|
|
|
+ String ossUrl = configConstant.ossDomain + ossPath;
|
|
|
+ log.info("剪切模型上传oss完成: {}", ossUrl);
|
|
|
+
|
|
|
+ // 保存数据到数据库
|
|
|
+ Integer maxId = 0;
|
|
|
+ CutModelEntity cutEntity = findById(sceneCode);
|
|
|
+ if (cutEntity == null) {
|
|
|
+ cutEntity = new CutModelEntity();
|
|
|
+ cutEntity.setId(sceneCode);
|
|
|
+ cutEntity.setCreateTime(LocalDateTime.now());
|
|
|
+ cutEntity.setData(initCutModelDto(ossUrl, null));
|
|
|
+ maxId = 1;
|
|
|
+ } else {
|
|
|
+ // 修改一次,加一条记录
|
|
|
+ cutEntity.setUpdateTime(LocalDateTime.now());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<CutModelDto> data = getDataBySceneCode(sceneCode);
|
|
|
+ if (data.size() != 0){
|
|
|
+
|
|
|
+ // 遍历参数,获取id, 保存新list
|
|
|
+ List<Integer> collectId = data.stream().map(CutModelDto::getId).collect(Collectors.toList());
|
|
|
+ log.info("参数id: {}", collectId);
|
|
|
+ // 获取最大id
|
|
|
+ if (data.size() != 0) {
|
|
|
+ Optional<CutModelDto> max = data.stream().max(Comparator.comparingInt(CutModelDto::getId));
|
|
|
+ maxId = max.get().getId();
|
|
|
+ maxId ++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<CutModelDto> cutModelDtos = initCutModelDto(ossUrl, maxId);
|
|
|
+ // 合并两个流,
|
|
|
+ data.addAll(cutModelDtos);
|
|
|
+ cutEntity.setData(data);
|
|
|
+
|
|
|
+ }
|
|
|
+ entityMapper.save(cutEntity);
|
|
|
+
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("job_id", maxId);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public Result findByDataId(String sceneCode, Integer dataId) {
|
|
@@ -375,9 +373,10 @@ public class CutModelServiceImpl extends IBaseServiceImpl implements CutModelSer
|
|
|
|
|
|
for (DataSetPo po : dataSetInfos) {
|
|
|
Double[] location = po.getLocation();
|
|
|
- // gis坐标转本地坐标
|
|
|
+ // gis坐标转本地坐标, 平移坐标
|
|
|
double[] doubles = GisCoordinateUtil.transformBLToLocation(location[0], location[1], pointCalculate);
|
|
|
|
|
|
+ // 旋转角度
|
|
|
Double orientation = po.getOrientation();
|
|
|
|
|
|
// 将本地坐标, 旋转角度按顺序封装起来
|
|
@@ -401,7 +400,9 @@ public class CutModelServiceImpl extends IBaseServiceImpl implements CutModelSer
|
|
|
cutJson.put("dataSetId", dataSetId);
|
|
|
// 算法要求用空格隔开
|
|
|
cutJson.put("file", basePath + "/laser.las");
|
|
|
+ // 平移参数
|
|
|
cutJson.put("translation", point[0] + " " + point[1] + " " + point[2]);
|
|
|
+ // 旋转参数
|
|
|
cutJson.put("rotation", point[3]);
|
|
|
models.add(cutJson);
|
|
|
} else { // 多数据集
|
|
@@ -425,7 +426,9 @@ public class CutModelServiceImpl extends IBaseServiceImpl implements CutModelSer
|
|
|
cutJson.put("dataSetId", dataSetId);
|
|
|
// 算法要求用空格隔开
|
|
|
cutJson.put("file", info.getPath() + "/laser.las");
|
|
|
+ // 平移参数
|
|
|
cutJson.put("translation", point[0] + " " + point[1] + " " + point[2]);
|
|
|
+ // 旋转参数
|
|
|
cutJson.put("rotation", point[3]);
|
|
|
models.add(cutJson);
|
|
|
}
|
|
@@ -437,7 +440,7 @@ public class CutModelServiceImpl extends IBaseServiceImpl implements CutModelSer
|
|
|
// 修剪模型参数
|
|
|
JSONObject mergeCut = new JSONObject();
|
|
|
mergeCut.put("model", models);
|
|
|
- // 这个值目前写死
|
|
|
+ // 这个值目前写死, 剪切参数
|
|
|
mergeCut.put("aabb", "b-0.5 -0.5 -0.5 0.5 0.5 0.5");
|
|
|
|
|
|
// 剪切模型参数json写入服务器
|
|
@@ -467,6 +470,74 @@ public class CutModelServiceImpl extends IBaseServiceImpl implements CutModelSer
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result multipleCrop2(String sceneCode, MultipleCropDto param) {
|
|
|
+
|
|
|
+ // 1. 合并场景表(t_merge_info)获取dataSetId, 场景码
|
|
|
+ List<MergeInfoEntity> mergeInfo = mergeInfoService.findBySceneCode(sceneCode);
|
|
|
+
|
|
|
+ HashMap<Integer, MergeInfoEntity> mergeMap = new HashMap<>();
|
|
|
+ for (MergeInfoEntity infoEntity : mergeInfo) {
|
|
|
+ mergeMap.put(infoEntity.getDataSetId(), infoEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ // models参数
|
|
|
+ JSONArray models = new JSONArray();
|
|
|
+ List<Crop> cropMatrix = param.getTransformation_matrix();
|
|
|
+ for (Crop crop : cropMatrix) {
|
|
|
+ Integer dataSetId = crop.getId();
|
|
|
+ if (dataSetId==null) {
|
|
|
+ throw new BaseRuntimeException("剪切模型参数,数据集id不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ MergeInfoEntity infoEntity = mergeMap.get(dataSetId);
|
|
|
+ JSONObject model = new JSONObject();
|
|
|
+ model.put("sceneCode", infoEntity.getMergeCode());
|
|
|
+ model.put("dataSetId", dataSetId);
|
|
|
+ // 算法要求用空格隔开
|
|
|
+ model.put("file", infoEntity.getPath() + "/laser.las");
|
|
|
+ // 矩阵(剪裁参数已包含在里面的)
|
|
|
+ model.put("cut_transformation", format(crop.getMatrix()));
|
|
|
+ model.put("modelMatrix", format(crop.getModelMatrix()));
|
|
|
+
|
|
|
+ models.add(model);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修剪模型参数
|
|
|
+ JSONObject mergeCut = new JSONObject();
|
|
|
+ mergeCut.put("model", models);
|
|
|
+ // 剪裁参数
|
|
|
+ mergeCut.put("aabb", param.getAabb());
|
|
|
+ log.info("剪切参数json:", mergeCut);
|
|
|
+
|
|
|
+
|
|
|
+ String basePath = redisPath(sceneCode);
|
|
|
+
|
|
|
+ // 剪切模型参数json写入服务器
|
|
|
+
|
|
|
+ if ("dev".equals(configConstant.active)){
|
|
|
+ basePath = configConstant.serverBasePath + "/" + sceneCode + "/results/laserData";
|
|
|
+ }
|
|
|
+ String savePath = basePath + "/merge_cut_param.json";
|
|
|
+ log.info("剪切参数保存路径:{}", savePath);
|
|
|
+ FileUtil.writeUtf8String(mergeCut.toJSONString(), savePath);
|
|
|
+ log.info("剪切参数json写入完成");
|
|
|
+
|
|
|
+ // 剪切并oss上传模型
|
|
|
+ String ossUrl = cutLas(basePath, sceneCode);
|
|
|
+
|
|
|
+ // 数据更新到数据库
|
|
|
+ saveLasInfo(sceneCode, ossUrl);
|
|
|
+
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ // 返回值id, 默认1
|
|
|
+ result.put("job_id", 1);
|
|
|
+ return Result.success(result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2021-11-04
|
|
|
* 处理剪切模型参数并剪切模型,结果上传oss
|