瀏覽代碼

Merge remote-tracking branch 'origin/master'

csw 5 月之前
父節點
當前提交
82c9e8eb9a
共有 1 個文件被更改,包括 167 次插入14 次删除
  1. 167 14
      src/main/java/com/ecnu/platform/test/Test.groovy

+ 167 - 14
src/main/java/com/ecnu/platform/test/Test.groovy

@@ -2,32 +2,185 @@ package com.ecnu.platform.test
 
 import com.ecnu.alg.pojo.path.data.AlgPathStrategyInputData
 import com.ecnu.alg.pojo.path.inputs.AlgBaseMap
+import com.ecnu.alg.pojo.path.inputs.AlgObstacle
+import com.ecnu.alg.pojo.path.inputs.AlgParkSpace
 import com.ecnu.alg.pojo.path.inputs.AlgVehicle
+import com.ecnu.alg.pojo.path.inputs.AlgVehicleTask
 import com.three.common.utils.GsonUtil
 
 class Test {
 
     static void main(String[] args) {
-        AlgBaseMap algBaseMap = new AlgBaseMap()
-        algBaseMap.setId("qqqq")
-        algBaseMap.setName("ff")
-        String str = GsonUtil.toJson(algBaseMap)
-        List<AlgBaseMap> algBaseMapList = new ArrayList<>()
-        algBaseMapList.add(algBaseMap)
-        println(str)
-        println(GsonUtil.toJson(algBaseMapList))
 
+        ArrayList<Integer> xUnitList = new ArrayList<>()
+        ArrayList<Integer> yUnitList = new ArrayList<>()
+        // int[] xUnit = {0 1 1 0 0}
+        xUnitList.add(0)
+        xUnitList.add(1)
+        xUnitList.add(1)
+        xUnitList.add(0)
+        xUnitList.add(0)
+        // int[] yUnit = {0 0 1 1 0}
+        yUnitList.add(0)
+        yUnitList.add(0)
+        yUnitList.add(1)
+        yUnitList.add(1)
+        yUnitList.add(0)
+        double multiple = 1
+        double xInitial = 8
+        double yInitial = 70
 
 
         AlgPathStrategyInputData algPathStrategyInputData = new AlgPathStrategyInputData()
-        algPathStrategyInputData.setAlgBaseMap(algBaseMap)
-        algPathStrategyInputData.setAlgVehicleList(new ArrayList<AlgVehicle>())
 
-        println(GsonUtil.toJson(algPathStrategyInputData))
+        // 测试底图1
+        AlgBaseMap algBaseMap = new AlgBaseMap()
+        algBaseMap.setId("test1")
+        algBaseMap.setName("测试底图1")
+
+        double xBaseMap = xInitial + 0 * multiple
+        double yBaseMap = yInitial + 0 * multiple
+        double widthBaseMap = 197 * multiple
+        double heightBaseMap = 149 * multiple
+        String coordinateBaseMap = new String()
+        for (int i = 0; i < 5; i++){
+            coordinateBaseMap += xBaseMap + xUnitList.get(i) * widthBaseMap + ","
+            coordinateBaseMap += yBaseMap + yUnitList.get(i) * heightBaseMap
+            if (i != 4){
+                coordinateBaseMap += ";"
+            }
+        }
+        algBaseMap.setPcsBorder(coordinateBaseMap)
+
+
+        // 车辆列表
+        ArrayList<AlgVehicle> algVehicleList = new ArrayList<>()
+
+
+        // 车辆任务列表
+        ArrayList<AlgVehicleTask> algVehicleTaskList = new ArrayList<>()
+
+
+        // 障碍物列表
+        ArrayList<AlgObstacle> algObstacleList = new ArrayList<>()
+
+        // 障碍物1
+        AlgObstacle algObstacle1 = new AlgObstacle()
+        algObstacle1.setMapId("test1")
+        algObstacle1.setId("O1")
+        algObstacle1.setName("障碍物1")
+
+        double xObstacle1 = xInitial + 4 * multiple
+        double yObstacle1 = yInitial + 72 * multiple
+        double widthObstacle1 = 106 * multiple
+        double heightObstacle1 = 5 * multiple
+        String coordinateObstacle1 = new String()
+        for (int i = 0; i < 5; i++){
+            coordinateObstacle1 += xObstacle1 + xUnitList.get(i) * widthObstacle1 + ","
+            coordinateObstacle1 += yObstacle1 + yUnitList.get(i) * heightObstacle1
+            if (i != 4){
+                coordinateObstacle1 += ";"
+            }
+        }
+        algObstacle1.setPcsBorder(coordinateObstacle1)
+        algObstacleList.add(algObstacle1)
+
+        // 障碍物2
+        AlgObstacle algObstacle2 = new AlgObstacle()
+        algObstacle2.setMapId("test1")
+        algObstacle2.setId("O2")
+        algObstacle2.setName("障碍物2")
 
-        String str1 = "{\"algBaseMap\":{\"id\":\"qqqq\",\"name\":\"ff\"},\"algVehicleList\":[]}"
+        double xObstacle2 = xInitial + 165 * multiple
+        double yObstacle2 = yInitial + 72 * multiple
+        double widthObstacle2 = 28 * multiple
+        double heightObstacle2 = 5 * multiple
+        String coordinateObstacle2 = new String()
+        for (int i = 0; i < 5; i++){
+            coordinateObstacle2 += xObstacle2 + xUnitList.get(i) * widthObstacle2 + ","
+            coordinateObstacle2 += yObstacle2 + yUnitList.get(i) * heightObstacle2
+            if (i != 4){
+                coordinateObstacle2 += ";"
+            }
+        }
+        algObstacle2.setPcsBorder(coordinateObstacle2)
+        algObstacleList.add(algObstacle2)
 
-        AlgPathStrategyInputData algPathStrategyInputData1 = GsonUtil.fromJsonObject(str1, AlgPathStrategyInputData.class)
-        println(algPathStrategyInputData1)
+
+        // 停车位列表
+        ArrayList<AlgParkSpace> algParkSpaceList = new ArrayList<>()
+
+        // 停车库房列表
+        double xGarage = xInitial + 107 * multiple
+        double yGarage = yInitial + 3 * multiple
+        double widthGarage = 16 * multiple
+        double heightGarage = 32 * multiple
+        double gapGarage = 5 * multiple
+
+        for (int i = 0; i < 3; i++){
+            AlgParkSpace algParkGarage  = new AlgParkSpace()
+            algParkGarage.setMapId("test1")
+            String garageId = "G" + (i+1)
+            algParkGarage.setId(garageId)
+
+            double xNext = xGarage + i * (widthGarage + gapGarage)
+            String coordinateGarage = new String()
+            for (int j = 0; j < 5; j++){
+                coordinateGarage += xNext + xUnitList.get(j) * widthGarage + ","
+                coordinateGarage += yGarage + yUnitList.get(j) * heightGarage
+                if (j != 4){
+                    coordinateGarage += ";"
+                }
+            }
+            algParkGarage.setPcsBorder(coordinateGarage)
+            algParkSpaceList.add(algParkGarage)
+        }
+
+        // 停车位列表
+        ArrayList<Integer> blankList = new ArrayList<>()
+        for (int i = 0; i < 4; i++){
+            blankList.add(7+i)
+        }
+
+        double xSpace = xInitial + 2 * multiple
+        double ySpace = yInitial + 3 * multiple
+        double widthSpace = 13 * multiple
+        double heightSpace = 32 * multiple
+        double gapHorizontal = 2 * multiple
+        double gapVertical = 79 * multiple
+        int k = 1
+
+        for (int i = 0; i < 26; i++){
+            if (!blankList.contains(i)){
+                AlgParkSpace algParkSpace  = new AlgParkSpace()
+                algParkSpace.setMapId("test1")
+                String spaceId = "S" + k
+                algParkSpace.setId(spaceId)
+
+                double xNext = xSpace + (i % 13) * (widthSpace + gapHorizontal)
+                double yNext = ySpace + Math.floor(i/13) * (heightSpace + gapVertical)
+                String coordinateSpace = new String()
+                for (int j = 0; j < 5; j++){
+                    coordinateSpace += xNext + xUnitList.get(j) * widthSpace + ","
+                    coordinateSpace += yNext + yUnitList.get(j) * heightSpace
+                    if (j != 4){
+                        coordinateSpace += ";"
+                    }
+                }
+                algParkSpace.setPcsBorder(coordinateSpace)
+                algParkSpaceList.add(algParkSpace)
+                k += 1
+            }
+        }
+
+
+        // 输入数据
+        algPathStrategyInputData.setAlgBaseMap(algBaseMap)
+        algPathStrategyInputData.setAlgVehicleList(algVehicleList)
+        algPathStrategyInputData.setAlgVehicleTaskList(algVehicleTaskList)
+        algPathStrategyInputData.setAlgObstacleList(algObstacleList)
+        algPathStrategyInputData.setAlgParkSpaceList(algParkSpaceList)
+
+        println(GsonUtil.toJson(algPathStrategyInputData))
     }
 }