SceneUtil.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package com.fdkankan.model.utils;
  2. import cn.hutool.core.io.FileUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.alibaba.fastjson.JSON;
  5. import com.alibaba.fastjson.JSONArray;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.fdkankan.model.constants.ConstantFilePath;
  8. import java.io.File;
  9. import java.nio.charset.Charset;
  10. import java.util.HashMap;
  11. import java.util.List;
  12. import java.util.Map;
  13. import java.util.stream.Collectors;
  14. /**
  15. * <p>
  16. * 此工具类提供场景信息处理相关工具函数
  17. * </p>
  18. *
  19. * @author dengsixing
  20. * @since 2022/3/10
  21. **/
  22. public class SceneUtil {
  23. public static String getPath(String path, String cameraName, String fileId, int cameraType, String unicode){
  24. if(cameraType < 3){
  25. return path;
  26. }
  27. String localPath = cameraName.replace("4DKKPRO_", "")
  28. .replace("-fdage", "").toLowerCase() +
  29. File.separator + fileId + File.separator + unicode;
  30. if(cameraType == 5 || cameraType == 6){
  31. path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
  32. }else if(cameraType == 14) {
  33. path = ConstantFilePath.BUILD_MODEL_LASER_PATH + localPath;
  34. } else{
  35. path = ConstantFilePath.BUILD_MODEL_PATH + localPath;
  36. }
  37. return path;
  38. }
  39. /**
  40. * 根据vision.txt获取全景图名称列表
  41. * @param visionPath
  42. * @return
  43. */
  44. public static List<String> getPanoramaImageList(String visionPath){
  45. String visionTxt = FileUtil.readString(visionPath, Charset.forName("UTF-8"));
  46. JSONObject visionObject = JSON.parseObject(visionTxt);
  47. JSONArray sweepLocations = visionObject.getJSONArray("sweepLocations");
  48. List<String> imageList = sweepLocations.parallelStream().map(o -> {
  49. JSONObject item = (JSONObject) o;
  50. return item.getString("uuid") + ".jpg";
  51. }).collect(Collectors.toList());
  52. return imageList;
  53. }
  54. /**
  55. * 根据dataSource获取原始资源目录
  56. * @param dataSource
  57. * @return
  58. */
  59. public static String getHomePath(String dataSource) {
  60. String homePath = ConstantFilePath.OSS_PREFIX
  61. + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
  62. .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
  63. if (!homePath.endsWith("/")) {
  64. homePath = homePath.concat("/");
  65. }
  66. return homePath;
  67. }
  68. public static Map<String, String> getPropertyFromDataSource(String dataSource){
  69. if(StrUtil.isEmpty(dataSource)){
  70. return null;
  71. }
  72. String homePath = getHomePath(dataSource);
  73. homePath = homePath.substring(0, homePath.lastIndexOf("/"));
  74. String[] arr = homePath.split("/");
  75. Map<String, String> result = new HashMap<>();
  76. result.put("homePath", homePath);
  77. result.put("snCode", arr[1]);
  78. result.put("fileId", arr[2]);
  79. result.put("uuid", arr[3]);
  80. return result;
  81. }
  82. public static void main(String[] args) {
  83. String str = "27";
  84. int n = 8;
  85. System.out.println("10进制=" + Integer.parseInt(str, n));
  86. System.out.println(Integer.toHexString(Integer.parseInt(str, n)));
  87. }
  88. }