Bläddra i källkod

添加乱码注释

wuweihao 4 år sedan
förälder
incheckning
51867c0133

+ 5 - 1
laser/src/main/java/com/fdkankan/indoor/base/constant/ConfigConstant.java

@@ -11,10 +11,13 @@ import org.springframework.stereotype.Component;
 @Component
 public class ConfigConstant {
 
-    /** 服务器文件地址*/
+    /** 前端服务器文件地址*/
     @Value("${server.file.path}")
     public  String serverBasePath;
 
+    /**后端文件保存路径*/
+    @Value("${my.back.file.path")
+    public  String myBackBasePath;
 
     /** 数据模板路径*/
     @Value("${my.template.path}")
@@ -24,6 +27,7 @@ public class ConfigConstant {
     @Value("${web.site}")
     public String webSitePath;
 
+    /**配置环境*/
     @Value("${spring.profiles.active}")
     public String active;
 

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

@@ -39,7 +39,7 @@ public class ConvertToVision {
 			JSONObject item = new JSONObject();
 			
 			JSONObject sweepItem = sweepLocations.getJSONObject(i);
-			//navvis��֧��id��0�����ε�
+			//navvis不支持id是0的漫游点
 			//int id = sweepItem.getInt("id");
 
 			int id = sweepItem.getInt("uuid");
@@ -48,10 +48,10 @@ public class ConvertToVision {
 			JSONObject translation = pose.getJSONObject("translation");
 			JSONObject puck = sweepItem.getJSONObject("puck");
 			
-			item.put("id", id);   //��һ��Ԫ�ص�id��1
+			item.put("id", id);   //第一个元素的id是1
 			item.put("rotation", rotation);    //quaternation
-			item.put("translation", translation);     //�������
-			item.put("puck", puck);     // ��������
+			item.put("translation", translation);     //相机坐标
+			item.put("puck", puck);     // 地面坐标
 			
 			result.add(item);
 		}
@@ -85,17 +85,17 @@ public class ConvertToVision {
 			//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����
+			//gis坐标
 			double[] _location = TransformGPS.convert(location,dto);
 			double[] _floor_location = TransformGPS.convert(floor_location, dto);
 			location[0] = _location[0];
@@ -105,12 +105,12 @@ public class ConvertToVision {
 			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");

+ 0 - 2
laser/src/main/java/com/fdkankan/indoor/base/convert/FixRouteMap.java

@@ -186,7 +186,5 @@ public class FixRouteMap {
         System.out.println("执行完成");
 
 
-//        double[] oldPoint = new double[3];     //
-//        double[] newPoint =  fixRouteMap.applyMatrix4(oldPoint,newMatrix);  //修改棋盘每个顶点坐标,然后再入库
     }
 }

+ 1 - 133
laser/src/main/java/com/fdkankan/indoor/base/convert/GetRoute.java

@@ -330,138 +330,6 @@ public class GetRoute {
 		return route;
 	}
 
-//	private static JSONArray convertFromPath(List<Node> mappath, RouteInputDto dto, ControlPointEntity controlPoint) {
-//		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();
-//
-//
-//		List<Node> path = new ArrayList<Node>();
-//		for(int i = mappath.size()-1;i>-1;--i) {
-//			Node node = mappath.get(i);
-//			path.add(node);
-//		}
-//
-//		JSONArray route = new JSONArray();
-//
-//		//起点不在path上,path的第一个点对应的是格子
-//		JSONObject start = new JSONObject();
-////		start.put("longitude", startX);
-////		start.put("latitude", startY);
-//
-//		double[] startPosition = {startX,startY};
-//		startPosition = TransformGPS.convert(startPosition, controlPoint);
-//		start.put("longitude", startPosition[0]);
-//		start.put("latitude", startPosition[1]);
-//		start.put("z", startZ);
-//		Double[] location = new Double[3];
-////		location[0] = startX;
-////		location[1] = startY;
-//
-//		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.convert(position, controlPoint);
-//			item.put("longitude", position[0]);
-//			item.put("latitude", position[1]);
-//
-////			item.put("longitude", node.coord.x);
-////			item.put("latitude", node.coord.y);
-//			item.put("z", node.coord.z);
-//			location = new Double[3];
-////			location[0] = node.coord.x;
-////			location[1] = node.coord.y;
-//
-//			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;
-//
-//			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.convert(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);
@@ -531,7 +399,7 @@ public class GetRoute {
 		
 		JSONArray route = new JSONArray();
 		
-		//��㲻��path�ϣ�path�ĵ�һ�����Ӧ���Ǹ���
+		//起点不在path上,path的第一个点对应的是格子
 		JSONObject start = new JSONObject();
 		start.put("longitude", startX);
 		start.put("latitude", startY);

+ 101 - 0
laser/src/main/java/com/fdkankan/indoor/base/convert/MergeRouteMap.java

@@ -0,0 +1,101 @@
+package com.fdkankan.indoor.base.convert;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.json.JSONObject;
+
+/**
+ * 合并Route表
+ */
+public class MergeRouteMap {
+    private String path1 = "";
+    private String pate2 = "";
+    private static final float cell = 0.36f;
+    private static final int lineNum = 100;
+
+    //FixRouteMap之后
+    public static List<Integer> getEdge(List<JSONObject> list) {
+        List<Integer> edges = new ArrayList<Integer>();
+        for (int i = 0; i < list.size(); ++i) {
+            JSONObject item = (JSONObject) list.get(i);
+            String linkedIds = item.getString("linkedIds");
+            if (linkedIds.indexOf("-1") > -1) {
+                edges.add(i);
+            }
+        }
+        return edges;
+    }
+
+    public static double getDis(double x, double y, double z, double _x, double _y, double _z) {
+        double distance = Math.pow((x - _x), 2) + Math.pow((y - _y), 2) + Math.pow((z - _z), 2);
+        distance = Math.sqrt(distance);
+        return distance;
+    }
+
+    public static int getMini(JSONObject item, List<JSONObject> list) {
+        double minDistance = 10000;
+        int linked = -1;
+
+        double x = item.getDouble("x");
+        double y = item.getDouble("y");
+        double z = item.getDouble("z");
+
+        for (int i = 0; i < list.size(); ++i) {
+            JSONObject _item = list.get(i);
+            double _x = item.getDouble("_x");
+            double _y = item.getDouble("_y");
+            double _z = item.getDouble("_z");
+
+            if (Math.abs(x - _x) < cell && Math.abs(y - _y) < cell && Math.abs(z - _z) < cell) {
+                continue;
+            } else {
+                double distance = getDis(x, y, z, _x, _y, _z);
+                if (distance < minDistance) {
+                    minDistance = distance;
+                    linked = lineNum + i;
+                }
+            }
+        }
+        return linked;
+    }
+
+    public static void main(String args[]) {
+
+        try {
+            List<JSONObject> list1 = new ArrayList<JSONObject>();
+            List<JSONObject> list2 = new ArrayList<JSONObject>();
+
+            List<Integer> edges1 = getEdge(list1);
+            List<Integer> edges2 = getEdge(list2);
+
+            //第一个表里找边缘点与第二个表比较
+            for (int i = 0; i < edges1.size(); ++i) {
+                int index = edges1.get(i);
+                JSONObject item1 = list1.get(index);
+                int linked = getMini(item1, list2);
+                if (linked != -1) {
+                    String linkedIds = item1.getString("linkedIds").replaceFirst("-1", String.valueOf(linked));
+                    item1.put("linkedIds", linkedIds);
+                }
+            }
+
+            //第二个表里找边缘点与第一个表比较
+            edges2 = getEdge(list2);
+            for (int i = 0; i < edges2.size(); ++i) {
+                int index = edges2.get(i);
+                JSONObject item2 = list2.get(index);
+                int linked = getMini(item2, list1);
+                if (linked != -1) {
+                    String linkedIds = item2.getString("linkedIds").replaceFirst("-1", String.valueOf(linked));
+                    item2.put("linkedIds", linkedIds);
+                }
+            }
+
+            System.out.println("ok");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+}

+ 1 - 40
laser/src/main/java/com/fdkankan/indoor/base/convert/ModifyDataSets.java

@@ -58,46 +58,7 @@ public class ModifyDataSets {
 	}
 
 
-//	public static DataSetPo createDataSetPo(Map<String ,Double[]> param){
-//		DataSetPo po = new DataSetPo();
-//
-//		SecurityDto securityDto = new SecurityDto();
-//
-//		securityDto.setGroup_read(0);
-//		securityDto.setGroup_write(1);
-//		// 默认true
-//		securityDto.setCan_write(true);
-//		// 默认true
-//		po.setSecurity(securityDto);
-//
-//		po.setId(1);
-//		po.setBundle_id(1);
-//		po.setType("4dage");
-//		po.setName("chunk1");
-//		po.setTitle("chunk1");
-//		po.setColor("pink");
-//		po.setVisible(false);
-//
-//		//double[] location = {0,0,0};
-//		//location = TransformGPS.convert(location);
-//		//原点 ,获取特征点的原点
-////		Double[] doubles = param.get(TypeConstant.POI_ORIGIN);
-//		po.setLocation(param.get(TypeConstant.POI_ORIGIN));
-//		po.setOrientation(0.0);
-//		Integer[] site_model_entity_ids = {10,11,12};
-//		po.setSite_model_entity_ids(site_model_entity_ids);
-//		po.setPoint_cloud_type("POTREE");
-//
-//		//添加boundingbox,从modifyCloud里的convertFromBoundingBox获取
-//
-//		// 使用的是虚拟坐标
-//		po.setBounding_box_max(param.get(TypeConstant.POI_BOUNDINGBOX_MAX));
-//		po.setBounding_box_min(param.get(TypeConstant.POI_BOUNDINGBOX_MIN));
-//
-//		po.setHas_depth_images(true);
-//		po.setHas_images(true);
-//		return po;
-//	}
+
 
 
 	/**

+ 167 - 195
laser/src/main/java/com/fdkankan/indoor/base/convert/kesar/AStar.java

@@ -1,4 +1,5 @@
 package com.fdkankan.indoor.base.convert.kesar;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.PriorityQueue;
@@ -8,201 +9,172 @@ import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
 /**
- * 
- * ClassName: AStar 
- * @Description: A鏄熺畻娉�
+ * ClassName: AStar
+ *
  * @author kesar
+ * @Description: A星算法
  */
-public class AStar
-{
-	public final static int BAR = 1; // 闅滅鍊�
-	public final static int PATH = 2; // 璺緞
-	public final static int DIRECT_VALUE = 10; // 妯珫绉诲姩浠d环
-	public final static int OBLIQUE_VALUE = 14; // 鏂滅Щ鍔ㄤ唬浠�
-	
-	Queue<Node> openList = new PriorityQueue<Node>(); // 浼樺厛闃熷垪(鍗囧簭)
-	List<Node> closeList = new ArrayList<Node>();
-	
-	/**
-	 * 寮�濮嬬畻娉�
-	 */
-	public List<Node> start(MapInfo mapInfo)
-	{
-		if(mapInfo==null) return null;
-		// clean
-		openList.clear();
-		closeList.clear();
-		// 寮�濮嬫悳绱�
-		openList.add(mapInfo.start);
-		return moveNodes(mapInfo);
-	}
-
-	/**
-	 * 绉诲姩褰撳墠缁撶偣
-	 */
-	private List<Node> moveNodes(MapInfo mapInfo)
-	{
-		while (!openList.isEmpty())
-		{
-			Node current = openList.poll();
-			closeList.add(current);
-			addNeighborNodeInOpen(mapInfo,current);
-			if (isCoordInClose(mapInfo.end.id))
-			{
-				List<Node> list = drawPath(mapInfo.maps, mapInfo.end);
-				return list;
-			}
-		}
-		return null;
-	}
-	
-	/**
-	 * 鍦ㄤ簩缁存暟缁勪腑缁樺埗璺緞
-	 */
-	private List<Node> drawPath(JSONArray maps, Node end)
-	{
-		if(end==null||maps==null) return null;
-		System.out.println("路线" + end.id);
-		List<Node> list = new ArrayList<Node>();
-		while (end != null)
-		{
-			System.out.println("路线" + end.id);
-			list.add(end);
-			Coord c = end.coord;
-			//maps[c.y][c.x] = PATH;
-			end = end.parent;
-		}
-		return list;
-	}
-
-	/**
-	 * 娣诲姞鎵�鏈夐偦缁撶偣鍒皁pen琛�
-	 */
-	private void addNeighborNodeInOpen(MapInfo mapInfo,Node current)
-	{
-		int id = current.id;
-		JSONObject item = mapInfo.maps.getJSONObject(id);
-		String[] linkedIds = item.getString("linkedIds").split(",");
-		
-		for(int i=0;i<linkedIds.length;++i) {
-			int linkedId = Integer.valueOf(linkedIds[i])-1;
-			if (canAddNodeToOpen(mapInfo,linkedId))
-			{
-				Node end=mapInfo.end;
-				//Coord coord = new Coord(x, y);
-				//Double G = current.G + current.weight; // 计算邻结点的G值
-
-				JSONObject linkedNode = mapInfo.maps.getJSONObject(linkedId);
-				double weight = calcH(current.coord,new Coord(linkedNode.getDouble("x"),linkedNode.getDouble("y"),linkedNode.getDouble("z")));
-				Double G = current.G + weight; // 计算邻结点的G值
-				//Double G = current.G + current.weight; // 计算邻结点的G值
-				Node child = findNodeInOpen(linkedId);
-				if (child == null)
-				{
-					Double H=calcH(end.coord,current.coord); // 璁$畻H鍊�
-					if(isEndNode(end.id,linkedId))
-					{
-						child=end;
-						child.G=G;
-						child.H=H;
-					}
-					else
-					{
-						JSONObject neighItem = mapInfo.maps.getJSONObject(linkedId);
-						child = new Node(linkedId, neighItem.getDouble("weight"),
-								new Coord(neighItem.getDouble("x"), neighItem.getDouble("y"),neighItem.getDouble("z")), null, G, H);
-					}
-					child.parent=current;
-					openList.add(child);
-				}
-				else if (child.G > G)
-				{
-					child.G = G;
-					child.parent = current;
-					openList.add(child);
-				}
-			}
-		}
-
-	}
-
-	/**
-	 * 浠嶰pen鍒楄〃涓煡鎵剧粨鐐�
-	 */
-	private Node findNodeInOpen(int id)
-	{
-		if (openList.isEmpty()) return null;
-		for (Node node : openList)
-		{
-			if (node.id == id)
-			{
-				return node;
-			}
-		}
-		return null;
-	}
-
-
-	/**
-	 * 璁$畻H鐨勪及鍊硷細鈥滄浖鍝堥】鈥濇硶锛屽潗鏍囧垎鍒彇宸�肩浉鍔�
-	 */
-	public Double calcH(Coord end,Coord coord)
-	{
-		return Math.sqrt(Math.pow(end.x - coord.x,2)+ Math.pow(end.y - coord.y,2)+ Math.pow(end.z - coord.z,2));
-	}
-	
-	/**
-	 * 鍒ゆ柇缁撶偣鏄惁鏄渶缁堢粨鐐�
-	 */
-	private boolean isEndNode(int endId,int id)
-	{
-		return  endId == id;
-	}
-
-	/**
-	 * 鍒ゆ柇缁撶偣鑳藉惁鏀惧叆Open鍒楄〃
-	 */
-	private boolean canAddNodeToOpen(MapInfo mapInfo,int id)
-	{
-		// 鏄惁鍦ㄥ湴鍥句腑
-		//if (x < 0 || x >= mapInfo.width || y < 0 || y >= mapInfo.hight) return false;
-		// 鍒ゆ柇鏄惁鏄笉鍙�氳繃鐨勭粨鐐�
-		//if (mapInfo.maps[y][x] == BAR) return false;
-		// 鍒ゆ柇缁撶偣鏄惁瀛樺湪close琛�
-		if (isCoordInClose(id)) return false;
-
-		return true;
-	}
-
-	/**
-	 * 鍒ゆ柇鍧愭爣鏄惁鍦╟lose琛ㄤ腑
-	 */
-	private boolean isCoordInClose(int id)
-	{
-		if (closeList.isEmpty()) return false;
-		for (Node node : closeList)
-		{
-			if (node.id == id)
-			{
-				return true;
-			}
-		}
-		return false;
-	}
-
-	/**
-	 * 鍒ゆ柇鍧愭爣鏄惁鍦╟lose琛ㄤ腑
-	 */
-	private boolean isCoordInClose(int x, int y)
-	{
-		if (closeList.isEmpty()) return false;
-		for (Node node : closeList)
-		{
-			if (node.coord.x == x && node.coord.y == y)
-			{
-				return true;
-			}
-		}
-		return false;
-	}
+public class AStar {
+    public final static int BAR = 1; // 障碍值
+    public final static int PATH = 2; // 路径
+    public final static int DIRECT_VALUE = 10; // 横竖移动代价
+    public final static int OBLIQUE_VALUE = 14; // 斜移动代价
+
+    Queue<Node> openList = new PriorityQueue<Node>(); //  优先队列(升序)
+    List<Node> closeList = new ArrayList<Node>();
+
+    /**
+     * 开始算法
+     */
+    public List<Node> start(MapInfo mapInfo) {
+        if (mapInfo == null) return null;
+        // clean
+        openList.clear();
+        closeList.clear();
+        // 开始算法
+        openList.add(mapInfo.start);
+        return moveNodes(mapInfo);
+    }
+
+    /**
+     * 移动当前结点
+     */
+    private List<Node> moveNodes(MapInfo mapInfo) {
+        while (!openList.isEmpty()) {
+            Node current = openList.poll();
+            closeList.add(current);
+            addNeighborNodeInOpen(mapInfo, current);
+            if (isCoordInClose(mapInfo.end.id)) {
+                List<Node> list = drawPath(mapInfo.maps, mapInfo.end);
+                return list;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 在二维数组中绘制路径
+     */
+    private List<Node> drawPath(JSONArray maps, Node end) {
+        if (end == null || maps == null) return null;
+        System.out.println("路线" + end.id);
+        List<Node> list = new ArrayList<Node>();
+        while (end != null) {
+            System.out.println("路线" + end.id);
+            list.add(end);
+            Coord c = end.coord;
+            //maps[c.y][c.x] = PATH;
+            end = end.parent;
+        }
+        return list;
+    }
+
+    /**
+     * 添加所有邻结点到open表
+     */
+    private void addNeighborNodeInOpen(MapInfo mapInfo, Node current) {
+        int id = current.id;
+        JSONObject item = mapInfo.maps.getJSONObject(id);
+        String[] linkedIds = item.getString("linkedIds").split(",");
+
+        for (int i = 0; i < linkedIds.length; ++i) {
+            int linkedId = Integer.valueOf(linkedIds[i]) - 1;
+            //是否在close表里
+            if (canAddNodeToOpen(mapInfo, linkedId)) {
+                Node end = mapInfo.end;
+                //Coord coord = new Coord(x, y);
+                //Double G = current.G + current.weight; // 计算邻结点的G值
+
+                JSONObject linkedNode = mapInfo.maps.getJSONObject(linkedId);
+                double weight = calcH(current.coord, new Coord(linkedNode.getDouble("x"), linkedNode.getDouble("y"), linkedNode.getDouble("z")));
+                Double G = current.G + weight; // 计算邻结点的G值
+                //Double G = current.G + current.weight; // 计算邻结点的G值
+                Node child = findNodeInOpen(linkedId);
+                if (child == null) {
+                    Double H = calcH(end.coord, current.coord); // 璁$畻H鍊�
+                    if (isEndNode(end.id, linkedId)) {
+                        child = end;
+                        child.G = G;
+                        child.H = H;
+                    } else {
+                        JSONObject neighItem = mapInfo.maps.getJSONObject(linkedId);
+                        child = new Node(linkedId, neighItem.getDouble("weight"),
+                                new Coord(neighItem.getDouble("x"), neighItem.getDouble("y"), neighItem.getDouble("z")), null, G, H);
+                    }
+                    child.parent = current;
+                    openList.add(child);
+                } else if (child.G > G) {
+                    child.G = G;
+                    child.parent = current;
+                    openList.add(child);
+                }
+            }
+        }
+
+    }
+
+    /**
+     * 从Open列表中查找结点
+     */
+    private Node findNodeInOpen(int id) {
+        if (openList.isEmpty()) return null;
+        for (Node node : openList) {
+            if (node.id == id) {
+                return node;
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * 计算H的估值:“曼哈顿”法,坐标分别取差值相加
+     */
+    public Double calcH(Coord end, Coord coord) {
+        return Math.sqrt(Math.pow(end.x - coord.x, 2) + Math.pow(end.y - coord.y, 2) + Math.pow(end.z - coord.z, 2));
+    }
+
+    /**
+     * 判断结点是否是最终结点
+     */
+    private boolean isEndNode(int endId, int id) {
+        return endId == id;
+    }
+
+    /**
+     * 鍒ゆ柇缁撶偣鑳藉惁鏀惧叆Open鍒楄〃
+     */
+    private boolean canAddNodeToOpen(MapInfo mapInfo, int id) {
+
+        // 判断结点是否存在close表
+        if (isCoordInClose(id)) return false;
+
+        return true;
+    }
+
+    /**
+     * 鍒ゆ柇鍧愭爣鏄惁鍦╟lose琛ㄤ腑
+     */
+    private boolean isCoordInClose(int id) {
+        if (closeList.isEmpty()) return false;
+        for (Node node : closeList) {
+            if (node.id == id) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 鍒ゆ柇鍧愭爣鏄惁鍦╟lose琛ㄤ腑
+     */
+    private boolean isCoordInClose(int x, int y) {
+        if (closeList.isEmpty()) return false;
+        for (Node node : closeList) {
+            if (node.coord.x == x && node.coord.y == y) {
+                return true;
+            }
+        }
+        return false;
+    }
 }

+ 5 - 18
laser/src/main/java/com/fdkankan/indoor/base/convert/kesar/MapInfo.java

@@ -5,34 +5,21 @@ import net.sf.json.JSONArray;
 /**
  * 
  * ClassName: MapInfo 
- * @Description: 鍖呭惈鍦板浘鎵�闇�鐨勬墍鏈夎緭鍏ユ暟鎹�
+ * @Description: 包含地图所需的所有输入数据
  * @author kesar
  */
 public class MapInfo
 {
-	//public int[][] maps; // 浜岀淮鏁扮粍鐨勫湴鍥�
-	//public int width; // 鍦板浘鐨勫
-	//public int hight; // 鍦板浘鐨勯珮
+
 	public JSONArray maps;
-	public Node start; // 璧峰缁撶偣
-	public Node end; // 鏈�缁堢粨鐐�
+	public Node start; // 起始结点
+	public Node end; // 最终结点
 	
-	/*
-	public MapInfo(int[][] maps, int width, int hight, Node start, Node end)
-	{
-		this.maps = maps;
-		this.width = width;
-		this.hight = hight;
-		this.start = start;
-		this.end = end;
-	}
-	*/
+
 	
 	public MapInfo(JSONArray maps, Node start, Node end)
 	{
 		this.maps = maps;
-		//this.width = width;
-		//this.hight = hight;
 		this.start = start;
 		this.end = end;
 	}

+ 4 - 4
laser/src/main/java/com/fdkankan/indoor/base/convert/kesar/Node.java

@@ -10,10 +10,10 @@ public class Node implements Comparable<Node>
 {
 	public int id;
 	public Double weight;
-	public Coord coord; // 鍧愭爣
-	public Node parent; // 鐖剁粨鐐�
-	public Double G; // G锛氭槸涓噯纭殑鍊硷紝鏄捣鐐瑰埌褰撳墠缁撶偣鐨勪唬浠�
-	public Double H; // H锛氭槸涓及鍊硷紝褰撳墠缁撶偣鍒扮洰鐨勭粨鐐圭殑浼拌浠d环
+	public Coord coord; // 坐标
+	public Node parent; // 父结点
+	public Double G; // G:是个准确的值,是起点到当前结点的代价
+	public Double H; // H:是个估值,当前结点到目的结点的估计代价
 
 	public Node(int id ,Double weight,Coord coord, Node parent, Double g, Double h)
 	{

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

@@ -40,7 +40,12 @@ public class DateSetController {
     }
 
 
-
+    /**
+     * FixRouteMap
+     * @param sceneCode
+     * @param param
+     * @return
+     */
     @WebControllerLog(description = "场景信息接口-修改")
     @ApiOperation(value = "修改数据", notes = "会修改route数据")
     @PutMapping("indoor/{sceneCode}/api/datasets")

+ 5 - 0
laser/src/main/java/com/fdkankan/indoor/core/controller/PoseController.java

@@ -22,6 +22,11 @@ public class PoseController {
     @Autowired
     PoseService poseService;
 
+    /**
+     * 2021-08-31 可能废弃
+     * @param sceneCode
+     * @return
+     */
     @WebControllerLog(description = "生成pose.json")
     @ApiOperation(value = "生成pose.json")
     @GetMapping("indoor/{sceneCode}/api/reposes")

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

@@ -177,6 +177,21 @@ public class SiteModelController {
         return search.getData();
     }
 
+    /**
+     * 返回:{"total_floor_changing":1,"are_maps_invalidated":false}
+     * 如果floor的内容有改变,total_floor_changing的值是1,否则是0
+     * @param sceneCode
+     * @param param
+     * @return
+     */
+    @WebControllerLog(description = "-数据集的分类信息-检查floor数据是否有变")
+    @ApiOperation(value = "检查floor数据是否有变", notes = "传入参数目前不处理")
+    @PostMapping("indoor/{sceneCode}/api/site_model/check_map_invalidation")
+    public Object checkMapInvalidation(@PathVariable String sceneCode, @RequestBody List<SiteDto> param) {
+        Result search = entityService.checkMapInvalidation(sceneCode, param);
+        return search.getData();
+    }
+
 
 
 

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

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

+ 8 - 12
laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java

@@ -94,12 +94,7 @@ public class InitServiceImpl implements InitService {
     /**
      * initDataStep1
      * 有顺序分,不能乱
-     * @param sceneCode
-     * @param path
-     * @param from :age  四维看看重算,其他:手动重算
-     *
-     * @param title
-     * @return
+     *  from :age  四维看看重算,其他:手动重算
      */
     @Override
     public Result initData(InitDto param) {
@@ -118,14 +113,11 @@ public class InitServiceImpl implements InitService {
         InitEntity init = findById(sceneCode);
         if (init != null) {
             log.info("初始化数据已存在: {}", sceneCode);
-//            if ("age".equals(from)){
-//                log.error("场景:[{}] 已存在,不需要重算", sceneCode);
-//                return Result.failure(MsgCode.e3001, "场景已存在,不需要重算:" + sceneCode);
-//            }
 
             // 重算
 
             if ("recount".equals(from)){
+                log.info("进行手动重新");
                 path = init.getPath();
                 title = init.getTitle();
             }
@@ -143,7 +135,6 @@ public class InitServiceImpl implements InitService {
             // https://testlaser.4dkankan.com/maxkk/ + 场景码
             init.setWebSite(configConstant.webSitePath + sceneCode);
             init.setUserId(param.getUserId());
-//            init.setPhone(param.getPhone());
             init.setUserName(param.getPhone());
 
             initMapper.save(init);
@@ -364,7 +355,11 @@ public class InitServiceImpl implements InitService {
 
         String indexStr = cn.hutool.core.io.FileUtil.readUtf8String(indexPath);
         if (!indexStr.contains("@replace")) {
-            throw new BaseRuntimeException(MsgCode.e3001, "index.html不包含默认值, 请查看default文件是否正确");
+            throw new BaseRuntimeException(MsgCode.e3001, "index.html不包@replace含默认值, 请查看default文件是否正确");
+        }
+
+        if (!indexStr.contains("@title")) {
+            throw new BaseRuntimeException(MsgCode.e3001, "index.html不包@title含默认值, 请查看default文件是否正确");
         }
 
 
@@ -421,6 +416,7 @@ public class InitServiceImpl implements InitService {
         entity.setId(sceneCode);
         entity.setCreateTime(LocalDateTime.now());
         entity.setStatus(0);
+        // 控制点保存方法有很多处理逻辑
         controlPointService.save(entity, null);
         log.info("controlPoint控制点初始化完成");
     }

+ 48 - 10
laser/src/main/java/com/fdkankan/indoor/core/service/impl/SiteModelServiceImpl.java

@@ -1,5 +1,7 @@
 package com.fdkankan.indoor.core.service.impl;
 
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.indoor.base.convert.DistanceUtil;
 import com.fdkankan.indoor.base.util.GisUtils;
@@ -404,15 +406,6 @@ public class SiteModelServiceImpl implements SiteModelService {
     }
 
 
-//    @Override
-//    public SiteModelEntity findById(String sceneCode){
-//        Optional<SiteModelEntity> optional = entityMapper.findById(sceneCode);
-//        if (!optional.isPresent()){
-//            throw new BaseRuntimeException("SiteModel数据不存在");
-//        }
-//        return optional.get();
-//    }
-
     @Override
     public SiteModelEntity findById(String sceneCode){
         Optional<SiteModelEntity> optional = entityMapper.findById(sceneCode);
@@ -429,6 +422,52 @@ public class SiteModelServiceImpl implements SiteModelService {
     }
 
     /**
+     * 儿子child不比较
+     *
+     * 目前写死返回值
+     * @param sceneCode
+     * @param param
+     * @return
+     */
+    @Override
+    public Result checkMapInvalidation(String sceneCode, List<SiteDto> param) {
+//        SiteDto inSiteDto = param.get(0);
+//        // 去空格后,用json字符串比较
+//        List<SiteDto> inLoopModel = getLoopModel(inSiteDto);
+//        SiteDto inSiteDto1 = inLoopModel.get(0);
+//        Object o = JSON.toJSON(inSiteDto1);
+//        JSONObject inJson = JSONObject.parseObject(o.toString());
+//        System.out.println("in:" + inJson.toJSONString());
+//
+//
+//        List<SiteDto> originalDto = getDataById(sceneCode);
+//        List<SiteDto> originalData = getLoopModel(originalDto.get(0));
+//        SiteDto siteDto = originalData.get(0);
+//        JSONObject outJson = JSONObject.parseObject(JSON.toJSON(siteDto).toString());
+//        System.out.println("0:" + outJson.toJSONString());
+//
+//
+//        // 去空格
+//        StrUtil.cleanBlank("");
+//
+//        System.out.println();
+// {"total_floor_changing":0,"are_maps_invalidated":false}
+        JSONObject result = new JSONObject();
+        // 目前写死返回值
+        result.put("total_floor_changing", 0);
+        result.put("are_maps_invalidated", false);
+        return Result.success(result);
+    }
+
+    private List<SiteDto> getDataById(String sceneCode){
+        SiteModelEntity originalEntity = findById(sceneCode);
+        if (originalEntity != null) {
+            return originalEntity.getData();
+        }
+        return null;
+    }
+
+    /**
      * 2021-07-16
      * 递归出每一个对象
      * @param siteModel
@@ -441,7 +480,6 @@ public class SiteModelServiceImpl implements SiteModelService {
         // 做为父节点的低一条
         models.add(newSiteModel);
         if (!CollectionUtils.isEmpty(siteModel.getChildren())) {
-//            organizeModels2(siteModel, models);
             organizeModels3(siteModel, models);
         }
         log.info("models.size: {}", models.size());

+ 4 - 0
laser/src/main/resources/application-dev.properties

@@ -34,8 +34,12 @@ swagger.title=${project.sc}-dev
 swagger.description=${swagger.title}
 swagger.version=1.0
 
+# \u540E\u7AEF\u6587\u4EF6\u4FDD\u5B58\u8DEF\u5F84
 server.file.path=F:\\test\\ngin\\${project.en}_data
+# \u6A21\u677F\u6587\u4EF6\u4F4D\u7F6E
 my.template.path=F:/test/project/age_laser/laserData/baseData
+# \u540E\u7AEF\u6587\u4EF6\u4FDD\u5B58\u8DEF\u5F84
+my.back.file.path=${server.file.path}
 
 
 oss.point=http://oss-cn-shenzhen-internal.aliyuncs.com

+ 3 - 1
laser/src/main/resources/application-sit.properties

@@ -29,10 +29,12 @@ swagger.title=${project.sc}-sit
 swagger.description=${swagger.title}
 swagger.version=1.0
 
-# \u4E0A\u4F20\u6587\u4EF6\u4FDD\u5B58\u8DEF\u5F84
+# \u540E\u7AEF\u6587\u4EF6\u4FDD\u5B58\u8DEF\u5F84
 server.file.path=/var/www/html/laser/maxkk
 # \u6A21\u677F\u6587\u4EF6\u4F4D\u7F6E
 my.template.path=/root/user/java/jar_run/baseData
+# \u540E\u7AEF\u6587\u4EF6\u4FDD\u5B58\u8DEF\u5F84
+my.back.file.path=/mnt/data/${project.en}_data
 
 
 oss.point=http://oss-cn-shenzhen-internal.aliyuncs.com

+ 1 - 1
laser/src/main/resources/application.properties

@@ -9,7 +9,7 @@ logging.config=classpath:logback-spring.xml
 logging.level.com.fdkankan=info
 
 # \uFFFD\uFFFD\u013F\uFFFD\uFFFD\uFFFD\uFFFD
-project.en=age_camera_germany
+project.en=age_laser
 project.sc=\u6FC0\u5149\u76F8\u673A
 
 #\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F