|
@@ -145,105 +145,105 @@ public class CutModelServiceImpl extends IBaseServiceImpl implements CutModelSer
|
|
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
- public Result cutModel(String sceneCode) {
|
|
|
- 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);
|
|
|
+// @Override
|
|
|
+// public Result cutModel(String sceneCode) {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
|
|
|
- JSONObject result = new JSONObject();
|
|
|
- result.put("job_id", maxId);
|
|
|
- return Result.success(result);
|
|
|
- }
|
|
|
+// @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 findByDataId(String sceneCode, Integer dataId) {
|
|
@@ -266,73 +266,90 @@ public class CutModelServiceImpl extends IBaseServiceImpl implements CutModelSer
|
|
|
List<DataSetPo> dataSetInfos = dataSetService.getDataBySceneCode(sceneCode);
|
|
|
|
|
|
|
|
|
- // 转坐标,获取控制点计算值
|
|
|
- ControlPointCalculateEntity pointCalculate = controlPointCalculateService.findById(sceneCode);
|
|
|
+ String ossUrl;
|
|
|
+ String basePath = redisPath(sceneCode);
|
|
|
+ if (dataSetInfos.size() == 1) { // 只有一个数据集时
|
|
|
+ // 2021-10-13 把算法提供的点云直接上传oss
|
|
|
|
|
|
- HashMap<Object, double[] > covertPoint = new HashMap<>();
|
|
|
- for (DataSetPo po : dataSetInfos) {
|
|
|
- Double[] location = po.getLocation();
|
|
|
- // gis坐标转本地坐标
|
|
|
- double[] doubles = GisCoordinateUtil.transformBLToLocation(location[0], location[1], pointCalculate);
|
|
|
+ String ossPath = "data/" +sceneCode + "/download/merge_cut.las";
|
|
|
+ String outPath = basePath + "/laser.las";
|
|
|
+ aliYunOssUtil.upload(outPath, ossPath);
|
|
|
|
|
|
- Double orientation = po.getOrientation();
|
|
|
+ ossUrl = configConstant.ossDomain + ossPath + "?m=" + System.currentTimeMillis();
|
|
|
+ log.info("单数据集,直接上传算法提供的点云到oss");
|
|
|
|
|
|
- // 将本地坐标, 旋转角度按顺序封装起来
|
|
|
- double[] resParam = {doubles[0], doubles[1], location[2], orientation};
|
|
|
- Integer id = po.getId();
|
|
|
+ } else { // 多个数据集
|
|
|
+ // 转坐标,获取控制点计算值
|
|
|
+ ControlPointCalculateEntity pointCalculate = controlPointCalculateService.findById(sceneCode);
|
|
|
|
|
|
- // dataSetId做为key
|
|
|
- covertPoint.put(id, resParam);
|
|
|
- }
|
|
|
+ HashMap<Object, double[] > covertPoint = new HashMap<>();
|
|
|
+ for (DataSetPo po : dataSetInfos) {
|
|
|
+ Double[] location = po.getLocation();
|
|
|
+ // gis坐标转本地坐标
|
|
|
+ double[] doubles = GisCoordinateUtil.transformBLToLocation(location[0], location[1], pointCalculate);
|
|
|
|
|
|
+ Double orientation = po.getOrientation();
|
|
|
|
|
|
- // 2. 合并场景表(t_merge_info)获取dataSetId, 场景码
|
|
|
- List<MergeInfoEntity> mergeInfo = mergeInfoService.findBySceneCode(sceneCode, 1);
|
|
|
+ // 将本地坐标, 旋转角度按顺序封装起来
|
|
|
+ double[] resParam = {doubles[0], doubles[1], location[2], orientation};
|
|
|
+ Integer id = po.getId();
|
|
|
|
|
|
- int SizeDataSet = dataSetInfos.size();
|
|
|
- int SizeMergeDataSet = mergeInfo.size();
|
|
|
- log.info("数据集数量:{}, 合并数据集数量: {}", SizeDataSet, SizeMergeDataSet);
|
|
|
+ // dataSetId做为key
|
|
|
+ covertPoint.put(id, resParam);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ // 2. 合并场景表(t_merge_info)获取dataSetId, 场景码
|
|
|
+ List<MergeInfoEntity> mergeInfo = mergeInfoService.findBySceneCode(sceneCode, 1);
|
|
|
|
|
|
- JSONArray models = new JSONArray();
|
|
|
- for (MergeInfoEntity info : mergeInfo) {
|
|
|
- // 获取本地坐标,旋转角度
|
|
|
- Integer dataSetId = info.getDataSetId();
|
|
|
- double[] point = covertPoint.get(dataSetId);
|
|
|
+ int SizeDataSet = dataSetInfos.size();
|
|
|
+ int SizeMergeDataSet = mergeInfo.size();
|
|
|
+ log.info("数据集数量:{}, 合并数据集数量: {}", SizeDataSet, SizeMergeDataSet);
|
|
|
|
|
|
- JSONObject cutJson = new JSONObject();
|
|
|
- cutJson.put("file", info.getPath() + "/laser.las");
|
|
|
- cutJson.put("sceneCode", info.getMergeCode());
|
|
|
- cutJson.put("dataSetId", dataSetId);
|
|
|
- // 算法要求用空格隔开
|
|
|
- cutJson.put("translation", point[0] + " " + point[1] + " " + point[2]);
|
|
|
- cutJson.put("rotation", point[3]);
|
|
|
- models.add(cutJson);
|
|
|
- }
|
|
|
|
|
|
- // 修剪模型参数
|
|
|
- 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写入服务器
|
|
|
- String basePath = redisPath(sceneCode);
|
|
|
- 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写入完成");
|
|
|
+ JSONArray models = new JSONArray();
|
|
|
+ for (MergeInfoEntity info : mergeInfo) {
|
|
|
+ // 获取本地坐标,旋转角度
|
|
|
+ Integer dataSetId = info.getDataSetId();
|
|
|
+ double[] point = covertPoint.get(dataSetId);
|
|
|
+
|
|
|
+ JSONObject cutJson = new JSONObject();
|
|
|
+ cutJson.put("file", info.getPath() + "/laser.las");
|
|
|
+ cutJson.put("sceneCode", info.getMergeCode());
|
|
|
+ cutJson.put("dataSetId", dataSetId);
|
|
|
+ // 算法要求用空格隔开
|
|
|
+ cutJson.put("translation", point[0] + " " + point[1] + " " + point[2]);
|
|
|
+ cutJson.put("rotation", point[3]);
|
|
|
+ models.add(cutJson);
|
|
|
+ }
|
|
|
|
|
|
- // 剪切并oss上传模型
|
|
|
- String ossUrl = cutLas(basePath, sceneCode);
|
|
|
+ // 修剪模型参数
|
|
|
+ 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写入服务器
|
|
|
+
|
|
|
+ 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上传模型
|
|
|
+ ossUrl = cutLas(basePath, sceneCode);
|
|
|
+
|
|
|
+ }
|
|
|
// 数据更新到数据库
|
|
|
saveLasInfo(sceneCode, ossUrl);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
JSONObject result = new JSONObject();
|
|
|
// 返回值id, 默认1
|
|
|
result.put("job_id", 1);
|