Kaynağa Gözat

修改控制点计算,用计算值转换坐标, 大改动

wuweihao 3 yıl önce
ebeveyn
işleme
72ebb23fba
33 değiştirilmiş dosya ile 4398 ekleme ve 748 silme
  1. 92 0
      laser/pom.xml
  2. 32 0
      laser/src/main/java/com/fdkankan/indoor/base/convert/AffineTransform.java
  3. 235 103
      laser/src/main/java/com/fdkankan/indoor/base/convert/ConvertToVision.java
  4. 218 136
      laser/src/main/java/com/fdkankan/indoor/base/convert/FixRouteMap.java
  5. 221 5
      laser/src/main/java/com/fdkankan/indoor/base/convert/GetRoute.java
  6. 3 0
      laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateTransform.java
  7. 299 265
      laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateUtil.java
  8. 124 91
      laser/src/main/java/com/fdkankan/indoor/base/convert/ModifyCloud.java
  9. 19 0
      laser/src/main/java/com/fdkankan/indoor/base/convert/Point.java
  10. 58 67
      laser/src/main/java/com/fdkankan/indoor/base/convert/TransformGPS.java
  11. 1 1
      laser/src/main/java/com/fdkankan/indoor/core/controller/ControlPointController.java
  12. 16 1
      laser/src/main/java/com/fdkankan/indoor/core/controller/FilterController.java
  13. 116 7
      laser/src/main/java/com/fdkankan/indoor/core/controller/LoginController.java
  14. 15 0
      laser/src/main/java/com/fdkankan/indoor/core/controller/SiteModelController.java
  15. 31 0
      laser/src/main/java/com/fdkankan/indoor/core/entity/ControlPointCalculateEntity.java
  16. 14 0
      laser/src/main/java/com/fdkankan/indoor/core/mapper/ControlPointCalculateMapper.java
  17. 21 0
      laser/src/main/java/com/fdkankan/indoor/core/service/ControlPointCalculateService.java
  18. 1 0
      laser/src/main/java/com/fdkankan/indoor/core/service/FilterService.java
  19. 7 2
      laser/src/main/java/com/fdkankan/indoor/core/service/LoginService.java
  20. 2 0
      laser/src/main/java/com/fdkankan/indoor/core/service/SiteModelService.java
  21. 71 2
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/CloudServiceImpl.java
  22. 51 0
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/ControlPointCalculateServiceImpl.java
  23. 3 1
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/ControlPointServiceImpl.java
  24. 5 1
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/DataSetServiceImpl.java
  25. 4 3
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/FilterServiceImpl.java
  26. 163 17
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java
  27. 58 4
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/LoginServiceImpl.java
  28. 41 11
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/MergeSceneServiceImpl.java
  29. 34 30
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/PoseServiceImpl.java
  30. 9 1
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/RouteServiceImpl.java
  31. 26 0
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/SiteModelServiceImpl.java
  32. 100 0
      laser/src/main/java/com/fdkankan/indoor/test/TestAffineTransform.java
  33. 2308 0
      laser/src/main/resources/data/cameraHeads.json

+ 92 - 0
laser/pom.xml

@@ -27,6 +27,8 @@
 		<aliyun.oss.version>2.5.0</aliyun.oss.version>
 		<spring.boot.version>2.3.4.RELEASE</spring.boot.version>
 		<pagehelper.version>1.2.5</pagehelper.version>
+		<!--<geotools.version>24-SNAPSHOT</geotools.version>-->
+		<geotools.version>19.4</geotools.version>
 	</properties>
 
 	<dependencies>
@@ -200,6 +202,96 @@
 			<artifactId>spring-boot-starter-data-redis</artifactId>
 		</dependency>
 
+
+		<!-- Java使用GeoTools读取shapefile 文件-->
+		<!--<dependency>-->
+			<!--<groupId>org.geotools</groupId>-->
+			<!--<artifactId>gt-shapefile</artifactId>-->
+			<!--<version>18.4</version>-->
+		<!--</dependency>-->
+
+		<!--
+     		mvn install:install-file -Dfile=gt-shapefile-19.4.jar -DgroupId=org.geotools -DartifactId=gt-shapefile -Dversion=19.4 -Dpackaging=jar
+		-->
+		<!--<dependency>-->
+			<!--<groupId>org.geotools</groupId>-->
+			<!--<artifactId>gt-shapefile</artifactId>-->
+			<!--<version>19.4</version>-->
+		<!--</dependency>-->
+
+
+		<!--
+     		mvn install:install-file -Dfile=gt-api-19.4.jar -DgroupId=org.geotools -DartifactId=gt-api -Dversion=19.4 -Dpackaging=jar
+		-->
+		<!--<dependency>-->
+			<!--<groupId>org.geotools</groupId>-->
+			<!--<artifactId>gt-api</artifactId>-->
+			<!--<version>19.4</version>-->
+		<!--</dependency>-->
+
+
+
+		<!--<dependency>-->
+			<!--<groupId>org.geotools</groupId>-->
+			<!--<artifactId>gt-shapefile</artifactId>-->
+			<!--<version>${geotools.version}</version>-->
+		<!--</dependency>-->
+
+		<!--
+     		mvn install:install-file -Dfile=gt-swing-19.4.jar -DgroupId=org.geotools -DartifactId=gt-swing -Dversion=19.4 -Dpackaging=jar
+		-->
+		<!--<dependency>-->
+			<!--<groupId>org.geotools</groupId>-->
+			<!--<artifactId>gt-swing</artifactId>-->
+			<!--<version>${geotools.version}</version>-->
+		<!--</dependency>-->
+
+
+		<!--
+     mvn install:install-file -Dfile=gt-main-19.4.jar -DgroupId=org.geotools -DartifactId=gt-main -Dversion=19.4 -Dpackaging=jar
+-->
+		<!--<dependency>-->
+			<!--<groupId>org.geotools</groupId>-->
+			<!--<artifactId>gt-main</artifactId>-->
+			<!--<version>19.4</version>-->
+		<!--</dependency>-->
+
+		<!--
+mvn install:install-file -Dfile=gt-opengis-19.4.jar -DgroupId=org.geotools -DartifactId=gt-opengis -Dversion=19.4 -Dpackaging=jar
+-->
+		<!--<dependency>-->
+		<!--<groupId>org.geotools</groupId>-->
+		<!--<artifactId>gt-opengis</artifactId>-->
+		<!--<version>19.4</version>-->
+		<!--</dependency>-->
+
+
+		<!--<dependency>-->
+			<!--<groupId>com.vividsolutions</groupId>-->
+			<!--<artifactId>jts-core</artifactId>-->
+			<!--<version>1.14.0</version>-->
+		<!--</dependency>-->
+
+
+
+		<!--
+     mvn install:install-file -Dfile=opencv-320.jar -DgroupId=org.opencv -DartifactId=opencv -Dversion=3.2.0 -Dpackaging=jar
+-->
+		<!--<dependency>-->
+			<!--<groupId>org.opencv</groupId>-->
+			<!--<artifactId>opencv</artifactId>-->
+			<!--&lt;!&ndash;<version>3.2.0</version>&ndash;&gt;-->
+			<!--<version>4.1.1</version>-->
+		<!--</dependency>-->
+
+		<!-- https://mvnrepository.com/artifact/org.openpnp/opencv -->
+		<!--<dependency>-->
+			<!--<groupId>org.openpnp</groupId>-->
+			<!--<artifactId>opencv</artifactId>-->
+			<!--<version>3.2.0-1</version>-->
+		<!--</dependency>-->
+
+
 	</dependencies>
 
 	<build>

+ 32 - 0
laser/src/main/java/com/fdkankan/indoor/base/convert/AffineTransform.java

@@ -0,0 +1,32 @@
+package com.fdkankan.indoor.base.convert;
+
+public class AffineTransform {
+    public static double getAngle(Point p1, Point p2) {
+        double angle = Math.atan2(p2.getX() - p1.getX(), p2.getY() - p1.getY());
+        return angle * (180 / Math.PI);
+    }
+
+    public static double getScale(Point p1, Point b1, Point p2, Point b2) {
+        return getLength(b1, b2) / getLength(p1, p2);
+    }
+
+    public static double getLength(Point p1, Point p2) {
+        return Math.sqrt(Math.pow(p2.getX() - p1.getX(), 2) + Math.pow(p2.getY() - p1.getY(), 2));
+    }
+
+    public static double getXTranslation(Point p1, Point b1, double rotation, double scale) {
+        double v = b1.getX() - scale * (p1.getX() * Math.cos(rotation) - p1.getY() * Math.sin(rotation));
+        return v;
+    }
+
+    public static double getYTranslation(Point p1, Point b1, double rotation, double scale) {
+        return (b1.getY() - scale * (p1.getX() * Math.sin(rotation) + p1.getY() * Math.cos(rotation)));
+    }
+
+    public static Point transformBoePoint(Point gp, double rotation, double scale, double dx, double dy) {
+        double A = scale * Math.cos(rotation);
+        double B = scale * Math.sin(rotation);
+        return new Point(A * gp.getX() - B * gp.getY() + dx, B * gp.getX() + A * gp.getY() + dy);
+    }
+
+}

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

@@ -5,6 +5,7 @@ import java.time.LocalDateTime;
 
 import com.fdkankan.indoor.base.constant.TypeConstant;
 import com.fdkankan.indoor.base.util.SnowFlakeUUidUtils;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import com.fdkankan.indoor.core.entity.SpecialPointEntity;
 import com.fdkankan.indoor.core.service.SpecialPointService;
@@ -66,10 +67,119 @@ public class ConvertToVision {
 	 * @param dto
 	 * @return
 	 */
-	private  JSONArray createVisionToFilter(String sceneCode, JSONArray panoInfos,  ControlPointEntity dto) {
-		
+//	private  JSONArray createVisionToFilter(String sceneCode, JSONArray panoInfos,  ControlPointEntity dto) {
+//
+//		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();
+//			int id = item.getInt("id");
+//			laserPano.put("camera_head_id", 12);
+//			laserPano.put("dataset_id", 1);
+////			laserPano.put("file_path", "data/chunk1");
+//			// 2021-8-26
+//			laserPano.put("file_path", "data/" + sceneCode);
+//			laserPano.put("hidden", false);
+//			laserPano.put("id", id);
+////			laserPano.put("site_model_entity_id", 12);
+//			// 2021-09-06改用floor类型的id
+//			laserPano.put("site_model_entity_id", 11);
+//
+//			//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坐标
+//			log.warn("=============== _location 开始" + i +" =========================");
+//			double[] _location = TransformGPS.convertLocationToGis(location,dto);
+//			log.warn("=============== _location 结束" + i +" =========================");
+//			double[] _floor_location = TransformGPS.convertLocationToGis(floor_location, dto);
+//			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 存入数据库
+//				SpecialPointEntity pointEntity = new SpecialPointEntity();
+//				// 经度 22 纬度 113
+//				Double[] edit = {_location[0], _location[1]};
+//				pointEntity.setPoi(edit);
+//				pointEntity.setSceneCode(sceneCode);
+//				pointEntity.setUpdateTime(LocalDateTime.now());
+//				pointEntity.setId(SnowFlakeUUidUtils.getUuid("SP"));
+//				pointEntity.setPoiKey(TypeConstant.POI_FIRST_VIEW);
+//				specialPointService.save(pointEntity);
+//				log.info("firstVieW保存成功");
+//			}
+//		}
+//		log.info("需要的大地坐标值:结束====================================================================");
+//		return laserPanos;
+//	}
+
+
+	/**
+	 * 初始化vision数据
+	 * @param sceneCode
+	 * @param panoInfos
+	 * @return
+	 */
+	private  JSONArray createVisionToFilter(String sceneCode, JSONArray panoInfos,  ControlPointCalculateEntity calculateEntity) {
+
 		JSONArray laserPanos = new JSONArray();
-		for(int i=0;i<panoInfos.size();++i) {
+		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();
 			int id = item.getInt("id");
@@ -85,6 +195,7 @@ public class ConvertToVision {
 			laserPano.put("site_model_entity_id", 11);
 
 			//JSONObject pose = item.getJSONObject("pose");
+			// vision.txt: puck、translation 这两个值是一样的。所以算出来的_location、_floor_location值也应该一样
 			JSONObject position2 = item.getJSONObject("puck");
 			JSONObject position1 = item.getJSONObject("translation");
 			//相机
@@ -98,8 +209,12 @@ public class ConvertToVision {
 			floor_location[1] = position2.getDouble("y");
 			floor_location[2] = position2.getDouble("z");
 			//gis坐标
-			double[] _location = TransformGPS.convert(location,dto);
-			double[] _floor_location = TransformGPS.convert(floor_location, dto);
+			log.warn("=============== _location 开始" + i +" =========================");
+//			double[] _location = TransformGPS.convertLocationToGis(location,dto);
+			double[] _location = GisCoordinateUtil.transformLocationToBL(location[0], location[1], calculateEntity);
+			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];
 			location[1] = _location[1];
 			floor_location[0] = _floor_location[0];
@@ -138,7 +253,7 @@ public class ConvertToVision {
 				fileId = "0"+fileId;
 			}
 			laserPano.put("file_id", fileId);
-			
+
 			laserPanos.add(laserPano);
 			//firstView
 			if(i == 0) {
@@ -156,101 +271,116 @@ public class ConvertToVision {
 				log.info("firstVieW保存成功");
 			}
 		}
+		log.info("需要的大地坐标值:结束====================================================================");
 		return laserPanos;
 	}
 
 
-	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){
+//	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){
 		if (!cn.hutool.core.io.FileUtil.isFile(path)) {
 			log.error("文件路径不存在: {}", path);
 			throw new RuntimeException("文件路径不存在");
 		}
 		try {
 			JSONArray panoInfos = readVisionTxt(path);
-			return createVisionToFilter(sceneCode, panoInfos, dto);
+			return createVisionToFilter(sceneCode, panoInfos, calculateEntity);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
@@ -258,21 +388,23 @@ public class ConvertToVision {
 	}
 
 
+
+
 	/**
 	 * 测试热点- vision, filter
 	 * @param args
 	 */
-	public static void main(String[] args) {
-		String inputFilePath = "F:\\test\\project\\age_laser\\laserData\\vision.txt";
-		try {
-			JSONArray panoInfos = readVisionTxt(inputFilePath);
-			JSONArray jsonArray = createVisionToFilter(panoInfos);
-			System.out.println();
-		}
-		catch(Exception e){
-			e.printStackTrace();
-		}
-	}
+//	public static void main(String[] args) {
+//		String inputFilePath = "F:\\test\\project\\age_laser\\laserData\\vision.txt";
+//		try {
+//			JSONArray panoInfos = readVisionTxt(inputFilePath);
+//			JSONArray jsonArray = createVisionToFilter(panoInfos);
+//			System.out.println();
+//		}
+//		catch(Exception e){
+//			e.printStackTrace();
+//		}
+//	}
 
 	/**
 	 * 测试控制点, 还有filter热点
@@ -299,7 +431,7 @@ public class ConvertToVision {
 		dto.setAgeControlLocation2(controlLocation2);
 		dto.setGpsControlCoordinate1(controlCoordinate1);
 		dto.setGpsControlCoordinate2(controlCoordinate2);
-		JSONArray array = createFilter("t11", filterPath, dto);
+//		JSONArray array = createFilter("t11", filterPath, dto);
 		System.out.println("111111111111");
 	}
 }

+ 218 - 136
laser/src/main/java/com/fdkankan/indoor/base/convert/FixRouteMap.java

@@ -2,6 +2,7 @@ package com.fdkankan.indoor.base.convert;
 
 import com.fdkankan.indoor.base.constant.MsgCode;
 import com.fdkankan.indoor.base.exception.BaseRuntimeException;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import lombok.extern.slf4j.Slf4j;
 import net.sf.json.JSONObject;
@@ -50,64 +51,66 @@ 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 {
+//    /**
+//     * 更新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坐标转本地坐标
+//        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;
+//
+//    }
 
-        // 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;
-
-    }
-
     /**
      * 旋转平移
      * @param orientation
@@ -117,10 +120,11 @@ public class FixRouteMap {
      * @return
      * @throws Exception
      */
-    public static  List<JSONObject> getRotate(double orientation, double[] gpsLocation, ControlPointEntity controlPoint, String path)  {
+    public static  List<JSONObject> getRotate(double orientation, double[] gpsLocation, ControlPointCalculateEntity controlPoint, String path)  {
 
         // dataSet.location的gps坐标转本地坐标
-        double[] ageLocation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
+//        double[] ageLocation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
+        double[] ageLocation = GisCoordinateUtil.transformBLToLocation(gpsLocation[0], gpsLocation[1], controlPoint);
 
         // 新的本地坐标, 转出来应该是原点, 很接近0
         JSONObject newLocation = new JSONObject();
@@ -186,83 +190,161 @@ public class FixRouteMap {
 
     }
 
-    /**
-     * 本地测试 修改 Route数据
-     * @param args
-     * @throws Exception
-     */
-    public static void main(String[] args) throws Exception {
-//        FixRouteMap fixRouteMap = new FixRouteMap();
-
-        //对应的是datasets表里的orientation
-        double newOrientation = 0;
-
-        //需要转换,将gis坐标转换本地坐标
-        //将datasets表里location的坐标还原成本地坐标
-//        double[] gpsLocation = {113.595719800031, 22.3666054020125, 0.0};
-        double[] gpsLocation = {113.59571980003058, 22.36660540201251, 0};
-        // 将 gps 同 age
-
-        // 控制点
-        ControlPointEntity controlPoint = new ControlPointEntity();
-        double[] controlCoordinate1 = {113.595725873337,22.366579193007}; //gps坐标
-        double[] controlCoordinate2 = {113.595757230122,22.3666213677456};  //gps坐标
-
-        double[] controlLocation1 = {0.617759,-2.904041};  // 四维看看坐标
-        double[] controlLocation2 = {3.859914,1.75765}; // 四维看看坐标
-
-
-        controlPoint.setGpsControlCoordinate1(controlCoordinate1);
-        controlPoint.setGpsControlCoordinate2(controlCoordinate2);
-        controlPoint.setAgeControlLocation1(controlLocation1);
-        controlPoint.setAgeControlLocation2(controlLocation2);
-        double[] ageLocation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
-
-        // 新的本地坐标
-        JSONObject newLocation = new JSONObject();
-        newLocation.put("x", ageLocation[0]);
-        newLocation.put("y", ageLocation[1]);
-        newLocation.put("z", gpsLocation[2]);
-        log.info("ageLocation: {}", newLocation );
-
-
-
-        double[] newMatrix = getTransfromMatrix(newOrientation, newLocation);
-
-
-        // 读取棋盘的坐标,读文件final_freespace.csv,不要读数据库,最初的坐标
-
-        String path = "F:\\test\\project\\age_laser\\laserData";
-        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);
-
-        // 修改棋盘每个顶点坐标,然后再入库
-        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("]", "");
-            System.out.println(newLine);
-            newRoute.add(newLine);
-        }
-
-        System.out.println("执行完成");
-
-
-    }
+//    /**
+//     * 旋转平移
+//     * @param orientation
+//     * @param gpsLocation
+//     * @param controlPoint
+//     * @param path
+//     * @return
+//     * @throws Exception
+//     */
+//    public static  List<JSONObject> getRotate(double orientation, double[] gpsLocation, ControlPointEntity controlPoint, String path)  {
+//
+//        // 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 = null;
+//        try {
+//            list = FileUtil.readFileByLines2(routePath);
+//            log.info("数据读取成功");
+//
+//            // 修改棋盘每个顶点坐标,然后再入库
+//            List<JSONObject> 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);
+//
+//                StringBuilder lineBuffer = new StringBuilder();
+//
+//                for (int i = 0; i < split.length; i++) {
+//                    if (i>3) {
+//                        lineBuffer.append(split[i]);
+//                        if (i != split.length-1){
+//                            lineBuffer.append(" ");
+//                        }
+//                    }
+//
+//                }
+//                JSONObject linkedIds = new JSONObject();
+//                linkedIds.put("linkedIds", lineBuffer.toString());
+//
+//                linkedIds.put("x", newPoint[0]);
+//                linkedIds.put("y", newPoint[1]);
+//                linkedIds.put("z", newPoint[2]);
+//                linkedIds.put("k", split[3]);
+//                newRoute.add(linkedIds);
+//
+//
+//            }
+//            log.info("数据解析成功");
+//            return newRoute;
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//
+//        return null;
+//
+//    }
+
+//    /**
+//     * 本地测试 修改 Route数据
+//     * @param args
+//     * @throws Exception
+//     */
+//    public static void main(String[] args) throws Exception {
+////        FixRouteMap fixRouteMap = new FixRouteMap();
+//
+//        //对应的是datasets表里的orientation
+//        double newOrientation = 0;
+//
+//        //需要转换,将gis坐标转换本地坐标
+//        //将datasets表里location的坐标还原成本地坐标
+////        double[] gpsLocation = {113.595719800031, 22.3666054020125, 0.0};
+//        double[] gpsLocation = {113.59571980003058, 22.36660540201251, 0};
+//        // 将 gps 同 age
+//
+//        // 控制点
+//        ControlPointEntity controlPoint = new ControlPointEntity();
+//        double[] controlCoordinate1 = {113.595725873337,22.366579193007}; //gps坐标
+//        double[] controlCoordinate2 = {113.595757230122,22.3666213677456};  //gps坐标
+//
+//        double[] controlLocation1 = {0.617759,-2.904041};  // 四维看看坐标
+//        double[] controlLocation2 = {3.859914,1.75765}; // 四维看看坐标
+//
+//
+//        controlPoint.setGpsControlCoordinate1(controlCoordinate1);
+//        controlPoint.setGpsControlCoordinate2(controlCoordinate2);
+//        controlPoint.setAgeControlLocation1(controlLocation1);
+//        controlPoint.setAgeControlLocation2(controlLocation2);
+//        double[] ageLocation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
+//
+//        // 新的本地坐标
+//        JSONObject newLocation = new JSONObject();
+//        newLocation.put("x", ageLocation[0]);
+//        newLocation.put("y", ageLocation[1]);
+//        newLocation.put("z", gpsLocation[2]);
+//        log.info("ageLocation: {}", newLocation );
+//
+//
+//
+//        double[] newMatrix = getTransfromMatrix(newOrientation, newLocation);
+//
+//
+//        // 读取棋盘的坐标,读文件final_freespace.csv,不要读数据库,最初的坐标
+//
+//        String path = "F:\\test\\project\\age_laser\\laserData";
+//        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);
+//
+//        // 修改棋盘每个顶点坐标,然后再入库
+//        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("]", "");
+//            System.out.println(newLine);
+//            newRoute.add(newLine);
+//        }
+//
+//        System.out.println("执行完成");
+//
+//
+//    }
 }

+ 221 - 5
laser/src/main/java/com/fdkankan/indoor/base/convert/GetRoute.java

@@ -8,6 +8,7 @@ import com.fdkankan.indoor.base.convert.kesar.AStar;
 import com.fdkankan.indoor.base.convert.kesar.Coord;
 import com.fdkankan.indoor.base.convert.kesar.MapInfo;
 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 net.sf.json.JSONArray;
@@ -72,6 +73,46 @@ public class GetRoute {
 	private static AStar g_AStar = new AStar();
 
 
+//	/**
+//	 * 读取文件,获取文件内容
+//	 *   F:\test\project\age_laser\routeMap.txt
+//	 *
+//	 *   list 是routeMap的结果集
+//	 * @return
+//	 */
+//	public static JSONArray getRoute(List<String> list, RouteInputDto dto, ControlPointEntity controlPoint){
+//		try {
+//			JSONArray maps = readMap(list, dto);
+//			MapInfo info=new MapInfo(maps,start,end);
+//			List<Node> path = g_AStar.start(info);
+//			JSONArray jsonArray = convertFromPath(path, dto, controlPoint);
+//			return jsonArray;
+//		} catch (Exception e) {
+//			e.printStackTrace();
+//		}
+//		return null;
+//	}
+
+//	/**
+//	 * 读取文件,获取文件内容
+//	 *   F:\test\project\age_laser\routeMap.txt
+//	 *
+//	 *   list 是routeMap的结果集
+//	 * @return
+//	 */
+//	public static JSONArray getRoute(List<String> list, RouteInputDto dto, ControlPointEntity controlPoint){
+//		try {
+//			JSONArray maps = readMap(list, dto);
+//			MapInfo info=new MapInfo(maps,start,end);
+//			List<Node> path = g_AStar.start(info);
+//			JSONArray jsonArray = convertFromPath(path, dto, controlPoint);
+//			return jsonArray;
+//		} catch (Exception e) {
+//			e.printStackTrace();
+//		}
+//		return null;
+//	}
+
 	/**
 	 * 读取文件,获取文件内容
 	 *   F:\test\project\age_laser\routeMap.txt
@@ -79,7 +120,7 @@ public class GetRoute {
 	 *   list 是routeMap的结果集
 	 * @return
 	 */
-	public static JSONArray getRoute(List<String> list, RouteInputDto dto, ControlPointEntity controlPoint){
+	public static JSONArray getRoute(List<String> list, RouteInputDto dto, ControlPointCalculateEntity controlPoint){
 		try {
 			JSONArray maps = readMap(list, dto);
 			MapInfo info=new MapInfo(maps,start,end);
@@ -159,7 +200,7 @@ public class GetRoute {
 	}
 
 
-	private static JSONArray convertFromPath(List<Node> mappath, RouteInputDto dto, ControlPointEntity controlPoint) {
+	private static JSONArray convertFromPath(List<Node> mappath, RouteInputDto dto, ControlPointCalculateEntity controlPoint) {
 		double defaultdistance = 0.36;
 		if(mappath == null||mappath.size() == 0) {
 			return null;
@@ -228,7 +269,8 @@ public class GetRoute {
 
 
 		double[] startPosition = {startX,startY};
-		startPosition = TransformGPS.convert(startPosition, controlPoint);
+//		startPosition = TransformGPS.convertLocationToGis(startPosition, controlPoint);
+		startPosition = GisCoordinateUtil.transformLocationToBL(startPosition[0], startPosition[1], controlPoint);
 		start.put("longitude", startPosition[0]);
 		start.put("latitude", startPosition[1]);
 		start.put("z", startZ);
@@ -252,7 +294,8 @@ public class GetRoute {
 
 			//转经纬度
 			double[] position = {node.coord.x,node.coord.y};
-			position = TransformGPS.convert(position, controlPoint);
+//			position = TransformGPS.convertLocationToGis(position, controlPoint);
+			position = GisCoordinateUtil.transformLocationToBL(position[0], position[1], controlPoint);
 			item.put("longitude", position[0]);
 			item.put("latitude", position[1]);
 
@@ -311,7 +354,8 @@ public class GetRoute {
 		JSONObject endItem = route.getJSONObject(route.size()-1);
 		JSONObject end = new JSONObject();
 		double[] endPosition = {endX,endY};
-		endPosition = TransformGPS.convert(endPosition, controlPoint);
+//		endPosition = TransformGPS.convertLocationToGis(endPosition, controlPoint);
+		endPosition = GisCoordinateUtil.transformLocationToBL(endPosition[0], endPosition[1], controlPoint);
 
 		end.put("longitude", endPosition[0]);
 		end.put("latitude", endPosition[1]);
@@ -331,6 +375,178 @@ public class GetRoute {
 	}
 
 
+//	private static JSONArray convertFromPath(List<Node> mappath, RouteInputDto dto, ControlPointEntity controlPoint) {
+//		double defaultdistance = 0.36;
+//		if(mappath == null||mappath.size() == 0) {
+//			return null;
+//		}
+//
+//		// 起始点
+//		Double startX = dto.getSource_longitude();
+//		Double startY = dto.getSource_latitude();
+//		Double startZ = dto.getSource_z();
+//
+//		// 终点
+//		Double endX = dto.getDestination_longitude();
+//		Double endY = dto.getDestination_latitude();
+//		Double endZ = dto.getDestination_z();
+//
+//		if(mappath.size()>5){
+//
+//			//从前三个和后三个路径点开始优化,防止绕来绕去
+//			Node tempNode = mappath.get(mappath.size()-2);
+//			double dis = g_AStar.calcH(tempNode.coord,new Coord(startX,startY,startZ));
+//			if(dis<defaultdistance){
+//				mappath.remove(mappath.size()-1);
+//			}
+//
+//			tempNode = mappath.get(mappath.size()-2);
+//			dis = g_AStar.calcH(tempNode.coord,new Coord(startX,startY,startZ));
+//			if(dis<defaultdistance){
+//				mappath.remove(mappath.size()-1);
+//			}
+//
+//			tempNode = mappath.get(0);
+//			dis = g_AStar.calcH(tempNode.coord,new Coord(startX,startY,startZ));
+//			if(dis<defaultdistance){
+//				mappath.remove(0);
+//			}
+//
+//			tempNode = mappath.get(0);
+//			dis = g_AStar.calcH(tempNode.coord,new Coord(startX,startY,startZ));
+//			if(dis<defaultdistance){
+//				mappath.remove(0);
+//			}
+//		}
+//
+//		List<Node> path = new ArrayList<Node>();
+////		for(int i = mappath.size()-1;i>-1;--i) {
+////			Node node = mappath.get(i);
+////			path.add(node);
+////		}
+//
+//		// 点的距离
+//		for(int i = mappath.size()-1;i>-1;) {
+//			Node node = mappath.get(i);
+//			if(mappath.size()>4){
+//				i -= 3;
+//			}
+//			else{
+//				--i;
+//			}
+//			path.add(node);
+//		}
+//
+//		JSONArray route = new JSONArray();
+//
+//		//起点不在path上,path的第一个点对应的是格子
+//		JSONObject start = new JSONObject();
+//
+//
+//		double[] startPosition = {startX,startY};
+//		startPosition = TransformGPS.convertLocationToGis(startPosition, controlPoint);
+//		start.put("longitude", startPosition[0]);
+//		start.put("latitude", startPosition[1]);
+//		start.put("z", startZ);
+//		Double[] location = new Double[3];
+//
+//
+//		location[0] = startPosition[0];
+//		location[1] = startPosition[1];
+//		location[2] = startZ;
+//
+//		start.put("location", location);
+//		start.put("distance", 0);
+//		start.put("distance_to_previous", 0);
+//		start.put("instruction", null);
+//		route.add(start);
+//
+//		Double[] virtualEndPosition = new Double[3];
+//		for(int i=0;i<path.size();++i) {
+//			Node node = path.get(i);
+//			JSONObject item = new JSONObject();
+//
+//			//转经纬度
+//			double[] position = {node.coord.x,node.coord.y};
+//			position = TransformGPS.convertLocationToGis(position, controlPoint);
+//			item.put("longitude", position[0]);
+//			item.put("latitude", position[1]);
+//
+//
+//			item.put("z", node.coord.z);
+//			location = new Double[3];
+//
+//
+//			location[0] = position[0];
+//			location[1] = position[1];
+//
+//			location[2] = node.coord.z;
+//			item.put("location", location);
+//			item.put("id", node.id);
+//
+//			JSONObject instruction = null;
+//
+//			virtualEndPosition[0] = node.coord.x;
+//			virtualEndPosition[1] = node.coord.y;
+//			virtualEndPosition[2] = node.coord.z;
+//
+//			if(i == 0) {
+//				item.put("distance", g_AStar.calcH(node.coord,new Coord(startX,startY,startZ)));
+//				item.put("distance_to_previous", g_AStar.calcH(node.coord,new Coord(startX,startY,startZ)));
+//				item.put("instruction", instruction);
+//
+//				instruction = new JSONObject();
+//				instruction.put("type", "source_projection_to_navgraph");
+//				item.put("instruction", instruction);
+//			} else {
+//				Node prenode = path.get(i-1);
+//				JSONObject preitem = route.getJSONObject(i);
+//				Double distance_to_previous = g_AStar.calcH(node.coord,prenode.coord);
+//				item.put("distance_to_previous", distance_to_previous);
+//				Double distance = preitem.getDouble("distance")+distance_to_previous;
+//				item.put("distance", distance);
+//				if(i == path.size()-1) {
+//					instruction = new JSONObject();
+//					instruction.put("type", "destination_projection_to_navgraph");
+//					item.put("instruction", instruction);
+//
+////					virtualEndPosition[0] = node.coord.x;
+////					virtualEndPosition[1] = node.coord.y;
+////					virtualEndPosition[2] = node.coord.z;
+//
+//				}
+//				else {
+//					item.put("instruction", instruction);
+//				}
+//				System.out.println("distance:"+distance_to_previous);
+//			}
+//
+//			route.add(item);
+//		}
+//
+//		JSONObject endItem = route.getJSONObject(route.size()-1);
+//		JSONObject end = new JSONObject();
+//		double[] endPosition = {endX,endY};
+//		endPosition = TransformGPS.convertLocationToGis(endPosition, controlPoint);
+//
+//		end.put("longitude", endPosition[0]);
+//		end.put("latitude", endPosition[1]);
+//		end.put("z", endZ);
+//		location = new Double[3];
+//		location[0] = endPosition[0];
+//		location[1] = endPosition[1];
+//		location[2] = endZ;
+//		end.put("location", location);
+//		Double enddistance = g_AStar.calcH(new Coord(virtualEndPosition[0],virtualEndPosition[1],virtualEndPosition[2]),new Coord(endX,endY,endZ));
+//		end.put("distance", enddistance+(float)endItem.getDouble("distance"));
+//		end.put("distance_to_previous", enddistance);
+//		end.put("instruction", null);
+//		route.add(end);
+//
+//		return route;
+//	}
+
+
 	private static JSONArray readMap() throws Exception {
 		List<String> list = FileUtil.readFileByLines2(inputFilePath);
 		JSONArray maps = new JSONArray();

+ 3 - 0
laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateTransform.java

@@ -218,4 +218,7 @@ public  class GisCoordinateTransform {
         output[1] = latitude1 / iPI;
         return output;
     }
+
+
+
 }

+ 299 - 265
laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateUtil.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.indoor.base.convert.GisCoordinateTransform;
 import com.fdkankan.indoor.base.exception.BaseRuntimeException;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
@@ -22,6 +23,90 @@ public class GisCoordinateUtil {
     private final static String coordCode4326 = "EPSG:4326";
     private final static String coordCode3857 = "EPSG:3857";
 
+
+
+    private   static  double dx1;//x方向增量
+    private  static  double dy1;//y方向增量
+    private  static  double rotation1;//旋转角度
+    private  static  double scale1;//缩放比例
+
+    private   static  double dx2;//x方向增量
+    private  static  double dy2;//y方向增量
+    private  static  double rotation2;//旋转角度
+    private  static  double scale2;//缩放比例
+
+
+
+
+
+
+    /**
+     * 本地坐标转经纬度
+     * 这里可以获取平面坐标, 结果是很大的
+     * @param loctionX
+     * @param loctionY
+     * @return
+     */
+//    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);
+//        Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), rotation2, scale2, dx2, dy2);
+//        log.info("本地坐标转平面坐标输出结果:{}, {}", resultPoint.getX(),resultPoint.getY());
+//        log.warn("本地转经纬度 平面 end ====");
+//        return GisCoordinateTransform.convertByProj4(resultPoint.getX(),resultPoint.getY(),"EPSG:4547","EPSG:4490");
+//    }
+
+    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());
+        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 ====");
+        return GisCoordinateTransform.convertByProj4(resultPoint.getX(),resultPoint.getY(),"EPSG:4547","EPSG:4490");
+    }
+
+
+    /**
+     * 经纬度转本地坐标
+     * @param lon 经度 十进制度
+     * @param lat 纬度 十进制度
+     * @return
+     */
+//    public static  double[] transformBLToLocation(double lon,double lat){
+//        double[] gauss= GisCoordinateTransform.convertByProj4(lon, lat,"EPSG:4490","EPSG:4547");
+//        log.info("经纬度转本地坐标,大地坐标:{}, {}", gauss[0],gauss[1]);
+//        Point point = new Point(gauss[0],gauss[1]);
+//        Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), rotation1, scale1, dx1, dy1);
+//
+//        double[] location=new double[2];
+//        location[0]=resultPoint.getX();
+//        location[1]=resultPoint.getY();
+//        return location;
+//    }
+
+
+    public static  double[] transformBLToLocation(double lon,double lat, ControlPointCalculateEntity dto){
+        double[] gauss= GisCoordinateTransform.convertByProj4(lon, lat,"EPSG:4490","EPSG:4547");
+        log.info("经纬度转本地坐标,大地坐标:{}, {}", gauss[0],gauss[1]);
+        Point point = new Point(gauss[0],gauss[1]);
+        Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), dto.getRotation1(), dto.getScale1(), dto.getDx1(), dto.getDy1());
+
+        double[] location=new double[2];
+        location[0]=resultPoint.getX();
+        location[1]=resultPoint.getY();
+        return location;
+    }
+
+    /**
+
     /**
      * 解析控制点文件
      *
@@ -70,103 +155,13 @@ public class GisCoordinateUtil {
         double blat = bPointCoordinate.getDouble("latitude");
         double bX = bPointLocation.getDouble("x");
         double bY = bPointLocation.getDouble("y");
-        calculateVariable(alon, alat, aX, aY, blon, blat, bX, bY);
+//        calculateVariable(alon, alat, aX, aY, blon, blat, bX, bY);
         //  System.out.println(alon+" "+alat+" "+aX+" "+aY+" "+blon+" "+blat+" "+bX+" "+bY);
     }
 
-    /**
-     * 控制点
-     * 根据两个控制点计算增量及用于计算角度的两个向量
-     *
-     * @param alon
-     * @param alat
-     * @param aX
-     * @param aY
-     * @param blon
-     * @param blat
-     * @param bX
-     * @param bY
-     */
-    public static void calculateVariable(double alon, double alat, double aX, double aY, double blon, double blat, double bX, double bY)  {
-
-        double[] a = GisCoordinateTransform.convert2000BLToGauss(alon, alat);
-        double[] b = GisCoordinateTransform.convert2000BLToGauss(blon, blat);
-
-        dx = a[0] - aX;
-        dy = a[1] - aY;
-        locationplaneVector = new double[2];
-        locationplaneVector[0] = a[0] - b[0];
-        locationplaneVector[1] = a[1] - b[1];
-        geographicplaneVector = new double[2];
-        geographicplaneVector[0] = aX - bX;
-        geographicplaneVector[1] = aY - bY;
-        centerLon = GisCoordinateTransform.getZone3CenterLon(alon);
-    }
 
 
-    /**
-     * 本地坐标转经纬度
-     *
-     * @param loctionX
-     * @param loctionY
-     * @return
-     */
-    public static double[] transformLocationToBL(double loctionX, double loctionY) {
-        double x1 = locationplaneVector[0];
-        double y1 = locationplaneVector[1];
-        double x2 = geographicplaneVector[0];
-        double y2 = geographicplaneVector[1];
-//        double tana1=y1/x1;
-//        double tana2=y2/x2;
-        double a1 = Math.atan2(y1, x1);
-        double a2 = Math.atan2(y2, x2);
-        double a = a2 - a1;
-        double sinazimuth, cosazimuth;
-        cosazimuth = Math.cos(a);
-        sinazimuth = Math.sin(a);
-        double resultX = loctionY * sinazimuth + loctionX * cosazimuth;
-        double resultY = loctionY * cosazimuth - loctionX * sinazimuth;
-        double x = resultX + dx;
-        double y = resultY + dy;
-
-
-//        return GisCoordinateTransform.Convert2000GaussToBL(x,y,centerLon);
-//        return GisCoordinateTransform.convertByProj4(x,y, coordCode3857, coordCode4326);
-        return GisCoordinateTransform.convert2000GaussToBL(x, y, centerLon);
-    }
-
 
-    /**
-     * 经纬度转本地坐标
-     *
-     * @param lon 经度 十进制度
-     * @param lat 纬度 十进制度
-     * @return
-     */
-    public static double[] transformBLToLocation(double lon, double lat) {
-
-
-        double[] gauss = GisCoordinateTransform.convert2000BLToGauss(lon, lat);
-        double x1 = locationplaneVector[0];
-        double y1 = locationplaneVector[1];
-        double x2 = geographicplaneVector[0];
-        double y2 = geographicplaneVector[1];
-        double a1 = Math.atan2(y1, x1);
-        double a2 = Math.atan2(y2, x2);
-//        double a=a1-a2;
-        double a = 0;
-        double sinazimuth, cosazimuth;
-        cosazimuth = Math.cos(a);
-        sinazimuth = Math.sin(a);
-        double resultX = gauss[1] * sinazimuth + gauss[0] * cosazimuth;
-        double resultY = gauss[1] * cosazimuth - gauss[0] * sinazimuth;
-        double x = resultX - dx;
-        double y = resultY - dy;
-        double[] location = new double[2];
-        location[0] = x;
-        location[1] = y;
-        return location;
-    }
 
 
     /**
@@ -176,195 +171,31 @@ public class GisCoordinateUtil {
      * @param dto      控制点
      * @return
      */
-    public static double[] convertGpsToLocation(double[] position, ControlPointEntity dto) {
-        double[] controlLocation1 = dto.getAgeControlLocation1();
-        double[] controlLocation2 = dto.getAgeControlLocation2();
-
-        double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
-        double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
-        try {
-            GisCoordinateUtil.calculateVariable(controlCoordinate1[0], controlCoordinate1[1], controlLocation1[0], controlLocation1[1], controlCoordinate2[0], controlCoordinate2[1], controlLocation2[0], controlLocation2[1]);
-            double[] d = GisCoordinateUtil.transformBLToLocation(position[0], position[1]);
-            return d;
-        } catch (RuntimeException e) {
-            log.error("坐标转换输入参数有误,请检查");
-            e.printStackTrace();
-        }
-       return null;
-    }
-
-//    /**
-//     * 本地坐标转经纬度
-//     *
-//     * @param position 经纬度
-//     * @param dto      控制点
-//     * @return
-//     */
-//    public static double[] convertLocationToGps(double[] position, ControlPointEntity dto) {
+//    public static double[] convertGpsToLocation(double[] position, ControlPointEntity dto) {
 //        double[] controlLocation1 = dto.getAgeControlLocation1();
 //        double[] controlLocation2 = dto.getAgeControlLocation2();
 //
 //        double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
 //        double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
-//        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;
-//    }
-
-
-    /**
-     *  两个控制点的纠偏,已知两个控制点的未纠偏前的经纬度和控制点的真实经纬度,求真实位置相对于未纠偏之前的旋转 角度
-     * @param relativePoint1     【经度,纬度】   [113,22]  ,页面输入的相对坐标转gis坐标
-     * @param absolutelyPoint1   【经度,纬度】   [113,22]  绝对坐标:用页面输入的坐标
-     * @param relativePoint2        【经度,纬度】   [113,22] ,页面输入的相对坐标转gis坐标
-     * @param absolutelyPoint2      【经度,纬度】   [113,22] 绝对坐标:用页面输入的坐标
-     * @return 弧度 设置到dataSet.orientation
-     */
-//    private static double getAngle(double[] relativePoint1,double[] absolutelyPoint1,double[] relativePoint2,double[] absolutelyPoint2){
-//        double[]  relativeVector=new double[2];
-//        double[]  absolutelyVector=new double[2];
-//        relativeVector[0]=relativePoint2[0]-relativePoint1[0];
-//        relativeVector[1]=relativePoint2[1]-relativePoint1[1];
-//        absolutelyVector[0]=absolutelyPoint2[0]-absolutelyPoint1[0];
-//        absolutelyVector[1]=absolutelyPoint2[1]-absolutelyPoint1[1];
-//        double a1=Math.atan2(relativeVector[1], relativeVector[0]);
-//        double a2=Math.atan2(absolutelyVector[1], absolutelyVector[0]);
-//        return  a1-a2;
-//    }
-
-    /**
-     * 获取弧度
-     *
-     * @param dto
-     * @return
-     */
-//    public static double getAngle(ControlPointEntity dto){
-//
-//        double[] relativePoint1 = dto.getRelativePoint1();
-//        double[] absolutelyPoint1 = dto.getGpsControlCoordinate1();
-//        double[] relativePoint2 = dto.getRelativePoint2();
-//        double[] absolutelyPoint2 = dto.getGpsControlCoordinate2();
-//        return getAngle(relativePoint1, absolutelyPoint1, relativePoint2, absolutelyPoint2);
-//
-//    }
-
-
-    /**
-     * 获取弧度, 采用本地坐标
-     *
-     * @param dto
-     * @return
-     */
-//    public static double getAngleOrientation(ControlPointEntity dto) {
-//
-//        //gps转本地坐标
-//        double[] defaultP1 = convertGpsToLocation(dto.getGpsControlCoordinate1(), dto);
-//        double[] defaultP2 = convertGpsToLocation(dto.getGpsControlCoordinate2(), dto);
-//
-//        double[] ageControlLocation1 = dto.getAgeControlLocation1();
-//        double[] ageControlLocation2 = dto.getAgeControlLocation2();
-//
-//        return getAngle(defaultP1, defaultP2, ageControlLocation1, ageControlLocation2);
-//
-//    }
-
-    //采用本地坐标
-
-    /**
-     * 获取弧度, 采用本地坐标
-     * P1,P2是传过来的本地坐标
-     * defaultP1和defaultP2是传过来的gis坐标通过当前的控制点转换成新的本地坐标
-     *
-     * @param defaultP1
-     * @param defaultP2
-     * @param P1        P1,P2是传过来的本地坐标
-     * @param P2
-     * @return
-     */
-//    private static double getAngle(double[] defaultP1, double[] defaultP2, double[] P1, double[] P2) {
-//        double dx = P1[0] - defaultP1[0];
-//        double dy = P1[1] - defaultP1[1];
-//
-//        P2[0] = P2[0] - dx;
-//        P2[1] = P2[1] - dy;
-//
-//        //p1,p2,defaultP2
-//        double angle = Angle(P1, P2, defaultP2);
-//        return angle;
-//    }
-//
-//    private static double Angle(double[] p, double[] p1, double[] p2) {
-//        double cosfi = 0, fi = 0, norm = 0;
-//        double dsx = p1[0] - p[0];
-//        double dsy = p1[1] - p[1];
-//        double dex = p2[0] - p[0];
-//        double dey = p2[1] - p[1];
-//
-//        cosfi = dsx * dex + dsy * dey;
-//        norm = (dsx * dsx + dsy * dsy) * (dex * dex + dey * dey);
-//        cosfi /= Math.sqrt(norm);
-//
-//        if (cosfi >= 1.0) return 0;
-//        //if (cosfi <= -1.0) return Math.PI;
-//        if (cosfi <= -1.0) return 180;
-//        fi = Math.acos(cosfi);
-//
-//        if (180 * fi / Math.PI < 180) {
-//            return fi;
-//        } else {
-//            return 2 * Math.PI - fi;
+//        try {
+////            log.info("输入控制点3: {}, {}, {}, {}, {}, {}, {}, {}", controlCoordinate1[0], controlCoordinate1[1], controlLocation1[0], controlLocation1[1], controlCoordinate2[0], controlCoordinate2[1], controlLocation2[0], controlLocation2[1]);
+////            GisCoordinateUtil.calculateVariable(controlCoordinate1[0], controlCoordinate1[1], controlLocation1[0], controlLocation1[1], controlCoordinate2[0], controlCoordinate2[1], controlLocation2[0], controlLocation2[1]);
+//            double[] d = GisCoordinateUtil.transformBLToLocation(position[0], position[1]);
+//            return d;
+//        } catch (RuntimeException e) {
+//            log.error("坐标转换输入参数有误,请检查");
+//            e.printStackTrace();
 //        }
+//       return null;
 //    }
 
 
-    /**
-     * 采用本地坐标
-     * 获取dataSet.orientation:弧度
-     * @param dto 控制点
-     * @return
-     */
-    public static double getDataSetOrientation(ControlPointEntity dto) {
 
-        //web输入控制点的gis坐标
-        double[] webGisP1 = dto.getGpsControlCoordinate1();
-        double[] webGisP2 = dto.getGpsControlCoordinate2();
-
-
-       // 将算法部提供控制点赋值,用于计算
-        double[] defaultGisP1 = dto.getDefaultGisP1();
-        double[] defaultGisP2 = dto.getDefaultGisP2();
-        double[] defaultLocation1 = dto.getDefaultLocation1();
-        double[] defaultLocation2 = dto.getDefaultLocation2();
-        if (defaultGisP1 == null || defaultGisP2 == null || defaultLocation1 == null || defaultLocation2 == null) {
-            log.error("默认控制点数据有空值, 请检查默认控制点。尝试重算解决");
-            throw new BaseRuntimeException("默认控制点数据有空值, 请检查默认控制点。尝试重算解决");
-        }
 
-        dto.setGpsControlCoordinate1(defaultGisP1);
-        dto.setGpsControlCoordinate2(defaultGisP2);
-        dto.setAgeControlLocation1(defaultLocation1);
-        dto.setAgeControlLocation2(defaultLocation2);
-        log.info("准备转换坐标");
-        // defaultP1,defaultP2使用的是算法部提供的控制点得出结果, 人工输入gis坐标转 本地坐标
-        double[] defaultP1 = convertGpsToLocation(webGisP1, dto);
-        double[] defaultP2 = convertGpsToLocation(webGisP2, dto);
-        log.info("转换本地坐标完成");
 
 
 
-        // web输入控制点的本地坐标
-        double[] ageControlLocation1 = dto.getAgeControlLocation1();
-        double[] ageControlLocation2 = dto.getAgeControlLocation2();
 
-        return getOrientation(defaultP1, defaultP2, ageControlLocation1, ageControlLocation2);
-
-    }
-
-
-    @Test
-    public void test11(){
-        getDataSetOrientation(new ControlPointEntity());
-    }
 
 
 
@@ -415,6 +246,209 @@ public class GisCoordinateUtil {
     }
 
 
+    /**
+     * 求方位角度
+     * @param x
+     * @param y
+     * @return
+     */
+    private static  double azimyth(double x,double y){
+        double returnValue=0;
+        if(y>0&&x>0){
+            returnValue=Math.atan(y/x);
+        }else if(y>0&&x<0){
+            returnValue=Math.PI- Math.atan(y/Math.abs(x));
+        }else if(y<0&&x<0){
+            returnValue=Math.PI+Math.atan(y/x);
+        }else if(y<0&&x>0){
+            returnValue=2*Math.PI-Math.atan(Math.abs(y)/x);
+        }
+        return  returnValue;
+    }
+
+
+
+
+
+
+//    /**
+//     * 控制点初始化作用, 只有控制点变化, 才会调用一次, 以后坐标转换都是基于这个值使用
+//     * @param alon
+//     * @param alat
+//     * @param aX
+//     * @param aY
+//     * @param blon
+//     * @param blat
+//     * @param bX
+//     * @param bY
+//     */
+//    public static  void calculateVariable (double alon,double alat,double aX,double aY,double blon,double blat,double bX,double bY){
+//
+//
+//        try {
+//            double[] a= new double[0];
+//            a = GisCoordinateTransform.convertByProj4(alon, alat,"EPSG:4490","EPSG:4547");
+//            double[] b= GisCoordinateTransform.convertByProj4(blon, blat,"EPSG:4490","EPSG:4547");
+//            log.info("经度2、纬度2: {}, {}", alon, alat );
+//            log.info("经度4、纬度4: {}, {}", blon, blat );
+//            log.info("大地2: {}, {}", a[0], a[1]);
+//            log.info("大地4: {}, {}", b[0], b[1]);
+//            Point point1 = new Point(a[0],a[1]);
+//            Point point2 = new Point(b[0],b[1]);
+//            Point newPoint1 = new Point(aX,aY);
+//            Point newPoint2 = new Point(bX,bY);
+//            log.info("========== start calculateVariable =================");
+//            // 2021-09-13 修改:前后对调一下
+//            rotation1 = Math.toRadians(AffineTransform.getAngle(point1 , point2 ) - AffineTransform.getAngle(newPoint1 , newPoint2 ));
+//            scale1 = AffineTransform.getScale( point1 , newPoint1 , point2 , newPoint2);
+////            log.info("rotation1: {}", rotation1);
+//            dx1 = AffineTransform.getXTranslation( point1 ,newPoint1, rotation1, scale1);
+//            dy1 = AffineTransform.getYTranslation( point1 ,newPoint1, rotation1, scale1);
+//            log.warn("rotation1: {}", rotation1);
+//            log.warn("scale1: {}", scale1);
+//            log.warn("tx1: {}", dx1);
+//            log.warn("ty1: {}", dy1);
+//            rotation2 = Math.toRadians(AffineTransform.getAngle(newPoint1 , newPoint2 ) - AffineTransform.getAngle(point1 , point2 ));
+////            log.info("rotation2: {}", rotation2);
+//            scale2 = AffineTransform.getScale( newPoint1 , point1 , newPoint2 , point2);
+//            dx2 = AffineTransform.getXTranslation( newPoint1 ,point1, rotation2, scale1);
+//            dy2 = AffineTransform.getYTranslation( newPoint1 ,point1, rotation2, scale1);
+//
+//            log.warn("rotation2: {}", rotation2);
+//            log.warn("scale2: {}", scale2);
+//            log.warn("tx2: {}", dx2);
+//            log.warn("ty2: {}", dy2);
+//
+//            log.info("========== end calculateVariable =================");
+//        } catch (RuntimeException e) {
+//            e.printStackTrace();
+//        }
+//    }
+
+
+    /**
+     * 控制点初始化作用, 只有控制点变化, 才会调用一次, 以后坐标转换都是基于这个值使用
+//     * @param alon
+//     * @param alat
+//     * @param aX
+//     * @param aY
+//     * @param blon
+//     * @param blat
+//     * @param bX
+//     * @param bY
+     */
+//    public static  void calculateVariable (double alon,double alat,double aX,double aY,double blon,double blat,double bX,double bY){
+    public static ControlPointCalculateEntity calculateVariable (ControlPointEntity dto){
+        double[] controlLocation1 = dto.getAgeControlLocation1();
+        double[] controlLocation2 = dto.getAgeControlLocation2();
+
+        double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
+        double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
+
+        double alon = controlCoordinate1[0];
+        double alat = controlCoordinate1[1];
+        double aX = controlLocation1[0];
+        double aY =  controlLocation1[1];
+        double blon = controlCoordinate2[0];
+        double blat = controlCoordinate2[1];
+        double bX = controlLocation2[0];
+        double bY = controlLocation2[1];
+
+        try {
+            double[] a= new double[0];
+            a = GisCoordinateTransform.convertByProj4(alon, alat,"EPSG:4490","EPSG:4547");
+            double[] b= GisCoordinateTransform.convertByProj4(blon, blat,"EPSG:4490","EPSG:4547");
+            Point point1 = new Point(a[0],a[1]);
+            Point point2 = new Point(b[0],b[1]);
+            Point newPoint1 = new Point(aX,aY);
+            Point newPoint2 = new Point(bX,bY);
+            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);
+            double dx1 = AffineTransform.getXTranslation( point1 ,newPoint1, rotation1, scale1);
+            double dy1 = AffineTransform.getYTranslation( point1 ,newPoint1, rotation1, scale1);
+
+            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);
+//            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);
+            double dy2 = AffineTransform.getYTranslation( newPoint1 ,point1, rotation2, scale2);
+            log.info("输出结果 dy2:{}, {}", dy2);
+
+
+            ControlPointCalculateEntity entity = new ControlPointCalculateEntity();
+            entity.setRotation1(rotation1);
+            entity.setScale1(scale1);
+            entity.setDx1(dx1);
+            entity.setDy1(dy1);
+
+
+            entity.setRotation2(rotation2);
+            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");
+
+            return entity;
+        } catch (RuntimeException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    /**
+     * 控制点赋值,初始化
+     */
+//    public void initAssign(ControlPointEntity dto){
+//        double[] controlLocation1 = dto.getAgeControlLocation1();
+//        double[] controlLocation2 = dto.getAgeControlLocation2();
+//
+//        double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
+//        double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
+//
+//        log.info("输入控制点1: {}, {}, {}, {}, {}, {}, {}, {}", controlCoordinate1[0], controlCoordinate1[1], controlLocation1[0], controlLocation1[1], controlCoordinate2[0], controlCoordinate2[1], controlLocation2[0], controlLocation2[1]);
+//        GisCoordinateUtil.calculateVariable (
+//                controlCoordinate1[0],controlCoordinate1[1],
+//                controlLocation1[0],controlLocation1[1],
+//                controlCoordinate2[0],controlCoordinate2[1],
+//                controlLocation2[0],controlLocation2[1]);
+//    }
+
+
+
+    @Test
+    public void testcp(){
+        double[]  a1 = GisCoordinateTransform.convertByProj4(113.594635361111 , 22.367307611111 ,"EPSG:4490","EPSG:4547");
+        double[]  a2 = GisCoordinateTransform.convertByProj4(113.594615305556 , 22.367325305556 ,"EPSG:4490","EPSG:4547");
+        double[]  a3 = GisCoordinateTransform.convertByProj4(113.594646722222 , 22.367337138889 ,"EPSG:4490","EPSG:4547");
+        double[]  a4 = GisCoordinateTransform.convertByProj4(113.594664777778 , 22.367347694444 ,"EPSG:4490","EPSG:4547");
+        log.info("a1: {}, {}", a1[0], a1[1]);
+        log.info("a2: {}, {}", a2[0], a2[1]);
+        log.info("a3: {}, {}", a3[0], a3[1]);
+        log.info("a4: {}, {}", a4[0], a4[1]);
+    }
+
+
+
 
 
 }

+ 124 - 91
laser/src/main/java/com/fdkankan/indoor/base/convert/ModifyCloud.java

@@ -3,6 +3,7 @@ package com.fdkankan.indoor.base.convert;
 import java.io.IOException;
 
 
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
@@ -64,50 +65,62 @@ public class ModifyCloud {
 		return result;
 	}
 
-	//把原点(0,0,0)的坐标转换成gps坐标
-	public static double[] convertFromOrigin(ControlPointEntity dto) {
-		double[] location = {0,0,0};
-		location = TransformGPS.convert(location, dto);
-		return location;
-	}
-
+//	//把原点(0,0,0)的坐标转换成gps坐标
+//	public static double[] convertFromOrigin(ControlPointEntity dto) {
+//		double[] location = {0,0,0};
+//		location = TransformGPS.convertLocationToGis(location, dto);
+//		return location;
+//	}
 
-	public static double[] convertFromOrigin() {
+	//把原点(0,0,0)的坐标转换成gps坐标
+	public static double[] convertFromOrigin(ControlPointCalculateEntity dto) {
 		double[] location = {0,0,0};
-		location = TransformGPS.convert(location);
+//		location = TransformGPS.convertLocationToGis(location, dto);
+		location = GisCoordinateUtil.transformLocationToBL(location[0], location[1], dto);
 		return location;
 	}
 
-	//把boundingbox的顶点和中心点转换成gps坐标
-	public static JSONObject convertFromBoundingBox(JSONObject boundingBox, ControlPointEntity dto) {
-		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")};
 
+//	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")};
+//		double[] min = {boundingBox.getDouble("minX"),boundingBox.getDouble("minY"),boundingBox.getDouble("minZ")};
+//		double[] centre = {boundingBox.getDouble("centreX"),boundingBox.getDouble("centreY"),boundingBox.getDouble("centreZ")};
+//
+//
+//		max = TransformGPS.convertLocationToGis(max, dto);
+//		min = TransformGPS.convertLocationToGis(min, dto);
+//		centre = TransformGPS.convertLocationToGis(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", newCentre);
+//		return result;
+//	}
 
-		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", newCentre);
-		return result;
-	}
 
 	//把boundingbox的顶点和中心点转换成gps坐标
-	public static JSONObject convertFromBoundingBox(JSONObject boundingBox) {
+	public static JSONObject convertFromBoundingBox(JSONObject boundingBox, ControlPointCalculateEntity dto) {
 		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);
+//		max = TransformGPS.convertLocationToGis(max, dto);
+//		min = TransformGPS.convertLocationToGis(min, dto);
+//		centre = TransformGPS.convertLocationToGis(centre, dto);
+		max = GisCoordinateUtil.transformLocationToBL(max[0], max[1], dto);
+		min = GisCoordinateUtil.transformLocationToBL(min[0], max[1], dto);
+		centre = GisCoordinateUtil.transformLocationToBL(centre[0], centre[1], dto);
 		// 处理centreZ
 		double[] newCentre = {centre[0],centre[1], boundingBox.getDouble("centreZ")} ;
 
@@ -118,6 +131,26 @@ public class ModifyCloud {
 		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;
+//	}
+
 
     /**
      * 2021-08-05
@@ -127,67 +160,67 @@ public class ModifyCloud {
 	 *
      * @param args
      */
-	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);
-
-            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);
-
-            Double[] gpsMax = getKey1(resJson, "max");
-            Double[] gpsMin = getKey1(resJson, "min");
-            Double[] gpsCentre = getKey1(resJson, "centre");
-
-
-
-			JSONObject gpsJson = convertFromBoundingBox(boundingbox);//boundingbox_min,boundingbox_max,centre
-			Object max = gpsJson.get("max");
-			Object min = gpsJson.get("min");
-			Object centre = gpsJson.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);
+//
+//            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);
+//
+//            Double[] gpsMax = getKey1(resJson, "max");
+//            Double[] gpsMin = getKey1(resJson, "min");
+//            Double[] gpsCentre = getKey1(resJson, "centre");
+//
+//
+//
+//			JSONObject gpsJson = convertFromBoundingBox(boundingbox);//boundingbox_min,boundingbox_max,centre
+//			Object max = gpsJson.get("max");
+//			Object min = gpsJson.get("min");
+//			Object centre = gpsJson.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();
+//		}
+//
+//	}
 
     /**
      * json数组转 double[]

+ 19 - 0
laser/src/main/java/com/fdkankan/indoor/base/convert/Point.java

@@ -0,0 +1,19 @@
+package com.fdkankan.indoor.base.convert;
+public class Point {
+	private double x;
+    private double y;
+    
+	public Point(double x, double y)
+	{
+		this.x = x;
+		this.y = y;
+	}
+    
+    public double getX() {
+    	return this.x;
+    }
+    
+    public double getY() {
+    	return this.y;
+    }
+}

+ 58 - 67
laser/src/main/java/com/fdkankan/indoor/base/convert/TransformGPS.java

@@ -2,10 +2,12 @@ package com.fdkankan.indoor.base.convert;
 
 
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
+import lombok.extern.slf4j.Slf4j;
 
 /***
  * 控制点(三维坐标)坐标转经纬度
  */
+@Slf4j
 public class TransformGPS {
 	
 	public static final String CRS = "EPSG:4490";
@@ -27,87 +29,76 @@ public class TransformGPS {
 
 	/**
 	 * transformLocationToBL这个方法把高度省略了
+	 * 本地转Gis
 	 * @param position
 	 * @param dto
 	 * @return
 	 */
-	public static double[] convert(double[] position, ControlPointEntity dto) {
-
-		double[] controlLocation1 = dto.getAgeControlLocation1();
-		double[] controlLocation2 = dto.getAgeControlLocation2();
-
-		double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
-		double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
-
-
-		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[][] positions,  ControlPointEntity dto){
-
-		double[] controlLocation1 = dto.getAgeControlLocation1();
-		double[] controlLocation2 = dto.getAgeControlLocation2();
-
-		double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
-		double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
-
-
-		GisCoordinateUtil.calculateVariable (
-				controlCoordinate1[0],controlCoordinate1[1],
-				controlLocation1[0],controlLocation1[1],
-				controlCoordinate2[0],controlCoordinate2[1],
-				controlLocation2[0],controlLocation2[1]);
-		double[][] result = new double[positions.length][2];
-		for(int i=0;i<positions.length;++i) {
-			double[] d = GisCoordinateUtil.transformLocationToBL(positions[i][0], positions[i][1]);
-			result[i] = d;
-
-		}
+//	public static double[] convertLocationToGis(double[] position) {
+//		double[] d = GisCoordinateUtil.transformLocationToBL(position[0], position[1]);
+//		log.info("输出结果:{}, {}", d[0], d[1]);
+//		return d;
+//
+//	}
 
-		return result;
-	}
+//	public static double[][] convert(double[][] positions,  ControlPointEntity dto){
+//
+//		double[] controlLocation1 = dto.getAgeControlLocation1();
+//		double[] controlLocation2 = dto.getAgeControlLocation2();
+//
+//		double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
+//		double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
+//
+//		log.info("输入控制点2: {}, {}, {}, {}, {}, {}, {}, {}", controlCoordinate1[0], controlCoordinate1[1], controlLocation1[0], controlLocation1[1], controlCoordinate2[0], controlCoordinate2[1], controlLocation2[0], controlLocation2[1]);
+//		GisCoordinateUtil.calculateVariable (
+//				controlCoordinate1[0],controlCoordinate1[1],
+//				controlLocation1[0],controlLocation1[1],
+//				controlCoordinate2[0],controlCoordinate2[1],
+//				controlLocation2[0],controlLocation2[1]);
+//		double[][] result = new double[positions.length][2];
+//		for(int i=0;i<positions.length;++i) {
+//			double[] d = GisCoordinateUtil.transformLocationToBL(positions[i][0], positions[i][1]);
+//			result[i] = d;
+//
+//		}
+//
+//		return result;
+//	}
 
 
 
 
 
-	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){
-	   	GisCoordinateUtil.calculateVariable (controlCoordinate1[0],controlCoordinate1[1],controlLocation1[0],controlLocation1[1],controlCoordinate2[0],controlCoordinate2[1],controlLocation2[0],controlLocation2[1]);
-        double[][] result = new double[positions.length][2];
-	   	for(int i=0;i<positions.length;++i) {
-	   		double[] d = GisCoordinateUtil.transformLocationToBL(positions[i][0], positions[i][1]);
-	   		result[i] = d;
-	   		
-	   	}
-	   	
-        return result;
-	}
+//	private static double[][] convert(double[][] positions){
+//	   	GisCoordinateUtil.calculateVariable (controlCoordinate1[0],controlCoordinate1[1],controlLocation1[0],controlLocation1[1],controlCoordinate2[0],controlCoordinate2[1],controlLocation2[0],controlLocation2[1]);
+//        double[][] result = new double[positions.length][2];
+//	   	for(int i=0;i<positions.length;++i) {
+//	   		double[] d = GisCoordinateUtil.transformLocationToBL(positions[i][0], positions[i][1]);
+//	   		result[i] = d;
+//
+//	   	}
+//
+//        return result;
+//	}
 
 	/**
 	 * 四维坐标转gis坐标
 	 * @param args
 	 */
-    public static void main(String[] args) {
-    	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(0, 0);
-        System.out.println(d[0]+" "+d[1]);
-    }
+//    public static void main(String[] args) {
+//    	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(0, 0);
+//        System.out.println(d[0]+" "+d[1]);
+//    }
 }

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

@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
 /**
  * Created by owen on 2021/7/29 0029 18:27
  */
-@Api(tags = "控制点管理")
+@Api(tags = "controlPoint-控制点管理")
 @RestController
 public class ControlPointController {
 

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

@@ -20,7 +20,7 @@ import java.util.List;
  * 漫游点
  */
 @Slf4j
-@Api(tags = "漫游点-filter")
+@Api(tags = "filter-漫游点")
 @RestController
 public class FilterController {
 
@@ -99,4 +99,19 @@ public class FilterController {
     }
 
 
+    /**
+     * 2021-09-10
+     * owen自己加
+     * @param sceneCode
+     * @return
+     */
+    @WebControllerLog(description = "漫游点-查询所有")
+    @ApiOperation(value = "查询所有")
+    @GetMapping("indoor/{sceneCode}/api/images")
+    public Object findAll(@PathVariable String sceneCode) {
+        Result result = filterService.findAll(sceneCode);
+        return result.getData();
+    }
+
+
 }

+ 116 - 7
laser/src/main/java/com/fdkankan/indoor/core/controller/LoginController.java

@@ -9,11 +9,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
+
 /**
  * Created by owen on 2021/7/19 0019 11:30
  */
 @Slf4j
-@Api(tags = "api用户相关接口")
+@Api(tags = "login- api相关接口")
 @RestController
 public class LoginController {
 
@@ -63,12 +65,119 @@ public class LoginController {
         return result.getData();
     }
 
-//    @ApiOperation(value = "configs", notes = "数据目前是写死的")
-//    @GetMapping("indoor/{sceneCode}/api/configs")
-//    public Object configs(@PathVariable String sceneCode){
-//        Result result = loginService.configs(sceneCode);
-//        return result.getData();
-//    }
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "features", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/features")
+    public Object features(@PathVariable String sceneCode){
+        Result result = loginService.features();
+        return result.getData();
+    }
+
+
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "gtm", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/gtm")
+    public Object gtm(@PathVariable String sceneCode){
+        Result result = loginService.gtm();
+        return result.getData();
+    }
+
+
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "information", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/information")
+    public Object information(@PathVariable String sceneCode){
+        Result result = loginService.information();
+        return result.getData();
+    }
+
+
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "affineRefSys", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/affine_ref_sys")
+    public Object affineRefSys(@PathVariable String sceneCode){
+        return new ArrayList<>();
+    }
+
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "bundles", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/bundles")
+    public Object bundles(@PathVariable String sceneCode){
+        Result result = loginService.bundles();
+        return result.getData();
+    }
+
+
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "vectorLayers", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/vector_layers")
+    public Object vectorLayers(@PathVariable String sceneCode){
+        return new ArrayList<>();
+    }
+
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "vectorEntities", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/vector_entities")
+    public Object vectorEntities(@PathVariable String sceneCode){
+        return new ArrayList<>();
+    }
+
+
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "vectorMaps", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/vector_maps")
+    public Object vectorMaps(@PathVariable String sceneCode){
+        return new ArrayList<>();
+    }
+
+
+    /**
+     * 2021-09-10
+     * @param sceneCode
+     * @return
+     */
+    @ApiOperation(value = "cameraHeads", notes = "数据目前是写死的")
+    @GetMapping("indoor/{sceneCode}/api/camera_heads")
+    public Object cameraHeads(@PathVariable String sceneCode){
+        Result result = loginService.cameraHeads();
+        return result.getData();
+    }
+
+
+
+
 
 
 }

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

@@ -193,6 +193,21 @@ public class SiteModelController {
     }
 
 
+    /**
+     * 2021-09-10
+     * owen自己加
+     * @param sceneCode
+     * @return
+     */
+    @WebControllerLog(description = "分类信息-更新siteModel")
+    @ApiOperation(value = "更新siteModel",notes = "修改传过来的id, 且返回当前id值")
+    @PostMapping("indoor/{sceneCode}/api/site_model")
+    public Object updateSiteModelById(@PathVariable String sceneCode, @RequestBody List<SiteDto> param) {
+        Result search = entityService.updateSiteModelById(sceneCode, param);
+        return search.getData();
+    }
+
+
 
 
 }

+ 31 - 0
laser/src/main/java/com/fdkankan/indoor/core/entity/ControlPointCalculateEntity.java

@@ -0,0 +1,31 @@
+package com.fdkankan.indoor.core.entity;
+
+import lombok.Data;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * Created by owen on 2021/9/13 0013 10:46
+ * 初始化控制点后的计算结果(平面坐标)
+ */
+@Document(collection = "t_control_point_calculate")
+@Data
+public class ControlPointCalculateEntity extends BaseEntity  {
+
+    private double rotation1;
+    
+    private double scale1;
+    
+    // 平面坐标x
+    private double dx1;
+    private double dy1;
+
+    private double rotation2;
+
+    private double scale2;
+
+    // 平面坐标x
+    private double dx2;
+    private double dy2;
+
+
+}

+ 14 - 0
laser/src/main/java/com/fdkankan/indoor/core/mapper/ControlPointCalculateMapper.java

@@ -0,0 +1,14 @@
+package com.fdkankan.indoor.core.mapper;
+
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
+import com.fdkankan.indoor.core.entity.ControlPointEntity;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by owen on 2021/7/27 0027 15:19
+ */
+@Component
+public interface ControlPointCalculateMapper extends MongoRepository<ControlPointCalculateEntity, String> {
+
+}

+ 21 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/ControlPointCalculateService.java

@@ -0,0 +1,21 @@
+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.ControlPointEntity;
+import com.fdkankan.indoor.core.entity.dto.ControlPointDto;
+
+import java.time.LocalDateTime;
+import java.util.Optional;
+
+/**
+ * Created by owen on 2021/7/28 0028 20:05
+ */
+public interface ControlPointCalculateService {
+
+ void saveEntity(ControlPointCalculateEntity param);
+
+
+   ControlPointCalculateEntity findById(String id);
+}

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

@@ -33,4 +33,5 @@ public interface FilterService {
 
      List<FilterHotDto> getDataBySceneCode(String sceneCode);
 
+    Result findAll(String sceneCode);
 }

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

@@ -15,12 +15,17 @@ public interface LoginService {
 
     Result health(String sceneCode);
 
-//    Result configs(String sceneCode);
-
     Result user(String sceneCode);
 
     Result users(String sceneCode);
 
+    Result features();
+
+    Result gtm();
+
+    Result information();
 
+    Result bundles();
 
+    Result cameraHeads();
 }

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

@@ -39,4 +39,6 @@ public interface SiteModelService {
     List<SiteDto> getDataBySceneCode(String sceneCode);
 
     Result checkMapInvalidation(String sceneCode, List<SiteDto> param);
+
+    Result updateSiteModelById(String sceneCode, List<SiteDto> param);
 }

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

@@ -7,6 +7,7 @@ import com.fdkankan.indoor.base.constant.TypeConstant;
 import com.fdkankan.indoor.base.convert.ModifyCloud;
 import com.fdkankan.indoor.base.util.Result;
 import com.fdkankan.indoor.base.util.SnowFlakeUUidUtils;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import com.fdkankan.indoor.core.entity.SiteModelEntity;
 import com.fdkankan.indoor.core.entity.SpecialPointEntity;
@@ -75,14 +76,82 @@ public class CloudServiceImpl extends IBaseServiceImpl implements CloudService {
         return Result.success();
     }
 
+//    /**
+//     * 处理上传的点云数据:siteModel -> 原点、中心点、最大点、最小点
+//     * @param sceneCode 场景码
+//     * @param laserDataPath 基础路径
+//     * @param controlPoint 控制点
+//     */
+//    private void processCoule(String sceneCode, String laserDataPath, ControlPointEntity controlPoint){
+//       String path = laserDataPath + "/webcloud/cloud.js";
+//        // 处理原点,将原点坐标转为坐标, 转换后的原点只有经纬度,没有高度, 高度现在默认是0
+//        double[] doubles = ModifyCloud.convertFromOrigin(controlPoint);
+//        // 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, controlPoint);
+//
+//            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();
+//        }
+//    }
+
+
     /**
      * 处理上传的点云数据:siteModel -> 原点、中心点、最大点、最小点
      * @param sceneCode 场景码
      * @param laserDataPath 基础路径
      * @param controlPoint 控制点
      */
-    private void processCoule(String sceneCode, String laserDataPath, ControlPointEntity controlPoint){
-       String path = laserDataPath + "/webcloud/cloud.js";
+    private void processCoule(String sceneCode, String laserDataPath, ControlPointCalculateEntity controlPoint){
+        String path = laserDataPath + "/webcloud/cloud.js";
         // 处理原点,将原点坐标转为坐标, 转换后的原点只有经纬度,没有高度, 高度现在默认是0
         double[] doubles = ModifyCloud.convertFromOrigin(controlPoint);
         // 2021-08-4 原点默认 z:0

+ 51 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/impl/ControlPointCalculateServiceImpl.java

@@ -0,0 +1,51 @@
+package com.fdkankan.indoor.core.service.impl;
+
+import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
+import com.fdkankan.indoor.core.entity.ControlPointEntity;
+import com.fdkankan.indoor.core.entity.InitEntity;
+import com.fdkankan.indoor.core.entity.dto.ControlPointDto;
+import com.fdkankan.indoor.core.mapper.ControlPointCalculateMapper;
+import com.fdkankan.indoor.core.mapper.ControlPointMapper;
+import com.fdkankan.indoor.core.service.ControlPointCalculateService;
+import com.fdkankan.indoor.core.service.ControlPointService;
+import com.fdkankan.indoor.core.service.InitService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Created by owen on 2021/7/28 0028 20:05
+ */
+@Service
+@Slf4j
+public class ControlPointCalculateServiceImpl implements ControlPointCalculateService {
+
+    @Autowired
+    ControlPointCalculateMapper entityMapper;
+
+
+    @Override
+    public void saveEntity(ControlPointCalculateEntity param){
+        param.setUpdateTime(LocalDateTime.now());
+        entityMapper.save(param);
+    }
+
+
+    @Override
+    public ControlPointCalculateEntity findById(String id) {
+        Optional<ControlPointCalculateEntity> optional = entityMapper.findById(id);
+        return optional.orElse(null);
+    }
+
+
+
+
+
+}

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

@@ -2,11 +2,14 @@ package com.fdkankan.indoor.core.service.impl;
 
 import cn.hutool.core.util.StrUtil;
 import com.fdkankan.indoor.base.constant.MsgCode;
+import com.fdkankan.indoor.base.convert.GisCoordinateUtil;
 import com.fdkankan.indoor.base.exception.BaseRuntimeException;
 import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import com.fdkankan.indoor.core.entity.InitEntity;
 import com.fdkankan.indoor.core.entity.dto.ControlPointDto;
+import com.fdkankan.indoor.core.mapper.ControlPointCalculateMapper;
 import com.fdkankan.indoor.core.mapper.ControlPointMapper;
 import com.fdkankan.indoor.core.service.ControlPointService;
 import com.fdkankan.indoor.core.service.InitService;
@@ -33,7 +36,6 @@ public class ControlPointServiceImpl implements ControlPointService {
     @Autowired
     InitService initService;
 
-
     @Override
     public Result save(ControlPointDto param, String sceneCode) {
 

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

@@ -45,6 +45,9 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
     @Autowired
     MergeInfoService mergeInfoService;
 
+    @Autowired
+    ControlPointCalculateService controlPointCalculateService;
+
 
     @Override
     public void save(DataSetEntity entity) {
@@ -181,7 +184,8 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
 
 
         // 获取控制点
-        ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
+//        ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
+        ControlPointCalculateEntity controlPoint = controlPointCalculateService.findById(sceneCode);
         // 原场景码地址
         String sceneCodePath = redisPath(sceneCode) + "/laserData";
         if ("dev".equals(configConstant.active)) {

+ 4 - 3
laser/src/main/java/com/fdkankan/indoor/core/service/impl/FilterServiceImpl.java

@@ -60,9 +60,10 @@ public class FilterServiceImpl implements FilterService {
         return data;
     }
 
-
-
-
+    @Override
+    public Result findAll(String sceneCode) {
+        return Result.success(getDataBySceneCode(sceneCode));
+    }
 
 
     @Override

+ 163 - 17
laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java

@@ -16,6 +16,7 @@ import com.fdkankan.indoor.core.entity.dto.*;
 import com.fdkankan.indoor.core.entity.*;
 import com.fdkankan.indoor.core.entity.merge.MergeDateSetDto;
 import com.fdkankan.indoor.core.entity.po.DataSetPo;
+import com.fdkankan.indoor.core.mapper.ControlPointCalculateMapper;
 import com.fdkankan.indoor.core.mapper.InitMapper;
 import com.fdkankan.indoor.core.service.*;
 import lombok.extern.slf4j.Slf4j;
@@ -91,6 +92,10 @@ public class InitServiceImpl implements InitService {
     @Autowired
     MergeInfoService mergeInfoService;
 
+
+    @Autowired
+    ControlPointCalculateService controlPointCalculateService;
+
     /**
      * initDataStep1
      * 有顺序分,不能乱
@@ -250,17 +255,28 @@ public class InitServiceImpl implements InitService {
         // step:0 获取控制点
         ControlPointEntity controlPoint = getControlPoint(sceneCode);
 
+        // 2021-09-13 初始化控制点计算,并保存数据库
+        ControlPointCalculateEntity calculateEntity = GisCoordinateUtil.calculateVariable(controlPoint);
+        calculateEntity.setId(sceneCode);
+        controlPointCalculateService.saveEntity(calculateEntity);
+        log.info("更新控制点计算完成");
+
+
+
         // step1: 处理vision.txt 创建filter表, 处理特殊点:firstView
-        createFilter(sceneCode, laserDataPath, controlPoint);
+//        createFilter(sceneCode, laserDataPath, controlPoint);
+        createFilter(sceneCode, laserDataPath, calculateEntity);
 
         // step2 处理could.js、创建sitModel, 使用的是代码初始化,创建site_model, 处理原点、中心点、最大点、最小点
-        processCould(sceneCode, laserDataPath, controlPoint);
+//        processCould(sceneCode, laserDataPath, controlPoint);
+        processCould(sceneCode, laserDataPath, calculateEntity);
 
         // step6 创建t_configs表, 使用的是模板数据 , 需要firstView;
         createConfig(sceneCode);
 
         // step7 创建t_datasets表, 使用的是代码, 需要处理原点之后执行
-        createDataSet(sceneCode, laserDataPath, controlPoint);
+        createDataSet(sceneCode, laserDataPath, calculateEntity.getRotation2());
+//        createDataSet(sceneCode, laserDataPath, calculateEntity);
 
         // step 10 创建 t_tiled_map表, 需要用到dataSet数据
         tiledMapService.init(sceneCode);
@@ -277,12 +293,33 @@ 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){
         // step1: 获取控制点
-        ControlPointEntity controlPoint = getControlPoint(sceneCode);
+        ControlPointCalculateEntity controlPoint = getControlPointCalculate(sceneCode);
         if (controlPoint == null){
-            throw new BaseRuntimeException("控制点不存在:" + sceneCode);
+            throw new BaseRuntimeException("控制点计算不存在:" + sceneCode);
         }
 
         // step2: init数据路径
@@ -526,18 +563,23 @@ public class InitServiceImpl implements InitService {
 
         // step:0 获取控制点
         ControlPointEntity controlPoint = getControlPoint(sceneCode);
+        // 2021-09-13 初始化控制点计算,并保存数据库
+        ControlPointCalculateEntity calculateEntity = GisCoordinateUtil.calculateVariable(controlPoint);
+        calculateEntity.setId(sceneCode);
+        controlPointCalculateService.saveEntity(calculateEntity);
+        log.info("更新控制点计算完成");
 
         // step1: 处理vision.txt 创建filter表, 处理特殊点:firstView
-        createFilter(sceneCode, laserDataPath, controlPoint);
+        createFilter(sceneCode, laserDataPath, calculateEntity);
 
         // step2 处理could.js 使用的是代码初始化,创建site_model, 处理原点、中心点、最大点、最小点
-        processCould(sceneCode, laserDataPath, controlPoint);
+        processCould(sceneCode, laserDataPath, calculateEntity);
 
         // step6 创建t_configs表, 使用的是模板数据 , 需要firstView;
         createConfig(sceneCode);
 
-        // step7 创建t_datasets表, 使用的是代码, 需要处理原点之后执行
-        createDataSet(sceneCode, laserDataPath, controlPoint);
+        // step7 创建t_datasets表, 使用的是代码, 需要处理原点之后执行, dataSet.orientation: 计算控制点结果rotation2
+        createDataSet(sceneCode, laserDataPath, calculateEntity.getRotation2());
 
 
         // step8 目录pano、pano_depth、webcloud上传oss,
@@ -551,13 +593,31 @@ 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, ControlPointEntity dto){
+    private void createFilter(String sceneCode, String path, ControlPointCalculateEntity calculateEntity){
         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);
+        JSONArray jsonArray = convertToVision.createFilter(sceneCode, path, calculateEntity);
         FilterEntity entity = new FilterEntity();
         entity.setId(sceneCode);
         entity.setCreateTime(LocalDateTime.now());
@@ -568,12 +628,13 @@ public class InitServiceImpl implements InitService {
         log.info("filter数据初始化创建完成");
     }
 
+
     /**
      * 处理could.js 并做相应的计算
      * @param sceneCode
      * @param path
      */
-    private void processCould(String sceneCode, String path, ControlPointEntity dto){
+    private void processCould(String sceneCode, String path, ControlPointCalculateEntity dto){
         path = path + "/webcloud/cloud.js";
         // 处理原点,将原点坐标转为坐标, 转换后的原点只有经纬度,没有高度, 高度现在默认是0
         double[] doubles = ModifyCloud.convertFromOrigin(dto);
@@ -635,6 +696,73 @@ 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){
         //读取初始文件
@@ -795,9 +923,10 @@ public class InitServiceImpl implements InitService {
      * location: 原点坐标(特殊点表)
      * bounding_box_max:(特殊点表)
      * bounding_box_min:(特殊点表)
+     * orientation : rotation2
      * @param sceneCode
      */
-    private void createDataSet(String sceneCode, String laserDataPath, ControlPointEntity controlPoint){
+    private void createDataSet(String sceneCode, String laserDataPath, double orientation){
         log.info("run createDataSet");
         DataSetEntity entity = new DataSetEntity();
         entity.setId(sceneCode);
@@ -838,8 +967,8 @@ public class InitServiceImpl implements InitService {
 
         mergeDto.setPath(laserDataPath);
 
-        // 处理弧度
-        mergeDto.setOrientation(getOrientation(controlPoint));
+        // 处理弧度, 使用计算控制点的rotation2
+        mergeDto.setOrientation(orientation);
 
         DataSetPo po = ModifyDataSets.mergeDataSetPo(map, mergeDto);
         entity.setData(Arrays.asList(po));
@@ -852,8 +981,20 @@ public class InitServiceImpl implements InitService {
      * @param controlPoint
      * @return
      */
-    private Double getOrientation(ControlPointEntity controlPoint){
-        double angle = GisCoordinateUtil.getDataSetOrientation(controlPoint);
+//    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;
     }
@@ -931,6 +1072,11 @@ public class InitServiceImpl implements InitService {
        return controlPointService.findById(sceneCode);
     }
 
+
+    private ControlPointCalculateEntity getControlPointCalculate(String sceneCode){
+        return controlPointCalculateService.findById(sceneCode);
+    }
+
     /**
      *
      * @param sceneCode 场景码

+ 58 - 4
laser/src/main/java/com/fdkankan/indoor/core/service/impl/LoginServiceImpl.java

@@ -1,5 +1,8 @@
 package com.fdkankan.indoor.core.service.impl;
 
+import cn.hutool.core.io.FileUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.indoor.base.util.JwtUtil;
 import com.fdkankan.indoor.base.util.Result;
 import com.fdkankan.indoor.core.entity.dto.ConfigDto;
@@ -21,6 +24,7 @@ import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
@@ -102,7 +106,7 @@ public class LoginServiceImpl  extends IBaseServiceImpl implements LoginService
     @Override
     public Result health(String sceneCode) {
         Query query = new Query();
-        query.addCriteria(Criteria.where("sceneCode").is(sceneCode));
+        query.addCriteria(Criteria.where("sceneCode").is("baseCode"));
         BaseVo vo = mongoTemplate.findOne(query, BaseVo.class, "t_health");
         return Result.success(vo.getData());
     }
@@ -129,13 +133,63 @@ public class LoginServiceImpl  extends IBaseServiceImpl implements LoginService
         return Result.success(vo.getData());
     }
 
+    @Override
+    public Result features() {
+        JSONObject result = new JSONObject();
+        result.put("cloud_processing", false);
+        result.put("developer_menu", false);
+        result.put("meshes", false);
+        return Result.success(result);
+    }
+
+    @Override
+    public Result gtm() {
+        JSONObject result = new JSONObject();
+        result.put("instance_name", null);
+        result.put("gtm_container_id", null);
+        result.put("instance_type", "undetermined");
+        result.put("tracking_enabled", false);
+        result.put("trial", false);
+        return Result.success(result);
+    }
+
+    @Override
+    public Result information() {
+        JSONObject result = new JSONObject();
+        result.put("oauth_login_url", null);
+        result.put("instance_id", "01ee548b-4d74-45f4-93af-28f5ae04ca48");
+        result.put("empty", "false");
+        result.put("private", false);
+        result.put("cloud_instance", false);
+        return Result.success(result);
+    }
 
+    @Override
+    public Result bundles() {
+        JSONObject result = new JSONObject();
+        SecurityDto securityDto = new SecurityDto();
+        securityDto.setGroup_read(0);
+        securityDto.setGroup_write(1);
+        securityDto.setCan_write(false);
+        result.put("security", securityDto);
+        result.put("id", 1);
+        result.put("serial", "abc");
+        result.put("name", "4dage");
+
+        return Result.success(Arrays.asList(result));
+    }
 
-    public SecurityDto changeSecurity(SecurityDto dto){
-        dto.setCan_write(false);
-        return dto;
+    @Override
+    public Result cameraHeads() {
+        String path = configConstant.templatePath + "/cameraHeads.json";
+        log.info("cameraHeads path : {}", path);
+        String content = FileUtil.readUtf8String(path);
+        content = content.trim();
+        JSONArray objects = JSONArray.parseArray(content);
+        return Result.success(objects);
     }
 
+
     /**
      * 检查登录
      * @return

+ 41 - 11
laser/src/main/java/com/fdkankan/indoor/core/service/impl/MergeSceneServiceImpl.java

@@ -71,6 +71,9 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
     @Autowired
     TiledMapService tiledMapService;
 
+    @Autowired
+    ControlPointCalculateService controlPointCalculateService;
+
     /**
      * 目前只支持没有合并过的场景
      * @param sceneCode
@@ -86,7 +89,10 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
         }
 
 
-        ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
+//        ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
+        ControlPointCalculateEntity controlPoint = controlPointCalculateService.findById(sceneCode);
+
+
 
         InitEntity initEntity = initService.findById(mergeCode);
 
@@ -108,7 +114,7 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
         // 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);
+        Integer dataSetId = mergeDateSet(sceneCode, mergeCode, siteModeIds, mergePath, controlPoint.getRotation2());
 
 
         mergeFilter(sceneCode, mergeCode, controlPoint, mergePath, siteModelId, dataSetId);
@@ -232,7 +238,7 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
 
 
 
-    private Integer  mergeDateSet(String sceneCode, String mergeCode, List<Integer> siteModeIds, String mergePath, ControlPointEntity controlPoint){
+    private Integer  mergeDateSet(String sceneCode, String mergeCode, List<Integer> siteModeIds, String mergePath, double orientation){
 
         // 获取原场景数据
         DataSetEntity entity = dataSetService.findById(sceneCode);
@@ -265,9 +271,10 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
 
         mergeDto.setPath(mergePath);
         // 处理弧度
-        double angle = GisCoordinateUtil.getDataSetOrientation(controlPoint);
-        log.info("Orientation弧度:{}", angle);
-        mergeDto.setOrientation(angle);
+//        double angle = GisCoordinateUtil.getDataSetOrientation(controlPoint);
+//        double angle = 0.0;
+        log.info("Orientation弧度:{}", orientation);
+        mergeDto.setOrientation(orientation);
 
 
         mergeDto.setColor(getColor());
@@ -288,7 +295,7 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
     }
 
 
-    private void  mergeFilter(String sceneCode, String mergeCode, ControlPointEntity controlPoint, String mergePath, Integer newSiteModelId, Integer dataSetId){
+    private void  mergeFilter(String sceneCode, String mergeCode, ControlPointCalculateEntity controlPoint, String mergePath, Integer newSiteModelId, Integer dataSetId){
 
 
         // 获取原场景数据
@@ -371,7 +378,7 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
 //    }
 
 
-    private Map<Object, Object>  mergeSiteModelFloor(String sceneCode, String mergeCode, String mergePath, ControlPointEntity controlPoint){
+    private Map<Object, Object>  mergeSiteModelFloor(String sceneCode, String mergeCode, String mergePath, ControlPointCalculateEntity controlPoint){
 
         // 获取原场景数据
         SiteModelEntity entity = siteModelService.findById(sceneCode);
@@ -558,6 +565,29 @@ 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;
+//    }
+
+
     /**
      *
      * @param sceneCode
@@ -565,7 +595,7 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
      * @param dto
      * @return
      */
-    private List<FilterHotDto> initMergeFilter(String sceneCode, String mergePath, ControlPointEntity dto){
+    private List<FilterHotDto> initMergeFilter(String sceneCode, String mergePath, ControlPointCalculateEntity dto){
         String path = mergePath +"/vision.txt";
         log.info("path: {}", path);
         if (!cn.hutool.core.io.FileUtil.isFile(path)){
@@ -586,7 +616,7 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
      * @param mergePath
      * @param dto
      */
-    private SiteDto initMergeSiteModel(String mergeCode, String mergePath, ControlPointEntity dto){
+    private SiteDto initMergeSiteModel(String mergeCode, String mergePath, ControlPointCalculateEntity dto){
         SiteDto siteDto =  processCould(mergeCode, mergePath, dto);
         return siteDto;
     }
@@ -596,7 +626,7 @@ public class MergeSceneServiceImpl extends IBaseServiceImpl implements MergeScen
      * @param sceneCode
      * @param path
      */
-    private SiteDto processCould(String sceneCode, String path, ControlPointEntity dto){
+    private SiteDto processCould(String sceneCode, String path, ControlPointCalculateEntity dto){
         path = path + "/webcloud/cloud.js";
 
         try {

+ 34 - 30
laser/src/main/java/com/fdkankan/indoor/core/service/impl/PoseServiceImpl.java

@@ -7,14 +7,12 @@ import com.fdkankan.indoor.base.constant.TypeConstant;
 import com.fdkankan.indoor.base.convert.GisCoordinateUtil;
 import com.fdkankan.indoor.base.exception.BaseRuntimeException;
 import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import com.fdkankan.indoor.core.entity.InitEntity;
 import com.fdkankan.indoor.core.entity.po.DataSetPo;
 import com.fdkankan.indoor.core.entity.vo.PoseVo;
-import com.fdkankan.indoor.core.service.ControlPointService;
-import com.fdkankan.indoor.core.service.DataSetService;
-import com.fdkankan.indoor.core.service.InitService;
-import com.fdkankan.indoor.core.service.PoseService;
+import com.fdkankan.indoor.core.service.*;
 import lombok.extern.slf4j.Slf4j;
 import net.sf.json.JSONObject;
 import org.junit.Test;
@@ -42,11 +40,15 @@ public class PoseServiceImpl extends IBaseServiceImpl implements PoseService {
     @Autowired
     ControlPointService controlPointService;
 
+    @Autowired
+    ControlPointCalculateService controlPointCalculateService;
+
     @Override
     public Result reposes(String sceneCode) {
         List<DataSetPo> data = dataSetService.getDataBySceneCode(sceneCode);
 
-        ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
+//        ControlPointEntity controlPoint = controlPointService.findById(sceneCode);
+        ControlPointCalculateEntity controlPoint = controlPointCalculateService.findById(sceneCode);
 
 
 
@@ -83,9 +85,10 @@ public class PoseServiceImpl extends IBaseServiceImpl implements PoseService {
     }
 
     // 本地gps坐标转本地坐标
-    private static JSONObject exeTranslation(Double[] location, ControlPointEntity controlPoint){
+    private static JSONObject exeTranslation(Double[] location, ControlPointCalculateEntity controlPoint){
         double[] gpsLocation = {location[0], location[1], location[2]};
-        double[] translation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
+//        double[] translation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
+        double[] translation = GisCoordinateUtil.transformBLToLocation(gpsLocation[0], gpsLocation[1], controlPoint);
         JSONObject translationJson = new JSONObject();
         translationJson.put("x", translation[0]);
         translationJson.put("y", translation[1]);
@@ -94,29 +97,30 @@ public class PoseServiceImpl extends IBaseServiceImpl implements PoseService {
         return translationJson;
     }
 
-    @Test
-    public void gpsToAge(){
-        double[] location = {113.595725873559, 22.366579192566, 0.075};
-
-        // 控制点
-        ControlPointEntity controlPoint = new ControlPointEntity();
-        double[] controlCoordinate1 = {113.595725873337,22.366579193007}; //gps坐标
-        double[] controlCoordinate2 = {113.595757230122,22.3666213677456};  //gps坐标
-
-        double[] controlLocation1 = {0.617759,-2.904041};  // 四维看看坐标
-        double[] controlLocation2 = {3.859914,1.75765}; // 四维看看坐标
-
-        controlPoint.setGpsControlCoordinate1(controlCoordinate1);
-        controlPoint.setGpsControlCoordinate2(controlCoordinate2);
-        controlPoint.setAgeControlLocation1(controlLocation1);
-        controlPoint.setAgeControlLocation2(controlLocation2);
-
-        double[] doubles = GisCoordinateUtil.convertGpsToLocation(location, controlPoint);
-        System.out.println(doubles[0]);
-        System.out.println(doubles[1]);
-        System.out.println(location[2]);
-
-    }
+//    @Test
+//    public void gpsToAge(){
+//        double[] location = {113.595725873559, 22.366579192566, 0.075};
+//
+//        // 控制点
+//        ControlPointEntity controlPoint = new ControlPointEntity();
+//        double[] controlCoordinate1 = {113.595725873337,22.366579193007}; //gps坐标
+//        double[] controlCoordinate2 = {113.595757230122,22.3666213677456};  //gps坐标
+//
+//        double[] controlLocation1 = {0.617759,-2.904041};  // 四维看看坐标
+//        double[] controlLocation2 = {3.859914,1.75765}; // 四维看看坐标
+//
+//        controlPoint.setGpsControlCoordinate1(controlCoordinate1);
+//        controlPoint.setGpsControlCoordinate2(controlCoordinate2);
+//        controlPoint.setAgeControlLocation1(controlLocation1);
+//        controlPoint.setAgeControlLocation2(controlLocation2);
+//
+////        double[] doubles = GisCoordinateUtil.convertGpsToLocation(location, controlPoint);
+//        double[] doubles = GisCoordinateUtil.transformBLToLocation(location[0], location[1], controlPoint);
+//        System.out.println(doubles[0]);
+//        System.out.println(doubles[1]);
+//        System.out.println(location[2]);
+//
+//    }
 
 
 //    private String redisPath(String sceneCode) {

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

@@ -8,10 +8,12 @@ import com.fdkankan.indoor.base.constant.MsgCode;
 import com.fdkankan.indoor.base.convert.GetRoute;
 import com.fdkankan.indoor.base.exception.BaseRuntimeException;
 import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.ControlPointCalculateEntity;
 import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import com.fdkankan.indoor.core.entity.dto.RouteInputDto;
 import com.fdkankan.indoor.core.entity.RouteEntity;
 import com.fdkankan.indoor.core.mapper.RouteMapper;
+import com.fdkankan.indoor.core.service.ControlPointCalculateService;
 import com.fdkankan.indoor.core.service.ControlPointService;
 import com.fdkankan.indoor.core.service.RouteService;
 import lombok.extern.slf4j.Slf4j;
@@ -42,6 +44,9 @@ public class RouteServiceImpl implements RouteService {
     @Autowired
     ConfigConstant configConstant;
 
+    @Autowired
+    ControlPointCalculateService controlPointCalculateService;
+
     @Override
     public void save(RouteEntity entity) {
         entityMapper.save(entity);
@@ -52,7 +57,10 @@ public class RouteServiceImpl implements RouteService {
         List<String> data = getDataBySceneCode(sceneCode);
 
         // 查询控制点
-        ControlPointEntity controlPointEntity = controlPointService.findById(sceneCode);
+//        ControlPointEntity controlPointEntity = controlPointService.findById(sceneCode);
+
+        ControlPointCalculateEntity controlPointEntity = controlPointCalculateService.findById(sceneCode);
+
         // route数据:头尾数据是没有id值的,其他都有
         JSONArray route = GetRoute.getRoute(data, param, controlPointEntity);
 

+ 26 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/impl/SiteModelServiceImpl.java

@@ -459,6 +459,32 @@ public class SiteModelServiceImpl implements SiteModelService {
         return Result.success(result);
     }
 
+    @Override
+    public Result updateSiteModelById(String sceneCode, List<SiteDto> param) {
+        SiteModelEntity entity = findById(sceneCode);
+        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());
+        }
+
+        // 把更新后的数据添加到原数据
+        data.addAll(param);
+
+        entity.setData(data);
+        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) {

+ 100 - 0
laser/src/main/java/com/fdkankan/indoor/test/TestAffineTransform.java

@@ -0,0 +1,100 @@
+package com.fdkankan.indoor.test;
+
+import com.fdkankan.indoor.base.convert.Point;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class TestAffineTransform {
+
+	/*
+	 *  1 x: 458249.577950831 y: 2474529.667443291  
+		2 x: 458247.51758545433 y: 2474531.6324389814
+		3 x: 458250.7569026919 y: 2474532.9341176464
+		4 x: 458252.6196984933 y: 2474534.0980041157
+	 * /
+	
+	/*
+	 *  1 x:-1.208132028579712 y:2.257599115371704
+	 *  2 x:1.6327489614486694 y:2.1368539333343506
+		3 x:0.05691400170326233 y:-0.97919100522995
+		4 x:-0.5570799708366394 y:-3.0515389442443848
+	 * */
+	
+	private static Point Point1 = new Point(1.6327489614486694,2.1368539333343506);
+	private static Point Point2 = new Point(-0.5570799708366394,-3.0515389442443848);
+	
+	private static Point newPoint1 = new Point(458247.51758545433,2474531.6324389814);
+	private static Point newPoint2 = new Point(458252.6196984933,2474534.0980041157);
+	
+//	private static Point Point1 = new Point(458247.51758545433,2474531.6324389814);
+//	private static Point Point2 = new Point(458252.6196984933,2474534.0980041157);
+//	
+//	private static Point newPoint1 = new Point(1.6327489614486694,2.1368539333343506);
+//	private static Point newPoint2 = new Point(-0.5570799708366394,-3.0515389442443848);
+	
+	public double getAngle(Point p1, Point p2) {
+        double angle = Math.atan2(p2.getX() - p1.getX(), p2.getY() - p1.getY());
+        return angle * (180 / Math.PI);
+    }
+
+	public double getScale(Point p1, Point b1, Point p2, Point b2) {
+        return getLength(b1, b2) / getLength(p1, p2);
+    }
+
+	public static double getLength(Point p1, Point p2) {
+        return Math.sqrt(Math.pow(p2.getX() - p1.getX(), 2) + Math.pow(p2.getY() - p1.getY(), 2));
+    }
+
+	public double getXTranslation(Point p1, Point b1, double rotation, double scale) {
+        return (b1.getX() - scale * (p1.getX() * Math.cos(rotation) - p1.getY() * Math.sin(rotation)));
+    }
+
+	public double getYTranslation(Point p1, Point b1, double rotation, double scale) {
+        return (b1.getY() - scale * (p1.getX() * Math.sin(rotation) + p1.getY() * Math.cos(rotation)));
+    }
+
+	public Point transformBoePoint(Point gp, double rotation, double scale, double dx, double dy) {
+        double A = scale * Math.cos(rotation);
+        double B = scale * Math.sin(rotation);
+        //return new Point(retain6(A * gp.getX() - B * gp.getY() + dx), retain6(B * gp.getX() + A * gp.getY() + dy));
+        return new Point(A * gp.getX() - B * gp.getY() + dx, B * gp.getX() + A * gp.getY() + dy);
+	}
+	
+	public static double retain6(double num) {
+        String result = String.format("%.6f", num);
+        return Double.valueOf(result);
+    }
+	
+	public static void main(String[] args) {
+		
+		TestAffineTransform testAffineTransform = new TestAffineTransform();
+		
+//		//��ʼ��4��
+//		double rotation = Math.toRadians(Math.abs(testAffineTransform.getAngle(Point1 , Point2 ) - testAffineTransform.getAngle(newPoint1 , newPoint2 )));
+//		//��ȡ��ת���������
+//		double scale = testAffineTransform.getScale(newPoint1 , Point1 , newPoint2 , Point2 );
+//		double tx = testAffineTransform.getXTranslation(newPoint1 , Point1 , rotation, scale);
+//		double ty = testAffineTransform.getYTranslation(newPoint1 , Point1 , rotation, scale);
+		
+		//��ʼ��4��
+		//double rotation = Math.toRadians(Math.abs(testAffineTransform.getAngle(Point1 , Point2 ) - testAffineTransform.getAngle(newPoint1 , newPoint2 )));
+		double rotation = Math.toRadians(testAffineTransform.getAngle(Point1 , Point2 ) - testAffineTransform.getAngle(newPoint1 , newPoint2 ));
+		//��ȡ��ת���������
+		double scale = testAffineTransform.getScale( Point1 , newPoint1 , Point2 , newPoint2);
+		log.info("输入参数1:{}, {}", Point1.getX(), Point1.getY());
+		log.info("输入参数2 :{}, {}", newPoint1.getX(), newPoint1.getY());
+		log.info("输入参数 rotation2:{}, {}", rotation);
+		log.info("输入参数 scale1:{}, {}", scale);
+		double tx = testAffineTransform.getXTranslation( Point1 ,newPoint1, rotation, scale);
+		double ty = testAffineTransform.getYTranslation( Point1 ,newPoint1, rotation, scale);
+		log.info("输出结果 dx2:{}, {}", tx);
+		log.info("输出结果 dy2:{}, {}", ty);
+		//��Ҫת�������� x,y
+		//Point point = new Point(458249.577950831,2474529.667443291);
+		//Point point = new Point(458250.7569026919,2474532.9341176464);
+		Point point = new Point(-1.208132028579712,2.257599115371704);
+		//Point point = new Point(0.05691400170326233,-0.97919100522995);
+		Point resultPoint = testAffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), rotation, scale, tx, ty);
+		System.out.println("x:"+resultPoint.getX()+",y:"+resultPoint.getY());
+	}
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 2308 - 0
laser/src/main/resources/data/cameraHeads.json