123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package com.fdkankan.model.utils;
- import cn.hutool.core.io.FileUtil;
- import cn.hutool.core.util.StrUtil;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.fdkankan.model.constants.ConstantFilePath;
- import java.io.File;
- import java.nio.charset.Charset;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- /**
- * <p>
- * 此工具类提供场景信息处理相关工具函数
- * </p>
- *
- * @author dengsixing
- * @since 2022/3/10
- **/
- public class SceneUtil {
- public static String getPath(String path, String cameraName, String fileId, int cameraType, String unicode){
- if(cameraType < 3){
- return path;
- }
- String localPath = cameraName.replace("4DKKPRO_", "")
- .replace("-fdage", "").toLowerCase() +
- File.separator + fileId + File.separator + unicode;
- if(cameraType == 5 || cameraType == 6){
- path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
- }else if(cameraType == 14) {
- path = ConstantFilePath.BUILD_MODEL_LASER_PATH + localPath;
- } else{
- path = ConstantFilePath.BUILD_MODEL_PATH + localPath;
- }
- return path;
- }
- /**
- * 根据vision.txt获取全景图名称列表
- * @param visionPath
- * @return
- */
- public static List<String> getPanoramaImageList(String visionPath){
- String visionTxt = FileUtil.readString(visionPath, Charset.forName("UTF-8"));
- JSONObject visionObject = JSON.parseObject(visionTxt);
- JSONArray sweepLocations = visionObject.getJSONArray("sweepLocations");
- List<String> imageList = sweepLocations.parallelStream().map(o -> {
- JSONObject item = (JSONObject) o;
- return item.getString("uuid") + ".jpg";
- }).collect(Collectors.toList());
- return imageList;
- }
- /**
- * 根据dataSource获取原始资源目录
- * @param dataSource
- * @return
- */
- public static String getHomePath(String dataSource) {
- String homePath = ConstantFilePath.OSS_PREFIX
- + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
- .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
- if (!homePath.endsWith("/")) {
- homePath = homePath.concat("/");
- }
- return homePath;
- }
- public static Map<String, String> getPropertyFromDataSource(String dataSource){
- if(StrUtil.isEmpty(dataSource)){
- return null;
- }
- String homePath = getHomePath(dataSource);
- homePath = homePath.substring(0, homePath.lastIndexOf("/"));
- String[] arr = homePath.split("/");
- Map<String, String> result = new HashMap<>();
- result.put("homePath", homePath);
- result.put("snCode", arr[1]);
- result.put("fileId", arr[2]);
- result.put("uuid", arr[3]);
- return result;
- }
- public static void main(String[] args) {
- String str = "27";
- int n = 8;
- System.out.println("10进制=" + Integer.parseInt(str, n));
- System.out.println(Integer.toHexString(Integer.parseInt(str, n)));
- }
- }
|