Bläddra i källkod

修改重算规则

wuweihao 4 år sedan
förälder
incheckning
ccabf785a4

+ 5 - 0
README.md

@@ -97,4 +97,9 @@ t-p307mDm   /mnt/data/00001001/872174780395028480/74ee2a32dbde_20210803173654643
 
 
 aa-p307mDm
+
+db.getCollection('t_special_point').find({"sceneCode":"t-RJlwqtc"})
+
+
+t-gWKRICl
              

+ 0 - 58
laser/README.md

@@ -1,58 +0,0 @@
-# 德国相机
-    demo-url:
-    api:http://indoor.popsmart.cn:8084/sxswsw/api/site_model/within?location=120.58645186143931&location=29.991567318555767&location=1.1677126884460454&type=BUILDING
-    demo:http://indoor.popsmart.cn:8084/sxswsw-sx/
-        type 返回都是相应坐标的参数
-            BUILDING: 建筑物 -> 只返回建筑物数据
-            FLOOR: 楼层 -> 只返回楼层数据 - 多边形数据为null, 把找到坐标房间信息返回给前端
-            ROOM: 房间 -> 只返回房间数据
-            type=null -> 返回相应参数的建筑物.楼层.房间数据
-            
-            
-  服务器信息
-    /阿里云-四维时代-官网测试服务器-120.25.146.52/root/user/java/jar_run/
-    
-    
-    aip: http://127.0.0.1:9294/indoor/aa/api/images/1288 
-    221.4.210.172:9294/indoor/aa/api/images/1288    
-    
-    
-#API
-    https://testlaser.4dkankan.com/indoor/test1/api/site_model/within?location=120.58629809780416&location=29.991469096442984&location=2.050019474815037&type=FLOOR    
-    https://testlaser.4dkankan.com/indoor/test1/api/site_model/within?location=120.58629809780416&location=29.991469096442984&location=2.050019474815037&type=FLOOR  
-    
-    http://127.0.0.1:9294/indoor
-    https://testlaser.4dkankan.com/indoor
-    
-    http://indoor.popsmart.cn:8084/sxswsw/api/site_model/within?location=120.58629809780416&location=29.991469096442984&location=2.050019474815037&type=FLOOR
-    
-    
-    http://test.4dkankan.com:9294/indoor/{test1}/api/images/{id} 
-    
-    
-    # 测试计算最小距离
-    http://127.0.0.1:9294/indoor/test1/api/images/filter?hidden=false&lat=29.99150810503829&limit=1&lon=120.58627208336249&z=2.050019474815037 
-    
-    # 有半径的
-    http://127.0.0.1:9294/indoor/test2/api/images/filter?hidden=false&lat=22.3668029722544&lon=113.595671720124&radius=20&site_model_entity=
-    
-    
-# 日志
-    # 2021-07-15
-    这个接口还有问题:
-    https://testlaser.4dkankan.com/indoor/test1/api/images/filter?hidden=false&lat_max=29.99143363257292&lat_min=29.991244191301476&lon_max=120.5867345486961&lon_min=120.58598839339827&site_model_entity=2&site_model_entity=&spacing=1.56
-    
-    
-    https://testlaser.4dkankan.com/indoor/test1/api/images/filter?hidden=false&lat_max=29.99143363257292&lat_min=29.991244191301476&lon_max=120.5867345486961&lon_min=120.58598839339827&site_model_entity=2&site_model_entity=&step=4&spacing=1.56
-    
-    这两个接口,一个有值,一个没有,这个不应该,都应该有值才对。估计是没有step这个参数导致的,这里要改改,step可以没有。  
-    
-    
-    # 2021-07-16
-        filte查询接口, 测试过是成功的
-          http://127.0.0.1:9294/indoor/test1/api/filter/filter?dataset=45&hidden=false&limit=100&site_model_entity=17&sort_by=asc&sort_order=file_id
-    
-    
-# mongodb
-    导入数据是,嵌套数据的id不需要改成_id
-             

+ 3 - 2
laser/src/main/java/com/fdkankan/indoor/base/convert/ConvertToPanoInfoFor4dkk.java

@@ -39,7 +39,8 @@ public class ConvertToPanoInfoFor4dkk {
 			
 			JSONObject sweepItem = sweepLocations.getJSONObject(i);
 			//navvis��֧��id��0�����ε�
-			int id = sweepItem.getInt("id");
+			//int id = sweepItem.getInt("id");
+			int id = sweepItem.getInt("uuid");
 			JSONObject pose = sweepItem.getJSONObject("pose");
 			JSONObject rotation = pose.getJSONObject("rotation");
 			JSONObject translation = pose.getJSONObject("translation");
@@ -68,7 +69,7 @@ public class ConvertToPanoInfoFor4dkk {
 			laserPano.put("dataset_orientation", null);
 			laserPano.put("file_path", "data/chunk1");
 			laserPano.put("hidden", false);
-			laserPano.put("id", id+1);
+			laserPano.put("id", id);
 			laserPano.put("site_model_entity_id", 11);
 			
 			//JSONObject pose = item.getJSONObject("pose");

+ 67 - 34
laser/src/main/java/com/fdkankan/indoor/base/convert/ModifyCloud.java

@@ -60,6 +60,13 @@ public class ModifyCloud {
 		return location;
 	}
 
+
+	public static double[] convertFromOrigin() {
+		double[] location = {0,0,0};
+		location = TransformGPS.convert(location);
+		return location;
+	}
+
 	//把boundingbox的顶点和中心点转换成gps坐标
 	public static JSONObject convertFromBoundingBox(JSONObject boundingBox, ControlPointEntity dto) {
 		double[] max = {boundingBox.getDouble("maxX"),boundingBox.getDouble("maxY"),boundingBox.getDouble("maxZ")};
@@ -70,45 +77,71 @@ public class ModifyCloud {
 		max = TransformGPS.convert(max, dto);
 		min = TransformGPS.convert(min, dto);
 		centre = TransformGPS.convert(centre, dto);
+		// 处理centreZ
+		double[] newCentre = {centre[0],centre[1], boundingBox.getDouble("centreZ")} ;
 		
 		JSONObject result = new JSONObject();
 		result.put("max", max);
 		result.put("min", min);
-		result.put("centre", centre);
+		result.put("centre", newCentre);
+		return result;
+	}
+
+	//把boundingbox的顶点和中心点转换成gps坐标
+	public static JSONObject convertFromBoundingBox(JSONObject boundingBox) {
+		double[] max = {boundingBox.getDouble("maxX"),boundingBox.getDouble("maxY"),boundingBox.getDouble("maxZ")};
+		double[] min = {boundingBox.getDouble("minX"),boundingBox.getDouble("minY"),boundingBox.getDouble("minZ")};
+		double[] centre = {boundingBox.getDouble("centreX"),boundingBox.getDouble("centreY"),boundingBox.getDouble("centreZ")};
+
+
+		max = TransformGPS.convert(max);
+		min = TransformGPS.convert(min);
+		centre = TransformGPS.convert(centre);
+		// 处理centreZ
+		double[] newCentre = {centre[0],centre[1], boundingBox.getDouble("centreZ")} ;
+
+		JSONObject result = new JSONObject();
+		result.put("max", max);
+		result.put("min", min);
+		result.put("centre", newCentre);
 		return result;
 	}
 	
-//	public static void main(String args[]) {
-//		String inputFilePath = "F:\\test\\project\\age_laser\\cloud.js";
-//		try
-//		{
-//			//修改cloud.js文件
-//			JSONObject info = fixCloud(inputFilePath);
-//			//将原点转换成gis坐标,后续要写到datasets里
-//			double[] doubles = convertFromOrigin();//原点 0,0,0 key:origin
-////将boundingbox坐标转换成gis坐标,site_model(第二张表)需要 , 这个获取z_max, z_min
-//			JSONObject boundingbox = getBoundingBox(info);
-//
-//			Object minZ = boundingbox.get("minZ");
-//
-//
-//			JSONObject resJson = convertFromBoundingBox(boundingbox);//boundingbox_min,boundingbox_max,centre
-//			Object max = resJson.get("max");
-//			Object min = resJson.get("min");
-//			Object centre = resJson.get("centre");
-//
-//			JSONArray object = resJson.getJSONArray("max");
-//			System.out.println();
-//			// 0:113, 1:22
-//			double[] max1 = {object.getDouble(0), object.getDouble(1)};
-//
-//			System.out.println();
-//
-//		}
-//		catch(Exception e)
-//		{
-//			e.printStackTrace();
-//		}
-//
-//	}
+	public static void main(String args[]) {
+		String inputFilePath = "F:\\test\\project\\age_laser\\laserData\\webcloud\\cloud.js";
+		try
+		{
+			//修改cloud.js文件
+			JSONObject info = fixCloud(inputFilePath);
+			//将原点转换成gis坐标,后续要写到datasets里,只有经纬度, 没有高度值
+			double[] doubles = convertFromOrigin();//原点 0,0,0 key:origin
+
+			/**
+			 * 将boundingbox坐标转换成gis坐标,site_model(第二张表)需要 , 这个获取z_max, z_min
+			 * boundingbox: 虚拟点坐标,需要存到特殊点
+			 */
+			JSONObject boundingbox = getBoundingBox(info);
+
+			Object minZ = boundingbox.get("minZ");
+
+
+			JSONObject resJson = convertFromBoundingBox(boundingbox);//boundingbox_min,boundingbox_max,centre
+			Object max = resJson.get("max");
+			Object min = resJson.get("min");
+			Object centre = resJson.get("centre");
+
+			JSONArray object = resJson.getJSONArray("max");
+			System.out.println();
+			// 0:113, 1:22
+			double[] max1 = {object.getDouble(0), object.getDouble(1)};
+
+			System.out.println();
+
+		}
+		catch(Exception e)
+		{
+			e.printStackTrace();
+		}
+
+	}
 }

+ 79 - 37
laser/src/main/java/com/fdkankan/indoor/base/convert/ModifyDataSets.java

@@ -1,8 +1,10 @@
 package com.fdkankan.indoor.base.convert;
 
 import java.io.IOException;
+import java.util.Map;
 
 
+import com.fdkankan.indoor.base.constant.TypeConstant;
 import com.fdkankan.indoor.core.entity.dto.SecurityDto;
 import com.fdkankan.indoor.core.entity.po.DataSetPo;
 import net.sf.json.JSON;
@@ -79,43 +81,83 @@ public class ModifyDataSets {
 	}
 
 
-		public static DataSetPo createDataSetPo(Double[] location){
-			DataSetPo po = new DataSetPo();
-
-			SecurityDto securityDto = new SecurityDto();
-
-			securityDto.setGroup_read(0);
-			securityDto.setGroup_write(1);
-			// 默认true
-			securityDto.setCan_write(true);
-			// 默认true
-			po.setSecurity(securityDto);
-
-			po.setId(0);
-			po.setBundle_id(1);
-			po.setType("4dage");
-			po.setName("chunk1");
-			po.setTitle("chunk1");
-			po.setColor("pink");
-			po.setVisible(false);
-
-			//double[] location = {0,0,0};
-			//location = TransformGPS.convert(location);
-			//原点 ,获取特征点的原点
-			po.setLocation(location);
-			po.setOrientation(0.0);
-			Integer[] site_model_entity_ids = {10,11,12};
-			po.setSite_model_entity_ids(site_model_entity_ids);
-			po.setPoint_cloud_type("POTREE");
-
-			//添加boundingbox,从modifyCloud里的convertFromBoundingBox获取
-			//dataset.put("bounding_box_min", "");
-			//dataset.put("bounding_box_max", "");
-
-			po.setHas_depth_images(true);
-			po.setHas_images(true);
-			return po;
-		}
+	public static DataSetPo createDataSetPo(Map<String ,Double[]> param){
+		DataSetPo po = new DataSetPo();
+
+		SecurityDto securityDto = new SecurityDto();
+
+		securityDto.setGroup_read(0);
+		securityDto.setGroup_write(1);
+		// 默认true
+		securityDto.setCan_write(true);
+		// 默认true
+		po.setSecurity(securityDto);
+
+		po.setId(0);
+		po.setBundle_id(1);
+		po.setType("4dage");
+		po.setName("chunk1");
+		po.setTitle("chunk1");
+		po.setColor("pink");
+		po.setVisible(false);
+
+		//double[] location = {0,0,0};
+		//location = TransformGPS.convert(location);
+		//原点 ,获取特征点的原点
+		po.setLocation(param.get(TypeConstant.POI_ORIGIN));
+		po.setOrientation(0.0);
+		Integer[] site_model_entity_ids = {10,11,12};
+		po.setSite_model_entity_ids(site_model_entity_ids);
+		po.setPoint_cloud_type("POTREE");
+
+		//添加boundingbox,从modifyCloud里的convertFromBoundingBox获取
+
+		// 使用的是虚拟坐标
+		po.setBounding_box_max(param.get(TypeConstant.POI_BOUNDINGBOX_MAX));
+		po.setBounding_box_min(param.get(TypeConstant.POI_BOUNDINGBOX_MIN));
+
+		po.setHas_depth_images(true);
+		po.setHas_images(true);
+		return po;
+	}
+
+//		public static DataSetPo createDataSetPo(Double[] location){
+//			DataSetPo po = new DataSetPo();
+//
+//			SecurityDto securityDto = new SecurityDto();
+//
+//			securityDto.setGroup_read(0);
+//			securityDto.setGroup_write(1);
+//			// 默认true
+//			securityDto.setCan_write(true);
+//			// 默认true
+//			po.setSecurity(securityDto);
+//
+//			po.setId(0);
+//			po.setBundle_id(1);
+//			po.setType("4dage");
+//			po.setName("chunk1");
+//			po.setTitle("chunk1");
+//			po.setColor("pink");
+//			po.setVisible(false);
+//
+//			//double[] location = {0,0,0};
+//			//location = TransformGPS.convert(location);
+//			//原点 ,获取特征点的原点
+//			po.setLocation(location);
+//			po.setOrientation(0.0);
+//			Integer[] site_model_entity_ids = {10,11,12};
+//			po.setSite_model_entity_ids(site_model_entity_ids);
+//			po.setPoint_cloud_type("POTREE");
+//
+//			//添加boundingbox,从modifyCloud里的convertFromBoundingBox获取
+//			//dataset.put("bounding_box_min", "");
+//			//dataset.put("bounding_box_max", "");
+//
+//			po.setHas_depth_images(true);
+//			po.setHas_images(true);
+//			return po;
+//		}
 	
 	public static JSONArray readSiteModel() throws IOException { 
 		String str = FileUtil.readStringFile(inputFilePath);

+ 33 - 11
laser/src/main/java/com/fdkankan/indoor/base/convert/TransformGPS.java

@@ -11,13 +11,25 @@ public class TransformGPS {
 	public static final String CRS = "EPSG:4490";
 	
 	// 控制点, 输入参数,需要存入数据库
-	public static double[] controlLocation1 = {6.774144f,-9.48061f};  // 四维看看坐标
-	public static double[] controlCoordinate1 = {113.595725873337f,22.366579193007f}; //gps坐标
-	
-	public static double[] controlLocation2 = {6.059886f,-12.197689f}; // 四维看看坐标
-	public static double[] controlCoordinate2 = {113.59571900944f,22.366554639591f};  //gps坐标
+//	public static double[] controlLocation1 = {6.774144f,-9.48061f};  // 四维看看坐标
+//	public static double[] controlCoordinate1 = {113.595725873337f,22.366579193007f}; //gps坐标
+//
+//	public static double[] controlLocation2 = {6.059886f,-12.197689f}; // 四维看看坐标
+//	public static double[] controlCoordinate2 = {113.59571900944f,22.366554639591f};  //gps坐标
+
+	public static double[] controlLocation1 = {-1.803582f,-1.927333f};  // 四维看看坐标
+	public static double[] controlCoordinate1 = {113.60044921875,22.364469401041667}; //gps坐标
+
+	public static double[] controlLocation2 = {3.489484f,0.962214f}; // 四维看看坐标
+	public static double[] controlCoordinate2 = {113.60044406467014,22.36447238498264};  //gps坐标
 
 
+	/**
+	 * transformLocationToBL这个方法把高度省略了
+	 * @param position
+	 * @param dto
+	 * @return
+	 */
 	public static double[] convert(double[] position, ControlPointEntity dto) {
 		double[] controlLocation1 = dto.getAgeControlLocation1();
 		double[] controlLocation2 = dto.getAgeControlLocation2();
@@ -59,11 +71,18 @@ public class TransformGPS {
 		return result;
 	}
 
-	
-	private static double[] convert(double[] position) {
-    	GisCoordinateUtil.calculateVariable (controlCoordinate1[0],controlCoordinate1[1],controlLocation1[0],controlLocation1[1],controlCoordinate2[0],controlCoordinate2[1],controlLocation2[0],controlLocation2[1]);
-        double[] d = GisCoordinateUtil.transformLocationToBL(position[0], position[1]);
-        return d;
+
+//	public static double[] convert(double[] position) {
+//    	GisCoordinateUtil.calculateVariable (controlCoordinate1[0],controlCoordinate1[1],controlLocation1[0],controlLocation1[1],controlCoordinate2[0],controlCoordinate2[1],controlLocation2[0],controlLocation2[1]);
+//        double[] d = GisCoordinateUtil.transformLocationToBL(position[0], position[1]);
+//        return d;
+//	}
+
+
+	public static double[] convert(double[] position) {
+		GisCoordinateUtil.calculateVariable (controlCoordinate1[0],controlCoordinate1[1],controlLocation1[0],controlLocation1[1],controlCoordinate2[0],controlCoordinate2[1],controlLocation2[0],controlLocation2[1]);
+		double[] d = GisCoordinateUtil.transformLocationToBL(position[0], position[1]);
+		return d;
 	}
 
 	private static double[][] convert(double[][] positions){
@@ -82,7 +101,10 @@ public class TransformGPS {
         //String url = "src/main/resources/demo.cp";
         //GisCoordinateUtil.parseControlPointsFile(url);
     	GisCoordinateUtil.calculateVariable (controlCoordinate1[0],controlCoordinate1[1],controlLocation1[0],controlLocation1[1],controlCoordinate2[0],controlCoordinate2[1],controlLocation2[0],controlLocation2[1]);
-        double[] d = GisCoordinateUtil.transformLocationToBL(3.489638, -11.538544);
+//        double[] d = GisCoordinateUtil.transformLocationToBL(3.489638, -11.538544);
+
+
+		double[] d = GisCoordinateUtil.transformLocationToBL(0, 0);
         System.out.println(d[0]+" "+d[1]);
     }
 }

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

@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
  *
  */
 @Slf4j
-@Api(tags = "四维看看数据转激光相机数据")
+@Api(tags = "初始化数据(init)")
 @RestController
 public class InitController {
 

+ 7 - 0
laser/src/main/java/com/fdkankan/indoor/core/entity/ControlPointEntity.java

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.data.mongodb.core.mapping.Document;
 
+import java.time.LocalDateTime;
+
 /**
  * Created by owen on 2021/7/29 0029 18:34
  * 控制点实体
@@ -31,5 +33,10 @@ public class ControlPointEntity {
     private double[] gpsControlCoordinate2;
 
 
+    private LocalDateTime createTime;
+
+    private LocalDateTime updateTime;
+
+
 
 }

+ 8 - 2
laser/src/main/java/com/fdkankan/indoor/core/entity/SpecialPointEntity.java

@@ -1,5 +1,6 @@
 package com.fdkankan.indoor.core.entity;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.data.mongodb.core.mapping.Document;
 
@@ -17,12 +18,17 @@ public class SpecialPointEntity extends BaseEntity {
 //    // 经度
 //    private Double lon;
 
-    // 特殊点
+    @ApiModelProperty(value = "虚拟坐标")
     private Double[] poi;
 
     // 场景码, 这个一定要场景码, 多条记录
     private String sceneCode;
 
-    // key
+    @ApiModelProperty(value = "特殊点key")
     private String poiKey;
+
+    @ApiModelProperty(value = "Gps坐标")
+    private Double[] gpsPoi;
+
+
 }

+ 4 - 0
laser/src/main/java/com/fdkankan/indoor/core/mapper/SpecialPointMapper.java

@@ -4,6 +4,8 @@ import com.fdkankan.indoor.core.entity.SpecialPointEntity;
 import org.springframework.data.mongodb.repository.MongoRepository;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+
 /**
  * Created by owen on 2021/7/27 0027 18:30
  */
@@ -13,4 +15,6 @@ public interface SpecialPointMapper extends MongoRepository<SpecialPointEntity,
     SpecialPointEntity findBySceneCodeAndPoiKey(String sceneCode, String poiKey);
 
     void deleteBySceneCode(String sceneCode);
+
+    List<SpecialPointEntity> findBySceneCode(String sceneCode);
 }

+ 4 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/SpecialPointService.java

@@ -2,6 +2,8 @@ package com.fdkankan.indoor.core.service;
 
 import com.fdkankan.indoor.core.entity.SpecialPointEntity;
 
+import java.util.List;
+
 /**
  * Created by owen on 2021/7/27 0027 18:31
  */
@@ -12,4 +14,6 @@ public interface SpecialPointService {
     SpecialPointEntity findBySceneCodeAndPoiKey(String sceneCode, String poiKey);
 
     void remove(String sceneCode);
+
+    List<SpecialPointEntity> findBySceneCode(String sceneCode);
 }

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

@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Optional;
 
@@ -40,21 +41,30 @@ public class ControlPointServiceImpl implements ControlPointService {
             return Result.failure("场景码不能为空");
         }
 
-        InitEntity initEntity = initService.findById(id);
-        Integer status = initEntity.getStatus();
-        if (status == 0) {
-            // 查询初始化状态
-            entityMapper.save(param);
-            log.info("控制点保存完成");
+        param.setUpdateTime(LocalDateTime.now());
+        entityMapper.save(param);
+        log.info("控制点保存完成");
 
-            // 初始化step2 数据
-            initService.initDataStep2(id);
-            log.info("初始化step2 完成");
-            return Result.success();
-        }
+        // 初始化step2 数据
+        initService.initDataStep2(id);
+        log.info("初始化step2 完成");
+        return Result.success();
 
-        log.info("已初始化, 不执行操作, 初始化状态为: {}", status);
-        return Result.failure("已初始化,不执行操作");
+//        InitEntity initEntity = initService.findById(id);
+//        Integer status = initEntity.getStatus();
+//        if (status == 0) {
+//            // 查询初始化状态
+//            entityMapper.save(param);
+//            log.info("控制点保存完成");
+//
+//            // 初始化step2 数据
+//            initService.initDataStep2(id);
+//            log.info("初始化step2 完成");
+//            return Result.success();
+//        }
+//
+//        log.info("已初始化, 不执行操作, 初始化状态为: {}", status);
+//        return Result.failure("已初始化,不执行操作");
     }
 
     @Override

+ 121 - 59
laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java

@@ -26,10 +26,7 @@ import org.springframework.stereotype.Service;
 
 import java.io.IOException;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -103,14 +100,21 @@ public class InitServiceImpl implements InitService {
         }
 
         // 防止为四维看看重复调用重算
+        InitEntity init = this.findById(sceneCode);
         if ("age".equals(from)){
-            InitEntity init = this.findById(sceneCode);
             if (init != null){
                 log.error("场景:[{}] 已存在,不需要重算", sceneCode);
                 return Result.success();
             }
         }
 
+        // 重算
+        if ("recount".equals(from)){
+            path = init.getPath();
+        }
+
+
+
 
 
         String laserDataPath = path + "/laserData";
@@ -128,9 +132,6 @@ public class InitServiceImpl implements InitService {
         // step5 创建poi_type_group表
         createPoiTypeGroup(sceneCode);
 
-
-
-
         // step7 复制静态资源
         copyDefault(sceneCode);
 
@@ -138,15 +139,21 @@ public class InitServiceImpl implements InitService {
          //step8 替换index.html、/locat/addDataSet.html的场景码, @replace
         replaceHtml(sceneCode);
 
-
-
         // 保存initDataStep1 状态
-        InitEntity entity = new InitEntity();
-        entity.setId(sceneCode);
-        entity.setPath(path);
-        entity.setCreateTime(LocalDateTime.now());
-        entity.setStatus(0);
-        initMapper.save(entity);
+        if (init == null) {
+             init = new InitEntity();
+            init.setId(sceneCode);
+            init.setPath(path);
+            init.setCreateTime(LocalDateTime.now());
+        } else {
+            init.setUpdateTime(LocalDateTime.now());
+            Integer recount = init.getRecount();
+            recount = recount == null ? 1 : recount + 1;
+            init.setRecount(recount);
+        }
+
+        init.setStatus(0);
+        initMapper.save(init);
         log.info("initDataStep_1处理完成");
 
         return Result.success();
@@ -155,6 +162,7 @@ public class InitServiceImpl implements InitService {
 
     /**
      * 需要控制点,才能完成以下操作
+     * 重新输入控制点时, 把相应数据删除, 重新初始化
      *
      *
      * @param sceneCode
@@ -163,10 +171,16 @@ public class InitServiceImpl implements InitService {
     public void initDataStep2(String sceneCode){
 
         Optional<InitEntity> optional = initMapper.findById(sceneCode);
-        InitEntity init = optional.get();
-        if (init.getStatus() !=0) {
-            throw new BaseRuntimeException("数据初始化失败");
+        if (!optional.isPresent()){
+            throw new BaseRuntimeException(MsgCode.e3001,"此场景的数据初始化不存在");
         }
+        InitEntity init = optional.get();
+//        if (init.getStatus() !=0) {
+//            throw new BaseRuntimeException("数据初始化失败");
+//        }
+
+        // 输入控制点,需要删除旧数据,重新初始化
+        removeInitDataStep2(sceneCode);
 
         String path = init.getPath();
         String laserDataPath = path + "/laserData";
@@ -200,31 +214,32 @@ public class InitServiceImpl implements InitService {
 
 
     /**
+     * 输入控制点,需要把相关数据从新初始化
+     * @param sceneCode
+     */
+    private void removeInitDataStep2(String sceneCode){
+        filterService.remove(sceneCode);
+        specialPointService.remove(sceneCode);
+        configService.remove(sceneCode);
+        dataSetService.remove(sceneCode);
+        log.info("删除initDataStep2数据完成");
+    }
+
+    /**
      * 重算场景
      * @param sceneCode
      * @return
      */
     @Override
     public Result initRecount(String sceneCode) {
-        InitEntity entity = this.findById(sceneCode);
 
         // 删除旧数据
         this.initRemove(sceneCode);
 
 
-        // 重新初始化数据
-        // 处理一下地址
-        String path = entity.getPath();
-//        path = path.replaceAll("/laserData", "");
-        log.info("path: {}", path);
-        this.initData(sceneCode, path, null);
+        // 重新初始化数据, 地址在里面处理
+        this.initData(sceneCode, null, "recount");
 
-        // 更新重算
-        Integer recount = entity.getRecount();
-        recount = recount == null ? 1 : recount;
-        entity.setRecount(recount);
-        entity.setUpdateTime(LocalDateTime.now());
-        initMapper.save(entity);
 
         // 记录重算日志
         RecountInfoEntity infoEntity = new RecountInfoEntity();
@@ -346,11 +361,12 @@ public class InitServiceImpl implements InitService {
      */
     private void processCould(String sceneCode, String path, ControlPointEntity dto){
         path = path + "/webcloud/cloud.js";
-        // 处理原点,将原点坐标转为坐标
+        // 处理原点,将原点坐标转为坐标, 转换后的原点只有经纬度,没有高度, 高度现在默认是0
         double[] doubles = ModifyCloud.convertFromOrigin(dto);
-        Double[] origin = {doubles[0] ,doubles[1]};
-        // 将数据保存到db
-        saveSpecialPoint(sceneCode, TypeConstant.POI_ORIGIN, origin);
+        // 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 {
@@ -360,26 +376,44 @@ public class InitServiceImpl implements InitService {
             cn.hutool.core.io.FileUtil.writeUtf8String(info.toString(), path);
             log.info("新的cloud.js写入完成:{}", path);
 
-            // 将boundingbox坐标转换成gis坐标, site_model需要
+            /**
+             * 将boundingBox坐标转换成gis坐标, site_model需要
+             * boundingBox:虚拟点坐标,存特殊点, dataSet数据要使用
+             */
             JSONObject boundingBox = ModifyCloud.getBoundingBox(info);
-            Double minZ = boundingBox.getDouble("minZ");
+            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[] max = getKey(resJson, "max");
-            Double[] min = getKey(resJson, "min");
-            Double[] centre = getKey(resJson, "centre");
+            Double[] gpsMax = getKey(resJson, "max");
+            Double[] gpsMin = getKey(resJson, "min");
+            Double[] gpsCentre = getKey(resJson, "centre");
 
             // 将数据保存到db
-            saveSpecialPoint(sceneCode, TypeConstant.POI_BOUNDINGBOX_MAX, max);
-            saveSpecialPoint(sceneCode, TypeConstant.POI_BOUNDINGBOX_MIN, min);
-            saveSpecialPoint(sceneCode, TypeConstant.POI_CENTRE, centre);
+            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, max, min, centre, maxZ, minZ);
+            createSiteModel(sceneCode, gpsMax, gpsMin, gpsCentre, maxZ, minZ);
 
         } catch (IOException e) {
             e.printStackTrace();
@@ -473,15 +507,16 @@ public class InitServiceImpl implements InitService {
      * 保存特质点
      * @param sceneCode 场景码
      * @param poiKey key
-     * @param poi 特殊点
+     * @param agePoi 虚拟点坐标(四维看看坐标)
      */
-    private void saveSpecialPoint(String sceneCode, String poiKey, Double[] poi){
+    private void saveSpecialPoint(String sceneCode, String poiKey, Double[] agePoi, Double[] gpsPoi){
         SpecialPointEntity entity = new SpecialPointEntity();
         entity.setId(SnowFlakeUUidUtils.getUuid("SP"));
         entity.setUpdateTime(LocalDateTime.now());
         entity.setSceneCode(sceneCode);
         entity.setPoiKey(poiKey);
-        entity.setPoi(poi);
+        entity.setPoi(agePoi);
+        entity.setGpsPoi(gpsPoi);
         specialPointService.save(entity);
     }
 
@@ -526,18 +561,40 @@ public class InitServiceImpl implements InitService {
     }
 
 
+    /**
+     * 初始化DataSet
+     * location: 原点坐标(特殊点表)
+     * bounding_box_max:(特殊点表)
+     * bounding_box_min:(特殊点表)
+     * @param sceneCode
+     */
     private void createDataSet(String sceneCode){
         DataSetEntity entity = new DataSetEntity();
         entity.setId(sceneCode);
         entity.setUpdateTime(LocalDateTime.now());
         // 设置原点坐标,通过场景码查询特殊点表的原点
-        SpecialPointEntity sp = specialPointService.findBySceneCodeAndPoiKey(sceneCode, TypeConstant.POI_ORIGIN);
-        if (sp == null) {
-            throw new BaseRuntimeException(MsgCode.e3001, "没有找到原点坐标");
+//        SpecialPointEntity sp = specialPointService.findBySceneCodeAndPoiKey(sceneCode, TypeConstant.POI_ORIGIN);
+        List<SpecialPointEntity> spList =  specialPointService.findBySceneCode(sceneCode);
+        // 正常是5条记录: db.getCollection('t_special_point').find({"sceneCode":"t97"})
+        if (spList.size() != 5) {
+            throw new BaseRuntimeException(MsgCode.e3001, "特殊点表坐标异常");
         }
-        Double[] poi = sp.getPoi();
-//        JSONObject dataSet = ModifyDataSets.createDataSet(poi);
-        DataSetPo po = ModifyDataSets.createDataSetPo(poi);
+
+//        List<String> poiKey = Arrays.asList(TypeConstant.POI_ORIGIN, TypeConstant.POI_BOUNDINGBOX_MAX, TypeConstant.POI_BOUNDINGBOX_MIN);
+        Map<String, Double[]> map = new HashMap<>();
+        for (SpecialPointEntity sp : spList) {
+            String key = sp.getPoiKey();
+            // 使用虚拟坐标
+            if (TypeConstant.POI_BOUNDINGBOX_MAX.equals(key) || TypeConstant.POI_BOUNDINGBOX_MIN.equals(key)) {
+                map.put(key, sp.getPoi());
+            }
+            // 使用gps坐标
+            if (TypeConstant.POI_ORIGIN.equals(key)){
+                map.put(key, sp.getGpsPoi());
+            }
+        }
+
+        DataSetPo po = ModifyDataSets.createDataSetPo(map);
         entity.setData(Arrays.asList(po));
         dataSetService.save(entity);
         log.info("DataSet数据初始化创建完成");
@@ -640,12 +697,17 @@ public class InitServiceImpl implements InitService {
 
     @Test
     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);
+//        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6);
+//        Stream<Integer> stream = list.stream();
+//        stream = stream.filter(p -> p > 3);
+//
+//        stream = stream.filter(p -> p > 5);
+//        System.out.println(stream.collect(Collectors.toList()));
 
-        stream = stream.filter(p -> p > 5);
-        System.out.println(stream.collect(Collectors.toList()));
+//        String[] poiKey = {TypeConstant.POI_ORIGIN, TypeConstant.POI_BOUNDINGBOX_MAX, TypeConstant.POI_BOUNDINGBOX_MIN};
+        List<String> poiKey = Arrays.asList(TypeConstant.POI_ORIGIN, TypeConstant.POI_BOUNDINGBOX_MAX, TypeConstant.POI_BOUNDINGBOX_MIN);
+        // origin
+        System.out.println(poiKey.contains("origi1n"));
 
     }
 

+ 8 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/impl/SpecialPointServiceImpl.java

@@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * Created by owen on 2021/7/27 0027 18:32
  */
@@ -32,6 +34,12 @@ public class SpecialPointServiceImpl implements SpecialPointService {
     public void remove(String sceneCode) {
         entityMapper.deleteBySceneCode(sceneCode);
     }
+
+    @Override
+    public List<SpecialPointEntity> findBySceneCode(String sceneCode) {
+
+        return entityMapper.findBySceneCode(sceneCode);
+    }
 }