wuweihao преди 3 години
родител
ревизия
5c34bef105
променени са 23 файла, в които са добавени 601 реда и са изтрити 599 реда
  1. 25 103
      laser/src/main/java/com/fdkankan/indoor/base/convert/ConvertToVision.java
  2. 57 56
      laser/src/main/java/com/fdkankan/indoor/base/convert/FixRouteMap.java
  3. 18 3
      laser/src/main/java/com/fdkankan/indoor/base/convert/GetRoute.java
  4. 31 32
      laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateUtil.java
  5. 76 6
      laser/src/main/java/com/fdkankan/indoor/base/convert/PlanGraph.java
  6. 5 0
      laser/src/main/java/com/fdkankan/indoor/base/convert/kesar/AStar.java
  7. 50 7
      laser/src/main/java/com/fdkankan/indoor/base/convert/quadTree/Solution.java
  8. 3 1
      laser/src/main/java/com/fdkankan/indoor/core/controller/PoiController.java
  9. 3 3
      laser/src/main/java/com/fdkankan/indoor/core/controller/SiteModelController.java
  10. 1 1
      laser/src/main/java/com/fdkankan/indoor/core/controller/TestController.java
  11. 3 2
      laser/src/main/java/com/fdkankan/indoor/core/controller/TiledMapController.java
  12. 4 0
      laser/src/main/java/com/fdkankan/indoor/core/entity/SiteModelEntity.java
  13. 2 2
      laser/src/main/java/com/fdkankan/indoor/core/service/InitService.java
  14. 3 0
      laser/src/main/java/com/fdkankan/indoor/core/service/RouteService.java
  15. 1 1
      laser/src/main/java/com/fdkankan/indoor/core/service/SiteModelService.java
  16. 1 1
      laser/src/main/java/com/fdkankan/indoor/core/service/TiledMapService.java
  17. 2 2
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/ControlPointServiceImpl.java
  18. 0 1
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/DataSetServiceImpl.java
  19. 112 219
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java
  20. 80 106
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/MergeSceneServiceImpl.java
  21. 55 1
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/RouteServiceImpl.java
  22. 46 40
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/SiteModelServiceImpl.java
  23. 23 12
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/TiledMapServiceImpl.java

+ 25 - 103
laser/src/main/java/com/fdkankan/indoor/base/convert/ConvertToVision.java

@@ -171,14 +171,14 @@ public class ConvertToVision {
 	 * 初始化vision数据
 	 * @param sceneCode
 	 * @param panoInfos
+	 * @param from web(手动控制点), null(默认控制点)
 	 * @return
 	 */
-	private  JSONArray createVisionToFilter(String sceneCode, JSONArray panoInfos,  ControlPointCalculateEntity calculateEntity) {
+	private  JSONArray createVisionToFilter(String sceneCode, JSONArray panoInfos,  ControlPointCalculateEntity calculateEntity, String from) {
 
 		JSONArray laserPanos = new JSONArray();
 		int visionSize = panoInfos.size();
 		log.info("漫游点位数量: {}", visionSize);
-		log.info("需要的大地坐标值:开始======================================================");
 		for(int i=0;i< visionSize;++i) {
 			JSONObject item = panoInfos.getJSONObject(i);
 			JSONObject laserPano = new JSONObject();
@@ -209,10 +209,10 @@ public class ConvertToVision {
 			floor_location[1] = position2.getDouble("y");
 			floor_location[2] = position2.getDouble("z");
 			//gis坐标
-			log.warn("=============== _location 开始" + i +" =========================");
+//			log.warn("=============== _location 开始" + i +" =========================");
 //			double[] _location = TransformGPS.convertLocationToGis(location,dto);
 			double[] _location = GisCoordinateUtil.transformLocationToBL(location[0], location[1], calculateEntity);
-			log.warn("=============== _location 结束" + i +" =========================");
+//			log.warn("=============== _location 结束" + i +" =========================");
 //			double[] _floor_location = TransformGPS.convertLocationToGis(floor_location, dto);
 			double[] _floor_location = GisCoordinateUtil.transformLocationToBL(floor_location[0], floor_location[1], calculateEntity);
 			location[0] = _location[0];
@@ -243,7 +243,15 @@ public class ConvertToVision {
 			quaternation[2] = rotation.getDouble("y");
 			quaternation[3] = rotation.getDouble("z");
 
-			laserPano.put("orientation", quaternation);
+			// 2021-09-14
+			if ("web".equals(from)) {
+				log.info("quaternation  from: {}", from);
+				laserPano.put("orientation", getQuaternation(rotation, calculateEntity.getRotation2()));
+			} else {
+				log.info("quaternation  from: {}", from);
+				laserPano.put("orientation", quaternation);
+			}
+
 			// 2021-08-11
 			laserPano.put("dataset_orientation", quaternation);
 			laserPano.put("dataset_floor_orientation", quaternation);
@@ -271,116 +279,30 @@ public class ConvertToVision {
 				log.info("firstVieW保存成功");
 			}
 		}
-		log.info("需要的大地坐标值:结束====================================================================");
 		return laserPanos;
 	}
 
+	/**
+	 * 手动输入控制点, 获取Quaternation值
+	 * rotation2: 计算控制点的弧度
+	 * @return
+	 */
+	private static double[] getQuaternation(JSONObject quaternation, double rotation2){
+		double[] result = PlanGraph.toArray(quaternation, rotation2);
+		return result;
+	}
+
 
-//	private static   JSONArray createVisionToFilter(JSONArray panoInfos) {
-//
-//		JSONArray laserPanos = new JSONArray();
-//		for(int i=0;i<panoInfos.size();++i) {
-//			JSONObject item = panoInfos.getJSONObject(i);
-//			JSONObject laserPano = new JSONObject();
-//			int id = item.getInt("id");
-//			laserPano.put("camera_head_id", 12);
-//			laserPano.put("dataset_id", 1);
-//			laserPano.put("file_path", "data/chunk1");
-//			laserPano.put("hidden", false);
-//			laserPano.put("id", id);
-//			laserPano.put("site_model_entity_id", 12);
-//
-//			//JSONObject pose = item.getJSONObject("pose");
-//			JSONObject position2 = item.getJSONObject("puck");
-//			JSONObject position1 = item.getJSONObject("translation");
-//			//���
-//			double[] location = new double[3];
-//			location[0] = position1.getDouble("x");
-//			location[1] = position1.getDouble("y");
-//			location[2] = position1.getDouble("z");
-//			//����
-//			double[] floor_location = new double[3];
-//			floor_location[0] = position2.getDouble("x");
-//			floor_location[1] = position2.getDouble("y");
-//			floor_location[2] = position2.getDouble("z");
-//			//gis����
-//			double[] _location = TransformGPS.convert(location);
-//			double[] _floor_location = TransformGPS.convert(floor_location);
-//			location[0] = _location[0];
-//			location[1] = _location[1];
-//			floor_location[0] = _floor_location[0];
-//			floor_location[1] = _floor_location[1];
-//			laserPano.put("location", location);
-//			laserPano.put("floor_location", floor_location);
-//
-//			//���
-//			double[] dataset_location = new double[3];
-//			dataset_location[0] = position2.getDouble("x");
-//			dataset_location[1] = position2.getDouble("y");
-//			dataset_location[2] = position1.getDouble("z");
-//			//����
-//			double[] dataset_floor_location = new double[3];
-//			dataset_floor_location[0] = position2.getDouble("x");
-//			dataset_floor_location[1] = position2.getDouble("y");
-//			dataset_floor_location[2] = position2.getDouble("z");
-//
-//			laserPano.put("dataset_location", dataset_location);
-//			laserPano.put("dataset_floor_location", dataset_floor_location);
-//
-//			JSONObject rotation = item.getJSONObject("rotation");
-//			double[] quaternation = new double[4];
-//			quaternation[0] = rotation.getDouble("w");
-//			quaternation[1] = rotation.getDouble("x");
-//			quaternation[2] = rotation.getDouble("y");
-//			quaternation[3] = rotation.getDouble("z");
-//
-//			laserPano.put("orientation", quaternation);
-//			// 2021-08-11
-//			laserPano.put("dataset_orientation", quaternation);
-//			laserPano.put("dataset_floor_orientation", quaternation);
-//
-//			String fileId = String.valueOf(id);
-//			while(fileId.length()<5) {
-//				fileId = "0"+fileId;
-//			}
-//			laserPano.put("file_id", fileId);
-//
-//			laserPanos.add(laserPano);
-//			//firstView
-//			if(i == 0) {
-//				//保存初始点的gis坐标
-//				// _location 存入数据库
-////				// 经度 22 纬度 113
-//				Double[] edit = {_location[0], _location[1]};
-//
-//				log.info("firstView保存成功");
-//			}
-//		}
-//		return laserPanos;
-//	}
 
-//	public  JSONArray createFilter(String sceneCode, String path, ControlPointEntity dto){
-//		if (!cn.hutool.core.io.FileUtil.isFile(path)) {
-//			log.error("文件路径不存在: {}", path);
-//			throw new RuntimeException("文件路径不存在");
-//		}
-//		try {
-//			JSONArray panoInfos = readVisionTxt(path);
-//			return createVisionToFilter(sceneCode, panoInfos, dto);
-//		} catch (IOException e) {
-//			e.printStackTrace();
-//		}
-//		return null;
-//	}
 
-	public  JSONArray createFilter(String sceneCode, String path, ControlPointCalculateEntity calculateEntity){
+	public  JSONArray createFilter(String sceneCode, String path, ControlPointCalculateEntity calculateEntity, String from){
 		if (!cn.hutool.core.io.FileUtil.isFile(path)) {
 			log.error("文件路径不存在: {}", path);
 			throw new RuntimeException("文件路径不存在");
 		}
 		try {
 			JSONArray panoInfos = readVisionTxt(path);
-			return createVisionToFilter(sceneCode, panoInfos, calculateEntity);
+			return createVisionToFilter(sceneCode, panoInfos, calculateEntity, from);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}

+ 57 - 56
laser/src/main/java/com/fdkankan/indoor/base/convert/FixRouteMap.java

@@ -51,63 +51,64 @@ public class FixRouteMap {
 
     }
 
-//    /**
-//     * 更新route数据
-//     * @param orientation dataSet.orientation
-//     * @param gpsLocation dataSet.location
-//     * @param controlPoint 对应场景码控制点
-//     * @param path final_freespace.csv 文件目录路径
-//     * @return
-//     * @throws Exception
-//     */
-//    public static List<String> updateRouteMap(double orientation, double[] gpsLocation, ControlPointEntity controlPoint, String path) throws Exception {
-//
-//        // dataSet.location的gps坐标转本地坐标
+    /**
+     * 更新route数据
+     * @param orientation dataSet.orientation
+     * @param gpsLocation dataSet.location
+     * @param controlPoint 对应场景码控制点
+     * @param path final_freespace.csv 文件目录路径
+     * @return
+     * @throws Exception
+     */
+    public static List<String> updateRouteMap(double orientation, double[] gpsLocation, ControlPointCalculateEntity controlPoint, String path) throws Exception {
+
+        // dataSet.location的gps坐标转本地坐标
 //        double[] ageLocation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
-//
-//        // 新的本地坐标, 转出来应该是原点, 很接近0
-//        JSONObject newLocation = new JSONObject();
-//        newLocation.put("x", ageLocation[0]);
-//        newLocation.put("y", ageLocation[1]);
-//        newLocation.put("z", gpsLocation[2]);
-//        log.info("newLocation: {}", newLocation );
-//
-//
-//        double[] newMatrix = getTransfromMatrix(orientation, newLocation);
-//
-//
-//        // 读取棋盘的坐标,读文件final_freespace.csv,不要读数据库,最初的坐标
-//        String routePath = path + "/final_freespace.csv";
-//        log.info("routePath: {}", routePath);
-//        if (!cn.hutool.core.io.FileUtil.isFile(routePath)){
-//            log.info("输入路径有误, path: {}", routePath);
-//            throw new BaseRuntimeException(MsgCode.e3001, "final_freespace.csv路径有误,文件不存在");
-//        }
-//        List<String> list = FileUtil.readFileByLines2(routePath);
-//        log.info("数据读取成功");
-//
-//        // 修改棋盘每个顶点坐标,然后再入库
-//        List<String> newRoute = new ArrayList<>();
-//        for (String line : list) {
-//            // 将每一行的坐标值获取处理进行修改
-//            String[] split = line.split(" ");
-//
-//            double[] oldPoint = {Double.valueOf(split[0]), Double.valueOf(split[1]), Double.valueOf(split[2])};
-//            double[] newPoint =  applyMatrix4(oldPoint,newMatrix);
-//
-//            // 重新组装每一行数据
-//            String newLine = Arrays.asList(newPoint[0], newPoint[1], newPoint[2], split[3], split[4],
-//                    split[5], split[6], split[7], split[8], split[9], split[10], split[11]).toString();
-//            // 去逗号
-//            newLine = newLine.replaceAll(",", "");
-//            newLine = newLine.replace("[", "");
-//            newLine = newLine.replace("]", "");
-//            newRoute.add(newLine);
-//        }
-//        log.info("数据解析成功");
-//        return newRoute;
-//
-//    }
+        double[] ageLocation = GisCoordinateUtil.transformBLToLocation(gpsLocation[0], gpsLocation[1], controlPoint);
+
+        // 新的本地坐标, 转出来应该是原点, 很接近0
+        JSONObject newLocation = new JSONObject();
+        newLocation.put("x", ageLocation[0]);
+        newLocation.put("y", ageLocation[1]);
+        newLocation.put("z", gpsLocation[2]);
+        log.info("newLocation: {}", newLocation );
+
+
+        double[] newMatrix = getTransfromMatrix(orientation, newLocation);
+
+
+        // 读取棋盘的坐标,读文件final_freespace.csv,不要读数据库,最初的坐标
+        String routePath = path + "/final_freespace.csv";
+        log.info("routePath: {}", routePath);
+        if (!cn.hutool.core.io.FileUtil.isFile(routePath)){
+            log.info("输入路径有误, path: {}", routePath);
+            throw new BaseRuntimeException(MsgCode.e3001, "final_freespace.csv路径有误,文件不存在");
+        }
+        List<String> list = FileUtil.readFileByLines2(routePath);
+        log.info("数据读取成功");
+
+        // 修改棋盘每个顶点坐标,然后再入库
+        List<String> newRoute = new ArrayList<>();
+        for (String line : list) {
+            // 将每一行的坐标值获取处理进行修改
+            String[] split = line.split(" ");
+
+            double[] oldPoint = {Double.valueOf(split[0]), Double.valueOf(split[1]), Double.valueOf(split[2])};
+            double[] newPoint =  applyMatrix4(oldPoint,newMatrix);
+
+            // 重新组装每一行数据
+            String newLine = Arrays.asList(newPoint[0], newPoint[1], newPoint[2], split[3], split[4],
+                    split[5], split[6], split[7], split[8], split[9], split[10], split[11]).toString();
+            // 去逗号
+            newLine = newLine.replaceAll(",", "");
+            newLine = newLine.replace("[", "");
+            newLine = newLine.replace("]", "");
+            newRoute.add(newLine);
+        }
+        log.info("数据解析成功");
+        return newRoute;
+
+    }
 
 
 

+ 18 - 3
laser/src/main/java/com/fdkankan/indoor/base/convert/GetRoute.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 
+import cn.hutool.core.util.StrUtil;
 import com.fdkankan.indoor.base.convert.kesar.AStar;
 import com.fdkankan.indoor.base.convert.kesar.Coord;
 import com.fdkankan.indoor.base.convert.kesar.MapInfo;
@@ -11,9 +12,10 @@ import com.fdkankan.indoor.base.convert.kesar.Node;
 import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import com.fdkankan.indoor.core.entity.dto.RouteInputDto;
+import lombok.extern.slf4j.Slf4j;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
-
+@Slf4j
 public class GetRoute {
 
 
@@ -119,7 +121,9 @@ public class GetRoute {
 		Double startDistance=1000.0;
 		Double endDistance = 1000.0;
 
-		for(int i=0;i<list.size();++i) {
+		int size = list.size();
+		log.info("数量: {}", size);
+		for(int i=0;i<size;++i) {
 			String str = list.get(i);
 			String[] strArray = str.trim().split(" ");
 			JSONObject item = new JSONObject();
@@ -136,9 +140,20 @@ public class GetRoute {
 				}
 			}
 
-			item.put("linkedIds", linkedIds.substring(0, linkedIds.length()-1));
+			if(StrUtil.isEmpty(linkedIds)){
+				log.warn("存在该点值为-1的点");
+				item.put("linkedIds", "");
+			}
+			else {
+				item.put("linkedIds", linkedIds.substring(0, linkedIds.length() - 1));
+			}
 			maps.add(item);
 
+
+			if(StrUtil.isEmpty(linkedIds)){
+				continue;
+			}
+
 			Coord coord = new Coord(Double.valueOf(strArray[0]),Double.valueOf(strArray[1]),Double.valueOf(strArray[2]));
 			Double _startDistance = g_AStar.calcH(_start, coord);
 			if(_startDistance<startDistance) {

+ 31 - 32
laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateUtil.java

@@ -49,14 +49,14 @@ public class GisCoordinateUtil {
      */
     public static  double[] transformLocationToBL(double loctionX,double loctionY){
         Point point = new Point(loctionX,loctionY);
-        log.warn("本地转经纬度 平面 start ====");
-        log.info("参数 rotation:{}", rotation2);
-        log.info("参数 scale:{}", scale2);
-        log.info("参数 tx:{}", dx2);
-        log.info("参数 ty:{}", dy2);
+//        log.warn("本地转经纬度 平面 start ====");
+//        log.info("参数 rotation:{}", rotation2);
+//        log.info("参数 scale:{}", scale2);
+//        log.info("参数 tx:{}", dx2);
+//        log.info("参数 ty:{}", dy2);
         Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), rotation2, scale2, dx2, dy2);
-        log.info("本地坐标转平面坐标输出结果:{}, {}", resultPoint.getX(),resultPoint.getY());
-        log.warn("本地转经纬度 平面 end ====");
+//        log.info("本地坐标转平面坐标输出结果:{}, {}", resultPoint.getX(),resultPoint.getY());
+//        log.warn("本地转经纬度 平面 end ====");
         return GisCoordinateTransform.convertByProj4(resultPoint.getX(),resultPoint.getY(),"EPSG:4547","EPSG:4490");
     }
 
@@ -70,14 +70,14 @@ public class GisCoordinateUtil {
      */
     public static  double[] transformLocationToBL(double loctionX,double loctionY, ControlPointCalculateEntity dto){
         Point point = new Point(loctionX,loctionY);
-        log.warn("本地转经纬度 平面 start ====");
-        log.info("参数 rotation:{}", dto.getRotation2());
-        log.info("参数 scale:{}", dto.getScale2());
-        log.info("参数 tx:{}", dto.getDx2());
-        log.info("参数 ty:{}", dto.getDy2());
+//        log.warn("本地转经纬度 平面 start ====");
+//        log.info("参数 rotation:{}", dto.getRotation2());
+//        log.info("参数 scale:{}", dto.getScale2());
+//        log.info("参数 tx:{}", dto.getDx2());
+//        log.info("参数 ty:{}", dto.getDy2());
         Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), dto.getRotation2(), dto.getScale2(), dto.getDx2(), dto.getDy2());
-        log.info("本地坐标转平面坐标输出结果:{}, {}", resultPoint.getX(),resultPoint.getY());
-        log.warn("本地转经纬度 平面 end ====");
+//        log.info("本地坐标转平面坐标输出结果:{}, {}", resultPoint.getX(),resultPoint.getY());
+//        log.warn("本地转经纬度 平面 end ====");
         return GisCoordinateTransform.convertByProj4(resultPoint.getX(),resultPoint.getY(),"EPSG:4547","EPSG:4490");
     }
 
@@ -86,7 +86,6 @@ public class GisCoordinateUtil {
      * 经纬度转本地坐标
      * @param lon 经度 十进制度
      * @param lat 纬度 十进制度
-     * @return
      */
     public static  double[] transformBLToLocation(double lon,double lat){
         double[] gauss= GisCoordinateTransform.convertByProj4(lon, lat,"EPSG:4490","EPSG:4547");
@@ -370,7 +369,7 @@ public class GisCoordinateUtil {
             Point point2 = new Point(b[0],b[1]);
             Point newPoint1 = new Point(aX,aY);
             Point newPoint2 = new Point(bX,bY);
-            log.info("========== start calculateVariable =================");
+//            log.info("========== start calculateVariable =================");
             double rotation1 = Math.toRadians(AffineTransform.getAngle(point1 , point2 ) - AffineTransform.getAngle(newPoint1 , newPoint2 ));
             double scale1 = AffineTransform.getScale( point1 , newPoint1 , point2 , newPoint2);
 //            log.info("rotation1: {}", rotation1);
@@ -379,18 +378,18 @@ public class GisCoordinateUtil {
 
             double rotation2 = Math.toRadians(AffineTransform.getAngle(newPoint1 , newPoint2 ) - AffineTransform.getAngle(point1 , point2 ));
             double scale2 = AffineTransform.getScale( newPoint1 , point1 , newPoint2 , point2);
-            log.info("输入参数1:{}, {}", newPoint1.getX(), newPoint1.getY());
-            log.info("输入参数2:{}, {}", point1.getX(), point1.getY());
-            log.info("输入参数 rotation2:{}, {}", rotation2);
-            log.info("输入参数 scale2:{}, {}", scale2);
+//            log.info("输入参数1:{}, {}", newPoint1.getX(), newPoint1.getY());
+//            log.info("输入参数2:{}, {}", point1.getX(), point1.getY());
+//            log.info("输入参数 rotation2:{}, {}", rotation2);
+//            log.info("输入参数 scale2:{}, {}", scale2);
 //            double dx2 = AffineTransform.getXTranslation( newPoint1 ,point1, rotation2, scale1);
 //            double dy2 = AffineTransform.getYTranslation( newPoint1 ,point1, rotation2, scale1);
 
             // 2021-09-13 这里应该使用scale2
             double dx2 = AffineTransform.getXTranslation( newPoint1 ,point1, rotation2, scale2);
-            log.info("输出结果 dx2:{}, {}", dx2);
+//            log.info("输出结果 dx2:{}, {}", dx2);
             double dy2 = AffineTransform.getYTranslation( newPoint1 ,point1, rotation2, scale2);
-            log.info("输出结果 dy2:{}, {}", dy2);
+//            log.info("输出结果 dy2:{}, {}", dy2);
 
 
             ControlPointCalculateEntity entity = new ControlPointCalculateEntity();
@@ -404,16 +403,16 @@ public class GisCoordinateUtil {
             entity.setScale2(scale2);
             entity.setDx2(dx2);
             entity.setDy2(dy2);
-            log.warn("平面坐标 start");
-            log.info("参数 rotation1:{}", rotation1);
-            log.info("参数 scale1:{}", scale1);
-            log.info("参数 dx1:{}", dx1);
-            log.info("参数 dy1:{}", dy1);
-            log.info("参数 rotation2:{}", rotation2);
-            log.info("参数 scale2:{}", scale2);
-            log.info("参数 dx2:{}", dx2);
-            log.info("参数 dy2:{}", dy2);
-            log.warn("平面坐标 end");
+//            log.warn("平面坐标 start");
+//            log.info("参数 rotation1:{}", rotation1);
+//            log.info("参数 scale1:{}", scale1);
+//            log.info("参数 dx1:{}", dx1);
+//            log.info("参数 dy1:{}", dy1);
+//            log.info("参数 rotation2:{}", rotation2);
+//            log.info("参数 scale2:{}", scale2);
+//            log.info("参数 dx2:{}", dx2);
+//            log.info("参数 dy2:{}", dy2);
+//            log.warn("平面坐标 end");
 
             return entity;
         } catch (RuntimeException e) {

+ 76 - 6
laser/src/main/java/com/fdkankan/indoor/base/convert/PlanGraph.java

@@ -20,7 +20,7 @@ public class PlanGraph {
         return angle * DEG2RAD;
     }
 
-    private static JSONObject setFromAxisAngle(JSONObject axis, double angle) {
+    public static JSONObject setFromAxisAngle(JSONObject axis, double angle) {
         // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
         // assumes axis is normalized
 
@@ -104,6 +104,53 @@ public class PlanGraph {
         //return [e[3], e[0], e[1], e[2]]
     }
 
+//    public static double[] toArray(JSONObject quaternion, double angle) {
+//
+//        //new THREE.Quaternion
+//		/*
+//		 * 	_w: 1
+//			_x: 0
+//			_y: 0
+//			_z: 0
+//		 * */
+//        //double[] Quaternion = {1,0,0,0};
+//        JSONObject axis = new JSONObject();
+//        axis.put("x", 0);
+//        axis.put("y", 0);
+//        axis.put("z", 1);
+//        JSONObject rot90 =  setFromAxisAngle(axis, degToRad(angle));
+//        JSONObject rot90Invert = inverse(rot90);//add 转出时旋回90度
+//        JSONObject t1 = multiply(quaternion,rot90Invert);
+//
+//        double[] e = {t1.getDouble("w"),t1.getDouble("x"),t1.getDouble("y"),t1.getDouble("z")};
+//        return e;
+//        //JSONObject e = t1.toArray();
+//        //return [e[3], e[0], e[1], e[2]]
+//    }
+
+
+    public static double[] toArray(JSONObject quaternion,double orientation) {
+
+        JSONObject axis = new JSONObject();
+        axis.put("x", 0);
+        axis.put("y", 0);
+        axis.put("z", 1);
+        JSONObject rot90 =  setFromAxisAngle(axis, degToRad(-90)); //add 转入时旋转90度
+        JSONObject rot90Invert = inverse(rot90);//add 转出时旋回90度
+
+        JSONObject u = multiply(quaternion,rot90);
+        JSONObject ee = setFromAxisAngle(axis,orientation );
+        u = multiply(u,ee);
+
+        JSONObject u1 = multiply(u,rot90Invert);
+        double[] e = {u1.getDouble("w"),u1.getDouble("x"),u1.getDouble("y"),u1.getDouble("z")};
+        return e;
+    }
+
+
+
+
+
     private  static JSONObject setFromEuler(double x,double y,double z) {
 
         double c1 = Math.cos( x / 2 );
@@ -140,17 +187,40 @@ public class PlanGraph {
 
     /**
      *
+     * @param orientation dataSet.orientation
+     * @return
+     */
+    public static Double[] tiledMapOrientation(Double orientation) {
+
+        net.sf.json.JSONObject axis = new net.sf.json.JSONObject();
+        axis.put("x", 0);
+        axis.put("y", 0);
+        axis.put("z", 1);
+        net.sf.json.JSONObject rot90 =  setFromAxisAngle(axis, degToRad(-90)); //add 转入时旋转90度
+        net.sf.json.JSONObject rot90Invert = inverse(rot90);//add 转出时旋回90度
+        net.sf.json.JSONObject c = setFromEuler(0,0,orientation);
+        net.sf.json.JSONObject u1 = multiply(c,rot90Invert);
+        Double[] e = {u1.getDouble("w"),u1.getDouble("x"),u1.getDouble("y"),u1.getDouble("z")};
+        return e;
+    }
+
+
+    /**
+     *
      * @param imgWidth 获取laserData/cover/info.json -> resolution.width/height的最大值
      * @param scale 写死1
      * @return
      */
     public static double getSize(int imgWidth, int scale) {
-        double level = imgWidth / 1024;  //以1024为基准
-        return 95.54628610610962 * level * scale; // 95.54628610610962 = 38.21851444244385 * (2+0.5), 其中38.21851444244385 = mapSizeM / Math.pow(2,maxDepth) = 40075017 / Math.pow(2,20) 可能表示地图在缩放zoom为20时的单块宽度
-        //0.5是试出来的,因为图片层的bias=0.5, 暂不知道其用处,所以试用了下……
-        //另:可能不是*2.5,  也许是*256/100 ?  不知道如何精确测试下
-        //有出现过一次错误是2048时的图但是大了一倍,发现是传图的那个网页在缩放值为0.1(即图为1:1显示,函数canvasFunction(extent, scale )时只有1024大小,后来刷新重新操作就是2048然后就正确。所以可能是这个网页出错。
+        return imgWidth*0.03;
     }
+//    public static double getSize(int imgWidth, int scale) {
+//        double level = imgWidth / 1024;  //以1024为基准
+//        return 95.54628610610962 * level * scale; // 95.54628610610962 = 38.21851444244385 * (2+0.5), 其中38.21851444244385 = mapSizeM / Math.pow(2,maxDepth) = 40075017 / Math.pow(2,20) 可能表示地图在缩放zoom为20时的单块宽度
+//        //0.5是试出来的,因为图片层的bias=0.5, 暂不知道其用处,所以试用了下……
+//        //另:可能不是*2.5,  也许是*256/100 ?  不知道如何精确测试下
+//        //有出现过一次错误是2048时的图但是大了一倍,发现是传图的那个网页在缩放值为0.1(即图为1:1显示,函数canvasFunction(extent, scale )时只有1024大小,后来刷新重新操作就是2048然后就正确。所以可能是这个网页出错。
+//    }
 
 
   @Test

+ 5 - 0
laser/src/main/java/com/fdkankan/indoor/base/convert/kesar/AStar.java

@@ -5,6 +5,7 @@ import java.util.List;
 import java.util.PriorityQueue;
 import java.util.Queue;
 
+import lombok.extern.slf4j.Slf4j;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
@@ -14,6 +15,7 @@ import net.sf.json.JSONObject;
  * @author kesar
  * @Description: A星算法
  */
+@Slf4j
 public class AStar {
     public final static int BAR = 1; // 障碍值
     public final static int PATH = 2; // 路径
@@ -78,6 +80,9 @@ public class AStar {
         String[] linkedIds = item.getString("linkedIds").split(",");
 
         for (int i = 0; i < linkedIds.length; ++i) {
+            if(linkedIds[i].equals("")){
+                System.out.println("ok");
+            }
             int linkedId = Integer.valueOf(linkedIds[i]) - 1;
             //是否在close表里
             if (canAddNodeToOpen(mapInfo, linkedId)) {

+ 50 - 7
laser/src/main/java/com/fdkankan/indoor/base/convert/quadTree/Solution.java

@@ -93,26 +93,68 @@ public class Solution {
 		}
 	}
 
+//	public String getXYTiles(File f){
+//		File[] files = f.listFiles();
+//		String tiles = "";
+//
+//		int maxX = files.length;
+//		int maxY = 0;
+//		for(int i=0;i<files.length;++i) {
+//			String[] fileNames = files[i].list();
+//			if(fileNames.length>maxY) {
+//				maxY = fileNames.length;
+//			}
+//			for(int j=0;j<fileNames.length;++j) {
+//				tiles += files[i].getName()+"-"+fileNames[j].replace(".png", "")+",";
+//			}
+//		}
+//
+//		int max = Math.max(maxX, maxY);
+//		max = getMaxDepth(max);
+//		int[][] numthree = new int[max][max];
+//
+//		for(int i=0;i<max;++i) {
+//			for(int j=0;j<max;++j) {
+//				if(tiles.indexOf(String.valueOf(i)+"-"+String.valueOf(j))>-1) {
+//					numthree[i][j] = 1;
+//				}
+//				else {
+//					numthree[i][j] = 0;
+//				}
+//			}
+//		}
+//
+//		Node node = construct(numthree);
+//		getSingleScore(node);
+//		ouput(node);
+//		return quadTree;
+//	}
+
+
 	public String getXYTiles(File f){
 		File[] files = f.listFiles();
 		String tiles = "";
 
-		int maxX = files.length;
-		int maxY = 0;
+		int maxX = -1;
+		int maxY = -1;
 		for(int i=0;i<files.length;++i) {
 			String[] fileNames = files[i].list();
-			if(fileNames.length>maxY) {
-				maxY = fileNames.length;
+			if(Integer.valueOf(files[i].getName())>maxX) {
+				maxX = Integer.valueOf(files[i].getName());
 			}
 			for(int j=0;j<fileNames.length;++j) {
+				String str = fileNames[j].substring(0,fileNames[j].indexOf("."));
+				if(Integer.valueOf(str)>maxY) {
+					maxY = Integer.valueOf(str);
+				}
 				tiles += files[i].getName()+"-"+fileNames[j].replace(".png", "")+",";
 			}
 		}
-		
+
 		int max = Math.max(maxX, maxY);
 		max = getMaxDepth(max);
 		int[][] numthree = new int[max][max];
-		
+
 		for(int i=0;i<max;++i) {
 			for(int j=0;j<max;++j) {
 				if(tiles.indexOf(String.valueOf(i)+"-"+String.valueOf(j))>-1) {
@@ -123,11 +165,12 @@ public class Solution {
 				}
 			}
 		}
-		
+
 		Node node = construct(numthree);
 		getSingleScore(node);
 		ouput(node);
 		return quadTree;
+//		System.out.println(quadTree);
 	}
 	
 	private  void ouput(Node node) {

+ 3 - 1
laser/src/main/java/com/fdkankan/indoor/core/controller/PoiController.java

@@ -113,9 +113,11 @@ public class PoiController {
     }
 
     @WebControllerLog(description = "poi热点-上传图标-post")
-    @ApiOperation(value = "上传图标")
+    @ApiOperation(value = "上传热点(图标、文件、视频)")
     @PostMapping("indoor/{sceneCode}/poi/image")
     public Object upload(@PathVariable String sceneCode, MultipartFile image){
+
+
         Result result = poiService.upload(sceneCode, image);
         return result.getData();
     }

+ 3 - 3
laser/src/main/java/com/fdkankan/indoor/core/controller/SiteModelController.java

@@ -200,10 +200,10 @@ public class SiteModelController {
      * @return
      */
     @WebControllerLog(description = "分类信息-更新siteModel")
-    @ApiOperation(value = "更新siteModel",notes = "修改传过来的id, 且返回当前id值")
+    @ApiOperation(value = "更新siteModel", notes = "这个接口会增删改")
     @PostMapping("indoor/{sceneCode}/api/site_model")
-    public Object updateSiteModelById(@PathVariable String sceneCode, @RequestBody List<SiteDto> param) {
-        Result search = entityService.updateSiteModelById(sceneCode, param);
+    public Object updateSiteMode(@PathVariable String sceneCode, @RequestBody List<SiteDto> param) {
+        Result search = entityService.updateSiteMode(sceneCode, param);
         return search.getData();
     }
 

+ 1 - 1
laser/src/main/java/com/fdkankan/indoor/core/controller/TestController.java

@@ -233,7 +233,7 @@ public class TestController {
     @ApiOperation("tiledMapInit")
     @GetMapping("tiledMapInit/init/{sceneCode}")
     public Result tiledMapInit(@PathVariable String sceneCode){
-        tiledMapService.init(sceneCode);
+        tiledMapService.init(sceneCode, null);
         return Result.success();
     }
 

+ 3 - 2
laser/src/main/java/com/fdkankan/indoor/core/controller/TiledMapController.java

@@ -1,5 +1,6 @@
 package com.fdkankan.indoor.core.controller;
 
+import com.fdkankan.indoor.base.aop.WebControllerLog;
 import com.fdkankan.indoor.base.util.Result;
 import com.fdkankan.indoor.core.entity.dto.TiledEditDto;
 import com.fdkankan.indoor.core.service.TiledMapService;
@@ -62,11 +63,11 @@ public class TiledMapController {
     @ApiOperation(value = "重置", notes = "重置,使用默认cover目录上传oss")
     @GetMapping("indoor/{sceneCode}/api/tiled_maps/init")
     public Result init(@PathVariable String sceneCode){
-        entityMap.init(sceneCode);
+        entityMap.init(sceneCode, null);
         return Result.success();
     }
 
-
+    @WebControllerLog(description = "平面图-上传平面图")
     @ApiOperation(value = "上传平面图", notes = "只支持zip, 压缩文件不能包含目录")
     @PostMapping("indoor/{sceneCode}/api/tiled_maps/upload")
     public Result upload(@PathVariable String sceneCode, MultipartFile file){

+ 4 - 0
laser/src/main/java/com/fdkankan/indoor/core/entity/SiteModelEntity.java

@@ -2,6 +2,7 @@ package com.fdkankan.indoor.core.entity;
 
 import com.fdkankan.indoor.core.entity.dto.PoiHotDto;
 import com.fdkankan.indoor.core.entity.dto.SiteDto;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.data.mongodb.core.mapping.Document;
 
@@ -20,5 +21,8 @@ public class SiteModelEntity extends BaseEntity {
 //    private List<PoiHotDto> data;
     private List<SiteDto> data;
 
+    @ApiModelProperty(value = "记录最大id")
+    private Integer maxId;
+
 
 }

+ 2 - 2
laser/src/main/java/com/fdkankan/indoor/core/service/InitService.java

@@ -12,7 +12,7 @@ import java.util.List;
 public interface InitService {
     Result initData(InitDto param);
 
-    void initDataStep2(String sceneCode);
+    void initDataStep2(String sceneCode, String from);
 
     List<InitEntity> findByStatus(Integer status);
 
@@ -24,7 +24,7 @@ public interface InitService {
 
     Result testRemove(String sceneCode);
 
-    void testInitDataStep2(String id);
+    void testInitDataStep2(String id, String from);
 
     void initSiteModel(String sceneCode);
 

+ 3 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/RouteService.java

@@ -1,6 +1,7 @@
 package com.fdkankan.indoor.core.service;
 
 import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.dto.RouteInputDto;
 import com.fdkankan.indoor.core.entity.RouteEntity;
 
@@ -15,4 +16,6 @@ public interface RouteService {
     void remove(String sceneCode);
 
     RouteEntity findBySceneCode(String sceneCode);
+
+    void updateRouteByControlPointCalculate(Double[] location, Double orientation, String sceneCode, ControlPointCalculateEntity controlPointDto, String laserDataPath);
 }

+ 1 - 1
laser/src/main/java/com/fdkankan/indoor/core/service/SiteModelService.java

@@ -40,5 +40,5 @@ public interface SiteModelService {
 
     Result checkMapInvalidation(String sceneCode, List<SiteDto> param);
 
-    Result updateSiteModelById(String sceneCode, List<SiteDto> param);
+    Result updateSiteMode(String sceneCode, List<SiteDto> param);
 }

+ 1 - 1
laser/src/main/java/com/fdkankan/indoor/core/service/TiledMapService.java

@@ -16,7 +16,7 @@ public interface TiledMapService {
 
 
 
-    void init(String sceneCode);
+    void init(String sceneCode, String form);
 
     void remove(String sceneCode);
 

+ 2 - 2
laser/src/main/java/com/fdkankan/indoor/core/service/impl/ControlPointServiceImpl.java

@@ -54,7 +54,7 @@ public class ControlPointServiceImpl implements ControlPointService {
         log.info("控制点保存完成");
 
         // 初始化step2 数据
-        initService.initDataStep2(sceneCode);
+        initService.initDataStep2(sceneCode, "web");
         log.info("初始化step2 完成");
         return Result.success();
     }
@@ -102,7 +102,7 @@ public class ControlPointServiceImpl implements ControlPointService {
         // 初始化step2 数据
         // 场景码
 
-        initService.testInitDataStep2(sceneCode);
+        initService.testInitDataStep2(sceneCode, "web");
         log.info("初始化step2 完成");
         return Result.success();
     }

+ 0 - 1
laser/src/main/java/com/fdkankan/indoor/core/service/impl/DataSetServiceImpl.java

@@ -184,7 +184,6 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
 
 
         // 获取控制点
-//        ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
         ControlPointCalculateEntity controlPoint = controlPointCalculateService.findById(sceneCode);
 
         if (controlPoint == null) {

+ 112 - 219
laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java

@@ -96,10 +96,12 @@ public class InitServiceImpl implements InitService {
     @Autowired
     ControlPointCalculateService controlPointCalculateService;
 
+
+
     /**
      * initDataStep1
      * 有顺序分,不能乱
-     *  from :age  四维看看重算,其他:手动重算
+     * from :age  四维看看重算,其他:手动重算
      */
     @Override
     public Result initData(InitDto param) {
@@ -121,7 +123,7 @@ public class InitServiceImpl implements InitService {
 
             // 重算
 
-            if ("recount".equals(from)){
+            if ("recount".equals(from)) {
                 log.info("进行手动重新");
                 path = init.getPath();
                 title = init.getTitle();
@@ -178,14 +180,13 @@ public class InitServiceImpl implements InitService {
         copyDefault(sceneCode);
 
 
-         //step8 替换index.html、/locat/addDataSet.html的场景码, @replace, @title
+        //step8 替换index.html、/locat/addDataSet.html的场景码, @replace, @title
         replaceHtml(sceneCode, title);
 
         // step9 创建 t_measurement表, 测量表,空数据
         createMeasurement(sceneCode);
 
 
-
         log.info("================== 初始化第一步完成 ==================");
 
         /**
@@ -196,7 +197,7 @@ public class InitServiceImpl implements InitService {
         String controlPointPath = laserDataPath + "/controlPoint.json";
         log.info("控制点文件路径:{}", controlPointPath);
         boolean flag = false;
-        if (cn.hutool.core.io.FileUtil.exist(controlPointPath)){
+        if (cn.hutool.core.io.FileUtil.exist(controlPointPath)) {
             log.info("处理控制点逻辑");
             createControlPoint(sceneCode, laserDataPath);
             flag = true;
@@ -212,7 +213,7 @@ public class InitServiceImpl implements InitService {
         init.setRecount(recount);
 
 
-        if (flag){
+        if (flag) {
             init.setStatus(1);
             log.info("完全初始化完成");
         } else {
@@ -226,22 +227,19 @@ public class InitServiceImpl implements InitService {
     }
 
 
-
-
     /**
      * 这个方法可以本地调试
      * 需要控制点,才能完成以下操作
      * 重新输入控制点时, 把相应数据删除, 重新初始化
      *
-     *
      * @param sceneCode
      */
     @Override
-    public void initDataStep2(String sceneCode){
+    public void initDataStep2(String sceneCode, String from) {
 
         Optional<InitEntity> optional = initMapper.findById(sceneCode);
-        if (!optional.isPresent()){
-            throw new BaseRuntimeException(MsgCode.e3001,"此场景的数据初始化不存在");
+        if (!optional.isPresent()) {
+            throw new BaseRuntimeException(MsgCode.e3001, "此场景的数据初始化不存在");
         }
         InitEntity init = optional.get();
 
@@ -262,10 +260,9 @@ public class InitServiceImpl implements InitService {
         log.info("更新控制点计算完成");
 
 
-
         // step1: 处理vision.txt 创建filter表, 处理特殊点:firstView
 //        createFilter(sceneCode, laserDataPath, controlPoint);
-        createFilter(sceneCode, laserDataPath, calculateEntity);
+        createFilter(sceneCode, laserDataPath, calculateEntity, from);
 
         // step2 处理could.js、创建sitModel, 使用的是代码初始化,创建site_model, 处理原点、中心点、最大点、最小点
 //        processCould(sceneCode, laserDataPath, controlPoint);
@@ -275,11 +272,14 @@ public class InitServiceImpl implements InitService {
         createConfig(sceneCode);
 
         // step7 创建t_datasets表, 使用的是代码, 需要处理原点之后执行
-        createDataSet(sceneCode, laserDataPath, calculateEntity.getRotation2());
+        DataSetPo dataSet = createDataSet(sceneCode, laserDataPath, calculateEntity.getRotation2(), from);
 //        createDataSet(sceneCode, laserDataPath, calculateEntity);
 
         // step 10 创建 t_tiled_map表, 需要用到dataSet数据
-        tiledMapService.init(sceneCode);
+        tiledMapService.init(sceneCode, from);
+
+        // Route数据重新计算, 并保存数据库
+        routeService.updateRouteByControlPointCalculate(dataSet.getLocation(), dataSet.getOrientation(), sceneCode, calculateEntity, laserDataPath);
 
 
         // step8 目录pano、pano_depth、webcloud上传oss, 初始化合并场景码跟原来的一样
@@ -293,32 +293,11 @@ public class InitServiceImpl implements InitService {
     }
 
 
-//    @Override
-//    public void initSiteModel(String sceneCode){
-//        // step1: 获取控制点
-//        ControlPointEntity controlPoint = getControlPoint(sceneCode);
-//        if (controlPoint == null){
-//            throw new BaseRuntimeException("控制点不存在:" + sceneCode);
-//        }
-//
-//        // step2: init数据路径
-//        InitEntity initEntity = this.findById(sceneCode);
-//        if (initEntity == null) {
-//            throw new BaseRuntimeException("初始化数据不存在:" + sceneCode);
-//        }
-//        String path = initEntity.getPath();
-//        path = path + "/laserData";
-//
-//        processCould(sceneCode, path, controlPoint);
-//
-//
-//    }
-
     @Override
-    public void initSiteModel(String sceneCode){
+    public void initSiteModel(String sceneCode) {
         // step1: 获取控制点
         ControlPointCalculateEntity controlPoint = getControlPointCalculate(sceneCode);
-        if (controlPoint == null){
+        if (controlPoint == null) {
             throw new BaseRuntimeException("控制点计算不存在:" + sceneCode);
         }
 
@@ -338,20 +317,26 @@ public class InitServiceImpl implements InitService {
 
     /**
      * 输入控制点,需要把相关数据从新初始化
+     *
      * @param sceneCode
      */
-    private void removeInitDataStep2(String sceneCode){
+    private void removeInitDataStep2(String sceneCode) {
         filterService.remove(sceneCode);
         specialPointService.remove(sceneCode);
         configService.remove(sceneCode);
         dataSetService.remove(sceneCode);
         siteService.remove(sceneCode);
+        tiledMapService.remove(sceneCode);
+        // 2021-09-15
+        routeService.remove(sceneCode);
+
 
         log.info("删除initDataStep2数据完成");
     }
 
     /**
      * 重算场景
+     *
      * @param sceneCode
      * @return
      */
@@ -359,7 +344,6 @@ public class InitServiceImpl implements InitService {
     public Result initRecount(String sceneCode) {
 
 
-
         log.info("执行手动重新:{}", sceneCode);
         // 重新初始化数据, 地址在里面处理
         InitDto initDto = new InitDto();
@@ -381,13 +365,14 @@ public class InitServiceImpl implements InitService {
     /**
      * 替换两个文件的c 换成场景码
      * index.html
+     *
      * @param sceneCode
      * @param title
      */
     private void replaceHtml(String sceneCode, String title) {
         String indexName = "index.html";
 
-        String basePath = configConstant.serverBasePath + "/" + sceneCode + "/" ;
+        String basePath = configConstant.serverBasePath + "/" + sceneCode + "/";
         String indexPath = basePath + indexName;
 
         String indexStr = cn.hutool.core.io.FileUtil.readUtf8String(indexPath);
@@ -411,12 +396,13 @@ public class InitServiceImpl implements InitService {
 
     /**
      * 初始化控制点
+     *
      * @param sceneCode
      * @param laserDataPath
      */
     private void createControlPoint(String sceneCode, String laserDataPath) {
         String path = laserDataPath + "/controlPoint.json";
-        if (!cn.hutool.core.io.FileUtil.exist(path)){
+        if (!cn.hutool.core.io.FileUtil.exist(path)) {
             throw new BaseRuntimeException("控制点文件不存在: " + path);
         }
 
@@ -439,8 +425,8 @@ public class InitServiceImpl implements InitService {
         double ageX_2 = poi_2.getJSONObject("location").getDouble("x");
         double ageY_2 = poi_2.getJSONObject("location").getDouble("y");
 
-        double[] gpsCoord1 = {gpsLon_1, gpsLat_1 };
-        double[] gpsCoord2 = { gpsLon_2, gpsLat_2};
+        double[] gpsCoord1 = {gpsLon_1, gpsLat_1};
+        double[] gpsCoord2 = {gpsLon_2, gpsLat_2};
         double[] ageLocation1 = {ageX_1, ageY_1};
         double[] ageLocation2 = {ageX_2, ageY_2};
 
@@ -465,7 +451,7 @@ public class InitServiceImpl implements InitService {
         log.info("算法控制点保存完成");
 
         // 执行initData2 初始化
-        this.initDataStep2(sceneCode);
+        this.initDataStep2(sceneCode, "age");
 
         log.info("controlPoint控制点初始化完成");
     }
@@ -480,9 +466,9 @@ public class InitServiceImpl implements InitService {
     }
 
 
-
     /**
      * 复制静态资源
+     *
      * @param sceneCode
      */
     private void copyDefault(String sceneCode) {
@@ -495,8 +481,6 @@ public class InitServiceImpl implements InitService {
     }
 
 
-
-
     @Override
     public List<InitEntity> findByStatus(Integer status) {
         return initMapper.findByStatus(status);
@@ -536,7 +520,6 @@ public class InitServiceImpl implements InitService {
     }
 
 
-
     @Override
     public Result testRemove(String sceneCode) {
         this.initRemove(sceneCode);
@@ -544,11 +527,11 @@ public class InitServiceImpl implements InitService {
     }
 
     @Override
-    public void testInitDataStep2(String sceneCode) {
+    public void testInitDataStep2(String sceneCode, String from) {
 
         Optional<InitEntity> optional = initMapper.findById(sceneCode);
-        if (!optional.isPresent()){
-            throw new BaseRuntimeException(MsgCode.e3001,"此场景的数据初始化不存在");
+        if (!optional.isPresent()) {
+            throw new BaseRuntimeException(MsgCode.e3001, "此场景的数据初始化不存在");
         }
         InitEntity init = optional.get();
 
@@ -568,7 +551,7 @@ public class InitServiceImpl implements InitService {
         log.info("更新控制点计算完成");
 
         // step1: 处理vision.txt 创建filter表, 处理特殊点:firstView
-        createFilter(sceneCode, laserDataPath, calculateEntity);
+        createFilter(sceneCode, laserDataPath, calculateEntity, from);
 
         // step2 处理could.js 使用的是代码初始化,创建site_model, 处理原点、中心点、最大点、最小点
         processCould(sceneCode, laserDataPath, calculateEntity);
@@ -577,7 +560,11 @@ public class InitServiceImpl implements InitService {
         createConfig(sceneCode);
 
         // step7 创建t_datasets表, 使用的是代码, 需要处理原点之后执行, dataSet.orientation: 计算控制点结果rotation2
-        createDataSet(sceneCode, laserDataPath, calculateEntity.getRotation2());
+        DataSetPo dataSet = createDataSet(sceneCode, laserDataPath, calculateEntity.getRotation2(), from);
+
+        // Route数据重新计算, 并保存数据库
+        routeService.updateRouteByControlPointCalculate(dataSet.getLocation(), dataSet.getOrientation(), sceneCode, calculateEntity, laserDataPath);
+
 
 
         // step8 目录pano、pano_depth、webcloud上传oss,
@@ -592,30 +579,14 @@ public class InitServiceImpl implements InitService {
     }
 
 
-//    // 这个不能本地调试
-//    private void createFilter(String sceneCode, String path, ControlPointEntity dto){
-//        path = path +"/vision.txt";
-//        if (!cn.hutool.core.io.FileUtil.isFile(path)){
-//            throw new BaseRuntimeException(MsgCode.e3001, "vision.txt不存在");
-//        }
-//        JSONArray jsonArray = convertToVision.createFilter(sceneCode, path, dto);
-//        FilterEntity entity = new FilterEntity();
-//        entity.setId(sceneCode);
-//        entity.setCreateTime(LocalDateTime.now());
-//        //将array数组转换成对象
-//        List<FilterHotDto> list = JSONArray.toList(jsonArray, FilterHotDto.class);
-//        entity.setData(list);
-//        filterService.save(entity);
-//        log.info("filter数据初始化创建完成");
-//    }
 
     // 这个不能本地调试
-    private void createFilter(String sceneCode, String path, ControlPointCalculateEntity calculateEntity){
-        path = path +"/vision.txt";
-        if (!cn.hutool.core.io.FileUtil.isFile(path)){
+    private void createFilter(String sceneCode, String path, ControlPointCalculateEntity calculateEntity, String from) {
+        path = path + "/vision.txt";
+        if (!cn.hutool.core.io.FileUtil.isFile(path)) {
             throw new BaseRuntimeException(MsgCode.e3001, "vision.txt不存在");
         }
-        JSONArray jsonArray = convertToVision.createFilter(sceneCode, path, calculateEntity);
+        JSONArray jsonArray = convertToVision.createFilter(sceneCode, path, calculateEntity, from);
         FilterEntity entity = new FilterEntity();
         entity.setId(sceneCode);
         entity.setCreateTime(LocalDateTime.now());
@@ -629,15 +600,16 @@ public class InitServiceImpl implements InitService {
 
     /**
      * 处理could.js 并做相应的计算
+     *
      * @param sceneCode
      * @param path
      */
-    private void processCould(String sceneCode, String path, ControlPointCalculateEntity dto){
+    private void processCould(String sceneCode, String path, ControlPointCalculateEntity dto) {
         path = path + "/webcloud/cloud.js";
         // 处理原点,将原点坐标转为坐标, 转换后的原点只有经纬度,没有高度, 高度现在默认是0
         double[] doubles = ModifyCloud.convertFromOrigin(dto);
         // 2021-08-4 原点默认 z:0
-        Double[] gpsOrigin = {doubles[0] ,doubles[1], 0.0};
+        Double[] gpsOrigin = {doubles[0], doubles[1], 0.0};
         // 将数据保存到db, dateSet数据location使用
         saveSpecialPoint(sceneCode, TypeConstant.POI_ORIGIN, null, gpsOrigin);
         log.info("原点保存成功");
@@ -668,9 +640,9 @@ public class InitServiceImpl implements InitService {
 
 
             // 虚拟点坐标(四维看看坐标)
-            Double[] ageMax = {maxX,maxY,maxZ};
-            Double[] ageMin = {minX,minY,minZ};
-            Double[] ageCentre = {centreX,centreY,centreZ};
+            Double[] ageMax = {maxX, maxY, maxZ};
+            Double[] ageMin = {minX, minY, minZ};
+            Double[] ageCentre = {centreX, centreY, centreZ};
 
             JSONObject resJson = ModifyCloud.convertFromBoundingBox(boundingBox, dto);
 
@@ -694,75 +666,10 @@ public class InitServiceImpl implements InitService {
 
     }
 
-//    /**
-//     * 处理could.js 并做相应的计算
-//     * @param sceneCode
-//     * @param path
-//     */
-//    private void processCould(String sceneCode, String path, ControlPointEntity dto){
-//        path = path + "/webcloud/cloud.js";
-//        // 处理原点,将原点坐标转为坐标, 转换后的原点只有经纬度,没有高度, 高度现在默认是0
-//        double[] doubles = ModifyCloud.convertFromOrigin(dto);
-//        // 2021-08-4 原点默认 z:0
-//        Double[] gpsOrigin = {doubles[0] ,doubles[1], 0.0};
-//        // 将数据保存到db, dateSet数据location使用
-//        saveSpecialPoint(sceneCode, TypeConstant.POI_ORIGIN, null, gpsOrigin);
-//        log.info("原点保存成功");
-//
-//        try {
-//            // 修改cloud.js文件
-//            JSONObject info = ModifyCloud.fixCloud(path);
-//
-//            cn.hutool.core.io.FileUtil.writeUtf8String(info.toString(), path);
-//            log.info("新的cloud.js写入服务器完成:{}", path);
-//
-//            /**
-//             * 将boundingBox坐标转换成gis坐标, site_model需要
-//             * boundingBox:虚拟点坐标,存特殊点, dataSet数据要使用
-//             */
-//            JSONObject boundingBox = ModifyCloud.getBoundingBox(info);
-//            Double maxX = boundingBox.getDouble("maxX");
-//            Double maxY = boundingBox.getDouble("maxY");
-//            Double maxZ = boundingBox.getDouble("maxZ");
-//
-//            Double minX = boundingBox.getDouble("minX");
-//            Double minY = boundingBox.getDouble("minY");
-//            Double minZ = boundingBox.getDouble("minZ");
-//
-//            Double centreX = boundingBox.getDouble("centreX");
-//            Double centreY = boundingBox.getDouble("centreY");
-//            Double centreZ = boundingBox.getDouble("centreZ");
-//
-//
-//            // 虚拟点坐标(四维看看坐标)
-//            Double[] ageMax = {maxX,maxY,maxZ};
-//            Double[] ageMin = {minX,minY,minZ};
-//            Double[] ageCentre = {centreX,centreY,centreZ};
-//
-//            JSONObject resJson = ModifyCloud.convertFromBoundingBox(boundingBox, dto);
-//
-//            Double[] gpsMax = getKey(resJson, "max");
-//            Double[] gpsMin = getKey(resJson, "min");
-//            Double[] gpsCentre = getKeyZ(resJson, "centre");
-//
-//            // 将数据保存到db
-//            saveSpecialPoint(sceneCode, TypeConstant.POI_BOUNDINGBOX_MAX, ageMax, gpsMax);
-//            saveSpecialPoint(sceneCode, TypeConstant.POI_BOUNDINGBOX_MIN, ageMin, gpsMin);
-//            saveSpecialPoint(sceneCode, TypeConstant.POI_CENTRE, ageCentre, gpsCentre);
-//            log.info("max、min、中心点保存成功");
-//
-//
-//            // 创建sitModel
-//            createSiteModel(sceneCode, gpsMax, gpsMin, gpsCentre, maxZ, minZ);
-//
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//        }
-//
-//    }
 
 
-    private void createSiteModel(String sceneCode,  Double[] max,  Double[] min,  Double[] centre, Double maxZ, Double minZ){
+
+    private void createSiteModel(String sceneCode, Double[] max, Double[] min, Double[] centre, Double maxZ, Double minZ) {
         //读取初始文件
         String content = cn.hutool.core.io.FileUtil.readUtf8String(configConstant.templatePath + "/site_model.json");
         List<SiteDto> siteModels = JSON.parseArray(content, SiteDto.class);
@@ -770,10 +677,10 @@ public class InitServiceImpl implements InitService {
         // max、min四个顶点替换BUILDING、FLOOR 的coordinates,
         // 顺时针,(x_max,y_max),(x_max,y_min),(x_min,y_min),(x_min,y_max)
         // 一般参数1:x, 参数2:Y
-        Double[] peak_1 = {max[0],max[1]};
-        Double[] peak_2 = {max[0],min[1]};
-        Double[] peak_3 = {min[0],min[1]};
-        Double[] peak_4 = {min[0],max[1]};
+        Double[] peak_1 = {max[0], max[1]};
+        Double[] peak_2 = {max[0], min[1]};
+        Double[] peak_3 = {min[0], min[1]};
+        Double[] peak_4 = {min[0], max[1]};
         List<List<Double[]>> doubles = Arrays.asList(Arrays.asList(peak_1, peak_2, peak_3, peak_4));
 
         // centre 替换BUILDING、FLOOR、ROOM 的center
@@ -789,7 +696,7 @@ public class InitServiceImpl implements InitService {
             // 第二层:FLOOR 层
             List<SiteDto> children = p.getChildren();
             if (children.size() > 0) {
-                children.forEach(c ->{
+                children.forEach(c -> {
                     c.setCenter(centre);
                     c.setZ_max(maxZ);
                     c.setZ_min(minZ);
@@ -821,12 +728,14 @@ public class InitServiceImpl implements InitService {
         entity.setCreateTime(LocalDateTime.now());
         // 默认热点为空
         entity.setData(siteModels);
+        // 2021-09-15 默认最大id:20
+        entity.setMaxId(20);
         siteService.save(entity);
         log.info("siteModel数据初始化创建完成");
     }
 
     @Test
-    public void  testSiteModel(){
+    public void testSiteModel() {
         String content = MyFileUtils.getResourceContent("data/site_model.json");
         List<SiteDto> siteModels = JSON.parseArray(content, SiteDto.class);
 
@@ -837,11 +746,12 @@ public class InitServiceImpl implements InitService {
     /**
      * 获取两个值的
      * json数组转 double[]
+     *
      * @param resJson
      * @param key
      * @return
      */
-    private Double[] getKey(JSONObject resJson , String key){
+    private Double[] getKey(JSONObject resJson, String key) {
         JSONArray array = resJson.getJSONArray(key);
         Double[] res = {array.getDouble(0), array.getDouble(1)};
         return res;
@@ -849,11 +759,12 @@ public class InitServiceImpl implements InitService {
 
     /**
      * 获取三个值的
+     *
      * @param resJson
      * @param key
      * @return
      */
-    private Double[] getKeyZ(JSONObject resJson , String key){
+    private Double[] getKeyZ(JSONObject resJson, String key) {
         JSONArray array = resJson.getJSONArray(key);
         Double[] res = {array.getDouble(0), array.getDouble(1), array.getDouble(2)};
         return res;
@@ -865,7 +776,7 @@ public class InitServiceImpl implements InitService {
      * @param poiKey key
      * @param agePoi 虚拟点坐标(四维看看坐标)
      */
-    private void saveSpecialPoint(String sceneCode, String poiKey, Double[] agePoi, Double[] gpsPoi){
+    private void saveSpecialPoint(String sceneCode, String poiKey, Double[] agePoi, Double[] gpsPoi) {
         SpecialPointEntity entity = new SpecialPointEntity();
         entity.setId(SnowFlakeUUidUtils.getUuid("SP"));
         entity.setUpdateTime(LocalDateTime.now());
@@ -876,7 +787,7 @@ public class InitServiceImpl implements InitService {
         specialPointService.save(entity);
     }
 
-    private void createPoi(String sceneCode){
+    private void createPoi(String sceneCode) {
         PoiEntity entity = new PoiEntity();
         entity.setId(sceneCode);
         entity.setUpdateTime(LocalDateTime.now());
@@ -888,7 +799,7 @@ public class InitServiceImpl implements InitService {
 
     }
 
-    private void createPoiType(String sceneCode){
+    private void createPoiType(String sceneCode) {
         PoiTypeEntity entity = new PoiTypeEntity();
         entity.setId(sceneCode);
         entity.setUpdateTime(LocalDateTime.now());
@@ -900,7 +811,7 @@ public class InitServiceImpl implements InitService {
         log.info("poiType数据初始化创建完成");
     }
 
-    private void createPoiTypeGroup(String sceneCode){
+    private void createPoiTypeGroup(String sceneCode) {
         PoiTypeGroupEntity entity = new PoiTypeGroupEntity();
         entity.setId(sceneCode);
         entity.setUpdateTime(LocalDateTime.now());
@@ -914,23 +825,23 @@ public class InitServiceImpl implements InitService {
     }
 
 
-
-
     /**
      * 初始化DataSet
      * location: 原点坐标(特殊点表)
      * bounding_box_max:(特殊点表)
      * bounding_box_min:(特殊点表)
      * orientation : rotation2
+     *
      * @param sceneCode
      */
-    private void createDataSet(String sceneCode, String laserDataPath, double orientation){
+//    private void createDataSet(String sceneCode, String laserDataPath, double orientation, String from) {
+    private DataSetPo createDataSet(String sceneCode, String laserDataPath, double orientation, String from) {
         log.info("run createDataSet");
         DataSetEntity entity = new DataSetEntity();
         entity.setId(sceneCode);
         entity.setUpdateTime(LocalDateTime.now());
         // 设置原点坐标,通过场景码查询特殊点表的原点
-        List<SpecialPointEntity> spList =  specialPointService.findBySceneCode(sceneCode);
+        List<SpecialPointEntity> spList = specialPointService.findBySceneCode(sceneCode);
         log.info("特殊点数量:{}", spList.size());
         // 正常是5条记录: db.getCollection('t_special_point').find({"sceneCode":"t97"})
         if (spList.size() != 5) {
@@ -945,7 +856,7 @@ public class InitServiceImpl implements InitService {
                 map.put(key, sp.getPoi());
             }
             // 使用gps坐标
-            if (TypeConstant.POI_ORIGIN.equals(key)){
+            if (TypeConstant.POI_ORIGIN.equals(key)) {
                 map.put(key, sp.getGpsPoi());
             }
         }
@@ -957,7 +868,7 @@ public class InitServiceImpl implements InitService {
         mergeDto.setTitle(sceneCode);
 //        Integer[] site_model_entity_ids = {10,11,12};
         // 2021-09-06
-        Integer[] site_model_entity_ids = {10,11};
+        Integer[] site_model_entity_ids = {10, 11};
         mergeDto.setSite_model_entity_ids(site_model_entity_ids);
         mergeDto.setSceneNum(sceneCode);
 
@@ -966,38 +877,23 @@ public class InitServiceImpl implements InitService {
         mergeDto.setPath(laserDataPath);
 
         // 处理弧度, 使用计算控制点的rotation2
-        mergeDto.setOrientation(orientation);
+        if ("web".equals(from)) {
+            mergeDto.setOrientation(orientation);
+        } else {
+            // 重算默认0.0
+            mergeDto.setOrientation(0.0);
+        }
 
         DataSetPo po = ModifyDataSets.mergeDataSetPo(map, mergeDto);
         entity.setData(Arrays.asList(po));
         dataSetService.save(entity);
         log.info("DataSet数据初始化创建完成");
+        return po;
     }
 
-    /**
-     * 处理弧度
-     * @param controlPoint
-     * @return
-     */
-//    private Double getOrientation(ControlPointEntity controlPoint){
-////        double angle = GisCoordinateUtil.getDataSetOrientation(controlPoint);
-//        double angle = 0.0;
-//        log.info("Orientation弧度:{}", angle);
-//        return angle;
-//    }
 
-    /**
-     * 处理弧度
-     * @return
-     */
-    private Double getOrientation(){
-//        double angle = GisCoordinateUtil.getDataSetOrientation(controlPoint);
-        double angle = 0.0;
-        log.info("Orientation弧度:{}", angle);
-        return angle;
-    }
 
-    private void createConfig(String sceneCode){
+    private void createConfig(String sceneCode) {
 
         // 根据场景码查询特殊点
         SpecialPointEntity sp = specialPointService.findBySceneCodeAndPoiKey(sceneCode, TypeConstant.POI_FIRST_VIEW);
@@ -1005,24 +901,24 @@ public class InitServiceImpl implements InitService {
             throw new BaseRuntimeException("firstView点不存在,请检查特殊点表或者检查createVisionToFilter方法初始化");
         }
         Double[] poi = sp.getPoi();
-        log.info("firstView: {}" , sp.getPoi());
+        log.info("firstView: {}", sp.getPoi());
 
 //        String content = MyFileUtils.getResourceContent("data/config.json");
         String content = cn.hutool.core.io.FileUtil.readUtf8String(configConstant.templatePath + "/config.json");
 
         List<ConfigDto> dtoList = com.alibaba.fastjson.JSONArray.parseArray(content, ConfigDto.class);
-        List<ConfigDto> resData =  new ArrayList<>();
+        List<ConfigDto> resData = new ArrayList<>();
         // 获取特殊点,firstView, lat:113, [0], x, lon:22, [1], y 方法参考:ModifyConfig.java
-            dtoList.forEach(p -> {
-                String name = p.getName();
-                if ("core.init.map.lon".equals(name)) {
-                    p.setValue(poi[1].toString());
+        dtoList.forEach(p -> {
+            String name = p.getName();
+            if ("core.init.map.lon".equals(name)) {
+                p.setValue(poi[1].toString());
 
-                } else if ("core.init.map.lat".equals(name)){
-                    p.setValue(poi[0].toString());
-                }
-                resData.add(p);
-            });
+            } else if ("core.init.map.lat".equals(name)) {
+                p.setValue(poi[0].toString());
+            }
+            resData.add(p);
+        });
 
 
         ConfigEntity entity = new ConfigEntity();
@@ -1036,17 +932,18 @@ public class InitServiceImpl implements InitService {
 
     /**
      * 最优路径算法-使用
+     *
      * @param path F:\test\project\age_laser/final_freespace.csv
      */
-    private void createRoute(String sceneCode, String path){
+    private void createRoute(String sceneCode, String path) {
         List<String> list = new ArrayList<>();
 //
-            String routePath = path + "/final_freespace.csv";
-            log.info("routePath: {}", routePath);
-            if (!cn.hutool.core.io.FileUtil.isFile(routePath)){
-                log.info("输入路径有误, path: {}", routePath);
-                throw new BaseRuntimeException(MsgCode.e3001, "final_freespace.csv路径有误,文件不存在");
-            }
+        String routePath = path + "/final_freespace.csv";
+        log.info("routePath: {}", routePath);
+        if (!cn.hutool.core.io.FileUtil.isFile(routePath)) {
+            log.info("输入路径有误, path: {}", routePath);
+            throw new BaseRuntimeException(MsgCode.e3001, "final_freespace.csv路径有误,文件不存在");
+        }
         try {
             list = FileUtil.readFileByLines2(routePath);
             RouteEntity entity = new RouteEntity();
@@ -1060,45 +957,41 @@ public class InitServiceImpl implements InitService {
         }
 
 
-
 //
 
 
     }
 
-    private ControlPointEntity getControlPoint(String sceneCode){
-       return controlPointService.findById(sceneCode);
+    private ControlPointEntity getControlPoint(String sceneCode) {
+        return controlPointService.findById(sceneCode);
     }
 
 
-    private ControlPointCalculateEntity getControlPointCalculate(String sceneCode){
+    private ControlPointCalculateEntity getControlPointCalculate(String sceneCode) {
         return controlPointCalculateService.findById(sceneCode);
     }
 
     /**
-     *
      * @param sceneCode 场景码
-     * @param path 基础路径
+     * @param path      基础路径
      * @param mergeCode 合并的场景码
-     *
      */
     @Override
-    public void ossUploadDirByLaserData(String sceneCode, String path, String mergeCode){
+    public void ossUploadDirByLaserData(String sceneCode, String path, String mergeCode) {
         String panoPath = path + "/pano";
         String panoDepthPath = path + "/pano_depth";
         String webCloudPath = path + "/webcloud";
 
 
-
         executeCmd(sceneCode, panoPath, "pano", mergeCode);
         log.info("pano目录上传oss完成");
-        executeCmd(sceneCode, panoDepthPath, "pano_depth",mergeCode);
+        executeCmd(sceneCode, panoDepthPath, "pano_depth", mergeCode);
         log.info("pano_depth目录上传oss完成");
-        executeCmd(sceneCode, webCloudPath,"webcloud", mergeCode);
+        executeCmd(sceneCode, webCloudPath, "webcloud", mergeCode);
         log.info("webcloud目录上传oss完成");
     }
 
-    private void executeCmd(String sceneCode, String uploadDir, String targetDir, String mergeCode){
+    private void executeCmd(String sceneCode, String uploadDir, String targetDir, String mergeCode) {
         String cmd = CmdConstant.OSSUTIL_UPLOAD_DIR_CHUNK;
         cmd = cmd.replaceAll("@sceneCode", sceneCode);
         cmd = cmd.replaceAll("@mergeCode", mergeCode);
@@ -1109,7 +1002,7 @@ public class InitServiceImpl implements InitService {
 
 
     @Test
-    public void test1(){
+    public void test1() {
 //        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6);
 //        Stream<Integer> stream = list.stream();
 //        stream = stream.filter(p -> p > 3);

+ 80 - 106
laser/src/main/java/com/fdkankan/indoor/core/service/impl/MergeSceneServiceImpl.java

@@ -89,7 +89,6 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
         }
 
 
-//        ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
         ControlPointCalculateEntity controlPoint = controlPointCalculateService.findById(sceneCode);
 
         if (controlPoint == null) {
@@ -98,8 +97,6 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
             return Result.failure(msg);
         }
 
-
-
         InitEntity initEntity = initService.findById(mergeCode);
 
         String mergePath = "";
@@ -112,13 +109,11 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
         log.info("合并场景路径:{}", mergePath);
 
         // siteMode要优先处理;
-//        Map<Object, Object> resMap = mergeSiteModel(sceneCode, mergeCode, mergePath, controlPoint);
         Map<Object, Object> resMap = mergeSiteModelFloor(sceneCode, mergeCode, mergePath, controlPoint);
 
         Integer siteModelId = (Integer)resMap.get("maxId");
 
         // dateSet.siteModelId是数组, 如果siteModel的模板id改了,这里要重新设置
-//        List<Integer> siteModeIds = Arrays.asList(10,11, siteModelId);
         List<Integer> siteModeIds = Arrays.asList(10, siteModelId);
         Integer dataSetId = mergeDateSet(sceneCode, mergeCode, siteModeIds, mergePath, controlPoint.getRotation2());
 
@@ -158,14 +153,6 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
     @Override
     public Result getExist(String sceneCode) {
 
-//        DataSetEntity entity = dataSetService.findById(sceneCode);
-//        List<DataSetPo> data = entity.getData();
-//        // 数量为1, 代表没有合并数据集
-//        if (data.size() <= 1) {
-//            return Result.success();
-//        }
-//        data = data.stream().filter(p -> !sceneCode.equals(p.getSceneNum())).collect(Collectors.toList());
-
         List<MergeInfoEntity> data = mergeInfoService.findBySceneCode(sceneCode);
 
         return Result.success(data);
@@ -353,37 +340,6 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
         return strings.get(i);
     }
 
-//    private Map<Object, Object>  mergeSiteModel(String sceneCode, String mergeCode, String mergePath, ControlPointEntity controlPoint){
-//
-//        // 获取原场景数据
-//        SiteModelEntity entity = siteModelService.findById(sceneCode);
-//        if (entity == null) {
-//            throw new BaseRuntimeException("原SiteModel数据不存在: " + sceneCode);
-//        }
-//
-//        List<SiteDto> originalData = entity.getData();
-//
-//
-//        // 初始化房间数据
-//        SiteDto roomDto = initMergeSiteModel(mergeCode, mergePath,controlPoint);
-//        // 添加数据
-//        Map<Object, Object> resMap = setRoom(originalData, roomDto);
-//         originalData = (List<SiteDto>) resMap.get("data");
-//
-//
-//        // 添加数据
-//
-//        entity.setData(originalData);
-//        entity.setUpdateTime(LocalDateTime.now());
-//
-//        siteModelService.save(entity);
-//        log.info("siteModel合并完成");
-//
-//        return resMap;
-//
-//    }
-
-
     private Map<Object, Object>  mergeSiteModelFloor(String sceneCode, String mergeCode, String mergePath, ControlPointCalculateEntity controlPoint){
 
         // 获取原场景数据
@@ -396,18 +352,22 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
 
 
         // 初始化房间数据
-//        SiteDto roomDto = initMergeSiteModel(mergeCode, mergePath,controlPoint);
         // 初始化Floor数据
         SiteDto floorDto = initMergeSiteModel(mergeCode, mergePath,controlPoint);
 
         // 添加数据
-        Map<Object, Object> resMap = setFloor(originalData, floorDto);
+        Map<Object, Object> resMap = setFloor(originalData, floorDto, entity.getMaxId());
         originalData = (List<SiteDto>) resMap.get("data");
 
 
         // 添加数据
 
         entity.setData(originalData);
+
+        // 2021-09-15 最大id存数据库
+        Integer siteModelId = (Integer)resMap.get("maxId");
+        entity.setMaxId(siteModelId);
+
         entity.setUpdateTime(LocalDateTime.now());
 
         siteModelService.save(entity);
@@ -478,62 +438,97 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
      *
      * @param dto 原数据
      * @param floorDto  需要加入的楼层
+     *   maxId: 输入的最大id
      */
-    private Map<Object, Object> setFloor(List<SiteDto> dto, SiteDto floorDto) {
-        // 用来获取最大id
-        List<Integer> ids = new ArrayList<>();
-
-        dto.forEach(p -> {
-            ids.add(p.getId());
-            List<SiteDto> floorChild = p.getChildren();
-            floorChild.forEach(f -> {
-                ids.add(f.getId());
-
-                List<SiteDto> roomChild = f.getChildren();
-                roomChild.forEach(r -> {
-                    ids.add(r.getId());
-                });
-
-            });
-
-        });
-
-        // 获取最大id
-        Integer maxId = ids.stream().reduce(Integer::max).get();
-        log.info("最大id: {}" , maxId);
+    private Map<Object, Object> setFloor(List<SiteDto> dto, SiteDto floorDto, Integer maxId) {
+//        // 用来获取最大id
+//        List<Integer> ids = new ArrayList<>();
+//
+//        dto.forEach(p -> {
+//            ids.add(p.getId());
+//            List<SiteDto> floorChild = p.getChildren();
+//            floorChild.forEach(f -> {
+//                ids.add(f.getId());
+//
+//                List<SiteDto> roomChild = f.getChildren();
+//                roomChild.forEach(r -> {
+//                    ids.add(r.getId());
+//                });
+//
+//            });
+//
+//        });
+//
+//        // 获取最大id
+//        Integer maxId = ids.stream().reduce(Integer::max).get();
+//        log.info("最大id: {}" , maxId);
 
         for (SiteDto buildingDto : dto) {
             List<SiteDto> floorChild = buildingDto.getChildren();
-            maxId ++;
             floorDto.setId(maxId);
             floorChild.add(floorDto);
-//            for (SiteDto roomDtos : floorChild) {
-//                maxId ++;
-//                roomDto.setId(maxId);
-//                List<SiteDto> children = roomDtos.getChildren();
-//                // 加入房间
-//                children.add(roomDto);
-//            }
-
+            maxId ++;
         }
 
-
         Map<Object, Object> result = new HashMap<>();
         log.info("返回值最大id: {}" , maxId);
         result.put("maxId", maxId);
         result.put("data", dto);
 
-//         删除最后一个
-//        ids.remove(ids.size()-1);
-
         // 提供给dataSet使用
-        ids.add(maxId);
-//        result.put("ids", ids);
+//        ids.add(maxId);
         return result;
 
     }
 
 
+//    /**
+//     *
+//     * @param dto 原数据
+//     * @param floorDto  需要加入的楼层
+//     */
+//    private Map<Object, Object> setFloor(List<SiteDto> dto, SiteDto floorDto) {
+//        // 用来获取最大id
+//        List<Integer> ids = new ArrayList<>();
+//
+//        dto.forEach(p -> {
+//            ids.add(p.getId());
+//            List<SiteDto> floorChild = p.getChildren();
+//            floorChild.forEach(f -> {
+//                ids.add(f.getId());
+//
+//                List<SiteDto> roomChild = f.getChildren();
+//                roomChild.forEach(r -> {
+//                    ids.add(r.getId());
+//                });
+//
+//            });
+//
+//        });
+//
+//        // 获取最大id
+//        Integer maxId = ids.stream().reduce(Integer::max).get();
+//        log.info("最大id: {}" , maxId);
+//
+//        for (SiteDto buildingDto : dto) {
+//            List<SiteDto> floorChild = buildingDto.getChildren();
+//            maxId ++;
+//            floorDto.setId(maxId);
+//            floorChild.add(floorDto);
+//        }
+//
+//        Map<Object, Object> result = new HashMap<>();
+//        log.info("返回值最大id: {}" , maxId);
+//        result.put("maxId", maxId);
+//        result.put("data", dto);
+//
+//        // 提供给dataSet使用
+//        ids.add(maxId);
+//        return result;
+//
+//    }
+
+
     /**
      * 初始化DataSet
      * location: 原点坐标(特殊点表)
@@ -571,28 +566,6 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
     }
 
 
-//    /**
-//     *
-//     * @param sceneCode
-//     * @param mergePath 合并文件地址
-//     * @param dto
-//     * @return
-//     */
-//    private List<FilterHotDto> initMergeFilter(String sceneCode, String mergePath, ControlPointEntity dto){
-//        String path = mergePath +"/vision.txt";
-//        log.info("path: {}", path);
-//        if (!cn.hutool.core.io.FileUtil.isFile(path)){
-//            throw new BaseRuntimeException(MsgCode.e3001, "vision.txt不存在");
-//        }
-//        JSONArray jsonArray = convertToVision.createFilter(sceneCode, path, dto);
-//        FilterEntity entity = new FilterEntity();
-//        entity.setId(sceneCode);
-//        entity.setCreateTime(LocalDateTime.now());
-//        //将array数组转换成对象
-//        List<FilterHotDto> list = JSONArray.toList(jsonArray, FilterHotDto.class);
-//        return list;
-//    }
-
 
     /**
      *
@@ -607,7 +580,8 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
         if (!cn.hutool.core.io.FileUtil.isFile(path)){
             throw new BaseRuntimeException(MsgCode.e3001, "vision.txt不存在");
         }
-        JSONArray jsonArray = convertToVision.createFilter(sceneCode, path, dto);
+        // 2021-09-14 todo 这里使用web
+        JSONArray jsonArray = convertToVision.createFilter(sceneCode, path, dto, "web");
         FilterEntity entity = new FilterEntity();
         entity.setId(sceneCode);
         entity.setCreateTime(LocalDateTime.now());

+ 55 - 1
laser/src/main/java/com/fdkankan/indoor/core/service/impl/RouteServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
 import com.fdkankan.indoor.base.constant.ConfigConstant;
 import com.fdkankan.indoor.base.constant.MsgCode;
+import com.fdkankan.indoor.base.convert.FixRouteMap;
 import com.fdkankan.indoor.base.convert.GetRoute;
 import com.fdkankan.indoor.base.exception.BaseRuntimeException;
 import com.fdkankan.indoor.base.util.Result;
@@ -33,7 +34,7 @@ import java.util.Optional;
  */
 @Service
 @Slf4j
-public class RouteServiceImpl implements RouteService {
+public class RouteServiceImpl extends IBaseServiceImpl implements RouteService {
 
     @Autowired
     RouteMapper entityMapper;
@@ -49,6 +50,7 @@ public class RouteServiceImpl implements RouteService {
 
     @Override
     public void save(RouteEntity entity) {
+        entity.setUpdateTime(LocalDateTime.now());
         entityMapper.save(entity);
     }
 
@@ -151,4 +153,56 @@ public class RouteServiceImpl implements RouteService {
         RouteEntity entity = findBySceneCode(sceneCode);
         return entity.getData();
     }
+
+
+    /**
+     * 2021-09-15
+     * @param location dateSet.location
+     * @param orientation dateSet.orientation
+     * @param sceneCode
+     * @throws Exception
+     */
+    @Override
+    public void updateRouteByControlPointCalculate(Double[] location, Double orientation, String sceneCode, ControlPointCalculateEntity controlPointDto, String laserDataPath){
+
+
+        double[] gpsLocation = {location[0], location[1], location[2]};
+        try {
+            List<String> routeMap = FixRouteMap.updateRouteMap(orientation, gpsLocation, controlPointDto, laserDataPath);
+//            RouteEntity routeEntity = this.findBySceneCode(sceneCode);
+            RouteEntity routeEntity = new RouteEntity();
+            routeEntity.setId(sceneCode);
+            routeEntity.setData(routeMap);
+            routeEntity.setCreateTime(LocalDateTime.now());
+            this.save(routeEntity);
+            log.info("Route数据更新完成");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+//        private void fixRouteMap(Double[] location, Double orientation, String sceneCode) throws Exception {
+//        String initKey = TypeConstant.REDIS_INIT_PATH + sceneCode;
+//        log.info("initKey: {}", initKey);
+//        String initPath = redisPath(sceneCode);
+//
+//        initPath = initPath + "/laserData";
+//        log.info("initPath: {}", initPath);
+//
+//        ControlPointEntity controlPointEntity = controlPointService.findById(sceneCode);
+//        if (controlPointEntity == null) {
+//            throw new BaseRuntimeException("控制点数据不存: {}" +sceneCode);
+//        }
+//        log.info("有控制点");
+//        double[] gpsLocation = {location[0], location[1], location[2]};
+//        List<String> routeMap = FixRouteMap.updateRouteMap(orientation, gpsLocation, controlPointEntity, initPath);
+//
+//        RouteEntity routeEntity = routeService.findBySceneCode(sceneCode);
+//        routeEntity.setData(routeMap);
+//        routeEntity.setUpdateTime(LocalDateTime.now());
+//        routeService.save(routeEntity);
+//        log.info("更新Route数据完成");
+//
+//    }
 }

+ 46 - 40
laser/src/main/java/com/fdkankan/indoor/core/service/impl/SiteModelServiceImpl.java

@@ -45,6 +45,8 @@ public class SiteModelServiceImpl implements SiteModelService {
     @Autowired
     InitService initService;
 
+    private Integer maxId;
+
     @Override
     public Result findBySceneCodeAndId(String sceneCode, Long id) {
         List list = getDataBySceneCode(sceneCode);
@@ -431,27 +433,6 @@ public class SiteModelServiceImpl implements SiteModelService {
      */
     @Override
     public Result checkMapInvalidation(String sceneCode, List<SiteDto> param) {
-//        SiteDto inSiteDto = param.get(0);
-//        // 去空格后,用json字符串比较
-//        List<SiteDto> inLoopModel = getLoopModel(inSiteDto);
-//        SiteDto inSiteDto1 = inLoopModel.get(0);
-//        Object o = JSON.toJSON(inSiteDto1);
-//        JSONObject inJson = JSONObject.parseObject(o.toString());
-//        System.out.println("in:" + inJson.toJSONString());
-//
-//
-//        List<SiteDto> originalDto = getDataById(sceneCode);
-//        List<SiteDto> originalData = getLoopModel(originalDto.get(0));
-//        SiteDto siteDto = originalData.get(0);
-//        JSONObject outJson = JSONObject.parseObject(JSON.toJSON(siteDto).toString());
-//        System.out.println("0:" + outJson.toJSONString());
-//
-//
-//        // 去空格
-//        StrUtil.cleanBlank("");
-//
-//        System.out.println();
-// {"total_floor_changing":0,"are_maps_invalidated":false}
         JSONObject result = new JSONObject();
         // 目前写死返回值
         result.put("total_floor_changing", 0);
@@ -460,39 +441,64 @@ public class SiteModelServiceImpl implements SiteModelService {
     }
 
     @Override
-    public Result updateSiteModelById(String sceneCode, List<SiteDto> param) {
+    public Result updateSiteMode(String sceneCode, List<SiteDto> param) {
         SiteModelEntity entity = findById(sceneCode);
-        List<SiteDto> data = entity.getData();
+//        List<SiteDto> data = entity.getData();
 
 
-        if (data.size() != 0){
-            // 遍历参数,获取id, 保存新list
-            List<Integer> collectId = param.stream().map(SiteDto::getId).collect(Collectors.toList());
-            log.info("参数id: {}", collectId);
-            // 判断原数据是否包含参数里的id, 包含则删除后重新添加
-            data = data.stream().filter(p -> !collectId.contains(p.getId())).collect(Collectors.toList());
-            log.info("过滤后数量: {}", data.size());
-        }
+//        if (data.size() != 0){
+//            // 遍历参数,获取id, 保存新list
+//            List<Integer> collectId = param.stream().map(SiteDto::getId).collect(Collectors.toList());
+//            log.info("参数id: {}", collectId);
+//            // 判断原数据是否包含参数里的id, 包含则删除后重新添加
+//            data = data.stream().filter(p -> !collectId.contains(p.getId())).collect(Collectors.toList());
+//            log.info("过滤后数量: {}", data.size());
+//        }
 
-        // 把更新后的数据添加到原数据
-        data.addAll(param);
 
-        entity.setData(data);
+        // maxId 只能用全局的
+        Integer oldMaxId = entity.getMaxId();
+        this.maxId = oldMaxId == null? 20: oldMaxId;
+        // 新数据添加id, 把更新后的数据添加到原数据, 递归调用后, 把param塞回去
+        recursion(param);
+        log.info("maxId: {}", this.maxId);
+//        data.addAll(param);
+
+        entity.setData(param);
+        entity.setMaxId(this.maxId);
         entity.setUpdateTime(LocalDateTime.now());
 
+
         this.save(entity);
 
         return Result.success(getDataBySceneCode(sceneCode));
     }
 
-    private List<SiteDto> getDataById(String sceneCode){
-        SiteModelEntity originalEntity = findById(sceneCode);
-        if (originalEntity != null) {
-            return originalEntity.getData();
+    /**
+     * 递归方法遍历
+     * maxId 使用全局
+     */
+    private  void recursion(List<SiteDto> param){
+        for (SiteDto dto : param) {
+            Integer id = dto.getId();
+            if (id == null) {
+                dto.setId(maxId);
+                maxId ++;
+            }
+            // 递归调用
+            List<SiteDto> children = dto.getChildren();
+            if (children.size() > 0) {
+                recursion(children);
+            }
         }
-        return null;
     }
 
+
+
+
+
+
+
     /**
      * 2021-07-16
      * 递归出每一个对象
@@ -503,7 +509,7 @@ public class SiteModelServiceImpl implements SiteModelService {
         List<SiteDto> models = new ArrayList<>();
         // copy实体对象
         SiteDto newSiteModel = copyModelNotContainChildren(siteModel);
-        // 做为父节点的一条
+        // 做为父节点的一条
         models.add(newSiteModel);
         if (!CollectionUtils.isEmpty(siteModel.getChildren())) {
             organizeModels3(siteModel, models);

+ 23 - 12
laser/src/main/java/com/fdkankan/indoor/core/service/impl/TiledMapServiceImpl.java

@@ -11,14 +11,12 @@ import com.fdkankan.indoor.base.exception.BaseRuntimeException;
 import com.fdkankan.indoor.base.util.AliYunOssUtil;
 import com.fdkankan.indoor.base.util.CmdUtils;
 import com.fdkankan.indoor.base.util.Result;
-import com.fdkankan.indoor.core.entity.DataSetEntity;
 import com.fdkankan.indoor.core.entity.TiledMapEntity;
 import com.fdkankan.indoor.core.entity.dto.TiledEditDto;
 import com.fdkankan.indoor.core.entity.dto.TiledMapDto;
 import com.fdkankan.indoor.core.entity.po.DataSetPo;
 import com.fdkankan.indoor.core.mapper.TiledMapMapper;
 import com.fdkankan.indoor.core.service.TiledMapService;
-import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -64,14 +62,14 @@ public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapSer
     }
 
     @Override
-    public void init(String sceneCode) {
+    public void init(String sceneCode, String from) {
         TiledMapEntity entity = findById(sceneCode);
         if (entity == null) {
             entity = new TiledMapEntity();
             entity.setCreateTime(LocalDateTime.now());
             entity.setId(sceneCode);
             // 2021.09.03
-            entity.setData(initData(sceneCode));
+            entity.setData(initData(sceneCode, from));
         } else {
             // web端重算, 把cover重新上传oss就行
             uploadCover(sceneCode);
@@ -130,10 +128,10 @@ public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapSer
             log.info("cover.zip解压完成");
 
 
-
             // 目录上传oss
             String uploadDir = basePath + "/cover";
 
+
             // 判断上传的cover.zip 是否包含目录,如有,抛异常
             if (!FileUtil.exist(uploadDir + "/0")){
                 String msg = "上传的zip包目录结构有误, 不能包含目录,请检查";
@@ -144,7 +142,7 @@ public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapSer
             uploadDiyCover(sceneCode, uploadDir );
 
             // 将cover.zip 更新到oss. data/sceneCode/upload_cover/cover.zip
-            String ossCoverZip = "data/" + sceneCode + "upload_cover/cover.zip";
+            String ossCoverZip = "data/" + sceneCode + "/upload_cover/cover.zip";
             aliYunOssUtil.upload(savePath, ossCoverZip);
             log.info("ossCoverZip更新oss完成:{}", ossCoverZip);
 
@@ -179,7 +177,12 @@ public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapSer
 
     @Override
     public Result findAll(String sceneCode) {
-        return Result.success(getDataBySceneCode(sceneCode));
+        TiledMapEntity entity = findById(sceneCode);
+        // 不显示状态时,返回空数组
+        if (entity.getDisplay() == 0) {
+            return Result.success();
+        }
+        return Result.success(entity.getData());
     }
 
     @Override
@@ -264,7 +267,7 @@ public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapSer
      * @param sceneCode
      * @return
      */
-    private List<TiledMapDto> initData(String sceneCode){
+    private List<TiledMapDto> initData(String sceneCode, String from){
         String path = redisPath(sceneCode) + "/laserData";
         if ("dev".equals(configConstant.active)) {
             path = "F:\\test\\ngin\\age_laser_data\\" + sceneCode + "\\results\\laserData";
@@ -294,10 +297,11 @@ public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapSer
         double mapSize_m = PlanGraph.getSize(imgWidth, 1);
         List<DataSetPo> data = dataSetService.getDataBySceneCode(sceneCode);
         DataSetPo dataSetPo = data.get(0);
+        // 用tiled_map使用dataSet的值
         Double orientation = dataSetPo.getOrientation();
         Double[] location = dataSetPo.getLocation();
 
-        double[] quaternion = PlanGraph.getQuaternion(orientation);
+
 
 
         // 四叉树
@@ -335,9 +339,13 @@ public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapSer
         dto.setMap_size_m(mapSize_m);
         // 使用dataSet.location
         dto.setLocation(location);
-        // 前端提供
-        Double[] calcQuaternion = {quaternion[0],quaternion[1],quaternion[2],quaternion[3]};
-        dto.setOrientation(calcQuaternion);
+//        double[] quaternion = PlanGraph.getQuaternion(orientation);
+//        Double[] calcQuaternion = {quaternion[0],quaternion[1],quaternion[2],quaternion[3]};
+//        dto.setOrientation(calcQuaternion);
+
+
+        // 计算 2021-09-14
+        dto.setOrientation(PlanGraph.tiledMapOrientation(orientation));
         List<TiledMapDto> list = new ArrayList<>();
         list.add(dto);
 
@@ -352,6 +360,9 @@ public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapSer
 
     }
 
+
+
+
     /**
      * 压缩并上传oss
      * @param path 服务器基础路径