人员定位代码优化修改
正在显示
2 个修改的文件
包含
54 行增加
和
39 行删除
... | @@ -2,13 +2,10 @@ package com.jkdata.service.impl; | ... | @@ -2,13 +2,10 @@ package com.jkdata.service.impl; |
2 | 2 | ||
3 | import cn.hutool.http.HttpUtil; | 3 | import cn.hutool.http.HttpUtil; |
4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
5 | import com.jkdata.tool.CommonConstant; | 5 | import com.jkdata.tool.*; |
6 | import com.jkdata.entity.ThirdPosition; | 6 | import com.jkdata.entity.ThirdPosition; |
7 | import com.jkdata.mapper.ThirdMapper; | 7 | import com.jkdata.mapper.ThirdMapper; |
8 | import com.jkdata.service.IThirdService; | 8 | import com.jkdata.service.IThirdService; |
9 | import com.jkdata.tool.MD5Util; | ||
10 | import com.jkdata.tool.RedisUtil; | ||
11 | import com.jkdata.tool.UUIDGenerator; | ||
12 | import org.apache.commons.lang.StringUtils; | 9 | import org.apache.commons.lang.StringUtils; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
... | @@ -89,49 +86,23 @@ public class IThirdServiceImpl implements IThirdService { | ... | @@ -89,49 +86,23 @@ public class IThirdServiceImpl implements IThirdService { |
89 | 86 | ||
90 | //B1定位坐标 | 87 | //B1定位坐标 |
91 | private void changCoordinateB1(ThirdPosition thirdPosition) { | 88 | private void changCoordinateB1(ThirdPosition thirdPosition) { |
89 | Map<String,Double> map = new HashMap<>();//初始化 | ||
92 | String x1 = thirdPosition.getPositionx(); | 90 | String x1 = thirdPosition.getPositionx(); |
93 | String y1 = thirdPosition.getPositiony(); | 91 | String y1 = thirdPosition.getPositiony(); |
94 | 92 | map = CoordinateUtil.changCoordinate("B1",x1,y1); | |
95 | double fd_x = CommonConstant.BLC1*(Double.valueOf(x1)-CommonConstant.LT_B1_X)+CommonConstant.LT_B1_X; | 93 | thirdPosition.setPositionx(String.valueOf(map.get("x"))); |
96 | double fd_y = CommonConstant.BLC1*(Double.valueOf(y1)+CommonConstant.LT_B1_Y)-CommonConstant.LT_B1_Y; | 94 | thirdPosition.setPositiony(String.valueOf(map.get("y"))); |
97 | System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y); | ||
98 | |||
99 | double a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x | ||
100 | double b = CommonConstant.MQ_B1_Y - CommonConstant.LT_B1_Y;//原点偏移y | ||
101 | System.out.println("偏移a:"+a+",b:"+b); | ||
102 | |||
103 | double x = Double.valueOf(fd_x) + a; | ||
104 | double y = Double.valueOf(fd_y) + b; | ||
105 | System.out.println("新坐标为:X:"+x+",Y:-"+y); | ||
106 | |||
107 | //原点偏移 | ||
108 | // double new_fd_x = 10*(Double.valueOf(x)-CommonConstant.MQ_B1_X)+CommonConstant.MQ_B1_X; | ||
109 | // double new_fd_y = 10*(Double.valueOf(y)+CommonConstant.MQ_B1_Y)-CommonConstant.MQ_B1_Y; | ||
110 | // System.out.println("新放大后的坐标为:X:"+new_fd_x+",Y:"+new_fd_y); | ||
111 | thirdPosition.setPositionx(String.valueOf(x)); | ||
112 | thirdPosition.setPositiony(String.valueOf(y)); | ||
113 | addPositionInfo(thirdPosition);//添加转换后坐标信息 | 95 | addPositionInfo(thirdPosition);//添加转换后坐标信息 |
114 | } | 96 | } |
115 | 97 | ||
116 | //B2定位坐标 | 98 | //B2定位坐标 |
117 | private void changCoordinateB2(ThirdPosition thirdPosition) { | 99 | private void changCoordinateB2(ThirdPosition thirdPosition) { |
100 | Map<String,Double> map = new HashMap<>();//初始化 | ||
118 | String x1 = thirdPosition.getPositionx(); | 101 | String x1 = thirdPosition.getPositionx(); |
119 | String y1 = thirdPosition.getPositiony(); | 102 | String y1 = thirdPosition.getPositiony(); |
120 | 103 | map = CoordinateUtil.changCoordinate("B2",x1,y1); | |
121 | double fd_x = CommonConstant.BLC2*(Double.valueOf(x1)-CommonConstant.LT_B2_X)+CommonConstant.LT_B2_X; | 104 | thirdPosition.setPositionx(String.valueOf(map.get("x"))); |
122 | double fd_y = CommonConstant.BLC2*(Double.valueOf(y1)+CommonConstant.LT_B2_Y)-CommonConstant.LT_B2_Y; | 105 | thirdPosition.setPositiony(String.valueOf(map.get("y"))); |
123 | System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y); | ||
124 | |||
125 | double a = CommonConstant.MQ_B2_X - CommonConstant.LT_B2_X;//原点偏移x | ||
126 | double b = CommonConstant.MQ_B2_Y - CommonConstant.LT_B2_Y;//原点偏移y | ||
127 | System.out.println("偏移a:"+a+",b:"+b); | ||
128 | |||
129 | double x = Double.valueOf(fd_x) + a; | ||
130 | double y = Double.valueOf(fd_y) + b; | ||
131 | System.out.println("新坐标为:X:"+x+",Y:-"+y); | ||
132 | |||
133 | thirdPosition.setPositionx(String.valueOf(x)); | ||
134 | thirdPosition.setPositiony(String.valueOf(y)); | ||
135 | addPositionInfo(thirdPosition);//添加转换后坐标信息 | 106 | addPositionInfo(thirdPosition);//添加转换后坐标信息 |
136 | } | 107 | } |
137 | 108 | ||
... | @@ -214,7 +185,7 @@ public class IThirdServiceImpl implements IThirdService { | ... | @@ -214,7 +185,7 @@ public class IThirdServiceImpl implements IThirdService { |
214 | 185 | ||
215 | @Override | 186 | @Override |
216 | public String getSafeArea() { | 187 | public String getSafeArea() { |
217 | String get = HttpUtil.get(CommonConstant.SAFE_AREA_URL+"?buildingId=10"); | 188 | String get = HttpUtil.get(CommonConstant.SAFE_AREA_URL+"?buildingId="+CommonConstant.BLD_ID); |
218 | return get; | 189 | return get; |
219 | } | 190 | } |
220 | 191 | ... | ... |
1 | package com.jkdata.tool; | ||
2 | |||
3 | import java.util.HashMap; | ||
4 | import java.util.Map; | ||
5 | |||
6 | public class CoordinateUtil { | ||
7 | |||
8 | public static Map<String,Double> changCoordinate (String floor, String x1, String y1){ | ||
9 | Map<String,Double> map = new HashMap<>();//初始化 | ||
10 | map.put("x", 0.00); | ||
11 | map.put("y", 0.00); | ||
12 | double fd_x = 0.00;//放大的X坐标 | ||
13 | double fd_y = 0.00;//放大的Y坐标 | ||
14 | double a = 0.00;//X偏移量 | ||
15 | double b = 0.00;//Y偏移量 | ||
16 | if("B2".equals(floor)){ | ||
17 | fd_x = CommonConstant.BLC2*(Double.valueOf(x1)-CommonConstant.LT_B2_X)+CommonConstant.LT_B2_X; | ||
18 | fd_y = CommonConstant.BLC2*(Double.valueOf(y1)+CommonConstant.LT_B2_Y)-CommonConstant.LT_B2_Y; | ||
19 | System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y); | ||
20 | a = CommonConstant.MQ_B2_X - CommonConstant.LT_B2_X;//原点偏移x | ||
21 | b = CommonConstant.MQ_B2_Y - CommonConstant.LT_B2_Y;//原点偏移y | ||
22 | System.out.println("偏移a:"+a+",b:"+b); | ||
23 | }else if("B1".equals(floor)){ | ||
24 | fd_x = CommonConstant.BLC1*(Double.valueOf(x1)-CommonConstant.LT_B1_X)+CommonConstant.LT_B1_X; | ||
25 | fd_y = CommonConstant.BLC1*(Double.valueOf(y1)+CommonConstant.LT_B1_Y)-CommonConstant.LT_B1_Y; | ||
26 | System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y); | ||
27 | a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x | ||
28 | b = CommonConstant.MQ_B1_Y - CommonConstant.LT_B1_Y;//原点偏移y | ||
29 | System.out.println("偏移a:"+a+",b:"+b); | ||
30 | }else{ | ||
31 | fd_x = 0.00; | ||
32 | fd_y = 0.00; | ||
33 | a = 0.00; | ||
34 | b = 0.00; | ||
35 | } | ||
36 | double x = Double.valueOf(fd_x) + a; | ||
37 | double y = Double.valueOf(fd_y) + b; | ||
38 | System.out.println("新坐标为:X:"+x+",Y:-"+y); | ||
39 | map.put("x",x); | ||
40 | map.put("y",y); | ||
41 | return map; | ||
42 | } | ||
43 | |||
44 | } |
-
请 注册 或 登录 后发表评论