|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.zy.acs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.acs.manager.core.service.astart.WaveNodeType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Optional; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 8/7/2024 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class MapDataUtils { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static Double[][][] preComputeCdaMatrix(String[][] cdaStrMatrix) { | 
|---|
|  |  |  | int rows = cdaStrMatrix.length; | 
|---|
|  |  |  | int cols = cdaStrMatrix[0].length; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Double[][][] cdaMatrix = new Double[rows][cols][2]; | 
|---|
|  |  |  | for (int i = 0; i < rows; i++) { | 
|---|
|  |  |  | for (int j = 0; j < cols; j++) { | 
|---|
|  |  |  | List<Double> cda = MapDataUtils.parseCdaNode(cdaStrMatrix[i][j]); | 
|---|
|  |  |  | cdaMatrix[i][j][0] = cda.get(0); | 
|---|
|  |  |  | cdaMatrix[i][j][1] = cda.get(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return cdaMatrix; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static List<String> parseWaveNode(String waveNodeStr) { | 
|---|
|  |  |  | List<String> waveNodeList = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static List<Double> parseCdaNode(String cdaNodeStr) { | 
|---|
|  |  |  | List<Double> waveNodeList = new ArrayList<>(); | 
|---|
|  |  |  | if (Cools.isEmpty(cdaNodeStr)) { | 
|---|
|  |  |  | return waveNodeList; | 
|---|
|  |  |  | return new ArrayList<>(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return JSON.parseArray(cdaNodeStr, Double.class); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String generateWaveNode(String originStr, String waveNode) { | 
|---|
|  |  |  | List<String> waveNodeList; | 
|---|
|  |  |  | if (originStr.equals(WaveNodeType.ENABLE.val)) { | 
|---|
|  |  |  | waveNodeList = new ArrayList<>(); | 
|---|
|  |  |  | waveNodeList.add(waveNode); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | waveNodeList = JSON.parseArray(originStr, String.class); | 
|---|
|  |  |  | if (!waveNodeList.contains(waveNode)) { | 
|---|
|  |  |  | waveNodeList.add(waveNode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return JSON.toJSONString(waveNodeList); | 
|---|
|  |  |  | List<String> originNode = JSON.parseArray(originStr, String.class); | 
|---|
|  |  |  | Set<String> set = new HashSet<>(originNode); | 
|---|
|  |  |  | set.add(waveNode); | 
|---|
|  |  |  | return JSON.toJSONString(set); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static Double getVehicleWaveSafeDistance(Integer diameter, Double factor) { | 
|---|